use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testResolverHookFiltersResultWithBlacklistAndVersionRange1.
public static void testResolverHookFiltersResultWithBlacklistAndVersionRange1() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(new File("testdata/osgi.cmpn-4.3.0.index.xml")));
registry.addPlugin(createRepo(new File("testdata/org.apache.felix.framework-4.0.2.index.xml")));
// Add a hook that removes all capabilities from resource with id
// "osgi.cmpn"
HashMap<String, String> blacklistProp = new HashMap<String, String>();
BndEditModel runModel = new BndEditModel();
ArrayList<Requirement> blacklistlist = new ArrayList<Requirement>();
blacklistlist.add(CapReqBuilder.createSimpleRequirement("osgi.identity", "osgi.cmpn", "[4.0.0,4.3.0)").buildSyntheticRequirement());
runModel.setRunBlacklist(blacklistlist);
runModel.setRunFw("org.apache.felix.framework");
Requirement requirement = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(&(osgi.wiring.package=org.osgi.util.tracker)(version>=1.5)(!(version>=1.6)))").buildSyntheticRequirement();
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers = context.findProviders(requirement);
assertEquals(2, providers.size());
assertEquals(new File("testdata/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
assertEquals(new File("testdata/osgi.cmpn-4.3.0.jar").toURI(), findContentURI(providers.get(1).getResource()));
}
use of test.lib.MockRegistry 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 test.lib.MockRegistry 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 test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testFrameworkIsMandatory.
public static void testFrameworkIsMandatory() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework;version='[4,4.1)'");
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
context.init();
assertEquals(IO.getFile("testdata/repo3/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(context.getFramework()));
}
use of test.lib.MockRegistry 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()));
}
Aggregations