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

The following examples show how to use org.jboss.arquillian.test.spi.event.suite.After. 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: RequestContextLifecycle.java    From quarkus with Apache License 2.0 6 votes vote down vote up
public void on(@Observes(precedence = DEFAULT_PRECEDENCE) After event) throws Throwable {
    //we are outside the runtime class loader, so we don't have direct access to the container
    ClassLoader classLoader = appClassloader.get();
    if (classLoader != null) {
        Class<?> arcClz = classLoader.loadClass(Arc.class.getName());
        Object container = arcClz.getMethod("container").invoke(null);
        if (container != null) {
            boolean running = (boolean) container.getClass().getMethod("isRunning").invoke(container);
            if (running) {
                Object context = container.getClass().getMethod("requestContext").invoke(container);
                context.getClass().getMethod("terminate").invoke(context);
                LOGGER.debug("RequestContextLifecycle activating CDI Request context.");
            }
        }
    }
}
 
Example #2
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 #3
Source File: DefaultAnnotationScreenshootingStrategy.java    From arquillian-recorder with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isTakingAction(Event event, TestResult result) {
    if (event instanceof AfterTestLifecycleEvent && !(event instanceof After)) {
        Screenshot screenshotAnnotation = ScreenshotAnnotationScanner.getScreenshotAnnotation(((AfterTestLifecycleEvent) event).getTestMethod());

        if (screenshotAnnotation != null) {
            if (screenshotAnnotation.takeAfterTest()) {
                return true;
            }
            if (result.getStatus() == Status.FAILED && screenshotAnnotation.takeWhenTestFailed()) {
                return true;
            }
        }
    }

    return false;
}
 
Example #4
Source File: GitHubGovernorRecorderTest.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Test
public void sholdReportGitHubGovernorParamsForClass(){
    After after = new After(new FakeTestClass(), getMethod("someTestMethod"));
    gitHubGovernorRecorder.gitHubReportEntries(after);

    verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture());

    List<PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues();

    KeyValueEntry gitHubURL = new KeyValueEntry("GitHub URL","https://github.com/dipak-pawar/governor-recorder-test/issues/1");

    LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>();
    tableOptions.put("Force", "true");
    tableOptions.put("Detector Value", "And");
    tableOptions.put("Detector Strategy", "True");

    assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(gitHubURL);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("GitHubOptions", tableOptions));
}
 
Example #5
Source File: JiraGovernorRecorderTest.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Test
public void sholdReportJiraGovernorParamsForClass(){
    After after = new After(new FakeTestClass(), getMethod("someTestMethod"));
    jiraGovernorRecorder.jiraReportEntries(after);

    verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture());

    List <PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues();

    KeyValueEntry jiraURL = new KeyValueEntry("JIRA URL","https://jboss.issues.org/browse/ARQ-234");

    LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>();
    tableOptions.put("Force", "false");
    tableOptions.put("Detector Value", "And");
    tableOptions.put("Detector Strategy", "Windows");

    assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(jiraURL);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("JiraOptions", tableOptions));
}
 
Example #6
Source File: JiraGovernorRecorderTest.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldReportJiraGovernorParamsForMethod() {

    After after = new After(new FakeTestClass(), getMethod("dummyTest"));
    jiraGovernorRecorder.jiraReportEntries(after);

    verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture());

    List <PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues();

    KeyValueEntry keyValueEntry = new KeyValueEntry("JIRA URL","https://jboss.issues.org/browse/ARQ-123");

    LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>();
    tableOptions.put("Force", "true");
    tableOptions.put("Detector Value", "And");
    tableOptions.put("Detector Strategy", "Unix");

    assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(keyValueEntry);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("JiraOptions", tableOptions));
}
 
Example #7
Source File: RedmineGovernorRecorder.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
public void redmineReportEntries(@Observes After event) {

        final Method testMethod = event.getTestMethod();
        final TestClass testClass = event.getTestClass();
        final String redmineServerURL = redmineGovernorConfigurationInstance.get().getServer();

        final Redmine redmineValue = getRedmineValue(testMethod, testClass);
        if (redmineValue != null) {
            final String issueURL = constructRedmineIssueURL(redmineServerURL, redmineValue.value());

            final TableEntry redmineDetector = new TableEntry();
            redmineDetector.setTableName("RedmineOptions");
            redmineDetector.getTableHead().getRow().addCells(new TableCellEntry("Force"));

            final TableRowEntry row = new TableRowEntry();

            row.addCells(new TableCellEntry(String.valueOf(redmineValue.force())));
            redmineDetector.getTableBody().addRow(row);

            propertyReportEvent.fire(new PropertyReportEvent(new KeyValueEntry("Redmine URL", issueURL)));
            propertyReportEvent.fire(new PropertyReportEvent(redmineDetector));
        }
    }
 
Example #8
Source File: DefaultScreenshootingStrategy.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTakingAction(Event event, TestResult result) {
    if (event instanceof AfterTestLifecycleEvent && !(event instanceof After)) {
        if (configuration.getTakeAfterTest()) {
            return true;
        }
        if (result.getStatus() == Status.FAILED && configuration.getTakeWhenTestFailed()) {
            return true;
        }
    }
    return false;
}
 
