Search in sources :

Example 1 with FelixCapabilityAdapter

use of org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter 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 2 with FelixCapabilityAdapter

use of org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter in project aries by apache.

the class FelixCapabilityAdapterTest method testObjectClassAttribute.

@Test
public void testObjectClassAttribute() {
    String objectClass = "com.foo.Bar";
    Capability cap = EasyMock.createNiceMock(Capability.class);
    EasyMock.expect(cap.getName()).andReturn(Capability.SERVICE);
    Map<String, Object> props = new HashMap<String, Object>();
    props.put(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE.toLowerCase(), objectClass);
    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 " + ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE, objectClass, adapter.getAttributes().get(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE));
}
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 3 with FelixCapabilityAdapter

use of org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter 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)

Example 4 with FelixCapabilityAdapter

use of org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter 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 5 with FelixCapabilityAdapter

use of org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter 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)

Aggregations

FelixCapabilityAdapter (org.apache.aries.subsystem.util.felix.FelixCapabilityAdapter)7 Resource (org.apache.felix.bundlerepository.Resource)7 Capability (org.apache.felix.bundlerepository.Capability)6 Test (org.junit.Test)6 HashMap (java.util.HashMap)3 Collection (java.util.Collection)1 FelixRepositoryAdapter (org.apache.aries.subsystem.util.felix.FelixRepositoryAdapter)1 FelixResourceAdapter (org.apache.aries.subsystem.util.felix.FelixResourceAdapter)1 OsgiRequirementAdapter (org.apache.aries.subsystem.util.felix.OsgiRequirementAdapter)1 Capability (org.osgi.resource.Capability)1 Requirement (org.osgi.resource.Requirement)1