use of org.osgi.resource.Requirement in project bnd by bndtools.
the class BndrunResolveContextTest method testEERequirementResolvesFramework.
public static void testEERequirementResolvesFramework() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
runModel.setEE(EE.JavaSE_1_6);
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
Requirement req = new CapReqBuilder("osgi.ee").addDirective("filter", "(osgi.ee=J2SE-1.5)").buildSyntheticRequirement();
List<Capability> providers = context.findProviders(req);
assertEquals(1, providers.size());
assertEquals(IO.getFile("testdata/repo3/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class BndrunResolveContextTest method testJREPackageResolvesFramework.
public static void testJREPackageResolvesFramework() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
runModel.setEE(EE.JavaSE_1_6);
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
Requirement req = CapReqBuilder.createPackageRequirement("javax.annotation", null).buildSyntheticRequirement();
List<Capability> providers = context.findProviders(req);
assertEquals(1, providers.size());
assertEquals(IO.getFile("testdata/repo3/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class BndrunResolveContextTest method testPreferLeastRequirementsAndMostCapabilities.
public static void testPreferLeastRequirementsAndMostCapabilities() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo4/index.xml")));
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
Requirement requirement = new CapReqBuilder("x").buildSyntheticRequirement();
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers = context.findProviders(requirement);
assertEquals(3, providers.size());
// x.3 has same requirements but more capabilities than x.2
assertEquals(IO.getFile("testdata/repo4/x.3.jar").toURI(), findContentURI(providers.get(0).getResource()));
// x.2 has same capabilities but fewer requirements than x.1
assertEquals(IO.getFile("testdata/repo4/x.2.jar").toURI(), findContentURI(providers.get(1).getResource()));
assertEquals(IO.getFile("testdata/repo4/x.1.jar").toURI(), findContentURI(providers.get(2).getResource()));
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class BndrunResolveContextTest method testEffective2.
public static void testEffective2() {
BndEditModel model = new BndEditModel();
model.genericSet(BndrunResolveContext.RUN_EFFECTIVE_INSTRUCTION, "active, arbitrary");
BndrunResolveContext context = new BndrunResolveContext(model, new MockRegistry(), log);
Requirement resolveReq = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, Namespace.EFFECTIVE_RESOLVE).buildSyntheticRequirement();
Requirement activeReq = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, Namespace.EFFECTIVE_ACTIVE).buildSyntheticRequirement();
Requirement arbitrary1Req = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, "arbitrary").buildSyntheticRequirement();
Requirement arbitrary2Req = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, "VeryArbitrary").buildSyntheticRequirement();
Requirement noEffectiveDirectiveReq = new CapReqBuilder("dummy.ns").buildSyntheticRequirement();
assertTrue(context.isEffective(resolveReq));
assertTrue(context.isEffective(activeReq));
assertTrue(context.isEffective(arbitrary1Req));
assertFalse(context.isEffective(arbitrary2Req));
assertTrue(context.isEffective(noEffectiveDirectiveReq));
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class BndrunResolveContextTest method testSelfCapabilityPreferredOverRepository.
public static void testSelfCapabilityPreferredOverRepository() {
MockRegistry registry = new MockRegistry();
Repository repo = createRepo(IO.getFile("testdata/repo4.index.xml"));
registry.addPlugin(repo);
Requirement resourceReq = new CapReqBuilder("osgi.identity").addDirective("filter", "(osgi.identity=dummy-selfcap)").buildSyntheticRequirement();
Resource resource = repo.findProviders(Collections.singleton(resourceReq)).get(resourceReq).iterator().next().getResource();
Requirement packageReq = resource.getRequirements("osgi.wiring.package").get(0);
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers = context.findProviders(packageReq);
assertNotNull(providers);
assertEquals(2, providers.size());
assertEquals(IO.getFile("testdata/repo4/dummy.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
Aggregations