Search in sources :

Example 1 with INACTIVE

use of org.codice.ddf.admin.application.service.ApplicationStatus.ApplicationState.INACTIVE in project ddf by codice.

the class TestApplicationService method bTestAppStatus.

@Test
public void bTestAppStatus() throws ApplicationServiceException, InterruptedException {
    systemSubject.execute(() -> {
        // Test AppService
        ApplicationService applicationService = getServiceManager().getService(ApplicationService.class);
        Set<Application> apps = applicationService.getApplications();
        List<Application> catalogList = apps.stream().filter(a -> CATALOG_APP.equals(a.getName())).collect(Collectors.toList());
        if (catalogList.size() != 1) {
            fail("Expected to find 1 " + CATALOG_APP + " in Application list.");
        }
        Application catalog = catalogList.get(0);
        try {
            applicationService.startApplication(catalog);
            getServiceManager().waitForAllBundles();
        } catch (ApplicationServiceException e) {
            LOGGER.error("Failed to start the {}: {}", CATALOG_APP, e.getMessage());
            fail();
        } catch (InterruptedException e) {
            LOGGER.error("Failed to start start all bundles {}", e.getMessage());
            fail();
        }
        assertNotNull("Application [" + CATALOG_APP + "] must not be null", catalog);
        ApplicationStatus status = applicationService.getApplicationStatus(catalog);
        assertThat("Application [" + CATALOG_APP + "] should be ACTIVE", status.getState(), is(ACTIVE));
        List<Application> registryList = apps.stream().filter(a -> REGISTRY_APP.equals(a.getName())).collect(Collectors.toList());
        if (catalogList.size() != 1) {
            fail("Expected to find 1 " + REGISTRY_APP + " in Application list.");
        }
        Application registry = registryList.get(0);
        assertNotNull("Application [" + REGISTRY_APP + "] must not be null", registry);
        status = applicationService.getApplicationStatus(registry);
        assertThat("Application [" + REGISTRY_APP + "] should be INACTIVE", status.getState(), is(INACTIVE));
        // Test Commands
        String response = console.runCommand(STATUS_COMMAND + CATALOG_APP);
        assertThat(CATALOG_APP + " should be ACTIVE", response, containsString(ACTIVE_APP));
        response = console.runCommand(STATUS_COMMAND + REGISTRY_APP);
        assertThat(REGISTRY_APP + " should be INACTIVE", response, containsString(INACTIVE_APP));
    });
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) MethodSorters(org.junit.runners.MethodSorters) PaxExam(org.ops4j.pax.exam.junit.PaxExam) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) INACTIVE(org.codice.ddf.admin.application.service.ApplicationStatus.ApplicationState.INACTIVE) CoreMatchers.not(org.hamcrest.CoreMatchers.not) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) Application(org.codice.ddf.admin.application.service.Application) Assert.assertThat(org.junit.Assert.assertThat) Subject(org.apache.shiro.subject.Subject) BeforeExam(org.codice.ddf.itests.common.annotations.BeforeExam) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Assert.fail(org.junit.Assert.fail) URI(java.net.URI) ApplicationStatus(org.codice.ddf.admin.application.service.ApplicationStatus) ApplicationService(org.codice.ddf.admin.application.service.ApplicationService) LoggingUtils(org.codice.ddf.itests.common.utils.LoggingUtils) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Logger(org.slf4j.Logger) Security(org.codice.ddf.security.common.Security) Assert.assertNotNull(org.junit.Assert.assertNotNull) Set(java.util.Set) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) ApplicationServiceException(org.codice.ddf.admin.application.service.ApplicationServiceException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) ExamReactorStrategy(org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy) PerSuite(org.ops4j.pax.exam.spi.reactors.PerSuite) List(java.util.List) Rule(org.junit.Rule) ACTIVE(org.codice.ddf.admin.application.service.ApplicationStatus.ApplicationState.ACTIVE) FixMethodOrder(org.junit.FixMethodOrder) ConditionalIgnoreRule(org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule) ApplicationServiceException(org.codice.ddf.admin.application.service.ApplicationServiceException) ApplicationStatus(org.codice.ddf.admin.application.service.ApplicationStatus) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Application(org.codice.ddf.admin.application.service.Application) ApplicationService(org.codice.ddf.admin.application.service.ApplicationService) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest) Test(org.junit.Test) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest)

Aggregations

URI (java.net.URI)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Subject (org.apache.shiro.subject.Subject)1 Application (org.codice.ddf.admin.application.service.Application)1 ApplicationService (org.codice.ddf.admin.application.service.ApplicationService)1 ApplicationServiceException (org.codice.ddf.admin.application.service.ApplicationServiceException)1 ApplicationStatus (org.codice.ddf.admin.application.service.ApplicationStatus)1 ACTIVE (org.codice.ddf.admin.application.service.ApplicationStatus.ApplicationState.ACTIVE)1 INACTIVE (org.codice.ddf.admin.application.service.ApplicationStatus.ApplicationState.INACTIVE)1 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)1 BeforeExam (org.codice.ddf.itests.common.annotations.BeforeExam)1 ConditionalIgnoreRule (org.codice.ddf.itests.common.annotations.ConditionalIgnoreRule)1 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)1 LoggingUtils (org.codice.ddf.itests.common.utils.LoggingUtils)1 Security (org.codice.ddf.security.common.Security)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 CoreMatchers.hasItem (org.hamcrest.CoreMatchers.hasItem)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1