use of org.osgi.resource.Resource in project bnd by bndtools.
the class ProjectResolverTest method add.
private void add(ResourcesRepository fr, File file) throws Exception {
ResourceBuilder rb = new ResourceBuilder();
rb.addFile(file, file.toURI());
Resource resource = rb.build();
fr.add(resource);
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class ResolveProcessTest method testBigNastyResolveRequired.
public void testBigNastyResolveRequired() throws ResolutionException, MalformedURLException, URISyntaxException {
ResolveProcess process = new ResolveProcess();
ResolverLogger logger = new ResolverLogger();
MockRegistry registry = new MockRegistry();
registry.addPlugin(getIndex("testdata/repo7/index.xml"));
registry.addPlugin(getIndex("testdata/repo7/index-aries.xml"));
registry.addPlugin(getIndex("testdata/repo7/index-gemini.xml"));
registry.addPlugin(getIndex("testdata/repo7/index-local.xml"));
Processor model = new Processor();
model.setProperty("-runfw", "org.apache.felix.framework");
model.setProperty("-runrequires", "osgi.extender;filter:='(osgi.extender=osgi.component)'");
Map<Resource, List<Wire>> requiredResources = process.resolveRequired(model, null, registry, new BndResolver(logger), Collections.<ResolutionCallback>emptyList(), logger);
Collection<Resource> optionalResources = process.getOptionalResources();
assertEquals(1, requiredResources.size());
assertEquals(13, optionalResources.size());
SortedSet<Resource> set = new TreeSet<Resource>(new ResourceComparator());
set.addAll(optionalResources);
Iterator<Resource> it = set.iterator();
checkOptionalResource(process, it.next(), "org.apache.felix.configadmin", parseVersion("1.8.2"), "org.osgi.service.cm");
checkOptionalResource(process, it.next(), "org.apache.felix.configadmin", parseVersion("1.8.8"), "org.osgi.service.cm");
checkOptionalResource(process, it.next(), "org.apache.felix.gogo.command", parseVersion("0.12.0"), "org.osgi.service.log");
checkOptionalResource(process, it.next(), "org.apache.felix.gogo.runtime", parseVersion("0.10.0"), "org.apache.felix.service.command");
checkOptionalResource(process, it.next(), "org.apache.felix.log", parseVersion("1.0.1"), "org.osgi.service.log");
checkOptionalResource(process, it.next(), "org.apache.felix.metatype", parseVersion("1.0.4"), "org.osgi.service.metatype");
checkOptionalResource(process, it.next(), "org.apache.felix.metatype", parseVersion("1.1.0"), "org.osgi.service.metatype");
checkOptionalResource(process, it.next(), "org.apache.felix.shell", parseVersion("1.4.2"), "org.osgi.service.log", "org.apache.felix.shell");
checkOptionalResource(process, it.next(), "org.eclipse.osgi.services", parseVersion("3.1.200.v20070605"), "org.osgi.service.cm", "org.osgi.service.log", "org.osgi.service.metatype");
checkOptionalResource(process, it.next(), "org.ops4j.pax.logging.pax-logging-api", parseVersion("1.4.0"), "org.osgi.service.log");
checkOptionalResource(process, it.next(), "osgi.cmpn", parseVersion("4.3.1.201210102024"), "org.osgi.service.cm", "org.osgi.service.log", "org.osgi.service.metatype");
checkOptionalResource(process, it.next(), "osgi.cmpn", parseVersion("5.0.0.201305092017"), "org.osgi.service.cm", "org.osgi.service.log", "org.osgi.service.metatype");
checkOptionalResource(process, it.next(), "osgi.enterprise", parseVersion("4.2.0.201003190513"), "org.osgi.service.cm", "org.osgi.service.log", "org.osgi.service.metatype");
}
use of org.osgi.resource.Resource in project bnd by bndtools.
the class ValidatorTest method testValidatingResourcesWithDocumentaryAttributes.
public void testValidatingResourcesWithDocumentaryAttributes() throws Exception {
try (ResolverValidator validator = new ResolverValidator()) {
ResourceBuilder system = new ResourceBuilder();
system.addEE(EE.JavaSE_1_8);
system.addManifest(OSGI_CORE.R6_0_0.getManifest());
validator.setSystem(system.build());
validator.setTrace(true);
ResourcesRepository repository = new ResourcesRepository();
ResourceBuilder builder = new ResourceBuilder();
File file = IO.getFile("testdata/osgi.cmpn-4.3.0.jar");
builder.addFile(file, file.toURI());
repository.add(builder.build());
builder = new ResourceBuilder();
file = IO.getFile("testdata/org.apache.felix.framework-4.0.0.jar");
builder.addFile(file, file.toURI());
repository.add(builder.build());
List<Resource> resources = repository.getResources();
validator.validateResources(repository, resources);
assertTrue(validator.check());
}
}
use of org.osgi.resource.Resource 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.Resource 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));
}
Aggregations