⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 externallyshutdownstandalonetesttest.java

📁 sourcode about java basic
💻 JAVA
字号:
package jsunit.java.tests_server.net.jsunit;

import junit.framework.TestCase;
import junit.framework.TestResult;
import net.jsunit.configuration.ConfigurationSource;
import net.jsunit.model.Browser;
import net.jsunit.model.ResultType;

public class ExternallyShutDownStandaloneTestTest extends TestCase {

    public ExternallyShutDownStandaloneTestTest(String name) {
        super(name);
    }

    protected ConfigurationSource configurationSource() {
        return new StubConfigurationSource() {
            public String browserFileNames() {
                return Browser.DEFAULT_SYSTEM_BROWSER;
            }

            public String url() {
                return "http://localhost:8080/jsunit/testRunner.html?" +
                        "testPage=http://localhost:8080/jsunit/tests/jsUnitTestSuite.html" +
                        "&autoRun=true&submitresults=true&resultId=foobar";
            }
        };
    }

    public void testBrowsersExternallyShutDown() throws Exception {
        final StandaloneTest test = new StandaloneTest(configurationSource());
        new Thread() {
            public void run() {
                try {
                    while (test.getServer() == null)
                        Thread.sleep(100);
                    while (test.getServer().getBrowserProcess() == null)
                        Thread.sleep(100);
                } catch (InterruptedException e) {
                    fail();
                }
                Process process = test.getServer().getBrowserProcess();
                process.destroy();
                try {
                    process.waitFor();
                } catch (InterruptedException e) {
                    fail();
                }
            }
        }.start();

        TestResult result = test.run();
        assertFalse(result.wasSuccessful());
        assertEquals(
                ResultType.EXTERNALLY_SHUT_DOWN,
                test.getServer().lastResult().getResultType());
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -