Search in sources :

Example 1 with JavaApplicationProcess

use of com.oracle.bedrock.runtime.java.JavaApplicationProcess in project oracle-bedrock by coherence-community.

the class SimpleJUnitTestRunTest method shouldAddListenersFromOptions.

@Test
public void shouldAddListenersFromOptions() throws Exception {
    Platform platform = mock(Platform.class);
    JavaApplicationProcess process = mock(JavaApplicationProcess.class);
    SimpleJUnitTestListener listener1 = new SimpleJUnitTestListener();
    SimpleJUnitTestListener listener2 = new SimpleJUnitTestListener();
    OptionsByType optionsByType = OptionsByType.of(listener1.asOption(), listener2.asOption());
    try (SimpleJUnitTestRun application = new SimpleJUnitTestRun(platform, process, optionsByType)) {
        assertThat(application.getRunListeners(), containsInAnyOrder(listener1, listener2));
    }
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) JavaApplicationProcess(com.oracle.bedrock.runtime.java.JavaApplicationProcess) SimpleJUnitTestRun(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestRun) SimpleJUnitTestListener(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener) OptionsByType(com.oracle.bedrock.OptionsByType) Test(org.junit.Test)

Example 2 with JavaApplicationProcess

use of com.oracle.bedrock.runtime.java.JavaApplicationProcess in project oracle-bedrock by coherence-community.

the class SimpleJUnitTestRunTest method shouldStartTests.

@Test
public void shouldStartTests() throws Exception {
    Platform platform = mock(Platform.class);
    JavaApplicationProcess process = mock(JavaApplicationProcess.class);
    OptionsByType optionsByType = OptionsByType.empty();
    try (SimpleJUnitTestRun application = new SimpleJUnitTestRun(platform, process, optionsByType)) {
        TestClasses testClasses = TestClasses.empty();
        OptionsByType testOptions = OptionsByType.of(testClasses);
        SimpleJUnitTestRun spyApp = spy(application);
        doReturn(null).when(spyApp).submit(any(RemoteCallable.class), anyVararg());
        spyApp.startTests(testOptions);
        ArgumentCaptor<RemoteCallable> captorCallable = ArgumentCaptor.forClass(RemoteCallable.class);
        verify(spyApp).submit(captorCallable.capture(), anyVararg());
        RemoteCallable callable = captorCallable.getValue();
        assertThat(callable, is(instanceOf(JUnitTestRunner.StartTests.class)));
        JUnitTestRunner.StartTests startTests = (JUnitTestRunner.StartTests) callable;
        assertThat(startTests.getOptions(), is(arrayContainingInAnyOrder(testClasses)));
    }
}
Also used : TestClasses(com.oracle.bedrock.testsupport.junit.options.TestClasses) Platform(com.oracle.bedrock.runtime.Platform) RemoteCallable(com.oracle.bedrock.runtime.concurrent.RemoteCallable) JavaApplicationProcess(com.oracle.bedrock.runtime.java.JavaApplicationProcess) SimpleJUnitTestRun(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestRun) OptionsByType(com.oracle.bedrock.OptionsByType) JUnitTestRunner(com.oracle.bedrock.testsupport.junit.JUnitTestRunner) Test(org.junit.Test)

Example 3 with JavaApplicationProcess

use of com.oracle.bedrock.runtime.java.JavaApplicationProcess in project oracle-bedrock by coherence-community.

the class SimpleJUnitTestRunTest method fireEvent.

public void fireEvent(JUnitTestListener.Event event, JUnitTestListener... listeners) throws Exception {
    Platform platform = mock(Platform.class);
    JavaApplicationProcess process = mock(JavaApplicationProcess.class);
    OptionsByType optionsByType = OptionsByType.empty();
    for (JUnitTestListener listener : listeners) {
        optionsByType.add(Decoration.of(listener));
    }
    try (SimpleJUnitTestRun application = new SimpleJUnitTestRun(platform, process, optionsByType)) {
        ArgumentCaptor<RemoteEventListener> captorListener = ArgumentCaptor.forClass(RemoteEventListener.class);
        ArgumentCaptor<Option> captorOptions = ArgumentCaptor.forClass(Option.class);
        verify(process).addListener(captorListener.capture(), captorOptions.capture());
        RemoteEventListener eventListener = captorListener.getValue();
        List<Option> listenerOpts = captorOptions.getAllValues();
        assertThat(eventListener, is(notNullValue()));
        assertThat(listenerOpts, containsInAnyOrder(JUnitTestRunner.STREAM_NAME));
        eventListener.onEvent(event);
    }
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) JUnitTestListener(com.oracle.bedrock.testsupport.junit.JUnitTestListener) SimpleJUnitTestListener(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener) JavaApplicationProcess(com.oracle.bedrock.runtime.java.JavaApplicationProcess) Option(com.oracle.bedrock.Option) SimpleJUnitTestRun(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestRun) OptionsByType(com.oracle.bedrock.OptionsByType) RemoteEventListener(com.oracle.bedrock.runtime.concurrent.RemoteEventListener)

Aggregations

OptionsByType (com.oracle.bedrock.OptionsByType)3 Platform (com.oracle.bedrock.runtime.Platform)3 JavaApplicationProcess (com.oracle.bedrock.runtime.java.JavaApplicationProcess)3 SimpleJUnitTestRun (com.oracle.bedrock.testsupport.junit.SimpleJUnitTestRun)3 SimpleJUnitTestListener (com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener)2 Test (org.junit.Test)2 Option (com.oracle.bedrock.Option)1 RemoteCallable (com.oracle.bedrock.runtime.concurrent.RemoteCallable)1 RemoteEventListener (com.oracle.bedrock.runtime.concurrent.RemoteEventListener)1 JUnitTestListener (com.oracle.bedrock.testsupport.junit.JUnitTestListener)1 JUnitTestRunner (com.oracle.bedrock.testsupport.junit.JUnitTestRunner)1 TestClasses (com.oracle.bedrock.testsupport.junit.options.TestClasses)1