Package org.osgi.service.packageadmin

Examples of org.osgi.service.packageadmin.ExportedPackage


    private Bundle getDummyHostBundle(String packageName) {

        if (packageAdmin == null)
            return null;

        ExportedPackage exp = packageAdmin.getExportedPackage(packageName);
        if (exp == null)
            return null;
        else
            return exp.getExportingBundle();
    }
View Full Code Here


      // if the bundle is already included (it's a required one), there's no need to look at it again
      if (!importedBundles.containsKey(analyzedBundle)) {
        ExportedPackage[] epa = pa.getExportedPackages(analyzedBundle);
        if (epa != null)
          for (int j = 0; j < epa.length; j++) {
            ExportedPackage exportedPackage = epa[j];
            Bundle[] importingBundles = exportedPackage.getImportingBundles();
            if (importingBundles != null)
              for (int k = 0; k < importingBundles.length; k++) {
                if (bundle.equals(importingBundles[k])) {
                  addImportedBundle(importedBundles, exportedPackage.getExportingBundle(),
                    exportedPackage.getName());
                }
              }
          }
      }
    }
View Full Code Here

    if (packages == null) {
      packages = new ArrayList(pkgs.length);
      map.put(bundle, packages);
    }
    for (int i = 0; i < pkgs.length; i++) {
      ExportedPackage exportedPackage = pkgs[i];
      packages.add(exportedPackage.getName());
    }
  }
View Full Code Here

    private Bundle getDummyHostBundle(String packageName) {

        if (packageAdmin == null)
            return null;

        ExportedPackage exp = packageAdmin.getExportedPackage(packageName);
        if (exp == null)
            return null;
        else
            return exp.getExportingBundle();
    }
View Full Code Here

    private Bundle getDummyHostBundle(String packageName) {
       
        if (packageAdmin == null)
            return null;
       
        ExportedPackage exp = packageAdmin.getExportedPackage(packageName);
        if (exp == null)
            return null;
        else
            return exp.getExportingBundle();
    }
View Full Code Here

        headers.put(Constants.BUNDLE_SYMBOLICNAME, "test");
        headers.put(Constants.BUNDLE_VERSION, "0.0.0");
        when(bundle.getHeaders()).thenReturn(headers);

        //exported packages
        ExportedPackage exported = mock(ExportedPackage.class);
        when(exported.getName()).thenReturn("org.apache.aries.jmx");
        when(exported.getVersion()).thenReturn(new Version("1.0.0"));
        when(exported.getExportingBundle()).thenReturn(bundle);
        when(packageAdmin.getExportedPackages(bundle)).thenReturn(new ExportedPackage[] { exported });

        //imported packages
        ExportedPackage ep1 = mock(ExportedPackage.class);
        when(ep1.getImportingBundles()).thenReturn(new Bundle[] { bundle, b2, b3 });
        when(ep1.getName()).thenReturn("org.apache.aries.jmx.b1");
        when(ep1.getVersion()).thenReturn(Version.emptyVersion);
        when(ep1.getExportingBundle()).thenReturn(b1);
        ExportedPackage ep2 = mock(ExportedPackage.class);
        when(ep2.getImportingBundles()).thenReturn(new Bundle[] { bundle, b3 });
        when(ep2.getName()).thenReturn("org.apache.aries.jmx.b2");
        when(ep2.getVersion()).thenReturn(Version.parseVersion("2.0.1"));
        when(ep2.getExportingBundle()).thenReturn(b2);
        headers.put(Constants.DYNAMICIMPORT_PACKAGE, "*");

        when(packageAdmin.getExportedPackages(b1)).thenReturn(new ExportedPackage[] { ep1 });
        when(packageAdmin.getExportedPackages(b2)).thenReturn(new ExportedPackage[] { ep2 });
        when(packageAdmin.getExportedPackages(b3)).thenReturn(null);
