Search in sources :

Example 1 with SleepingApplication

use of classloader.applications.SleepingApplication in project oracle-bedrock by coherence-community.

the class LocalPlatformJavaApplicationTest method shouldLaunchJavaApplicationUsingSystemPropertyWithSpaces.

/**
 * Ensure that {@link JavaApplication}s can is launched with a system-property
 * that contains spaces.
 */
@Test
public void shouldLaunchJavaApplicationUsingSystemPropertyWithSpaces() {
    // set a System-Property for the SleepingApplication (we'll request it back)
    String message = "Hello World";
    try (JavaApplication application = getPlatform().launch(JavaApplication.class, ClassName.of(SleepingApplication.class), SystemProperty.of("message", message), IPv4Preferred.yes())) {
        // request the system property from the SleepingApplication
        String propertyValue = application.invoke(new GetSystemProperty("message"));
        assertThat(propertyValue, is(message));
    }
}
Also used : SleepingApplication(classloader.applications.SleepingApplication) GetSystemProperty(com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SocketBasedRemoteChannelTest(com.oracle.bedrock.runtime.concurrent.socket.SocketBasedRemoteChannelTest) Test(org.junit.Test)

Example 2 with SleepingApplication

use of classloader.applications.SleepingApplication in project oracle-bedrock by coherence-community.

the class LocalPlatformJavaApplicationTest method shouldExecuteCallable.

/**
 * Ensure that {@link JavaApplication}s can have
 * {@link java.util.concurrent.Callable}s submitted to them and executed.
 */
@Test
public void shouldExecuteCallable() {
    // set a System-Property for the SleepingApplication (we'll request it back)
    String uuid = UUID.randomUUID().toString();
    try (JavaApplication application = getPlatform().launch(JavaApplication.class, ClassName.of(SleepingApplication.class), SystemProperty.of("uuid", uuid), IPv4Preferred.yes())) {
        // request the system property from the SleepingApplication
        CompletableFuture<String> future = application.submit(new GetSystemProperty("uuid"));
        Eventually.assertThat(future(String.class, future), is(uuid));
    }
}
Also used : SleepingApplication(classloader.applications.SleepingApplication) GetSystemProperty(com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SocketBasedRemoteChannelTest(com.oracle.bedrock.runtime.concurrent.socket.SocketBasedRemoteChannelTest) Test(org.junit.Test)

Aggregations

SleepingApplication (classloader.applications.SleepingApplication)2 GetSystemProperty (com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty)2 SocketBasedRemoteChannelTest (com.oracle.bedrock.runtime.concurrent.socket.SocketBasedRemoteChannelTest)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2