use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class NotActiveApplicationsCompleterTest method testNotActiveApplicationsCompleterNullAppService.
/**
* Tests the {@link NotActiveApplicationsCompleter#complete(String, int, List)} method
* for the case where the ApplicationService given to it is null
*/
// TODO RAP 29 Aug 16: DDF-2443 - Fix test to not depend on specific log output
@Test
public void testNotActiveApplicationsCompleterNullAppService() {
ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
final Appender mockAppender = mock(Appender.class);
when(mockAppender.getName()).thenReturn("MOCK");
root.addAppender(mockAppender);
root.setLevel(Level.ALL);
ApplicationService testAppService = null;
NotActiveApplicationsCompleter notActiveApplicationsCompleter = new NotActiveApplicationsCompleter();
notActiveApplicationsCompleter.setApplicationService(testAppService);
notActiveApplicationsCompleter.complete(null, commandLine, new ArrayList<>());
verify(mockAppender).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(NO_APP_SERV);
}
}));
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationConfigInstallerTest method testFileEmpty.
/**
* Tests the use case that there is a file but it does not have any apps
* listed in it (they are commented out). The test should not call the
* features stop and start since no apps were loaded.
*
* @throws Exception
*/
@Test
public void testFileEmpty() throws Exception {
FeaturesService featuresService = mock(FeaturesService.class);
ApplicationService appService = mock(ApplicationService.class);
URL fileURL = this.getClass().getResource("/" + EMPTY_FILE);
ApplicationConfigInstaller configInstaller = getApplicationConfigInstaller(fileURL.getFile(), appService, featuresService, START_FEATURE, STOP_FEATURE);
configInstaller.run();
// verify that the app service was never called
verify(appService, never()).addApplication(any(URI.class));
verify(appService, never()).startApplication(anyString());
// verify the post start and post stop features were not called
verify(featuresService, never()).installFeature(anyString(), any(EnumSet.class));
verify(featuresService, never()).uninstallFeature(anyString());
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationConfigInstallerTest method testFileInstall.
/**
* Tests with a valid file that contains one non-local application that all of the
* services were called correctly.
*
* @throws Exception
*/
@Test
public void testFileInstall() throws Exception {
FeaturesService featuresService = mock(FeaturesService.class);
ApplicationService appService = mock(ApplicationService.class);
URL fileURL = this.getClass().getResource("/" + INSTALL_FILE);
ApplicationConfigInstaller configInstaller = getApplicationConfigInstaller(fileURL.getFile(), appService, featuresService, START_FEATURE, STOP_FEATURE);
configInstaller.run();
// verify that the correct application was added and then started
verify(appService).addApplication(new URI("file:/location/to/solr-app-1.0.0.kar"));
verify(appService).startApplication("solr-app");
// verify the post start and post stop features were called
verify(featuresService).installFeature(START_FEATURE, EnumSet.of(Option.NoAutoRefreshBundles));
verify(featuresService).uninstallFeature(STOP_FEATURE);
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testGetApplicationStatusReturnsActiveStatusForNotInstalledFeatureDependencyThatContainsActiveBundle.
/**
* Test method for
* {@link ApplicationService#getApplicationStatus(Application)}
* <p>
* Verifies method returns an {@link ApplicationState#ACTIVE} state for an
* {@code Application} under the following conditions:
* <p>
* <ul>
* <li>Main feature is installed</li>
* <li>One dependency feature is NOT installed</li>
* <li>Dependency feature that is not installed contains a {@code Bundle}
* with a state of {@link Bundle#ACTIVE} and extended state of
* {@link BundleState#Active}</li>
* </ul>
* <p>
* This effectively emulates the circumstance in which there is a
* {@code Feature} in another {@code Application} that includes and starts
* the same {@code Bundle} that is contained in a {@code Feature} of the
* current {@code Application} that is not installed.
*
* @throws Exception
*/
@Test
public void testGetApplicationStatusReturnsActiveStatusForNotInstalledFeatureDependencyThatContainsActiveBundle() throws Exception {
Set<String> notInstalledFeatureNames = new HashSet<String>();
notInstalledFeatureNames.add(TEST_MAIN_FEATURES_1_FEATURE_1_NAME);
FeaturesService featuresService = createMockFeaturesService(mainFeatureRepo, notInstalledFeatureNames, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
assertNotNull("Features repo is missing feature with the name of \"" + TEST_MAIN_FEATURES_1_FEATURE_1_NAME + "\"", featuresService.getFeature(TEST_MAIN_FEATURES_1_FEATURE_1_NAME));
ApplicationService appService = createPermittedApplicationServiceImpl();
assertEquals(ApplicationService.class.getName() + " does not contain the expected number of Applications", 1, appService.getApplications().size());
assertEquals(mainFeatureRepo.getName() + " returned unexpected state", ApplicationState.ACTIVE, appService.getApplicationStatus(appService.getApplications().toArray(new Application[] {})[0]).getState());
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationServiceImplTest method testGetApplicationStatusReturnsInactiveWhenBundleStateServiceStateIsStopping.
/**
* Test method for
* {@link ApplicationServiceImpl#getApplicationStatus(Application)}
* <p>
* Verifies that {@link ApplicationState#INACTIVE} is returned when the
* extended bundle state reported by an injection framework states that one
* bundle is in an {@link BundleState#Stopping} state and the rest of the
* bundles are in an {@link BundleState#Active} state.
*
* @throws Exception
*/
@Test
public void testGetApplicationStatusReturnsInactiveWhenBundleStateServiceStateIsStopping() throws Exception {
ApplicationService appService = getAppServiceWithBundleStateServiceInGivenState(mainFeatureRepo2, BundleState.Stopping);
assertNotNull("Repository \"" + mainFeatureRepo.getName() + "\" does not contain any bundles", appService);
assertEquals(mainFeatureRepo2.getName() + " returned unexpected state", ApplicationState.INACTIVE, appService.getApplicationStatus(appService.getApplications().toArray(new Application[] {})[0]).getState());
}
Aggregations