use of com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldInheritRuntimeProperties.
/**
* Ensure that {@link JavaApplication}s correctly inherits arguments based on system properties
* starting with bedrock.runtime.inherit.xxx=
*/
@Test
public void shouldInheritRuntimeProperties() throws Exception {
// set a system property for this process
System.getProperties().setProperty("bedrock.runtime.inherit.property", "-Dmessage=hello");
// build and start the SleepingApplication
Platform platform = getRemotePlatform();
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), IPv4Preferred.yes())) {
// ask the application for the current system property value
String message = application.getSystemProperty("message");
// ensure that the application has the system property
Assert.assertThat(message, is("hello"));
} finally {
// remove the system property to clean up
System.getProperties().remove("bedrock.runtime.inherit.property");
}
}
use of com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication 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.remote.java.applications.SleepingApplication in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldSetWorkingDirectory.
@Test
public void shouldSetWorkingDirectory() throws Exception {
String appName = "sleeping";
File folder = temporaryFolder.newFolder();
String appNameSanitized = PlatformSeparators.autoDetect().asSanitizedFileName(appName);
File expectedDirectory = new File(folder, appNameSanitized);
// build and start the SleepingApplication
Platform platform = getRemotePlatform();
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), DisplayName.of(appName), WorkingDirectory.subDirectoryOf(folder))) {
String dir = application.invoke(new GetWorkingDirectory());
Assert.assertThat(dir, is(expectedDirectory.getCanonicalPath()));
WorkingDirectory workingDir = application.getOptions().get(WorkingDirectory.class);
Assert.assertThat(workingDir, is(notNullValue()));
Assert.assertThat(workingDir.getValue(), is((Object) expectedDirectory));
}
}
use of com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication 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.remote.java.applications.SleepingApplication 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));
}
}
Aggregations