コード例 #1
0
  public void testSupplementerRegistryWithRemovedSupplementer() throws Exception {
    final Hashtable headers = new Hashtable();
    headers.put("Eclipse-SupplementBundle", "test.bundle1");
    EasyMock.expect(bundle.getHeaders()).andStubReturn(headers);
    EasyMock.expect(context.getBundles()).andReturn(new Bundle[] {bundle});

    EasyMock.replay(mocks);

    registry.addBundle(bundle);
    registry.removeBundle(bundle);

    final ManifestElement[] imports =
        ManifestElement.parseHeader("Import-Package", "org.test1,\n org.test2");
    final ManifestElement[] exports =
        ManifestElement.parseHeader("Export-Package", "org.test3,\n org.test4");
    final List<Supplementer> supplementers =
        registry.getMatchingSupplementers("test.bundle1", imports, exports);
    assertNotNull(supplementers);
    assertEquals(0, supplementers.size());

    EasyMock.verify(mocks);
  }
コード例 #2
0
  /**
   * test different supplementers and removed supplementers
   *
   * @throws Exception
   */
  public void testSupplementerRegistryWithDifferentRemovedSupplementers() throws Exception {
    Hashtable headers = new Hashtable();
    headers.put("Eclipse-SupplementImporter", "test.import1");
    EasyMock.expect(supplementerBundle1.getHeaders()).andStubReturn(headers);

    headers = new Hashtable();
    headers.put("Eclipse-SupplementExporter", "test.export1");
    EasyMock.expect(supplementerBundle2.getHeaders()).andStubReturn(headers);

    headers = new Hashtable();
    headers.put("Eclipse-SupplementBundle", "symbolic-name-supplementedBundle*");
    EasyMock.expect(supplementerBundle3.getHeaders()).andStubReturn(headers);

    EasyMock.expect(context.getBundles())
        .andStubReturn(
            new Bundle[] {supplementerBundle1, supplementerBundle2, supplementerBundle3});

    headers = new Hashtable();
    headers.put("Import-Package", "test.import1");
    headers.put("Export-Package", "test.export1");
    EasyMock.expect(supplementedBundle1.getHeaders()).andStubReturn(headers);

    headers = new Hashtable();
    EasyMock.expect(supplementedBundle2.getHeaders()).andStubReturn(headers);

    EasyMock.expect(supplementedBundle1.getState()).andStubReturn(Bundle.RESOLVED);
    EasyMock.expect(supplementedBundle2.getState()).andStubReturn(Bundle.RESOLVED);

    packageAdmin.refreshPackages(EasyMock.aryEq(new Bundle[] {supplementedBundle1}));
    packageAdmin.refreshPackages(
        EasyMock.aryEq(new Bundle[] {supplementedBundle1, supplementedBundle2}));

    IWeavingAdaptor adaptor = EasyMock.createNiceMock(IWeavingAdaptor.class);
    EasyMock.expect(adaptorProvider.getAdaptor(6l)).andStubReturn(adaptor);
    EasyMock.expect(adaptorProvider.getAdaptor(7l)).andStubReturn(adaptor);

    EasyMock.replay(mocks);

    registry.addBundle(supplementerBundle1);
    registry.addBundle(supplementerBundle2);
    registry.addBundle(supplementerBundle3);
    registry.addBundle(supplementedBundle1);
    registry.addBundle(supplementedBundle2);

    registry.removeBundle(supplementerBundle1);
    registry.removeBundle(supplementerBundle3);

    Supplementer[] supplementers = registry.getSupplementers(supplementedBundle1);
    assertEquals(1, supplementers.length);
    assertFalse(containsSupplementer(supplementers, supplementerBundle1));
    assertTrue(containsSupplementer(supplementers, supplementerBundle2));
    assertFalse(containsSupplementer(supplementers, supplementerBundle3));

    supplementers = registry.getSupplementers(supplementedBundle2);
    assertEquals(0, supplementers.length);
    assertFalse(containsSupplementer(supplementers, supplementerBundle1));
    assertFalse(containsSupplementer(supplementers, supplementerBundle2));
    assertFalse(containsSupplementer(supplementers, supplementerBundle3));

    EasyMock.verify(mocks);
  }