use of org.apache.felix.bundlerepository.Capability in project aries by apache.
the class FelixResourceAdapterTest method testGetCapabilitiesWithNullNamespace.
@Test
public void testGetCapabilitiesWithNullNamespace() {
Resource resource = EasyMock.createNiceMock(Resource.class);
Capability capability = EasyMock.createNiceMock(Capability.class);
EasyMock.expect(capability.getName()).andReturn(Capability.PACKAGE);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(Capability.PACKAGE, "org.foo.bar");
EasyMock.expect(capability.getPropertiesAsMap()).andReturn(properties);
Capability[] capabilities = new Capability[] { capability };
EasyMock.expect(resource.getCapabilities()).andReturn(capabilities);
EasyMock.replay(resource);
FelixResourceAdapter adapter = new FelixResourceAdapter(resource);
List<org.osgi.resource.Capability> caps = adapter.getCapabilities(null);
// osgi.identity, osgi.content. osgi.wiring.host, and osgi.wiring.package
assertEquals("Null namespace should return all capabilities", 4, caps.size());
}
use of org.apache.felix.bundlerepository.Capability in project aries by apache.
the class FelixCapabilityAdapterTest method testOsgiWiringPackageNamespace.
@Test
public void testOsgiWiringPackageNamespace() {
Capability cap = EasyMock.createNiceMock(Capability.class);
EasyMock.expect(cap.getName()).andReturn(Capability.PACKAGE);
EasyMock.replay(cap);
FelixCapabilityAdapter adapter = new FelixCapabilityAdapter(cap, EasyMock.createNiceMock(org.osgi.resource.Resource.class));
assertEquals("Wrong namespace", PackageNamespace.PACKAGE_NAMESPACE, adapter.getNamespace());
}
use of org.apache.felix.bundlerepository.Capability in project aries by apache.
the class FelixCapabilityAdapterTest method testOsgiWiringBundleAttribute.
@Test
public void testOsgiWiringBundleAttribute() {
String symbolicName = "derbyclient";
Capability cap = EasyMock.createNiceMock(Capability.class);
EasyMock.expect(cap.getName()).andReturn(Capability.BUNDLE).anyTimes();
Map<String, Object> props = new HashMap<String, Object>();
props.put(Resource.SYMBOLIC_NAME, symbolicName);
EasyMock.expect(cap.getPropertiesAsMap()).andReturn(props);
EasyMock.replay(cap);
FelixCapabilityAdapter adapter = new FelixCapabilityAdapter(cap, EasyMock.createNiceMock(org.osgi.resource.Resource.class));
assertEquals("Wrong value for attribute " + BundleNamespace.BUNDLE_NAMESPACE, symbolicName, adapter.getAttributes().get(BundleNamespace.BUNDLE_NAMESPACE));
}
use of org.apache.felix.bundlerepository.Capability in project aries by apache.
the class FelixCapabilityAdapterTest method testOsgiWiringBundleNamespace.
@Test
public void testOsgiWiringBundleNamespace() {
Capability cap = EasyMock.createNiceMock(Capability.class);
EasyMock.expect(cap.getName()).andReturn(Capability.BUNDLE);
EasyMock.replay(cap);
FelixCapabilityAdapter adapter = new FelixCapabilityAdapter(cap, EasyMock.createNiceMock(org.osgi.resource.Resource.class));
assertEquals("Wrong namespace", BundleNamespace.BUNDLE_NAMESPACE, adapter.getNamespace());
}
use of org.apache.felix.bundlerepository.Capability in project aries by apache.
the class FelixCapabilityAdapterTest method testOsgiWiringPackageAttribute.
@Test
public void testOsgiWiringPackageAttribute() {
String pkg = "com.foo.Bar";
Capability cap = EasyMock.createNiceMock(Capability.class);
EasyMock.expect(cap.getName()).andReturn(Capability.PACKAGE).anyTimes();
Map<String, Object> props = new HashMap<String, Object>();
props.put(Capability.PACKAGE, pkg);
EasyMock.expect(cap.getPropertiesAsMap()).andReturn(props);
EasyMock.replay(cap);
FelixCapabilityAdapter adapter = new FelixCapabilityAdapter(cap, EasyMock.createNiceMock(org.osgi.resource.Resource.class));
assertEquals("Wrong value for attribute " + PackageNamespace.PACKAGE_NAMESPACE, pkg, adapter.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE));
}
Aggregations