Map<Requirement, Collection<Capability>> result = repo.findProviders(Collections.singleton(req));
assertEquals(1, result.size());
Collection<Capability> caps = result.values().iterator().next();
assertEquals(2, caps.size());
Capability tf1Cap = null;
for (Capability cap : caps)
{
if ("test_file_1".equals(cap.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE))) {
tf1Cap = cap;
break;
}
}
assertEquals(Version.parseVersion("1.0.0.SNAPSHOT"), tf1Cap.getAttributes().get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE));
assertEquals(IdentityNamespace.TYPE_BUNDLE, tf1Cap.getAttributes().get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE));
Resource res = tf1Cap.getResource();
assertEquals(0, res.getRequirements(null).size());
assertEquals(1, res.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).size());
assertEquals(1, res.getCapabilities(ContentNamespace.CONTENT_NAMESPACE).size());
assertEquals(1, res.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE).size());
assertEquals(8, res.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE).size());
assertEquals(1, res.getCapabilities("foo").size());
assertEquals(12, res.getCapabilities(null).size());
Capability contentCap = res.getCapabilities(ContentNamespace.CONTENT_NAMESPACE).iterator().next();
assertEquals("4b68ab3847feda7d6c62c1fbcbeebfa35eab7351ed5e78f4ddadea5df64b8015",
contentCap.getAttributes().get(ContentNamespace.CONTENT_NAMESPACE));
assertEquals(getClass().getResource("/repo_files/test_file_1.jar").toExternalForm(),
contentCap.getAttributes().get(ContentNamespace.CAPABILITY_URL_ATTRIBUTE));
assertEquals(1L, contentCap.getAttributes().get(ContentNamespace.CAPABILITY_SIZE_ATTRIBUTE));
assertEquals("application/vnd.osgi.bundle", contentCap.getAttributes().get(ContentNamespace.CAPABILITY_MIME_ATTRIBUTE));
Capability bundleCap = res.getCapabilities(BundleNamespace.BUNDLE_NAMESPACE).iterator().next();
assertEquals("2", bundleCap.getAttributes().get("manifestversion"));
assertEquals("dummy", bundleCap.getAttributes().get(BundleNamespace.BUNDLE_NAMESPACE));
assertEquals(Version.parseVersion("1.0.0.SNAPSHOT"), bundleCap.getAttributes().get(BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE));
assertEquals("Unnamed - dummy", bundleCap.getAttributes().get("presentationname"));
Capability packageCap = res.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE).get(7);
assertEquals("org.apache.commons.logging", packageCap.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
assertEquals(Version.parseVersion("1.0.4"), packageCap.getAttributes().get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE));
assertEquals("dummy", packageCap.getAttributes().get(PackageNamespace.CAPABILITY_BUNDLE_SYMBOLICNAME_ATTRIBUTE));
assertEquals(Version.parseVersion("1.0.0.SNAPSHOT"), packageCap.getAttributes().get(PackageNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE));
Capability fooCap = res.getCapabilities("foo").iterator().next();
assertEquals("someVal", fooCap.getAttributes().get("someKey"));
}