本文整理汇总了Java中jdk.testlibrary.ProcessTools.executeTestJvm方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessTools.executeTestJvm方法的具体用法?Java ProcessTools.executeTestJvm怎么用?Java ProcessTools.executeTestJvm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.testlibrary.ProcessTools
的用法示例。
在下文中一共展示了ProcessTools.executeTestJvm方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launchTests
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Runs the actual tests in nested class TestMain.
* The reason for running the tests in a separate process
* is that we need to modify the class path and
* the -Djava.io.tmpdir property.
*/
private static void launchTests(int pid, Path clientTmpDir) throws Throwable {
final String sep = File.separator;
// Need to add jdk/lib/tools.jar to classpath.
String classpath =
System.getProperty("test.class.path", "") + File.pathSeparator +
System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar";
String[] tmpDirArg = null;
if (clientTmpDir != null) {
tmpDirArg = new String [] {"-Djava.io.tmpdir=" + clientTmpDir};
}
// Arguments : [-Djava.io.tmpdir=] -classpath cp TempDirTest$TestMain pid
String[] args = RunnerUtil.concat(
tmpDirArg,
new String[] {
"-classpath",
classpath,
"TempDirTest$TestMain",
Integer.toString(pid) });
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
示例2: runTests
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Runs the actual tests in the nested class TestMain.
* We need to run the tests in a separate process,
* because we need to add to the classpath.
*/
private static void runTests() throws Throwable {
final String sep = File.separator;
String testClassPath = System.getProperty("test.class.path", "");
String testClasses = System.getProperty("test.classes", "") + sep;
String jdkLib = System.getProperty("test.jdk", ".") + sep + "lib" + sep;
// Need to add SimpleProvider.jar and tools.jar to classpath.
String classpath =
testClassPath + File.pathSeparator +
testClasses + "SimpleProvider.jar" + File.pathSeparator +
jdkLib + "tools.jar";
String[] args = {
"-classpath",
classpath,
"ProviderTest$TestMain" };
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
示例3: stopApplication
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Will stop the running Application.
* First tries to shutdown nicely by connecting to the shut down port.
* If that fails, the process will be killed hard with stopProcess().
*
* If the nice shutdown fails, then an Exception is thrown and the test should fail.
*
* @param port The shut down port.
* @param processThread The process to stop.
*/
public static void stopApplication(int port, ProcessThread processThread) throws Throwable {
if (processThread == null) {
System.out.println("RunnerUtil.stopApplication ignored since proc is null");
return;
}
try {
System.out.println("RunnerUtil.stopApplication waiting to for shutdown");
OutputAnalyzer output = ProcessTools.executeTestJvm(
"-classpath",
System.getProperty("test.class.path", "."),
"Shutdown",
Integer.toString(port));
// Verify that both the Shutdown command and the Application finished ok.
output.shouldHaveExitValue(0);
processThread.joinAndThrow();
processThread.getOutput().shouldHaveExitValue(0);
} catch (Throwable t) {
System.out.println("RunnerUtil.stopApplication failed. Will kill it hard: " + t);
processThread.stopProcess();
throw t;
}
}
示例4: runTests
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Runs the actual tests in nested class TestMain.
* The reason for running the tests in a separate process
* is that we need to modify the class path.
*/
private static void runTests(int pid) throws Throwable {
final String sep = File.separator;
// Need to add jdk/lib/tools.jar to classpath.
String classpath =
System.getProperty("test.class.path", "") + File.pathSeparator +
System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar";
String testClassDir = System.getProperty("test.classes", "") + sep;
// Argumenta : -classpath cp BasicTests$TestMain pid agent badagent redefineagent
String[] args = {
"-classpath",
classpath,
"BasicTests$TestMain",
Integer.toString(pid),
testClassDir + "Agent.jar",
testClassDir + "BadAgent.jar",
testClassDir + "RedefineAgent.jar" };
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
示例5: launchTests
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Runs the actual tests in nested class TestMain.
* The reason for running the tests in a separate process
* is that we need to modify the class path and
* the -Djava.io.tmpdir property.
*/
private static void launchTests(long pid, Path clientTmpDir) throws Throwable {
final String sep = File.separator;
String classpath =
System.getProperty("test.class.path", "");
String[] tmpDirArg = null;
if (clientTmpDir != null) {
tmpDirArg = new String [] {"-Djava.io.tmpdir=" + clientTmpDir};
}
// Arguments : [-Djava.io.tmpdir=] -classpath cp TempDirTest$TestMain pid
String[] args = RunnerUtil.concat(
tmpDirArg,
new String[] {
"-classpath",
classpath,
"TempDirTest$TestMain",
Long.toString(pid) });
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
示例6: runTests
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Runs the actual tests in the nested class TestMain.
* We need to run the tests in a separate process,
* because we need to add to the classpath.
*/
private static void runTests() throws Throwable {
final String sep = File.separator;
String testClassPath = System.getProperty("test.class.path", "");
String testClasses = System.getProperty("test.classes", "") + sep;
String jdkLib = System.getProperty("test.jdk", ".") + sep + "lib" + sep;
// Need to add SimpleProvider.jar to classpath.
String classpath =
testClassPath + File.pathSeparator +
testClasses + "SimpleProvider.jar";
String[] args = {
"-classpath",
classpath,
"ProviderTest$TestMain" };
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
示例7: runTests
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Runs the actual tests in nested class TestMain.
* The reason for running the tests in a separate process
* is that we need to modify the class path.
*/
private static void runTests(long pid) throws Throwable {
final String sep = File.separator;
// Need to add jdk/lib/tools.jar to classpath.
String classpath =
System.getProperty("test.class.path", "");
String testClassDir = System.getProperty("test.classes", "") + sep;
// Argumenta : -classpath cp BasicTests$TestMain pid agent badagent redefineagent
String[] args = {
"-classpath",
classpath,
"BasicTests$TestMain",
Long.toString(pid),
testClassDir + "Agent.jar",
testClassDir + "BadAgent.jar",
testClassDir + "RedefineAgent.jar" };
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
示例8: runTests
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Runs the actual test the nested class TestMain.
* The test is run in a separate process because we need to add to the classpath.
*/
private static void runTests(int pid) throws Throwable {
final String sep = File.separator;
// Need to add jdk/lib/tools.jar to classpath.
String classpath =
System.getProperty("test.class.path", "") + File.pathSeparator +
System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar";
String testSrc = System.getProperty("test.src", "") + sep;
// Use a policy that will NOT allow attach. Test will verify exception.
String[] args = {
"-classpath",
classpath,
"-Djava.security.manager",
String.format("-Djava.security.policy=%sjava.policy.deny", testSrc),
"PermissionTest$TestMain",
Integer.toString(pid),
"true" };
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
// Use a policy that will allow attach.
args = new String[] {
"-classpath",
classpath,
"-Djava.security.manager",
String.format("-Djava.security.policy=%sjava.policy.allow", testSrc),
"PermissionTest$TestMain",
Integer.toString(pid),
"false" };
output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
示例9: main
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
public static void main(String[] args) throws Throwable {
OutputAnalyzer output = ProcessTools.executeTestJvm("-classpath",
TEST_CLASSES,
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n",
"HelloWorld");
output.shouldHaveExitValue(0);
}
示例10: main
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
public static void main(String[] args) throws Throwable {
int port = Utils.getFreePort();
String jdwpOption = "-agentlib:jdwp=transport=dt_socket"
+ ",server=y" + ",suspend=n" + ",address=*:" + String.valueOf(port);
OutputAnalyzer output = ProcessTools.executeTestJvm("-classpath",
TEST_CLASSES,
jdwpOption, // Notice jdwpOption specified twice
jdwpOption,
"Exit0");
output.shouldContain("Cannot load this JVM TI agent twice");
output.shouldHaveExitValue(1);
}
示例11: runTests
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
/**
* Runs the actual test the nested class TestMain.
* The test is run in a separate process because we need to add to the classpath.
*/
private static void runTests(long pid) throws Throwable {
final String sep = File.separator;
String classpath =
System.getProperty("test.class.path", "");
String testSrc = System.getProperty("test.src", "") + sep;
// Use a policy that will NOT allow attach. Test will verify exception.
String[] args = {
"-classpath",
classpath,
"-Djava.security.manager",
String.format("-Djava.security.policy=%sjava.policy.deny", testSrc),
"PermissionTest$TestMain",
Long.toString(pid),
"true" };
OutputAnalyzer output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
// Use a policy that will allow attach.
args = new String[] {
"-classpath",
classpath,
"-Djava.security.manager",
String.format("-Djava.security.policy=%sjava.policy.allow", testSrc),
"PermissionTest$TestMain",
Long.toString(pid),
"false" };
output = ProcessTools.executeTestJvm(args);
output.shouldHaveExitValue(0);
}
示例12: main
import jdk.testlibrary.ProcessTools; //导入方法依赖的package包/类
public static void main(String[] args) throws Throwable {
OutputAnalyzer output = ProcessTools.executeTestJvm("-agentpath:/badAgent/agent", "-version");
output.shouldContain("Could not find agent library /badAgent/agent");
}