Last active
April 4, 2023 15:25
-
-
Save vitorz/a86764a13fba3ed6629f894dc0bf2fa4 to your computer and use it in GitHub Desktop.
skeleton for a test of signal handling of a running instance of qDup app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package io.hyperfoil.tools.qdup; | |
import java.io.IOException; | |
import java.lang.ProcessBuilder.Redirect; | |
import java.lang.ProcessHandle.Info; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Optional; | |
import org.junit.Test; | |
public class KillTest { | |
@Test | |
public void kill() throws IOException, InterruptedException{ | |
Info info = ProcessHandle.current().info(); | |
Optional<String> command = info.command(); | |
if (!command.isPresent()){ | |
//test failed - exit | |
} | |
List<String> cmdAndArgs = new ArrayList<>(6); | |
cmdAndArgs.add(info.command().get()); | |
cmdAndArgs.add("-cp"); | |
String classpath = System.getProperty("java.class.path"); | |
cmdAndArgs.add(classpath); | |
cmdAndArgs.add(QDup.class.getName()); | |
cmdAndArgs.add("-x"); | |
cmdAndArgs.add("<path to your yaml file>"); | |
ProcessBuilder processBuilder = new ProcessBuilder(cmdAndArgs); | |
processBuilder.inheritIO(); | |
Process proc = processBuilder.start(); | |
Thread.sleep(6000); | |
proc.destroy(); | |
proc.waitFor(); | |
//verify | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment