Beispiel #1
0
  public void testSimpleResolve() {
    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.gogo.shell", "[0,1)");
    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);
      Set<Resource> resources = resolved.keySet();
      Resource resource = getResource(resources, "org.apache.felix.gogo.runtime", "0.12");
      assertNotNull(resource);
    } catch (ResolutionException e) {
      fail("Resolve failed");
    }
  }
Beispiel #2
0
  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());
    }
  }
  @Test
  public void testRepositoryService() throws Exception {

    Repository repo = getRepository();
    MavenCoordinates coordinates =
        MavenCoordinates.parse("org.apache.felix:org.apache.felix.eventadmin:1.2.6");
    Requirement req = XRequirementBuilder.createArtifactRequirement(coordinates);
    assertNotNull("Requirement not null", req);

    Collection<Capability> caps = repo.findProviders(Collections.singleton(req)).get(req);
    assertEquals("Capability not null", 1, caps.size());

    XIdentityCapability xcap = (XIdentityCapability) caps.iterator().next();
    assertEquals("org.apache.felix.eventadmin", xcap.getSymbolicName());
    InputStream content = ((XResource) xcap.getResource()).getContent();
    try {
      Bundle bundle = context.installBundle(xcap.getSymbolicName(), content);
      try {
        bundle.start();
        Assert.assertEquals(Bundle.ACTIVE, bundle.getState());
        ServiceReference sref = context.getServiceReference("org.osgi.service.event.EventAdmin");
        assertNotNull("EventAdmin service not null", sref);
      } finally {
        bundle.uninstall();
      }
    } finally {
      content.close();
    }
  }
Beispiel #4
0
  public void testScr() {
    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.createSimpleRequirement("osgi.extender", "osgi.component", "[1.1,2)");
    requires.add(capReq.buildSyntheticRequirement());

    Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires);
    assertNotNull(shell);
    assertEquals(1, shell.size());
  }