Package org.osgi.service.packageadmin

Examples of org.osgi.service.packageadmin.ExportedPackage


        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

        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(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);
        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"));
        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 });
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

    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

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.