use of org.apache.karaf.features.FeaturesService in project ddf by codice.
the class ProfileInstallCommandTest method testNullFeature.
@Test(expected = IllegalArgumentException.class)
public void testNullFeature() throws Exception {
FeaturesService badFeatureService = mock(FeaturesService.class);
when(badFeatureService.getFeature(any())).thenReturn(null);
profileInstallCommand.profileName = "invalidFeatureUninstall";
profileInstallCommand.doExecute(applicationService, badFeatureService, bundleService);
}
use of org.apache.karaf.features.FeaturesService in project ddf by codice.
the class ProfileInstallCommandTest method testPostInstallerAndInstaller.
@Test
public void testPostInstallerAndInstaller() throws Exception {
Feature postInstallFeature = createMockFeature("admin-post-install-modules");
Feature installerFeature = createMockFeature("admin-modules-installer");
this.featuresService = mock(FeaturesService.class);
when(featuresService.getFeature("admin-post-install-modules")).thenReturn(postInstallFeature);
when(featuresService.getFeature("admin-modules-installer")).thenReturn(installerFeature);
when(featuresService.isInstalled(postInstallFeature)).thenReturn(false);
when(featuresService.isInstalled(installerFeature)).thenReturn(true);
profileInstallCommand.profileName = "invalidStopBundles";
profileInstallCommand.doExecute(applicationService, featuresService, bundleService);
verify(featuresService).installFeature(eq("admin-post-install-modules"), eq(NO_AUTO_REFRESH));
verify(featuresService).uninstallFeature(eq("admin-modules-installer"), eq(NO_AUTO_REFRESH));
}
use of org.apache.karaf.features.FeaturesService 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.apache.karaf.features.FeaturesService 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.apache.karaf.features.FeaturesService in project ddf by codice.
the class ApplicationConfigInstallerTest method testFileNotValid.
/**
* Tests that when a file is not found, the post install start and post
* install stop features are NOT called.
*/
@Test
public void testFileNotValid() throws Exception {
FeaturesService featuresService = mock(FeaturesService.class);
ApplicationConfigInstaller configInstaller = getApplicationConfigInstaller(BAD_FILE, null, featuresService, START_FEATURE, STOP_FEATURE);
configInstaller.run();
// verify the post start and post stop features were not called
verify(featuresService, never()).installFeature(anyString(), any(EnumSet.class));
verify(featuresService, never()).uninstallFeature(anyString());
}
Aggregations