Search in sources :

Example 1 with RemotePlatform

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));
    }
}
Also used : SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) AbstractRemoteTest(com.oracle.bedrock.runtime.remote.AbstractRemoteTest) Test(org.junit.Test)

Example 2 with RemotePlatform

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));
    }
}
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 3 with RemotePlatform

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"));
    }
}
Also used : SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) CapturingApplicationConsole(com.oracle.bedrock.runtime.console.CapturingApplicationConsole) 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 4 with RemotePlatform

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()));
    }
}
Also used : SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) RemoteDebugging(com.oracle.bedrock.runtime.java.profiles.RemoteDebugging) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) CapturingApplicationConsole(com.oracle.bedrock.runtime.console.CapturingApplicationConsole) 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 5 with RemotePlatform

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();
    }
}
Also used : File(java.io.File) JavaApplication(com.oracle.bedrock.runtime.java.JavaApplication) Application(com.oracle.bedrock.runtime.Application) SleepingApplication(com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication) RemotePlatform(com.oracle.bedrock.runtime.remote.RemotePlatform) Before(org.junit.Before)

Aggregations

RemotePlatform (com.oracle.bedrock.runtime.remote.RemotePlatform)21 JavaApplication (com.oracle.bedrock.runtime.java.JavaApplication)12 Test (org.junit.Test)12 SleepingApplication (com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication)11 AbstractRemoteTest (com.oracle.bedrock.runtime.remote.AbstractRemoteTest)8 JSchException (com.jcraft.jsch.JSchException)5 Session (com.jcraft.jsch.Session)5 OptionsByType (com.oracle.bedrock.OptionsByType)5 CapturingApplicationConsole (com.oracle.bedrock.runtime.console.CapturingApplicationConsole)4 File (java.io.File)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 ChannelExec (com.jcraft.jsch.ChannelExec)3 Application (com.oracle.bedrock.runtime.Application)3 Authentication (com.oracle.bedrock.runtime.remote.Authentication)3 Password (com.oracle.bedrock.runtime.remote.Password)3 RemoteApplicationProcess (com.oracle.bedrock.runtime.remote.RemoteApplicationProcess)3 ChannelSftp (com.jcraft.jsch.ChannelSftp)2 SftpException (com.jcraft.jsch.SftpException)2 DeployedArtifacts (com.oracle.bedrock.runtime.remote.DeployedArtifacts)2 HttpBasedAuthentication (com.oracle.bedrock.runtime.remote.http.HttpBasedAuthentication)2