Search in sources :

Example 1 with GetSystemProperty

use of com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty in project oracle-bedrock by coherence-community.

the class RemoteJavaApplicationLauncherTest method shouldLaunchJavaApplicationUsingSystemPropertyWithSpaces.

/**
 * Ensure that {@link JavaApplication}s can is launched with a system-property
 * that contains spaces.
 */
@Test
public void shouldLaunchJavaApplicationUsingSystemPropertyWithSpaces() throws Exception {
    RemotePlatform platform = getRemotePlatform();
    // set a System-Property for the SleepingApplication (we'll request it back)
    String message = "Hello World";
    try (JavaApplication application = platform.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"));
        Assert.assertThat(propertyValue, is(message));
    }
}
Also used : SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) GetSystemProperty(com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 2 with GetSystemProperty

use of com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty 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 3 with GetSystemProperty

use of com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty in project oracle-bedrock by coherence-community.

the class AbstractJavaApplicationTest method shouldDefineSystemPropertyInApplication.

/**
 * Ensure that we can define a {@link SystemProperty} in the {@link JavaApplication}
 * (and it won't be defined in this process).
 */
@Test
public void shouldDefineSystemPropertyInApplication() {
    // the custom property name and value
    String propertyName = "custom.property";
    String propertyValue = "gudday";
    try (JavaApplication application = getPlatform().launch(JavaApplication.class, ClassName.of(SleepingApplication.class), SystemProperty.of(propertyName, propertyValue), IPv4Preferred.yes())) {
        // assert that the custom property is defined in the application
        Eventually.assertThat(application, new GetSystemProperty(propertyName), is(propertyValue));
        // assert that the custom property is not defined in the test
        assertThat(System.getProperty(propertyName), is(nullValue()));
    }
}
Also used : SleepingApplication(classloader.applications.SleepingApplication) GetSystemProperty(com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty) StringContains.containsString(org.hamcrest.core.StringContains.containsString) AbstractTest(com.oracle.bedrock.testsupport.junit.AbstractTest) Test(org.junit.Test)

Example 4 with GetSystemProperty

use of com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty 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)

Example 5 with GetSystemProperty

use of com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty in project oracle-bedrock by coherence-community.

the class LocalPlatformJavaApplicationTest method shouldInheritRuntimeProperties.

/**
 * Ensure that {@link JavaApplication}s correctly inherit arguments based on system properties
 * starting with bedrock.runtime.inherit.xxx=
 */
@Test
public void shouldInheritRuntimeProperties() {
    System.getProperties().setProperty("bedrock.runtime.inherit.property", "-Dmessage=hello");
    try (JavaApplication application = getPlatform().launch(JavaApplication.class, ClassName.of(SleepingApplication.class), IPv4Preferred.yes())) {
        String message = application.invoke(new GetSystemProperty("message"));
        assertThat(message, is("hello"));
    } finally {
        System.getProperties().remove("bedrock.runtime.inherit.property");
    }
}
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

GetSystemProperty (com.oracle.bedrock.runtime.concurrent.callable.GetSystemProperty)5 Test (org.junit.Test)5 SleepingApplication (classloader.applications.SleepingApplication)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 SocketBasedRemoteChannelTest (com.oracle.bedrock.runtime.concurrent.socket.SocketBasedRemoteChannelTest)3 JavaApplication (com.oracle.bedrock.runtime.java.JavaApplication)1 AbstractRemoteTest (com.oracle.bedrock.runtime.remote.AbstractRemoteTest)1 RemotePlatform (com.oracle.bedrock.runtime.remote.RemotePlatform)1 SleepingApplication (com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication)1 AbstractTest (com.oracle.bedrock.testsupport.junit.AbstractTest)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1