Search in sources :

Example 1 with Capability

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());
}
Also used : Capability(org.apache.felix.bundlerepository.Capability) HashMap(java.util.HashMap) Resource(org.apache.felix.bundlerepository.Resource) FelixResourceAdapter(org.apache.aries.subsystem.util.felix.FelixResourceAdapter) Test(org.junit.Test)

Example 2 with Capability

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());
}
Also used : Capability(org.apache.felix.bundlerepository.Capability) FelixCapabilityAdapter(org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter) Resource(org.apache.felix.bundlerepository.Resource) Test(org.junit.Test)

Example 3 with Capability

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));
}
Also used : Capability(org.apache.felix.bundlerepository.Capability) HashMap(java.util.HashMap) FelixCapabilityAdapter(org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter) Resource(org.apache.felix.bundlerepository.Resource) Test(org.junit.Test)

Example 4 with Capability

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());
}
Also used : Capability(org.apache.felix.bundlerepository.Capability) FelixCapabilityAdapter(org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter) Resource(org.apache.felix.bundlerepository.Resource) Test(org.junit.Test)

Example 5 with Capability

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));
}
Also used : Capability(org.apache.felix.bundlerepository.Capability) HashMap(java.util.HashMap) FelixCapabilityAdapter(org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter) Resource(org.apache.felix.bundlerepository.Resource) Test(org.junit.Test)

Aggregations

Capability (org.apache.felix.bundlerepository.Capability)14 Resource (org.apache.felix.bundlerepository.Resource)10 Test (org.junit.Test)8 FelixCapabilityAdapter (org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter)6 HashMap (java.util.HashMap)5 Requirement (org.apache.felix.bundlerepository.Requirement)5 Map (java.util.Map)3 ModelledResource (org.apache.aries.application.modelling.ModelledResource)2 ModelledBundleResource (org.apache.aries.application.resolver.obr.ext.ModelledBundleResource)2 Reason (org.apache.felix.bundlerepository.Reason)2 Repository (org.apache.felix.bundlerepository.Repository)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1