use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class PremainClassTest method main.
// Use a javaagent where the manifest Premain-Class contains
// a non ascii character.
// Verify that the premain() function is executed correctly.
public static void main(String[] a) throws Exception {
String testArgs = String.format("-javaagent:%s/Agent.jar -classpath %s DummyMain", System.getProperty("test.src"), System.getProperty("test.classes", "."));
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(Utils.addTestJavaOpts(testArgs.split("\\s+")));
System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println("testjvm.stdout:" + output.getStdout());
System.out.println("testjvm.stderr:" + output.getStderr());
output.shouldHaveExitValue(0);
output.stdoutShouldContain("premain running");
output.stdoutShouldContain("Hello from DummyMain!");
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class ZeroArgPremainAgentTest method main.
// Use a javaagent with a zero argument premain() function.
// Verify that we get the correct exception.
public static void main(String[] a) throws Exception {
String testArgs = String.format("-javaagent:ZeroArgPremainAgent.jar -classpath %s DummyMain", System.getProperty("test.classes", "."));
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(Utils.addTestJavaOpts(testArgs.split("\\s+")));
System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
System.out.println("testjvm.stdout:" + output.getStdout());
System.out.println("testjvm.stderr:" + output.getStderr());
output.stderrShouldContain("java.lang.NoSuchMethodException");
if (0 == output.getExitValue()) {
throw new RuntimeException("Expected error but got exit value 0");
}
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class BasicTests method runTests.
/**
* 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);
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class PermissionTest method runTests.
/**
* 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);
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class ProviderTest method runTests.
/**
* 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);
}
Aggregations