use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testDontResolveBuildOnlyLibraries.
public static void testDontResolveBuildOnlyLibraries() {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/buildrepo.index.xml")));
BndEditModel runModel = new BndEditModel();
BndrunResolveContext context;
context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers1 = context.findProviders(CapReqBuilder.createPackageRequirement("org.osgi.framework", null).buildSyntheticRequirement());
assertEquals(0, providers1.size());
context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers2 = context.findProviders(CapReqBuilder.createPackageRequirement("java.security", null).buildSyntheticRequirement());
assertEquals(0, providers2.size());
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class TestLocalIndexGeneration method testNonGeneratingProvider.
public void testNonGeneratingProvider() throws Exception {
MockRegistry registry = new MockRegistry();
registry.addPlugin(new NonGeneratingProvider());
LocalIndexedRepo repo = new LocalIndexedRepo();
repo.setRegistry(registry);
repo.setReporter(reporter);
Map<String, String> config = new HashMap<String, String>();
config.put("local", outputDir.getAbsolutePath());
config.put("type", "Nongenerating");
repo.setProperties(config);
repo.put(new BufferedInputStream(new FileInputStream("testdata/bundles/name.njbartlett.osgi.emf.minimal-2.6.1.jar")), new RepositoryPlugin.PutOptions());
assertEquals(0, reporter.getErrors().size());
assertTrue(reporter.getWarnings().size() > 0);
reporter.clear();
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class ResolveProcessTest method testResolveRequired.
public void testResolveRequired() throws ResolutionException, MalformedURLException, URISyntaxException {
ResolveProcess process = new ResolveProcess();
ResolverLogger logger = new ResolverLogger();
MockRegistry registry = new MockRegistry();
registry.addPlugin(getIndex("testdata/repo7/index.xml"));
Processor model = new Processor();
model.setProperty("-runfw", "org.apache.felix.framework");
model.setProperty("-runrequires", "osgi.extender;filter:='(&(osgi.extender=osgi.component)(version>=1.3)(!(version>=2)))'");
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(3, 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.8"), "org.osgi.service.cm");
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.1.0"), "org.osgi.service.metatype");
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class ResolveTest method testResolveWithDistro.
/**
* Test if we can resolve with a distro
*
* @throws ResolutionException
*/
public void testResolveWithDistro() throws ResolutionException {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
BndEditModel model = new BndEditModel();
model.setDistro(Arrays.asList("testdata/distro.jar;version=file"));
List<Requirement> requires = new ArrayList<Requirement>();
CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.gogo.shell", "[0,1)");
requires.add(capReq.buildSyntheticRequirement());
model.setRunRequires(requires);
BndrunResolveContext context = new BndrunResolveContext(model, registry, log);
context.setLevel(0);
context.init();
Resolver resolver = new BndResolver(new ResolverLogger(4));
Map<Resource, List<Wire>> resolved = resolver.resolve(context);
Set<Resource> resources = resolved.keySet();
Resource shell = getResource(resources, "org.apache.felix.gogo.shell", "0.10.0");
assertNotNull(shell);
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class ResolveTest method assertAugmentResolve.
private static void assertAugmentResolve(String augment, String require, String effective) throws Exception {
MockRegistry registry = new MockRegistry();
registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
Processor model = new Processor();
model.setRunfw("org.apache.felix.framework");
model.setProperty("-augment", augment);
model.setRunRequires(require);
if (effective != null)
model.setProperty("-resolve.effective", effective);
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();
Resource resource = getResource(resources, "org.apache.felix.gogo.runtime", "0.10");
assertNotNull(resource);
}
Aggregations