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