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()));
}
}
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();
}
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();
}
Aggregations