org.jboss.arquillian.test.spi.event.suite.AfterSuite Java Examples

The following examples show how to use org.jboss.arquillian.test.spi.event.suite.AfterSuite. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecorderLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 6 votes vote down vote up
@Test
public void startBeforeSuiteTrueTest() throws Exception {

    Mockito.when(configuration.getStartBeforeSuite()).thenReturn(true);

    fire(new VideoExtensionConfigured());

    fire(new BeforeSuite());
    fire(new BeforeClass(DummyTestCase.class));
    fire(new Before(DummyTestCase.class, DummyTestCase.class.getMethod("test")));

    bind(TestScoped.class, TestResult.class, TestResult.passed());

    fire(new After(DummyTestCase.class, DummyTestCase.class.getMethod("test")));
    fire(new AfterClass(DummyTestCase.class));
    fire(new AfterSuite());

    assertEventFired(BeforeVideoStart.class, 1);
    assertEventFired(StartRecordSuiteVideo.class, 1);
    assertEventFired(AfterVideoStart.class, 1);

    assertEventFired(BeforeVideoStop.class, 1);
    assertEventFired(StopRecordSuiteVideo.class, 1);
    assertEventFired(AfterVideoStop.class, 1);
}
 
Example #2
Source File: RecorderLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 6 votes vote down vote up
@Test
public void startBeforeClassTrueTest() throws Exception {

    Mockito.when(configuration.getStartBeforeClass()).thenReturn(true);

    fire(new VideoExtensionConfigured());

    fire(new BeforeSuite());
    fire(new BeforeClass(DummyTestCase.class));
    fire(new Before(DummyTestCase.class, DummyTestCase.class.getMethod("test")));

    bind(TestScoped.class, TestResult.class, TestResult.passed());

    fire(new AfterRules(DummyTestCase.class, DummyTestCase.class.getMethod("test"), LifecycleMethodExecutor.NO_OP));
    fire(new AfterClass(DummyTestCase.class));
    fire(new AfterSuite());

    assertEventFired(BeforeVideoStart.class, 1);
    assertEventFired(StartRecordClassVideo.class, 1);
    assertEventFired(AfterVideoStart.class, 1);

    assertEventFired(BeforeVideoStop.class, 1);
    assertEventFired(StopRecordClassVideo.class, 1);
    assertEventFired(AfterVideoStop.class, 1);
}
 
Example #3
Source File: RecorderLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 6 votes vote down vote up
@Test
public void startBeforeTestTrueTest() throws Exception {

    Mockito.when(configuration.getStartBeforeTest()).thenReturn(true);

    fire(new VideoExtensionConfigured());

    fire(new BeforeSuite());
    fire(new BeforeClass(DummyTestCase.class));
    fire(new Before(DummyTestCase.class, DummyTestCase.class.getMethod("test")));

    bind(TestScoped.class, TestResult.class, TestResult.passed());

    fire(new AfterRules(DummyTestCase.class, DummyTestCase.class.getMethod("test"), LifecycleMethodExecutor.NO_OP));
    fire(new AfterClass(DummyTestCase.class));
    fire(new AfterSuite());

    assertEventFired(BeforeVideoStart.class, 1);
    assertEventFired(StartRecordVideo.class, 1);
    assertEventFired(AfterVideoStart.class, 1);

    assertEventFired(BeforeVideoStop.class, 1);
    assertEventFired(StopRecordVideo.class, 1);
    assertEventFired(AfterVideoStop.class, 1);
}
 
Example #4
Source File: CrossDCTestEnricher.java    From keycloak with Apache License 2.0 6 votes vote down vote up
public void afterSuite(@Observes(precedence = 4) AfterSuite event) {
    if (!suiteContext.isAuthServerCrossDc()) return;

    // Unfortunately, in AfterSuite, containerController context is already cleaned so stopAuthServerBackendNode()
    // and stopCacheServer cannot be used. On the other hand, Arquillian by default does not guarantee that cache
    // servers are terminated only after auth servers were, so the termination has to be done in this enricher.

    forAllBackendNodesStream()
      .map(ContainerInfo::getArquillianContainer)
      .map(StopContainer::new)
      .forEach(stopContainer::fire);

    if (!AuthServerTestEnricher.CACHE_SERVER_LIFECYCLE_SKIP) {
        DC.validDcsStream()
                .map(CrossDCTestEnricher::getCacheServer)
                .map(ContainerInfo::getArquillianContainer)
                .map(StopContainer::new)
                .forEach(stopContainer::fire);
    }
}
 
Example #5
Source File: JiraTestExecutionDecider.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
public void on(@Observes AfterSuite event, JiraGovernorClient jiraGovernorClient) {
    for (final Map.Entry<Annotation, Boolean> entry : closePassedDecider.get().get().entrySet()) {
        final Annotation annotation = entry.getKey();
        if (annotation.annotationType() == provides() && entry.getValue()) {
            final String id = ((Jira) annotation).value();
            jiraGovernorClient.close(id);
        }
    }
}
 
Example #6
Source File: GitHubTestExecutionDecider.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
public void on(@Observes AfterSuite event, GitHubGovernorClient githubGovernorClient) {
    for (final Map.Entry<Annotation, Boolean> entry : closePassedDecider.get().get().entrySet()) {
        final Annotation annotation = entry.getKey();
        if (annotation.annotationType() == provides() && entry.getValue()) {
            final String id = ((GitHub) annotation).value();
            githubGovernorClient.close(id);
        }
    }
}
 
