use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testEffective2.
public static void testEffective2() {
BndEditModel model = new BndEditModel();
model.genericSet(BndrunResolveContext.RUN_EFFECTIVE_INSTRUCTION, "active, arbitrary");
BndrunResolveContext context = new BndrunResolveContext(model, new MockRegistry(), log);
Requirement resolveReq = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, Namespace.EFFECTIVE_RESOLVE).buildSyntheticRequirement();
Requirement activeReq = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, Namespace.EFFECTIVE_ACTIVE).buildSyntheticRequirement();
Requirement arbitrary1Req = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, "arbitrary").buildSyntheticRequirement();
Requirement arbitrary2Req = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, "VeryArbitrary").buildSyntheticRequirement();
Requirement noEffectiveDirectiveReq = new CapReqBuilder("dummy.ns").buildSyntheticRequirement();
assertTrue(context.isEffective(resolveReq));
assertTrue(context.isEffective(activeReq));
assertTrue(context.isEffective(arbitrary1Req));
assertFalse(context.isEffective(arbitrary2Req));
assertTrue(context.isEffective(noEffectiveDirectiveReq));
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testSelfCapabilityPreferredOverRepository.
public static void testSelfCapabilityPreferredOverRepository() {
MockRegistry registry = new MockRegistry();
Repository repo = createRepo(IO.getFile("testdata/repo4.index.xml"));
registry.addPlugin(repo);
Requirement resourceReq = new CapReqBuilder("osgi.identity").addDirective("filter", "(osgi.identity=dummy-selfcap)").buildSyntheticRequirement();
Resource resource = repo.findProviders(Collections.singleton(resourceReq)).get(resourceReq).iterator().next().getResource();
Requirement packageReq = resource.getRequirements("osgi.wiring.package").get(0);
BndEditModel runModel = new BndEditModel();
runModel.setRunFw("org.apache.felix.framework");
BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
List<Capability> providers = context.findProviders(packageReq);
assertNotNull(providers);
assertEquals(2, providers.size());
assertEquals(IO.getFile("testdata/repo4/dummy.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class BndrunResolveContextTest method testEffective.
public static void testEffective() {
BndrunResolveContext context = new BndrunResolveContext(new BndEditModel(), new MockRegistry(), log);
Requirement resolveReq = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, Namespace.EFFECTIVE_RESOLVE).buildSyntheticRequirement();
Requirement activeReq = new CapReqBuilder("dummy.ns").addDirective(Namespace.REQUIREMENT_EFFECTIVE_DIRECTIVE, Namespace.EFFECTIVE_ACTIVE).buildSyntheticRequirement();
Requirement noEffectiveDirectiveReq = new CapReqBuilder("dummy.ns").buildSyntheticRequirement();
assertTrue(context.isEffective(resolveReq));
assertFalse(context.isEffective(activeReq));
assertTrue(context.isEffective(noEffectiveDirectiveReq));
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class TestLocalIndexGeneration method testFailToGenerate.
public void testFailToGenerate() throws Exception {
MockRegistry registry = new MockRegistry();
registry.addPlugin(new FailingGeneratingProvider());
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", "Fail");
repo.setProperties(config);
repo.put(new BufferedInputStream(new FileInputStream("testdata/bundles/name.njbartlett.osgi.emf.minimal-2.6.1.jar")), new RepositoryPlugin.PutOptions());
assertTrue(reporter.getErrors().size() > 0);
assertEquals(0, reporter.getWarnings().size());
reporter.clear();
}
use of test.lib.MockRegistry in project bnd by bndtools.
the class TestMultipleLocalIndexGeneration method setUp.
protected void setUp() throws Exception {
// Ensure output directory exists and is empty
outputDir = IO.getFile("generated/tmp/test/" + getName());
IO.deleteWithException(outputDir);
if (!outputDir.exists() && !outputDir.mkdirs()) {
throw new IOException("Could not create directory " + outputDir);
}
// Setup the repo
reporter = new Processor();
repo = new LocalIndexedRepo();
Map<String, String> config = new HashMap<String, String>();
config.put("local", outputDir.getAbsolutePath());
config.put("type", "OBR|R5");
repo.setProperties(config);
// Add the BundleIndexer plugin
registry = new MockRegistry();
BundleIndexerImpl obrIndexer = new BundleIndexerImpl();
registry.addPlugin(obrIndexer);
repo.setRegistry(registry);
repo.setReporter(reporter);
}
Aggregations