use of org.osgi.resource.Requirement 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());
}
use of org.osgi.resource.Requirement 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());
}
use of org.osgi.resource.Requirement in project aries by apache.
the class TestRepository method findProviders.
@Override
public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> requirements) {
Map<Requirement, Collection<Capability>> result = new HashMap<Requirement, Collection<Capability>>();
for (Requirement requirement : requirements) {
for (Resource resource : resources) {
List<Capability> capabilities = resource.getCapabilities(requirement.getNamespace());
for (Capability capability : capabilities) {
if (ResourceHelper.matches(requirement, capability)) {
Collection<Capability> c = result.get(requirement);
if (c == null) {
c = new HashSet<Capability>();
result.put(requirement, c);
}
c.add(capability);
}
}
}
}
return result;
}
use of org.osgi.resource.Requirement in project aries by apache.
the class TestResource method getRequirements.
@Override
public List<Requirement> getRequirements(String namespace) {
if (namespace == null)
return Collections.unmodifiableList(requirements);
ArrayList<Requirement> result = new ArrayList<Requirement>(requirements.size());
for (Requirement requirement : requirements) if (namespace.equals(requirement.getNamespace()))
result.add(requirement);
result.trimToSize();
return Collections.unmodifiableList(result);
}
use of org.osgi.resource.Requirement in project aries by apache.
the class Aries1429Test method testMissingParentChildEdgeNotTolerated.
@Test
public void testMissingParentChildEdgeNotTolerated() throws Exception {
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
try {
removeConnectionWithParent(applicationA);
try {
((AriesSubsystem) applicationA).addRequirements(Collections.singletonList((Requirement) new TestRequirement.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).attribute(PackageNamespace.PACKAGE_NAMESPACE, "org.osgi.framework").build()));
fail("No exception received");
} catch (SubsystemException e) {
Throwable cause = e.getCause();
assertNotNull("Wrong cause", cause);
assertEquals("Wrong cause", IllegalStateException.class, cause.getClass());
}
} finally {
uninstallSubsystemSilently(applicationA);
}
}
Aggregations