Example #7
Source File: VideoLifecycleObserver.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
public void afterSuite(@Observes AfterSuite event) {
    if (strategy.get().isTakingAction(event)) {
        VideoMetaData metaData = getMetaData();
        VideoType videoType = getVideoType();

        beforeVideoStop.fire(new BeforeVideoStop(videoType, metaData));

        stopRecordSuiteVideo.fire(new StopRecordSuiteVideo(videoType, metaData));

        afterVideoStop.fire(new AfterVideoStop(videoType, metaData));
    }
}
 
Example #8
Source File: DefaultVideoStrategy.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTakingAction(Event event) {
    if (event instanceof BeforeSuite
            || event instanceof AfterSuite) {
        return configuration.getStartBeforeSuite();
    } else if (event instanceof BeforeClass
            || event instanceof AfterClass) {
        return configuration.getStartBeforeClass();
    } else if (event instanceof Before) {
        return configuration.getStartBeforeTest()
            || configuration.getTakeOnlyOnFail();
    }

    return false;
}
 
Example #9
Source File: RecorderLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Test
public void defaultConfigurationTest() throws Exception {

    // by default, no videos are taken at all

    fire(new VideoExtensionConfigured());

    fire(new BeforeSuite());
    fire(new BeforeClass(DummyTestCase.class));
    fire(new Before(DummyTestCase.class, DummyTestCase.class.getMethod("test")));

    bind(TestScoped.class, TestResult.class, TestResult.passed());

    fire(new AfterRules(DummyTestCase.class, DummyTestCase.class.getMethod("test"), LifecycleMethodExecutor.NO_OP));
    fire(new AfterClass(DummyTestCase.class));
    fire(new AfterSuite());

    assertEventFired(BeforeVideoStart.class, 0);
    assertEventFired(StartRecordVideo.class, 0);
    assertEventFired(StartRecordSuiteVideo.class, 0);
    assertEventFired(AfterVideoStart.class, 0);

    assertEventFired(BeforeVideoStop.class, 0);
    assertEventFired(StopRecordVideo.class, 0);
    assertEventFired(StopRecordSuiteVideo.class, 0);
    assertEventFired(AfterVideoStop.class, 0);
}
 
Example #10
Source File: RecorderLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Test
public void takeOnlyOnFailTestFailedTest() throws Exception {

    Mockito.when(configuration.getTakeOnlyOnFail()).thenReturn(true);

    fire(new VideoExtensionConfigured());

    fire(new BeforeSuite());
    fire(new BeforeClass(DummyTestCase.class));
    fire(new Before(DummyTestCase.class, DummyTestCase.class.getMethod("test")));

    bind(TestScoped.class, TestResult.class, TestResult.failed(new RuntimeException("some exception")));

    fire(new AfterRules(DummyTestCase.class, DummyTestCase.class.getMethod("test"), LifecycleMethodExecutor.NO_OP));
    fire(new AfterClass(DummyTestCase.class));
    fire(new AfterSuite());

    assertEventFired(BeforeVideoStart.class, 1);
    assertEventFired(StartRecordVideo.class, 1);
    assertEventFired(AfterVideoStart.class, 1);

    assertEventFired(PropertyReportEvent.class, 1);

    assertEventFired(BeforeVideoStop.class, 1);
    assertEventFired(StopRecordVideo.class, 1);
    assertEventFired(AfterVideoStop.class, 1);
}
 
Example #11
Source File: RecorderLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Test
public void takeOnlyOnFailTestPassedTest() throws Exception {

    Mockito.when(configuration.getTakeOnlyOnFail()).thenReturn(true);

    fire(new VideoExtensionConfigured());

    fire(new BeforeSuite());
    fire(new BeforeClass(DummyTestCase.class));
    fire(new Before(DummyTestCase.class, DummyTestCase.class.getMethod("test")));

    bind(TestScoped.class, TestResult.class, TestResult.passed());

    fire(new AfterRules(DummyTestCase.class, DummyTestCase.class.getMethod("test"), LifecycleMethodExecutor.NO_OP));
    fire(new AfterClass(DummyTestCase.class));
    fire(new AfterSuite());

    assertEventFired(BeforeVideoStart.class, 1);
    assertEventFired(StartRecordVideo.class, 1);
    assertEventFired(AfterVideoStart.class, 1);

    assertEventFired(PropertyReportEvent.class, 0);

    assertEventFired(BeforeVideoStop.class, 1);
    assertEventFired(StopRecordVideo.class, 1);
    assertEventFired(AfterVideoStop.class, 1);
}
 
Example #12
Source File: H2TestEnricher.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public void stopH2(@Observes(precedence = -2) AfterSuite event) {
    if (runH2 && dockerDatabaseSkip && server.isRunning(false)) {
        log.info("Stopping H2 database.");
        server.stop();
        assert !server.isRunning(false);
    }
}
 
Example #13
Source File: SkipperReporter.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
public void on(@Observes AfterSuite afterSuite) {

        if (this.asciiDocExporter.get() != null) {
            this.asciiDocExporter.get().export();
        }
    }
 
Example #14
Source File: AuthServerTestEnricher.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public void stopTestClassProvider(@Observes(precedence = -1) AfterSuite afterSuite) {
    suiteContext.getTestClassProvider().stop();
}
 
Example #15
Source File: KeycloakContainerEventsController.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(@Observes AfterSuite event) {
    container.fire(new StopManualContainers());
    container.fire(new StopSuiteContainers());
}
 
Example #16
Source File: ReporterLifecycleObserver.java    From arquillian-recorder with Apache License 2.0 3 votes vote down vote up
public void observeAfterSuite(@Observes(precedence = Integer.MIN_VALUE) AfterSuite event) {

        reporter.get().getLastTestClassReport().setStop(new Date(System.currentTimeMillis()));
        reporter.get().getLastTestSuiteReport().setStop(new Date(System.currentTimeMillis()));

        exportReportEvent.fire(new ExportReport(reporter.get().getReport()));
    }