use of com.oracle.bedrock.runtime.Application in project oracle-bedrock by coherence-community.
the class RemoteJavaApplicationLauncherTest method assertCanConnectDebuggerToApplication.
protected void assertCanConnectDebuggerToApplication(JavaApplication application) throws Exception {
InetSocketAddress socket = application.getOptions().getInstancesOf(RemoteDebugging.Agent.class).iterator().next().getSocketAddress();
Assert.assertThat(socket, is(notNullValue()));
Eventually.assertThat(invoking(this).isListening(socket), is(true));
CapturingApplicationConsole console = new CapturingApplicationConsole();
try (Application jdb = LocalPlatform.get().launch(Application.class, Executable.named(findJDB()), Argument.of("-connect"), Argument.of(String.format("com.sun.jdi.SocketAttach:hostname=%s,port=%d", socket.getAddress().getHostAddress(), socket.getPort())), Console.of(console))) {
Eventually.assertThat(invoking(console).getCapturedOutputLines(), hasItem(startsWith("VM Started")));
console.getInputWriter().println("run");
console.getInputWriter().println("quit");
}
}
use of com.oracle.bedrock.runtime.Application 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();
}
}
use of com.oracle.bedrock.runtime.Application in project oracle-bedrock by coherence-community.
the class SimpleRemoteApplicationLauncherTest method shouldLaunchSimpleApplicationRemotely.
/**
* Ensure that we can launch deploy a test file.
*/
@Test
public void shouldLaunchSimpleApplicationRemotely() throws Exception {
RemotePlatform platform = getRemotePlatform();
try (Application application = platform.launch("ls", Argument.of("-la"), Console.system())) {
assertThat(application.waitFor(), is(0));
application.close();
assertThat(application.exitValue(), is(0));
}
}
use of com.oracle.bedrock.runtime.Application in project oracle-bedrock by coherence-community.
the class WGetHttpDeployer method deployArtifact.
@Override
protected void deployArtifact(URL sourceURL, String targetFileName, Platform platform) {
CapturingApplicationConsole console = new CapturingApplicationConsole();
try (Application application = platform.launch(Application.class, Executable.named(wgetCommand), Argument.of("-O"), Argument.of(targetFileName), Argument.of(sourceURL.toExternalForm()), DisplayName.of("Deploy"), Console.of(console))) {
int exitCode = application.waitFor();
application.close();
if (exitCode != 0) {
StringBuilder message = new StringBuilder("Error deploying ").append(targetFileName).append(" - wget returned ").append(exitCode).append("\n").append("wget output:");
for (String line : console.getCapturedOutputLines()) {
message.append(line);
}
for (String line : console.getCapturedErrorLines()) {
message.append(line);
}
throw new RuntimeException(message.toString());
}
}
}
use of com.oracle.bedrock.runtime.Application in project oracle-bedrock by coherence-community.
the class LocalPlatformJavaApplicationTest method shouldEnableRemoteDebugAndConnectBackToDebugger.
/**
* Start the {@link JavaApplication} with remote debugging enabled and mode set to
* {@link RemoteDebugging.Behavior#ATTACH_TO_DEBUGGER}
* and assert the process connects back to the debugger
*/
@Ignore("This test can cause JVMs to crash on various platforms. Disabled for now until there is a fix.")
@Test
public void shouldEnableRemoteDebugAndConnectBackToDebugger() throws Exception {
// make sure we can run the JDB debugger otherwise we cannot run this test
Assume.assumeThat(hasJDB(), is(true));
Capture<Integer> debuggerPort = new Capture<>(getPlatform().getAvailablePorts());
CapturingApplicationConsole jdbConsole = new CapturingApplicationConsole();
try (Application jdb = getPlatform().launch(Application.class, Executable.named("jdb"), Argument.of("-connect"), Argument.of("com.sun.jdi.SocketListen:localAddress=" + getPlatform().getAddress().getHostAddress() + ",port=" + debuggerPort.get()), Console.of(jdbConsole))) {
Eventually.assertThat("JDB did not start properly", invoking(jdbConsole).getCapturedOutputLines(), hasItem(startsWith("Listening at address:")));
CapturingApplicationConsole console = new CapturingApplicationConsole();
try (JavaApplication app = getPlatform().launch(JavaApplication.class, ClassName.of(SleepingApplication.class), DisplayName.of("TestApp"), // sleeping for 60 seconds to allow connection
Argument.of("60"), RemoteDebugging.enabled().attach().at(new RemoteDebugging.TransportAddress(debuggerPort)), Console.of(console))) {
Eventually.assertThat(invoking(console).getCapturedOutputLines(), hasItem(startsWith("Now sleeping")));
// assert that the application connects back to the debugger
// (this can take sometime as JDB initializes itself)
Eventually.assertThat("Application did not connect back to JDB", invoking(jdbConsole).getCapturedOutputLines(), hasItem(containsString("VM Started:")), delayedBy(10, TimeUnit.SECONDS));
}
}
}
Aggregations