use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldSubmitCallableBack.
@Test
public void shouldSubmitCallableBack() throws Exception {
Platform platform = getRemotePlatform();
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(EventingApplication.class), IPv4Preferred.yes())) {
EventingApplication.GetIntCallable.value = 1234;
CompletableFuture<Integer> result = application.submit(new EventingApplication.RoundTripCallable());
Assert.assertThat(result.get(), is(1234));
}
}
use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldReceiveEventsFromApplicationUsingListenerAsOption.
@Test
public void shouldReceiveEventsFromApplicationUsingListenerAsOption() throws Exception {
Platform platform = getRemotePlatform();
String name = "Foo";
int count = 10;
EventListener listener1 = new EventListener(count);
EventListener listener2 = new EventListener(count);
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(EventingApplication.class), IPv4Preferred.yes(), RemoteEvents.listener(listener1, StreamName.of(name)), RemoteEvents.listener(listener2, StreamName.of(name)), Argument.of(name), Argument.of(count))) {
Assert.assertThat(listener1.await(1, TimeUnit.MINUTES), is(true));
Assert.assertThat(listener2.await(1, TimeUnit.MINUTES), is(true));
application.close();
Assert.assertThat(listener1.getEvents().size(), is(count));
Assert.assertThat(listener2.getEvents().size(), is(count));
}
}
use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldTerminateUsingRuntimeExit.
/**
* Ensure that local {@link JavaApplication}s can be terminated using {@link RuntimeExit}.
*/
@Test
public void shouldTerminateUsingRuntimeExit() throws Exception {
// build and start the SleepingApplication
Platform platform = getRemotePlatform();
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), Argument.of("3"), IPv4Preferred.yes())) {
application.close(RuntimeExit.withExitCode(42));
int exitStatus = application.waitFor();
assertThat(exitStatus, is(42));
}
}
use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldTerminateUsingRuntimeHalt.
/**
* Ensure that local {@link JavaApplication}s can be terminated using {@link RuntimeHalt}.
*/
@Test
public void shouldTerminateUsingRuntimeHalt() throws Exception {
// build and start the SleepingApplication
Platform platform = getRemotePlatform();
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), Argument.of("3"), IPv4Preferred.yes())) {
application.close(RuntimeHalt.withExitCode(42));
int exitStatus = application.waitFor();
assertThat(exitStatus, is(42));
}
}
use of com.oracle.bedrock.runtime.Platform in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldReceiveEventFromApplication.
@Test
public void shouldReceiveEventFromApplication() throws Exception {
Platform platform = getRemotePlatform();
EventListener listener1 = new EventListener(1);
EventListener listener2 = new EventListener(1);
String name = "Foo";
RemoteEvent event = new EventingApplication.Event(19);
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(EventingApplication.class), IPv4Preferred.yes())) {
application.addListener(listener1, StreamName.of(name));
application.addListener(listener2, StreamName.of(name));
EventingApplication.fireEvent(application, name, event);
Assert.assertThat(listener1.await(1, TimeUnit.MINUTES), is(true));
Assert.assertThat(listener2.await(1, TimeUnit.MINUTES), is(true));
Assert.assertThat(listener1.getEvents().size(), is(1));
Assert.assertThat(listener1.getEvents().get(0), is(event));
Assert.assertThat(listener2.getEvents().size(), is(1));
Assert.assertThat(listener2.getEvents().get(0), is(event));
}
}
Aggregations