use of org.osgi.resource.Requirement in project bnd by bndtools.
the class JpmRepoTest method testUnresolved.
public void testUnresolved() throws ResolutionException {
Repository repo = ws.getPlugin(Repository.class);
BndEditModel model = new BndEditModel();
model.setRunFw("org.apache.felix.framework");
List<Requirement> requires = new ArrayList<Requirement>();
CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.webconsole", "[4,5)");
requires.add(capReq.buildSyntheticRequirement());
Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires);
assertNotNull(shell);
assertEquals(1, shell.size());
model.setRunRequires(requires);
BndrunResolveContext context = new BndrunResolveContext(model, ws, log);
Resolver resolver = new BndResolver(new org.apache.felix.resolver.Logger(4));
try {
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
fail("Resolve did not fail");
} catch (ResolutionException e) {
assertEquals(1, e.getUnresolvedRequirements().size());
ResolutionException augmented = ResolveProcess.augment(context, e);
assertEquals(2, augmented.getUnresolvedRequirements().size());
}
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class BndrunResolveContextTest method testBlacklistFramework.
/**
* See if we can reject the 4.0.2 framework, which should normally be
* selected because it is the highest (this is tested later).
*/
public static void testBlacklistFramework() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/org.apache.felix.framework-4.0.0.index.xml")));
registry.addPlugin(createRepo(IO.getFile("testdata/org.apache.felix.framework-4.0.2.index.xml")));
BndEditModel model = new BndEditModel();
model.setRunFw("org.apache.felix.framework;version='[4,4.1)'");
Requirement blacklist = new CapReqBuilder("osgi.identity").addDirective("filter", "(&(osgi.identity=org.apache.felix.framework)(version>=4.0.1))").buildSyntheticRequirement();
model.setRunBlacklist(Arrays.asList(blacklist));
BndrunResolveContext context = new BndrunResolveContext(model, registry, log);
context.init();
Resource framework = context.getFramework();
assertNotNull(framework);
assertEquals(IO.getFile("testdata/org.apache.felix.framework-4.0.0.jar").toURI(), findContentURI(framework));
}
use of org.osgi.resource.Requirement in project bnd by bndtools.
the class BndrunResolveContextTest method testResolveSystemCapabilitiesExtra.
public static void testResolveSystemCapabilitiesExtra() {
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.genericSet("-runsystemcapabilities", "osgi.extender;osgi.extender=foobar;version:Version=1.0");
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
Requirement req = new CapReqBuilder("osgi.extender").addDirective("filter", "(&(osgi.extender=foobar)(version>=1.0))").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 testResolveSystemBundleAlias.
public static void testResolveSystemBundleAlias() {
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.host").addDirective("filter", "(osgi.wiring.host=system.bundle)").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 testJREPackageNotResolved.
public static void testJREPackageNotResolved() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
// javax.annotation added in Java 6
runModel.setEE(EE.J2SE_1_5);
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
Requirement req = CapReqBuilder.createPackageRequirement("javax.annotation", null).buildSyntheticRequirement();
List<Capability> providers = context.findProviders(req);
assertEquals(0, providers.size());
}
Aggregations