当前位置: 首页>>代码示例>>Java>>正文


Java ProcessTools.executeTestJvm方法代码示例

本文整理汇总了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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:TempDirTest.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:ProviderTest.java

示例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;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:RunnerUtil.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:BasicTests.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:TempDirTest.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ProviderTest.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:BasicTests.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:PermissionTest.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:SuspendNoFlagTest.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DoubleAgentTest.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:PermissionTest.java

示例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");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:BadAgentPath.java


注:本文中的jdk.testlibrary.ProcessTools.executeTestJvm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。