View Full Code Here

        mbean = new PackageState(context, admin);
    }

    @Test
    public void testGetExportingBundles() throws IOException {
        ExportedPackage exported = Mockito.mock(ExportedPackage.class);
        Bundle bundle = Mockito.mock(Bundle.class);
        Mockito.when(exported.getVersion()).thenReturn(Version.parseVersion("1.0.0"));
        Mockito.when(exported.getExportingBundle()).thenReturn(bundle);
        Mockito.when(bundle.getBundleId()).thenReturn(Long.valueOf(5));
        ExportedPackage exported2 = Mockito.mock(ExportedPackage.class);
        Bundle bundle2 = Mockito.mock(Bundle.class);
        Mockito.when(exported2.getVersion()).thenReturn(Version.parseVersion("1.0.0"));
        Mockito.when(exported2.getExportingBundle()).thenReturn(bundle2);
        Mockito.when(bundle2.getBundleId()).thenReturn(Long.valueOf(6));
        Mockito.when(admin.getExportedPackages(Mockito.anyString())).thenReturn(new ExportedPackage[]{exported, exported2});
        long[] ids = mbean.getExportingBundles("test", "1.0.0");
        Assert.assertNotNull(ids);
        Assert.assertArrayEquals(new long[]{5,6}, ids);
View Full Code Here

        Assert.assertArrayEquals(new long[]{5,6}, ids);
    }

    @Test
    public void testGetImportingBundles() throws IOException {
        ExportedPackage exported = Mockito.mock(ExportedPackage.class);
        Bundle bundle = Mockito.mock(Bundle.class);
        Bundle exportingBundle = Mockito.mock(Bundle.class);
        Mockito.when(exported.getVersion()).thenReturn(Version.parseVersion("1.0.0"));
        Mockito.when(exported.getExportingBundle()).thenReturn(exportingBundle);
        Mockito.when(exportingBundle.getBundleId()).thenReturn(Long.valueOf(2));
        Mockito.when(exported.getImportingBundles()).thenReturn(new Bundle[]{bundle});
        Mockito.when(bundle.getBundleId()).thenReturn(Long.valueOf(4));
        Mockito.when(admin.getExportedPackages(Mockito.anyString())).thenReturn(new ExportedPackage[]{exported});
        long[] ids = mbean.getImportingBundles("test", "1.0.0", 2);
        Assert.assertArrayEquals(new long[]{4}, ids);
    }
View Full Code Here

        Assert.assertArrayEquals(new long[]{4}, ids);
    }

    @Test
    public void testIsRemovalPending() throws IOException {
        ExportedPackage exported = Mockito.mock(ExportedPackage.class);
        Bundle expBundle = Mockito.mock(Bundle.class);
        Mockito.when(exported.getVersion()).thenReturn(Version.parseVersion("1.0.0"));
        Mockito.when(exported.isRemovalPending()).thenReturn(true);
        Mockito.when(exported.getExportingBundle()).thenReturn(expBundle);
        Mockito.when(expBundle.getBundleId()).thenReturn(Long.valueOf(2));
        Mockito.when(admin.getExportedPackages(Mockito.anyString())).thenReturn(new ExportedPackage[]{exported});
        boolean isRemoval = mbean.isRemovalPending("test", "1.0.0", Long.valueOf(2));
        Assert.assertTrue(isRemoval);
    }
View Full Code Here

    @Test
    public void testListPackages() throws IOException {
        Bundle bundle = Mockito.mock(Bundle.class);
        Bundle impBundle = Mockito.mock(Bundle.class);
        Mockito.when(context.getBundles()).thenReturn(new Bundle[]{bundle});
        ExportedPackage exported = Mockito.mock(ExportedPackage.class);
        Mockito.when(exported.getVersion()).thenReturn(Version.parseVersion("1.0.0"));
        Mockito.when(exported.getImportingBundles()).thenReturn(new Bundle[]{impBundle});
        Mockito.when(exported.getName()).thenReturn("test");
        Mockito.when(exported.getExportingBundle()).thenReturn(bundle);
        Mockito.when(bundle.getBundleId()).thenReturn(Long.valueOf(4));
        Mockito.when(impBundle.getBundleId()).thenReturn(Long.valueOf(5));
        Mockito.when(admin.getExportedPackages(bundle)).thenReturn(new ExportedPackage[]{exported});
        TabularData table = mbean.listPackages();
        Assert.assertEquals(PackageStateMBean.PACKAGES_TYPE,table.getTabularType());
View Full Code Here

TOP

Related Classes of org.osgi.service.packageadmin.ExportedPackage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.