use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testReorderRepositories.
public static void testReorderRepositories() {
Requirement req = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(osgi.wiring.package=org.apache.felix.gogo.api)").buildSyntheticRequirement();
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo1.index.xml"), "Repository1"));
registry.addPlugin(createRepo(IO.getFile("testdata/repo2.index.xml"), "Repository2"));
BndrunResolveContext context;
List<Capability> providers;
Resource resource;
BndEditModel runModel;
runModel = new BndEditModel();
runModel.setRunRepos(Arrays.asList(new String[] { "Repository2", "Repository1" }));
context = new BndrunResolveContext(runModel, registry, log);
providers = context.findProviders(req);
assertEquals(2, providers.size());
resource = providers.get(0).getResource();
assertEquals(IO.getFile("testdata/repo2/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
resource = providers.get(1).getResource();
assertEquals(IO.getFile("testdata/repo1/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testResolverHookFiltersResult.
public static void testResolverHookFiltersResult() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/osgi.cmpn-4.3.0.index.xml")));
registry.addPlugin(createRepo(IO.getFile("testdata/org.apache.felix.framework-4.0.2.index.xml")));
// Add a hook that removes all capabilities from resource with id
// "osgi.cmpn"
registry.addPlugin(new ResolverHook() {
public void filterMatches(Requirement requirement, List<Capability> candidates) {
for (Iterator<Capability> iter = candidates.iterator(); iter.hasNext(); ) {
Object id = iter.next().getResource().getCapabilities("osgi.identity").get(0).getAttributes().get("osgi.identity");
if ("osgi.cmpn".equals(id))
iter.remove();
}
}
});
BndEditModel runModel = new BndEditModel();
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(1, providers.size());
assertEquals(IO.getFile("testdata/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
// The capability from osgi.cmpn is NOT here
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testSimple.
/**
* Simple test that checks if we can find a resource through the
* findProviders
*/
public static void testSimple() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo1.index.xml"), "Repository1"));
BndrunResolveContext context = new BndrunResolveContext(new BndEditModel(), registry, log);
Requirement req = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(osgi.wiring.package=org.apache.felix.gogo.api)").buildSyntheticRequirement();
List<Capability> providers = context.findProviders(req);
assertEquals(1, providers.size());
Resource resource = providers.get(0).getResource();
assertEquals(IO.getFile("testdata/repo1/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testUnsatisfiedSystemPackage.
public static void testUnsatisfiedSystemPackage() {
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.wiring.package").addDirective("filter", "(osgi.wiring.package=sun.reflect)").buildSyntheticRequirement();
List<Capability> providers = context.findProviders(req);
assertEquals(0, providers.size());
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testBasicFindProviders.
public static void testBasicFindProviders() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo1.index.xml")));
BndEditModel runModel = new BndEditModel();
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
Requirement req = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(osgi.wiring.package=org.apache.felix.gogo.api)").buildSyntheticRequirement();
List<Capability> providers = context.findProviders(req);
assertEquals(1, providers.size());
Resource resource = providers.get(0).getResource();
assertEquals(IO.getFile("testdata/repo1/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
}
Aggregations