Search in sources :

Example 6 with Platform

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));
    }
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) EventingApplication(com.oracle.bedrock.runtime.remote.java.applications.EventingApplication) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 7 with Platform

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));
    }
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RemoteEventListener(com.oracle.bedrock.runtime.concurrent.RemoteEventListener) EventingApplication(com.oracle.bedrock.runtime.remote.java.applications.EventingApplication) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 8 with Platform

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));
    }
}
Also used : SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) Platform(com.oracle.bedrock.runtime.Platform) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 9 with Platform

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));
    }
}
Also used : SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) Platform(com.oracle.bedrock.runtime.Platform) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 10 with Platform

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));
    }
}
Also used : Platform(com.oracle.bedrock.runtime.Platform) LocalPlatform(com.oracle.bedrock.runtime.LocalPlatform) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) RemoteEvent(com.oracle.bedrock.runtime.concurrent.RemoteEvent) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) RemoteEvent(com.oracle.bedrock.runtime.concurrent.RemoteEvent) RemoteEventListener(com.oracle.bedrock.runtime.concurrent.RemoteEventListener) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) EventingApplication(com.oracle.bedrock.runtime.remote.java.applications.EventingApplication) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Aggregations

Platform (com.oracle.bedrock.runtime.Platform)86 Test (org.junit.Test)69 OptionsByType (com.oracle.bedrock.OptionsByType)55 LocalPlatform (com.oracle.bedrock.runtime.LocalPlatform)49 MetaClass (com.oracle.bedrock.runtime.MetaClass)23 Arguments (com.oracle.bedrock.runtime.options.Arguments)18 Application (com.oracle.bedrock.runtime.Application)16 File (java.io.File)15 RemotePlatform (com.oracle.bedrock.runtime.remote.RemotePlatform)14 AbstractTest (com.oracle.bedrock.testsupport.junit.AbstractTest)12 DeploymentArtifact (com.oracle.bedrock.runtime.remote.DeploymentArtifact)11 JavaApplication (com.oracle.bedrock.runtime.java.JavaApplication)10 AbstractRemoteTest (com.oracle.bedrock.runtime.remote.AbstractRemoteTest)10 ArrayList (java.util.ArrayList)8 Option (com.oracle.bedrock.Option)7 GetClusterSize (com.oracle.bedrock.runtime.coherence.callables.GetClusterSize)7 GetLocalMemberId (com.oracle.bedrock.runtime.coherence.callables.GetLocalMemberId)7 Properties (java.util.Properties)7 Matchers.anyString (org.mockito.Matchers.anyString)7 EnvironmentVariables (com.oracle.bedrock.runtime.options.EnvironmentVariables)6