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));
}
}
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)));
}
}
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);
}
}
Aggregations