DefaultBundleFilter extends MotechBundleFilter { @Override public boolean passesCriteria(Bundle bundle) { return bundle != null && !isPlatformBundle(bundle) && importsExportsMotechPackage(bundle); }  @Override boolean passesCriteria(Bundle bundle);  }
@Test public void testWithMotechImport() { when(headers.get(ExtendedBundleInformation.IMPORT_PACKAGE)).thenReturn(MOTECH_IMPORT_EXPORT); when(headers.get(ExtendedBundleInformation.EXPORT_PACKAGE)).thenReturn(NON_MOTECH_IMPORT_EXPORT); when(bundle.getSymbolicName()).thenReturn(NON_PLATFORM_NAME); assertTrue(bundleFilter.passesCriteria(bundle)); }
@Test public void testWithMotechExport() { when(headers.get(ExtendedBundleInformation.IMPORT_PACKAGE)).thenReturn(NON_MOTECH_IMPORT_EXPORT); when(headers.get(ExtendedBundleInformation.EXPORT_PACKAGE)).thenReturn(MOTECH_IMPORT_EXPORT); when(bundle.getSymbolicName()).thenReturn(NON_PLATFORM_NAME); assertTrue(bundleFilter.passesCriteria(bundle)); }
@Test public void testPlatformBundle() { when(bundle.getSymbolicName()).thenReturn(PLATFORM_NAME); when(headers.get(ExtendedBundleInformation.EXPORT_PACKAGE)).thenReturn(MOTECH_IMPORT_EXPORT); when(headers.get(ExtendedBundleInformation.IMPORT_PACKAGE)).thenReturn(NON_MOTECH_IMPORT_EXPORT); assertFalse(bundleFilter.passesCriteria(bundle)); }
@Test public void testNonMotechBundle() { when(headers.get(ExtendedBundleInformation.EXPORT_PACKAGE)).thenReturn(NON_MOTECH_IMPORT_EXPORT); when(headers.get(ExtendedBundleInformation.IMPORT_PACKAGE)).thenReturn(NON_MOTECH_IMPORT_EXPORT); when(bundle.getSymbolicName()).thenReturn(NON_PLATFORM_NAME); assertFalse(bundleFilter.passesCriteria(bundle)); }
@Test public void testAdminBundle() { when(headers.get(ExtendedBundleInformation.EXPORT_PACKAGE)).thenReturn(MOTECH_IMPORT_EXPORT); when(headers.get(ExtendedBundleInformation.IMPORT_PACKAGE)).thenReturn(MOTECH_IMPORT_EXPORT); when(adminBundle.getHeaders()).thenReturn(headers); assertFalse(bundleFilter.passesCriteria(adminBundle)); }
@Test public void testFramework() { when(headers.get(ExtendedBundleInformation.EXPORT_PACKAGE)).thenReturn(MOTECH_IMPORT_EXPORT); when(bundle.getSymbolicName()).thenReturn("org.apache.felix.framework"); assertFalse(bundleFilter.passesCriteria(bundle)); }
@Test public void testOSGiPlatformBundle() { when(bundle.getSymbolicName()).thenReturn("org.motechproject.motech-osgi-platform"); when(headers.get(ExtendedBundleInformation.EXPORT_PACKAGE)).thenReturn(MOTECH_IMPORT_EXPORT); assertFalse(bundleFilter.passesCriteria(bundle)); }