use of com.oracle.bedrock.runtime.remote.RemotePlatform 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.remote.RemotePlatform 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.RemotePlatform in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldSetRemoteDebugEnabledSuspendedIsTrue.
/**
* Should run the application with remote debug enabled if set in schema
* with start suspended set to false.
*/
@Test
public void shouldSetRemoteDebugEnabledSuspendedIsTrue() throws Exception {
// Make sure we can run the JDB debugger otherwise we cannot run this test
Assume.assumeThat(hasJDB(), is(true));
CapturingApplicationConsole console = new CapturingApplicationConsole();
RemotePlatform platform = getRemotePlatform();
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), RemoteDebugging.enabled().startSuspended(true).at(new RemoteDebugging.TransportAddress(LocalPlatform.get().getAvailablePorts())), JavaHome.at(System.getProperty("java.home")), Console.of(console))) {
assertCanConnectDebuggerToApplication(application);
Eventually.assertThat(invoking(console).getCapturedOutputLines(), hasItem(startsWith("Now sleeping")));
List<String> args = application.invoke(new GetProgramArgs());
String debugArg = null;
for (String arg : args) {
if (arg.startsWith("-agentlib:jdwp=")) {
debugArg = arg.toLowerCase();
break;
}
}
Assert.assertThat(debugArg, is(notNullValue()));
Assert.assertThat(debugArg, startsWith("-agentlib:jdwp=transport=dt_socket,"));
Assert.assertThat(debugArg, containsString(",suspend=y"));
Assert.assertThat(debugArg, containsString(",server=y"));
}
}
use of com.oracle.bedrock.runtime.remote.RemotePlatform in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method shouldSetRemoteDebugDisabled.
/**
* Should run the application with remote debug disabled.
*
* NOTE: This test is ignored when running in an IDE in debug mode
* as the JavaVirtualMachine class will pick up the debug settings
* and pass them on to the process causing the test to fail
*/
@Test
public void shouldSetRemoteDebugDisabled() throws Exception {
CapturingApplicationConsole console = new CapturingApplicationConsole();
RemoteDebugging remoteDebugging = RemoteDebugging.disabled();
RemotePlatform platform = getRemotePlatform();
try (JavaApplication application = platform.launch(JavaApplication.class, ClassName.of(SleepingApplication.class), DisplayName.of("Java"), Argument.of("30"), Console.of(console), remoteDebugging)) {
Eventually.assertThat(invoking(console).getCapturedOutputLines(), hasItem(startsWith("Now sleeping")));
List<String> args = application.invoke(new GetProgramArgs());
String debugArg = null;
for (String arg : args) {
if (arg.startsWith("-agentlib:jdwp=")) {
debugArg = arg.toLowerCase();
break;
}
}
Assert.assertThat(debugArg, is(nullValue()));
}
}
use of com.oracle.bedrock.runtime.remote.RemotePlatform in project oracle-bedrock by coherence-community.
the class JSchFileShareDeployerTest method setup.
@Before
public void setup() throws Exception {
RemotePlatform platform = getRemotePlatform();
localShare = temporaryFolder.newFolder().getAbsolutePath();
workingDirectory = temporaryFolder.newFolder().getAbsolutePath();
File remoteParent = temporaryFolder.newFolder();
remoteShare = new File(remoteParent, "share").getAbsolutePath();
try (Application app = platform.launch(Application.class, Executable.named("ln"), Arguments.of("-s", localShare, remoteShare), DisplayName.of("Link"), Console.system())) {
app.waitFor();
}
}
Aggregations