use of org.osgi.service.repository.Repository in project bnd by bndtools.
the class ResolveTest method testenRouteGuard.
/**
* The enRoute base guard resolved but is missing bundles, the runbundles do
* not run
*/
public void testenRouteGuard() throws Exception {
MockRegistry registry = new MockRegistry();
Repository repo = createRepo(IO.getFile("testdata/enroute/index.xml"));
registry.addPlugin(repo);
List<Requirement> reqs = CapReqBuilder.getRequirementsFrom(new Parameters("osgi.wiring.package;filter:='(osgi.wiring.package=org.osgi.service.async)'"));
Collection<Capability> pack = repo.findProviders(reqs).get(reqs.get(0));
assertEquals(2, pack.size());
ResourceBuilder b = new ResourceBuilder();
File guard = IO.getFile("testdata/enroute/osgi.enroute.base.guard.jar");
Domain manifest = Domain.domain(guard);
b.addManifest(manifest);
Repository resourceRepository = new ResourcesRepository(b.build());
registry.addPlugin(resourceRepository);
Processor model = new Processor();
model.setRunfw("org.eclipse.osgi");
model.setRunblacklist("osgi.identity;filter:='(osgi.identity=osgi.enroute.base.api)',osgi.identity;filter:='(osgi.identity=osgi.cmpn)',osgi.identity;filter:='(osgi.identity=osgi.core)");
model.setRunRequires("osgi.identity;filter:='(osgi.identity=osgi.enroute.base.guard)'");
model.setRunee("JavaSE-1.8");
try {
BndrunResolveContext context = new BndrunResolveContext(model, null, registry, log);
Resolver resolver = new BndResolver(new ResolverLogger(4));
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
Set<Resource> resources = resolved.keySet();
} catch (ResolutionException e) {
String msg = e.getMessage().replaceAll("\\[caused by:", "\n->");
System.out.println(msg);
fail(msg);
}
}
use of org.osgi.service.repository.Repository in project bnd by bndtools.
the class StandaloneTest method testExtraAttribs.
public void testExtraAttribs() throws Exception {
File f = IO.getFile("testdata/standalone/attribs.bndrun");
Run run = Run.createRun(null, f);
List<Repository> repositories = run.getWorkspace().getPlugins(Repository.class);
assertEquals(1, repositories.size());
assertTrue(repositories.get(0) instanceof OSGiRepository);
OSGiRepository f0 = (OSGiRepository) repositories.get(0);
assertEquals("foo", f0.getName());
assertEquals("http://example.org/index.xml", f0.getLocation());
File cacheDir = IO.getFile(System.getProperty("user.home") + "/.custom_cache_dir");
assertEquals(cacheDir, f0.getRoot());
}
use of org.osgi.service.repository.Repository in project bnd by bndtools.
the class StandaloneTest method testStandalone.
public void testStandalone() throws Exception {
File f = IO.getFile("testdata/standalone/simple.bndrun");
Run run = Run.createRun(null, f);
List<Repository> repositories = run.getWorkspace().getPlugins(Repository.class);
assertEquals(1, repositories.size());
assertTrue(repositories.get(0) instanceof OSGiRepository);
OSGiRepository f0 = (OSGiRepository) repositories.get(0);
assertEquals("foo", f0.getName());
assertEquals("http://example.org/index.xml", f0.getLocation());
}
use of org.osgi.service.repository.Repository 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.service.repository.Repository in project bnd by bndtools.
the class GenericResolveContextResolveTest method testSimpleResolve.
/**
* Simple basic resolve. We use a small index with gogo + framework and then
* try to see if we can resolve the runtime from the shell requirement.
*
* @throws Exception
*/
public void testSimpleResolve() throws Exception {
Repository repository = createRepo(IO.getFile("testdata/repo3.index.xml"));
GenericResolveContext grc = new GenericResolveContext(logger);
grc.setLevel(2);
grc.addRepository(repository);
grc.addFramework("org.apache.felix.framework", null);
grc.addEE(EE.JavaSE_1_7);
grc.addRequireBundle("org.apache.felix.gogo.shell", new VersionRange("[0,1]"));
grc.done();
Resolver resolver = new BndResolver(new ResolverLogger(4));
Set<Resource> resources = resolver.resolve(grc).keySet();
assertNotNull(getResource(resources, "org.apache.felix.gogo.runtime", "0.10"));
}
Aggregations