use of com.oracle.bedrock.runtime.java.JavaApplication in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldLaunchJavaApplicationRemotely.
/**
* Ensure that we can launch Java remotely.
*/
@Test
public void shouldLaunchJavaApplicationRemotely() throws Exception {
RemotePlatform platform = getRemotePlatform();
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), Argument.of("3"), Console.system())) {
assertThat(application.waitFor(), is(0));
application.close();
assertThat(application.exitValue(), is(0));
}
}
use of com.oracle.bedrock.runtime.java.JavaApplication 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.java.JavaApplication 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.java.JavaApplication 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.java.JavaApplication 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));
}
}
Aggregations