use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testResolveSystemPackagesExtra.
public static void testResolveSystemPackagesExtra() {
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);
runModel.setSystemPackages(Collections.singletonList(new ExportedPackage("sun.reflect", new Attrs())));
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(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 testChooseHighestFrameworkVersion.
public static void testChooseHighestFrameworkVersion() {
MockRegistry registry;
BndEditModel runModel;
BndrunResolveContext context;
Collection<Resource> resources;
Resource fwkResource;
registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/org.apache.felix.framework-4.0.0.index.xml")));
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework;version='[4,4.1)'");
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()));
// Try it the other way round
registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
registry.addPlugin(createRepo(IO.getFile("testdata/org.apache.felix.framework-4.0.0.index.xml")));
runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework;version='[4,4.1)'");
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 testInputRequirementsAsMandatoryResource.
public static void testInputRequirementsAsMandatoryResource() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
Requirement req = new CapReqBuilder("osgi.identity").addDirective("filter", "(osgi.identity=org.apache.felix.gogo.command)").buildSyntheticRequirement();
runModel.setRunRequires(Collections.singletonList(req));
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()));
Collection<Resource> mandRes = context.getMandatoryResources();
assertEquals(1, mandRes.size());
Resource resource = mandRes.iterator().next();
assertNotNull(resource);
IdentityCapability ic = ResourceUtils.getIdentityCapability(resource);
assertNotNull(ic);
assertEquals("<<INITIAL>>", ic.osgi_identity());
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testProviderPreference.
public static void testProviderPreference() {
Requirement req = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(osgi.wiring.package=org.apache.felix.gogo.api)").buildSyntheticRequirement();
MockRegistry registry;
BndrunResolveContext context;
List<Capability> providers;
Resource resource;
// First try it with repo1 first
registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo1.index.xml")));
registry.addPlugin(createRepo(IO.getFile("testdata/repo2.index.xml")));
context = new BndrunResolveContext(new BndEditModel(), registry, log);
providers = context.findProviders(req);
assertEquals(2, providers.size());
resource = providers.get(0).getResource();
assertEquals(IO.getFile("testdata/repo1/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
resource = providers.get(1).getResource();
assertEquals(IO.getFile("testdata/repo2/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
// Now try it with repo2 first
registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo2.index.xml")));
registry.addPlugin(createRepo(IO.getFile("testdata/repo1.index.xml")));
context = new BndrunResolveContext(new BndEditModel(), 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 testResolverHookFiltersResultWithBlacklistAndVersionRange2.
public static void testResolverHookFiltersResultWithBlacklistAndVersionRange2() {
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.4.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(1, providers.size());
assertEquals(new File("testdata/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
Aggregations