Example #9
Source File: DefaultVideoStrategy.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isTakingAction(Event event, TestResult result) {
    if (event instanceof AfterTestLifecycleEvent && !(event instanceof After)) {
        switch (result.getStatus()) {
            case FAILED:
                return configuration.getTakeOnlyOnFail();
            case PASSED:
                return configuration.getStartBeforeTest() || configuration.getTakeOnlyOnFail();
            case SKIPPED:
            default:
                return false;
        }
    }
    return false;
}
 
Example #10
Source File: RecorderLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@org.junit.After
public void teardown() {
    if (videoFile != null && videoFile.exists()) {
        if (!videoFile.delete()) {
            throw new IllegalStateException("Unable to delete temporary file: " + videoFile.getAbsolutePath());
        }
    }
}
 
Example #11
Source File: CreationalContextDestroyer.java    From quarkus with Apache License 2.0 5 votes vote down vote up
public void destroy(@Observes EventContext<After> event) throws IOException {
    try {
        event.proceed();
    } finally {
        InjectionEnricher.CreationContextHolder cc = creationalContext.get();
        if (cc != null) {
            cc.close();
        }
    }
}
 
Example #12
Source File: ReporterLifecycleObserver.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
private boolean shouldReport(org.jboss.arquillian.core.spi.event.Event event, String frequency) {
    if (event instanceof AfterClass && ReportFrequency.CLASS.toString().equals(frequency)
            || (event instanceof After && ReportFrequency.METHOD.toString().equals(frequency)) ) {
        return true;
    }
    return false;
}
 
Example #13
Source File: AsciidoctorTestObserver.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
public void afterTestShutdownUnsharedAsciidoctorInstance(@Observes After after) {
    Asciidoctor asciidoctor = scopedAsciidoctor.get().getUnsharedAsciidoctor();
    if (asciidoctor != null) {
        asciidoctor.shutdown();
        scopedAsciidoctor.get().setUnsharedAsciidoctor(null);
    }
}
 
Example #14
Source File: AsciidoctorTestObserver.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
public void afterTestShutdownUnsharedTemporaryFolderInstance(@Observes After after) {
    TemporaryFolder temporaryFolder = scopedTemporaryFolder.get().getUnsharedTemporaryFolder();
    if (temporaryFolder != null) {
        temporaryFolder.delete();
        scopedTemporaryFolder.get().setUnsharedTemporaryFolder(null);
    }
}
 
Example #15
Source File: RedmineGovernorRecorderTest.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
@Test
public void sholdReportRedmineGovernorParamsForClass(){
    After after = new After(new FakeTestClass(), getMethod("someTestMethod"));
    redmineGovernorRecorder.redmineReportEntries(after);

    verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture());

    List <PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues();

    KeyValueEntry redmineURL = new KeyValueEntry("Redmine URL","http://redmine.test/issues/1");

    LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>();
    tableOptions.put("Force","true");

    assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(redmineURL);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("RedmineOptions", tableOptions));

}
 
Example #16
Source File: GitHubGovernorRecorderTest.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldReportGitHubGovernorParamsForMethod() {

    After after = new After(new FakeTestClass(), getMethod("dummyTest"));
    gitHubGovernorRecorder.gitHubReportEntries(after);

    verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture());

    List<PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues();

    KeyValueEntry gitHubURL = new KeyValueEntry("GitHub URL","https://github.com/dipak-pawar/governor-recorder-test/issues/2");

    LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>();
    tableOptions.put("Force", "false");
    tableOptions.put("Detector Value", "And");
    tableOptions.put("Detector Strategy", "True");

    assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(gitHubURL);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("GitHubOptions", tableOptions));

}
 
Example #17
Source File: RedmineGovernorRecorderTest.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldReportRedmineGovernorParamsForMethod() {

    After after = new After(new FakeTestClass(), getMethod("dummyTest"));
    redmineGovernorRecorder.redmineReportEntries(after);

    verify(propertyReportEvent, times(2)).fire(propertyReportEventArgumentCaptor.capture());

    List<PropertyReportEvent> propertyReportEvents = propertyReportEventArgumentCaptor.getAllValues();

    KeyValueEntry redmineURL = new KeyValueEntry("Redmine URL","http://redmine.test/issues/2");

    LinkedHashMap<String, String> tableOptions = new LinkedHashMap<String, String>();
    tableOptions.put("Force","false");

    assertThat(propertyReportEvents).hasSize(2).extracting("propertyEntry.class").contains(KeyValueEntry.class, TableEntry.class);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", KeyValueEntry.class).contains(redmineURL);
    assertThat(propertyReportEvents).extracting("propertyEntry").filteredOn("class", TableEntry.class) .contains(getTableEntry("RedmineOptions", tableOptions));
}
 
Example #18
Source File: AuthServerTestEnricher.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public void afterTest(@Observes(precedence = -1) After event) throws IOException {
    if (event.getTestMethod().getAnnotation(UncaughtServerErrorExpected.class) == null) {
        suiteContext.getServerLogChecker().checkFiles(false, this::checkForNoUnexpectedUncaughtError);
    }
}
 
Example #19
Source File: KeycloakContainerFeaturesController.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public void handleEnableFeaturesAnnotationAfterTest(@Observes(precedence = 2) After event) throws Exception {
    checkAnnotatedElementForFeatureAnnotations(event.getTestMethod(), State.AFTER);
}
 
Example #20
Source File: CrossDCTestEnricher.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public void afterTest(@Observes After event) {
    if (!suiteContext.isAuthServerCrossDc()) return;

    restorePeriodicTasks();
}