コード例 #1
0
  @Test
  public void testRequireBundle() throws Exception {

    RepositoryReader reader = storage.getRepositoryReader();
    XResource resource = reader.nextResource();
    Assert.assertNotNull("Resource not null", resource);
    Assert.assertNull("One resource only", reader.nextResource());

    XRequirementBuilder builder =
        XRequirementBuilder.create(BundleNamespace.BUNDLE_NAMESPACE, "org.acme.pool");
    XRequirement req = builder.getRequirement();

    Collection<Capability> providers = storage.findProviders(req);
    Assert.assertNotNull("Providers not null", providers);
    Assert.assertEquals("One provider", 1, providers.size());

    XCapability cap = (XCapability) providers.iterator().next();
    Assert.assertNotNull("Capability not null", cap);
    Assert.assertSame(resource, cap.getResource());
  }
コード例 #2
0
  @Test
  public void testRequireBundleWithFilter() throws Exception {

    XRequirementBuilder builder = XRequirementBuilder.create(BundleNamespace.BUNDLE_NAMESPACE);
    builder
        .getDirectives()
        .put(BundleNamespace.REQUIREMENT_FILTER_DIRECTIVE, "(osgi.wiring.bundle=org.acme.pool)");
    XRequirement req = builder.getRequirement();

    Collection<Capability> providers = storage.findProviders(req);
    Assert.assertNotNull("Providers not null", providers);
    Assert.assertEquals("One provider", 1, providers.size());
  }
コード例 #3
0
 @Before
 public void setUp() throws Exception {
   storage = new MemoryRepositoryStorage(Mockito.mock(XRepository.class));
   RepositoryReader reader = getRepositoryReader("xml/sample-repository.xml");
   storage.addResource(reader.nextResource());
 }