use of org.osgi.resource.Resource in project aries by apache.
the class SubsystemResource method computeDependencies.
void computeDependencies(DeploymentManifest manifest, Coordination coordination) {
if (manifest == null) {
computeDependencies(getSubsystemManifest(), coordination);
} else {
ProvisionResourceHeader header = manifest.getProvisionResourceHeader();
if (header == null)
return;
for (ProvisionResourceHeader.Clause clause : header.getClauses()) {
Resource resource = findDependency(clause);
if (resource == null)
throw new SubsystemException("A required dependency could not be found. This means the resource was either missing or not recognized as a supported resource format due to, for example, an invalid bundle manifest or blueprint XML file. Turn on debug logging for more information. The resource was: " + resource);
addDependency(resource);
}
}
}
use of org.osgi.resource.Resource 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)));
}
use of org.osgi.resource.Resource in project aries by apache.
the class Aries1453Test method shouldResolveFragmentHostWithVersionRangeAndMatchWithBundlesInThatRange.
@Test
public void shouldResolveFragmentHostWithVersionRangeAndMatchWithBundlesInThatRange() {
FragmentHostHeader header = new FragmentHostHeader("host-bundle;bundle-version=\"[9.6.0,10)\"");
FragmentHostRequirement requirement = new FragmentHostRequirement(header.getClauses().iterator().next(), null);
FragmentHostCapability capability = new FragmentHostCapability(new BundleSymbolicNameHeader("host-bundle"), new BundleVersionHeader("9.6.1"), new Resource() {
@Override
public List<Capability> getCapabilities(String namespace) {
return null;
}
@Override
public List<Requirement> getRequirements(String namespace) {
return null;
}
});
String filterDirective = requirement.getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE);
SimpleFilter simpleFilter = SimpleFilter.parse(filterDirective);
CapabilitySet capabilitySet = new CapabilitySet(Arrays.asList(HostNamespace.HOST_NAMESPACE), true);
capabilitySet.addCapability(capability);
Set<Capability> capabilities = capabilitySet.match(simpleFilter, true);
Assert.assertTrue(capabilities.size() == 1);
Assert.assertSame(capabilities.iterator().next(), capability);
}
use of org.osgi.resource.Resource in project aries by apache.
the class BundleRequiredExecutionEnvironmentHeaderTest method assertRequirement.
private void assertRequirement(BundleRequiredExecutionEnvironmentHeader.Clause clause, String filter) {
Resource resource = EasyMock.createNiceMock(Resource.class);
assertRequirement(clause.toRequirement(resource), filter, resource);
}
use of org.osgi.resource.Resource in project aries by apache.
the class BundleRequiredExecutionEnvironmentHeaderTest method testHeaderWithOneClause.
@SuppressWarnings("deprecation")
@Test
public void testHeaderWithOneClause() {
String value = "OSGi/Minimum-1.2";
String filter = "(&(osgi.ee=OSGi/Minimum)(version=1.2.0))";
BundleRequiredExecutionEnvironmentHeader header = new BundleRequiredExecutionEnvironmentHeader(value);
assertEquals("Wrong number of clauses", 1, header.getClauses().size());
assertClause(header.getClauses().iterator().next(), value, "OSGi/Minimum", "1.2", filter);
assertEquals("Wrong name", Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT, header.getName());
assertEquals("Wrong value", value, header.getValue());
Resource resource = EasyMock.createNiceMock(Resource.class);
List<? extends Requirement> requirements = header.toRequirements(resource);
assertEquals("Wrong number of requirements", 1, requirements.size());
assertRequirement(requirements.get(0), filter, resource);
}
Aggregations