use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class AddApplicationCommandTest method testAddApplicationCommandInvalidURIParam.
/**
* Tests the {@link AddApplicationCommand} class and its contained methods
* for the case where it is given an invalid URI as a parameter
*
* @throws Exception
*/
@Test
public void testAddApplicationCommandInvalidURIParam() throws Exception {
ApplicationService testAppService = mock(ApplicationServiceImpl.class);
AddApplicationCommand addApplicationCommand = new AddApplicationCommand();
addApplicationCommand.appName = ">BadURI<";
//Should have a graceful recovery, if an exception is thrown, this test fails.
addApplicationCommand.doExecute(testAppService);
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationConfigInstallerTest method testRunASE.
/**
* Tests the {@link ApplicationConfigInstaller#run()} method for the case
* where an ApplicationServiceException is thrown by appService.addApplication(..)
*
* @throws Exception
*/
// TODO RAP 29 Aug 16: DDF-2443 - Fix test to not depend on specific log output
@Test
public void testRunASE() throws Exception {
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);
FeaturesService featuresService = mock(FeaturesService.class);
ApplicationService testAppService = mock(ApplicationServiceImpl.class);
doThrow(new ApplicationServiceException()).when(testAppService).startApplication(anyString());
URL fileURL = this.getClass().getResource("/" + GOOD_FILE);
ApplicationConfigInstaller configInstaller = getApplicationConfigInstaller(fileURL.getFile(), testAppService, featuresService, START_FEATURE, STOP_FEATURE);
configInstaller.run();
verify(mockAppender).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(RUN_ASE_EX);
}
}));
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class ApplicationConfigInstallerTest method testFileValid.
/**
* Tests with a valid file that contains one application that all of the
* services were called correctly.
*
* @throws Exception
*/
@Test
public void testFileValid() throws Exception {
FeaturesService featuresService = mock(FeaturesService.class);
ApplicationService appService = mock(ApplicationService.class);
URL fileURL = this.getClass().getResource("/" + GOOD_FILE);
ApplicationConfigInstaller configInstaller = getApplicationConfigInstaller(fileURL.getFile(), appService, featuresService, START_FEATURE, STOP_FEATURE);
configInstaller.run();
// verify that the correct application was started
verify(appService, never()).addApplication(any(URI.class));
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 RemoveApplicationCommandTest method testRemoveApplicationCommand.
/**
* Tests the {@link RemoveApplicationCommand} class
*
* @throws Exception
*/
@Test
public void testRemoveApplicationCommand() throws Exception {
ApplicationService testAppService = mock(ApplicationServiceImpl.class);
RemoveApplicationCommand removeApplicationCommand = new RemoveApplicationCommand();
removeApplicationCommand.appName = APP_NAME;
removeApplicationCommand.doExecute(testAppService);
verify(testAppService).removeApplication(APP_NAME);
}
use of org.codice.ddf.admin.application.service.ApplicationService in project ddf by codice.
the class StopApplicationCommandTest method testStopApplicationCommandTest.
/**
* Tests the {@link StopApplicationCommand} class and its associated methods
*
* @throws Exception
*/
@Test
public void testStopApplicationCommandTest() throws Exception {
ApplicationService testAppService = mock(ApplicationServiceImpl.class);
Application testApp = mock(ApplicationImpl.class);
ApplicationStatus testStatus = mock(ApplicationStatus.class);
StopApplicationCommand stopApplicationCommand = new StopApplicationCommand();
stopApplicationCommand.appName = APP_NAME;
when(testStatus.getState()).thenReturn(ApplicationState.ACTIVE);
when(testAppService.getApplicationStatus(testApp)).thenReturn(testStatus);
when(testAppService.getApplication(APP_NAME)).thenReturn(testApp);
stopApplicationCommand.doExecute(testAppService);
verify(testAppService).stopApplication(APP_NAME);
}
Aggregations