Search in sources :

Example 36 with MockRegistry

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());
}
Also used : Capability(org.osgi.resource.Capability) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability) MockRegistry(test.lib.MockRegistry) BndEditModel(aQute.bnd.build.model.BndEditModel)

Example 37 with MockRegistry

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();
}
Also used : NonGeneratingProvider(test.repository.NonGeneratingProvider) HashMap(java.util.HashMap) BufferedInputStream(java.io.BufferedInputStream) MockRegistry(test.lib.MockRegistry) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) FileInputStream(java.io.FileInputStream)

Example 38 with MockRegistry

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");
}
Also used : Processor(aQute.bnd.osgi.Processor) MockRegistry(test.lib.MockRegistry) Resource(org.osgi.resource.Resource) TreeSet(java.util.TreeSet) List(java.util.List)

Example 39 with MockRegistry

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);
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Resolver(org.osgi.service.resolver.Resolver) MockRegistry(test.lib.MockRegistry) ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource) Requirement(org.osgi.resource.Requirement) ArrayList(java.util.ArrayList) List(java.util.List) BndEditModel(aQute.bnd.build.model.BndEditModel)

Example 40 with MockRegistry

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);
}
Also used : Processor(aQute.bnd.osgi.Processor) Resolver(org.osgi.service.resolver.Resolver) MockRegistry(test.lib.MockRegistry) Resource(org.osgi.resource.Resource) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MockRegistry (test.lib.MockRegistry)41 BndEditModel (aQute.bnd.build.model.BndEditModel)34 Requirement (org.osgi.resource.Requirement)32 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)28 Capability (org.osgi.resource.Capability)26 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)25 Resource (org.osgi.resource.Resource)15 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)7 List (java.util.List)6 Resolver (org.osgi.service.resolver.Resolver)6 Processor (aQute.bnd.osgi.Processor)5 File (java.io.File)4 ExportedPackage (aQute.bnd.build.model.clauses.ExportedPackage)2 Parameters (aQute.bnd.header.Parameters)2 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)2 ResolverHook (aQute.bnd.service.resolve.hook.ResolverHook)2 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 Iterator (java.util.Iterator)2