Package org.osgi.service.packageadmin

Examples of org.osgi.service.packageadmin.ExportedPackage


        Bundle bundle = mock(Bundle.class);
        PackageAdmin admin = mock(PackageAdmin.class);
       
        assertEquals(0, getBundleExportedPackages(bundle, admin).length);
       
        ExportedPackage exported = mock(ExportedPackage.class);
        when(exported.getName()).thenReturn("org.apache.aries.jmx");
        when(exported.getVersion()).thenReturn(new Version("1.0.0"));
        when(admin.getExportedPackages(bundle)).thenReturn(new ExportedPackage[] { exported });
       
        assertArrayEquals(new String[] { "org.apache.aries.jmx;1.0.0"} , getBundleExportedPackages(bundle, admin));
       
    }
View Full Code Here


        Bundle b1 = mock(Bundle.class);
        Bundle b2 = mock(Bundle.class);
        Bundle b3 = mock(Bundle.class);
        when(context.getBundles()).thenReturn(new Bundle[] { bundle, b1, b2, b3 });
       
        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);
        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"));
       
        PackageAdmin admin = mock(PackageAdmin.class);
        when(admin.getExportedPackages(b1)).thenReturn(new ExportedPackage[] { ep1 });
        when(admin.getExportedPackages(b2)).thenReturn(new ExportedPackage[] { ep2 });
        when(admin.getExportedPackages(b3)).thenReturn(null);
View Full Code Here

        {
            final Bundle bundle = bundles[i];
            final ExportedPackage[] bundleExports = pa.getExportedPackages(bundle);
            for (int j = 0; bundleExports != null && j < bundleExports.length; j++)
            {
                final ExportedPackage exportedPackage = bundleExports[j];
                Set/*<ExportedPackage>*/exportSet = (Set) exports.get(exportedPackage.getName());
                if (exportSet == null)
                {
                    exportSet = new TreeSet/*<ExportedPackage>*/(
                        EXPORT_PACKAGE_COMPARATOR);
                    exports.put(exportedPackage.getName(), exportSet);
                }
                exportSet.add(exportedPackage);
            }
        }

View Full Code Here

            {
                final JSONObject container = new JSONObject();
                ret.put(container);
                for (Iterator packageIter = exportSet.iterator(); packageIter.hasNext();)
                {
                    ExportedPackage exportedPackage = (ExportedPackage) packageIter.next();
                    final JSONObject json = toJSON(exportedPackage);
                    Bundle[] importers = exportedPackage.getImportingBundles();
                    for (int j = 0; importers != null && j < importers.length; j++)
                    {
                        json.append("importers", toJSON(importers[j], new JSONObject())); //$NON-NLS-1$
                    }
                    container//
                    .put("name", exportedPackage.getName()) //$NON-NLS-1$
                    .append("entries", json); //$NON-NLS-1$
                }
            }
        }
        return ret;
View Full Code Here

    {
        final JSONObject ret = new JSONObject();
        final ExportedPackage[] exports = pa.getExportedPackages(packageName);
        for (int i = 0; exports != null && i < exports.length; i++)
        {
            final ExportedPackage x = exports[i];
            ret.append("exporters", toJSON(x)); //$NON-NLS-1$
            exportingBundles.add(x.getExportingBundle());
        }
        return ret.put("name", packageName); //$NON-NLS-1$
    }
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

        Bundle bundle = mock(Bundle.class);
        PackageAdmin admin = mock(PackageAdmin.class);
       
        assertEquals(0, getBundleExportedPackages(bundle, admin).length);
       
        ExportedPackage exported = mock(ExportedPackage.class);
        when(exported.getName()).thenReturn("org.apache.aries.jmx");
        when(exported.getVersion()).thenReturn(new Version("1.0.0"));
        when(admin.getExportedPackages(bundle)).thenReturn(new ExportedPackage[] { exported });
       
        assertArrayEquals(new String[] { "org.apache.aries.jmx;1.0.0"} , getBundleExportedPackages(bundle, admin));
       
    }
View Full Code Here

        Bundle b1 = mock(Bundle.class);
        Bundle b2 = mock(Bundle.class);
        Bundle b3 = mock(Bundle.class);
        when(context.getBundles()).thenReturn(new Bundle[] { bundle, b1, b2, b3 });
       
        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);
        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"));
       
        PackageAdmin admin = mock(PackageAdmin.class);
        when(admin.getExportedPackages(b1)).thenReturn(new ExportedPackage[] { ep1 });
        when(admin.getExportedPackages(b2)).thenReturn(new ExportedPackage[] { ep2 });
        when(admin.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

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.