use of org.codice.ddf.admin.application.service.ApplicationServiceException in project ddf by codice.
the class ApplicationServiceImplTest method testStartApplicationASE.
/**
* Tests the {@link ApplicationServiceImpl#startApplication(Application)} method
* for the case where an exception is thrown
*
* @throws Exception
*/
@Test(expected = ApplicationServiceException.class)
public void testStartApplicationASE() throws Exception {
Set<Repository> activeRepos = new HashSet<Repository>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1, noMainFeatureRepo2));
FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
ApplicationService appService = new ApplicationServiceImpl(bundleStateServices) {
@Override
protected BundleContext getContext() {
return bundleContext;
}
};
Application testApp = mock(ApplicationImpl.class);
Feature testFeature = mock(Feature.class);
when(testFeature.getName()).thenReturn(TEST_FEATURE_1_NAME);
when(testApp.getAutoInstallFeatures()).thenReturn(new HashSet<>(Arrays.asList(testFeature)));
doThrow(new ApplicationServiceException()).when(featuresService).installFeatures(anySet(), any(EnumSet.class));
appService.startApplication(testApp);
}
use of org.codice.ddf.admin.application.service.ApplicationServiceException in project ddf by codice.
the class ApplicationServiceBeanTest method testStopApplicationException.
/**
* Tests the {@link ApplicationServiceBean#stopApplication(String)} method for the case where
* an exception is thrown
*
* @throws Exception
*/
@Test
public void testStopApplicationException() throws Exception {
ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer);
doThrow(new ApplicationServiceException()).when(testAppService).stopApplication(TEST_APP_NAME);
assertFalse(serviceBean.stopApplication(TEST_APP_NAME));
verify(testAppService).stopApplication(TEST_APP_NAME);
}
use of org.codice.ddf.admin.application.service.ApplicationServiceException in project ddf by codice.
the class ApplicationServiceBeanTest method testAddApplicationsASE.
/**
* Tests the {@link ApplicationServiceBean#addApplications(List)} method
* for the case where an ApplicationServiceException is thrown
*
* @throws Exception
*/
// TODO RAP 29 Aug 16: DDF-2443 - Fix test to not depend on specific log output
@Test
public void testAddApplicationsASE() 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);
root.setLevel(Level.ALL);
ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer);
List<Map<String, Object>> testURLList = new ArrayList<>();
Map<String, Object> testURLMap1 = mock(HashMap.class);
when(testURLMap1.get("value")).thenReturn(TEST_URL);
Map<String, Object> testURLMap2 = mock(HashMap.class);
when(testURLMap2.get("value")).thenReturn(TEST_URL);
testURLList.add(testURLMap1);
testURLList.add(testURLMap2);
doThrow(new ApplicationServiceException()).when(testAppService).addApplication(any(URI.class));
serviceBean.addApplications(testURLList);
verify(mockAppender, times(2)).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(ADD_APP_ASE);
}
}));
}
use of org.codice.ddf.admin.application.service.ApplicationServiceException in project ddf by codice.
the class ApplicationServiceBeanTest method testGetServicesASE.
/**
* Tests the {@link ApplicationServiceBean#getServices(String)} method
* for the case where an ApplicationServiceException is thrown
*
* @throws Exception
*/
// TODO RAP 29 Aug 16: DDF-2443 - Fix test to not depend on specific log output
@Test
public void testGetServicesASE() 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);
root.setLevel(Level.ALL);
ApplicationServiceBean serviceBean = new ApplicationServiceBean(testAppService, testConfigAdminExt, mBeanServer) {
@Override
protected BundleContext getContext() {
return bundleContext;
}
};
Bundle testBundle = mock(Bundle.class);
Bundle[] bundles = { testBundle };
when(bundleContext.getBundles()).thenReturn(bundles);
List<Map<String, Object>> services = new ArrayList<>();
Map<String, Object> testService1 = new HashMap<>();
services.add(testService1);
doThrow(new ApplicationServiceException()).when(testApp).getBundles();
when(testAppService.getApplication(TEST_APP_NAME)).thenReturn(testApp);
when(testConfigAdminExt.listServices(Mockito.any(String.class), Mockito.any(String.class))).thenReturn(services);
serviceBean.getServices(TEST_APP_NAME);
verify(mockAppender).doAppend(argThat(new ArgumentMatcher() {
@Override
public boolean matches(final Object argument) {
return ((LoggingEvent) argument).getFormattedMessage().contains(GET_SERV_ASE);
}
}));
}
use of org.codice.ddf.admin.application.service.ApplicationServiceException in project ddf by codice.
the class ProfileInstallCommandTest method testExtraProfileInvalidAppInstall.
@Test(expected = ApplicationServiceException.class)
public void testExtraProfileInvalidAppInstall() throws Exception {
profileInstallCommand.profileName = "invalidApp";
doThrow(new ApplicationServiceException()).when(applicationService).startApplication("badApp");
profileInstallCommand.doExecute(applicationService, featuresService, bundleService);
verify(applicationService, times(2)).startApplication(anyString());
}
Aggregations