Search in sources :

Example 1 with RemoteDebugging

use of com.oracle.bedrock.runtime.java.profiles.RemoteDebugging 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 2 with RemoteDebugging

use of com.oracle.bedrock.runtime.java.profiles.RemoteDebugging in project oracle-bedrock by coherence-community.

the class JavaVirtualMachineTest method shouldDefaultDebugModeToFalseFromJVM.

/**
 * Test that remote debug mode is set to the value returned
 * from {@link JavaVirtualMachine#shouldEnableRemoteDebugging()}
 */
@Test
@SuppressWarnings("unchecked")
public void shouldDefaultDebugModeToFalseFromJVM() throws Exception {
    JavaVirtualMachine jvm = JavaVirtualMachine.get();
    when(jvm.shouldEnableRemoteDebugging()).thenReturn(false);
    RemoteDebugging remoteDebugging = RemoteDebugging.autoDetect();
    Assert.assertThat(remoteDebugging.isEnabled(), is(false));
    verify(jvm, atLeastOnce()).shouldEnableRemoteDebugging();
}
Also used : RemoteDebugging(com.oracle.bedrock.runtime.java.profiles.RemoteDebugging) Test(org.junit.Test)

Example 3 with RemoteDebugging

use of com.oracle.bedrock.runtime.java.profiles.RemoteDebugging in project oracle-bedrock by coherence-community.

the class JavaVirtualMachineTest method shouldDefaultDebugModeToTrueFromJVM.

/**
 * Test that remote debug mode is set to the value returned
 * from {@link JavaVirtualMachine#shouldEnableRemoteDebugging()}
 */
@Test
@SuppressWarnings("unchecked")
public void shouldDefaultDebugModeToTrueFromJVM() throws Exception {
    JavaVirtualMachine jvm = JavaVirtualMachine.get();
    when(jvm.shouldEnableRemoteDebugging()).thenReturn(true);
    RemoteDebugging remoteDebugging = RemoteDebugging.autoDetect();
    Assert.assertThat(remoteDebugging.isEnabled(), is(true));
    verify(jvm, atLeastOnce()).shouldEnableRemoteDebugging();
}
Also used : RemoteDebugging(com.oracle.bedrock.runtime.java.profiles.RemoteDebugging) Test(org.junit.Test)

Aggregations

RemoteDebugging (com.oracle.bedrock.runtime.java.profiles.RemoteDebugging)3 Test (org.junit.Test)3 CapturingApplicationConsole (com.oracle.bedrock.runtime.console.CapturingApplicationConsole)1 JavaApplication (com.oracle.bedrock.runtime.java.JavaApplication)1 AbstractRemoteTest (com.oracle.bedrock.runtime.remote.AbstractRemoteTest)1 RemotePlatform (com.oracle.bedrock.runtime.remote.RemotePlatform)1 SleepingApplication (com.oracle.bedrock.runtime.remote.java.applications.SleepingApplication)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1