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

The following examples show how to use org.jboss.arquillian.test.spi.event.suite.BeforeSuite. 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: SuiteDeployer.java    From arquillian-suite-extension with Apache License 2.0 6 votes vote down vote up
/**
 * Startup event.
 *
 * @param event AfterStart event to catch
 */
public void startup(@Observes(precedence = -100) final BeforeSuite event) {
    if (extensionEnabled()) {
        debug("Catching BeforeSuite event {0}", event.toString());
        executeInClassScope(new Callable<Void>() {
            @Override
            public Void call() {
                generateDeploymentEvent.fire(new GenerateDeployment(new TestClass(deploymentClass)));
                suiteDeploymentScenario = classDeploymentScenario.get();
                return null;
            }
        });
        deployDeployments = true;
        extendedSuiteContext.get().activate();
        suiteDeploymentScenarioInstanceProducer.set(suiteDeploymentScenario);
    }
}
 
Example #5
Source File: VideoLifecycleObserver.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
public void beforeSuite(@Observes BeforeSuite event) {
    if (strategy.get().isTakingAction(event)) {
        VideoMetaData suiteMetaData = getMetaData();
        VideoType videoType = getVideoType();

        beforeVideoStart.fire(new BeforeVideoStart(videoType, suiteMetaData));

        startRecordSuiteVideo.fire(new StartRecordSuiteVideo(videoType, suiteMetaData));

        afterVideoStart.fire(new AfterVideoStart(videoType, suiteMetaData));
    }
}
 
Example #6
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 #7
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 #8
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 #9
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 #10
Source File: TomEEWebappObserver.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void beforeSuite(@Observes final BeforeSuite event) {
    final WebBeansContext webBeansContext = AppFinder.findAppContextOrWeb(
            Thread.currentThread().getContextClassLoader(), AppFinder.WebBeansContextTransformer.INSTANCE);
    if (webBeansContext != null) {
        beanManager.set(webBeansContext.getBeanManagerImpl());
    }
    try {
        context.set(new InitialContext());
    } catch (final NamingException e) {
        // no-op
    }
}
 
Example #11
Source File: RemoteTomEEObserver.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void beforeSuite(@Observes final BeforeSuite event) {
    final WebBeansContext webBeansContext = AppFinder.findAppContextOrWeb(
            Thread.currentThread().getContextClassLoader(), AppFinder.WebBeansContextTransformer.INSTANCE);
    if (webBeansContext != null) {
        beanManager.set(webBeansContext.getBeanManagerImpl());
    }
    try {
        context.set(new InitialContext());
    } catch (final NamingException e) {
        // no-op
    }
}
 
Example #12
Source File: AuthServerTestEnricher.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public void checkServerLogs(@Observes(precedence = -1) BeforeSuite event) throws IOException, InterruptedException {
    if (! suiteContext.getAuthServerInfo().isJBossBased()) {
        suiteContext.setServerLogChecker(new TextFileChecker());    // checks nothing
        return;
    }
    if (suiteContext.getServerLogChecker() == null) {
        setServerLogChecker();
    }
    boolean checkLog = Boolean.parseBoolean(System.getProperty("auth.server.log.check", "true"));
    if (checkLog) {
        suiteContext.getServerLogChecker()
            .checkFiles(true, AuthServerTestEnricher::failOnRecognizedErrorInLog);
    }
}
 
Example #13
Source File: H2TestEnricher.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public void startH2(@Observes(precedence = 3) BeforeSuite event) throws SQLException {
    if (runH2 && dockerDatabaseSkip) {
        log.info("Starting H2 database.");
        server = Server.createTcpServer();
        server.start();
        log.info(String.format("URL: %s", server.getURL()));
    }
}
 
Example #14
Source File: GovernorTestClassScanner.java    From arquillian-governor with Apache License 2.0 4 votes vote down vote up
public void onBeforeSuite(@Observes BeforeSuite event) {
    closePassedDecider.set(new ClosePassedDeciderImpl());
}
 
Example #15
Source File: ReporterLifecycleObserver.java    From arquillian-recorder with Apache License 2.0 4 votes vote down vote up
public void observeBeforeSuite(@Observes(precedence = Integer.MAX_VALUE) BeforeSuite event) {
    TestSuiteReport testSuiteReport = new TestSuiteReport();

    reporter.get().getReport().getTestSuiteReports().add(testSuiteReport);
    reporter.get().setTestSuiteReport(testSuiteReport);
}
 
Example #16
Source File: AuthServerTestEnricher.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public void startTestClassProvider(@Observes(precedence = 1) BeforeSuite beforeSuite) {
    TestClassProvider testClassProvider = new TestClassProvider();
    testClassProvider.start();
    suiteContext.setTestClassProvider(testClassProvider);
}