Search in sources :

Example 1 with ExtendedBundleInformation

use of org.motechproject.admin.bundles.ExtendedBundleInformation in project motech by motech.

the class BundleAdminServiceTest method testGetBundleDetails.

@Test
public void testGetBundleDetails() {
    final DateTime now = DateUtil.now();
    setupBundleRetrieval();
    when(bundle.getVersion()).thenReturn(version);
    when(bundle.getState()).thenReturn(Bundle.ACTIVE);
    when(bundle.getHeaders()).thenReturn(headers);
    when(bundle.getRegisteredServices()).thenReturn(new ServiceReference[] { serviceReference });
    when(bundleContext.getService(serviceReference)).thenReturn(new Object());
    when(bundle.getServicesInUse()).thenReturn(new ServiceReference[] { exposedServiceReference });
    when(bundleContext.getService(exposedServiceReference)).thenReturn(new Object());
    when(headers.get(ExtendedBundleInformation.BUILT_BY)).thenReturn("Builder");
    when(headers.get(ExtendedBundleInformation.BUILD_JDK)).thenReturn("JDK 7");
    when(headers.get(ExtendedBundleInformation.TOOL)).thenReturn("Hammer");
    when(headers.get(ExtendedBundleInformation.CREATED_BY)).thenReturn("Me");
    when(headers.get(ExtendedBundleInformation.VENDOR)).thenReturn("GF");
    when(headers.get(ExtendedBundleInformation.BUNDLE_ACTIVATOR)).thenReturn("org.my.Activator");
    when(headers.get(ExtendedBundleInformation.DESCRIPTION)).thenReturn("bla bla");
    when(headers.get(ExtendedBundleInformation.DOC_URL)).thenReturn("www.doc.org");
    when(headers.get(ExtendedBundleInformation.IMPORT_PACKAGE)).thenReturn("imp1,imp2");
    when(headers.get(ExtendedBundleInformation.EXPORT_PACKAGE)).thenReturn("exp1,exp2");
    when(headers.get(ExtendedBundleInformation.LAST_MODIFIED)).thenReturn(String.valueOf(now.getMillis()));
    ExtendedBundleInformation bundleInfo = moduleAdminService.getBundleDetails(BUNDLE_ID);
    verify(importExportResolver).resolveBundleWiring(bundleInfo);
    verify(bundleContext).getBundle(BUNDLE_ID);
    assertEquals(BundleInformation.State.ACTIVE, bundleInfo.getState());
    assertEquals(Arrays.asList(Object.class.getName()), bundleInfo.getRegisteredServices());
    assertEquals(Arrays.asList(Object.class.getName()), bundleInfo.getServicesInUse());
    assertEquals("Builder", bundleInfo.getBuiltBy());
    assertEquals("JDK 7", bundleInfo.getBuildJDK());
    assertEquals("Hammer", bundleInfo.getTool());
    assertEquals("Me", bundleInfo.getCreatedBy());
    assertEquals("GF", bundleInfo.getVendor());
    ;
    assertEquals("org.my.Activator", bundleInfo.getBundleActivator());
    assertEquals("bla bla", bundleInfo.getDescription());
    assertEquals("www.doc.org", bundleInfo.getDocURL());
    assertEquals("imp1, imp2", bundleInfo.getImportPackageHeader());
    assertEquals("exp1, exp2", bundleInfo.getExportPackageHeader());
    assertEquals(now, bundleInfo.getLastModified());
}
Also used : DateTime(org.joda.time.DateTime) ExtendedBundleInformation(org.motechproject.admin.bundles.ExtendedBundleInformation) Test(org.junit.Test)

Example 2 with ExtendedBundleInformation

use of org.motechproject.admin.bundles.ExtendedBundleInformation in project motech by motech.

the class ModuleAdminServiceImpl method getBundleDetails.

@Override
public ExtendedBundleInformation getBundleDetails(long bundleId) {
    Bundle bundle = getBundle(bundleId);
    ExtendedBundleInformation bundleInfo = new ExtendedBundleInformation(bundle);
    importExportResolver.resolveBundleWiring(bundleInfo);
    return bundleInfo;
}
Also used : Bundle(org.osgi.framework.Bundle) ExtendedBundleInformation(org.motechproject.admin.bundles.ExtendedBundleInformation)

Aggregations

ExtendedBundleInformation (org.motechproject.admin.bundles.ExtendedBundleInformation)2 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 Bundle (org.osgi.framework.Bundle)1