use of org.apache.aries.subsystem.core.internal.OsgiIdentityCapability in project aries by apache.
the class SubsystemManifest method toCapabilities.
public List<Capability> toCapabilities(Resource resource) {
ArrayList<Capability> capabilities = new ArrayList<Capability>();
for (Header<?> header : headers.values()) if (header instanceof CapabilityHeader)
capabilities.addAll(((CapabilityHeader<?>) header).toCapabilities(resource));
capabilities.add(new OsgiIdentityCapability(resource, getSubsystemSymbolicNameHeader().getSymbolicName(), getSubsystemVersionHeader().getVersion(), getSubsystemTypeHeader().getType()));
capabilities.trimToSize();
return capabilities;
}
use of org.apache.aries.subsystem.core.internal.OsgiIdentityCapability in project aries by apache.
the class Aries1425Test method testToRequirement.
@Test
public void testToRequirement() {
SubsystemContentHeader header = new SubsystemContentHeader(HEADER_1);
Collection<SubsystemContentHeader.Clause> clauses = header.getClauses();
assertEquals("Wrong size", 3, clauses.size());
Map<String, SubsystemContentHeader.Clause> map = new HashMap<String, SubsystemContentHeader.Clause>(3);
for (SubsystemContentHeader.Clause clause : clauses) {
map.put(clause.toString(), clause);
}
Resource resource = new Resource() {
@Override
public List<Capability> getCapabilities(String namespace) {
return Collections.emptyList();
}
@Override
public List<Requirement> getRequirements(String namespace) {
return Collections.emptyList();
}
};
SubsystemContentHeader.Clause clause = map.get(BUNDLE_A);
Requirement requirement = clause.toRequirement(resource);
assertTrue("Wrong requirement", ResourceHelper.matches(requirement, new OsgiIdentityCapability(resource, BUNDLE_A, Version.emptyVersion, IdentityNamespace.TYPE_FRAGMENT)));
assertTrue("Wrong requirement", ResourceHelper.matches(requirement, new OsgiIdentityCapability(resource, BUNDLE_A, Version.emptyVersion, IdentityNamespace.TYPE_BUNDLE)));
clause = map.get(BUNDLE_B);
requirement = clause.toRequirement(resource);
assertFalse("Wrong requirement", ResourceHelper.matches(requirement, new OsgiIdentityCapability(resource, "bundle.b", Version.emptyVersion, IdentityNamespace.TYPE_FRAGMENT)));
assertTrue("Wrong requirement", ResourceHelper.matches(requirement, new OsgiIdentityCapability(resource, "bundle.b", Version.emptyVersion, IdentityNamespace.TYPE_BUNDLE)));
clause = map.get(BUNDLE_C);
requirement = clause.toRequirement(resource);
assertTrue("Wrong requirement", ResourceHelper.matches(requirement, new OsgiIdentityCapability(resource, "bundle.c", Version.emptyVersion, IdentityNamespace.TYPE_FRAGMENT)));
assertFalse("Wrong requirement", ResourceHelper.matches(requirement, new OsgiIdentityCapability(resource, "bundle.c", Version.emptyVersion, IdentityNamespace.TYPE_BUNDLE)));
}
Aggregations