Search in sources :

Example 1 with OsgiRequirementAdapter

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

the class OsgiRequirementAdapterTest method testIsMultipleTrue.

@Test
public void testIsMultipleTrue() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    Map<String, String> directives = new HashMap<String, String>();
    directives.put(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_MULTIPLE);
    EasyMock.expect(req.getDirectives()).andReturn(directives);
    EasyMock.replay(req);
    OsgiRequirementAdapter adapter = new OsgiRequirementAdapter(req);
    assertTrue("Requirement was not multiple", adapter.isMultiple());
}
Also used : Requirement(org.osgi.resource.Requirement) HashMap(java.util.HashMap) OsgiRequirementAdapter(org.apache.aries.subsystem.util.felix.OsgiRequirementAdapter) Test(org.junit.Test)

Example 2 with OsgiRequirementAdapter

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

the class OsgiRequirementAdapterTest method testGetNamePackage.

@Test
public void testGetNamePackage() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    EasyMock.expect(req.getNamespace()).andReturn(PackageNamespace.PACKAGE_NAMESPACE);
    EasyMock.replay(req);
    OsgiRequirementAdapter adapter = new OsgiRequirementAdapter(req);
    assertEquals("Wrong name", Capability.PACKAGE, adapter.getName());
}
Also used : Requirement(org.osgi.resource.Requirement) OsgiRequirementAdapter(org.apache.aries.subsystem.util.felix.OsgiRequirementAdapter) Test(org.junit.Test)

Example 3 with OsgiRequirementAdapter

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

the class OsgiRequirementAdapterTest method testGetNameBundle.

@Test
public void testGetNameBundle() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    EasyMock.expect(req.getNamespace()).andReturn(BundleNamespace.BUNDLE_NAMESPACE);
    EasyMock.replay(req);
    OsgiRequirementAdapter adapter = new OsgiRequirementAdapter(req);
    assertEquals("Wrong name", Capability.BUNDLE, adapter.getName());
}
Also used : Requirement(org.osgi.resource.Requirement) OsgiRequirementAdapter(org.apache.aries.subsystem.util.felix.OsgiRequirementAdapter) Test(org.junit.Test)

Example 4 with OsgiRequirementAdapter

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

the class OsgiRequirementAdapterTest method testIsMultipleFalse.

@Test
public void testIsMultipleFalse() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    Map<String, String> directives = new HashMap<String, String>();
    directives.put(Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, Namespace.CARDINALITY_SINGLE);
    EasyMock.expect(req.getDirectives()).andReturn(directives);
    EasyMock.replay(req);
    OsgiRequirementAdapter adapter = new OsgiRequirementAdapter(req);
    assertFalse("Requirement was multiple", adapter.isMultiple());
}
Also used : Requirement(org.osgi.resource.Requirement) HashMap(java.util.HashMap) OsgiRequirementAdapter(org.apache.aries.subsystem.util.felix.OsgiRequirementAdapter) Test(org.junit.Test)

Example 5 with OsgiRequirementAdapter

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

the class OsgiRequirementAdapterTest method testGetNameService.

@Test
public void testGetNameService() {
    Requirement req = EasyMock.createNiceMock(Requirement.class);
    EasyMock.expect(req.getNamespace()).andReturn(ServiceNamespace.SERVICE_NAMESPACE);
    EasyMock.replay(req);
    OsgiRequirementAdapter adapter = new OsgiRequirementAdapter(req);
    assertEquals("Wrong name", Capability.SERVICE, adapter.getName());
}
Also used : Requirement(org.osgi.resource.Requirement) OsgiRequirementAdapter(org.apache.aries.subsystem.util.felix.OsgiRequirementAdapter) Test(org.junit.Test)

Aggregations

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