Search in sources :

Example 1 with OutputCatcher

use of org.h2.test.synth.OutputCatcher in project h2database by h2database.

the class TestAll method main.

/**
 * Run all tests.
 *
 * @param args the command line arguments
 */
public static void main(String... args) throws Exception {
    OutputCatcher catcher = OutputCatcher.start();
    run(args);
    catcher.stop();
    catcher.writeTo("Test Output", "docs/html/testOutput.html");
    if (atLeastOneTestFailed) {
        System.exit(1);
    }
}
Also used : OutputCatcher(org.h2.test.utils.OutputCatcher)

Example 2 with OutputCatcher

use of org.h2.test.synth.OutputCatcher in project h2database by h2database.

the class TestRecoverKillLoop method runTest.

private void runTest(int count) throws Exception {
    FileUtils.deleteRecursive("data/db", false);
    Random random = new Random(1);
    for (int i = 0; i < count; i++) {
        String[] procDef = { "java", "-cp", getClassPath(), "-Dtest.dir=data/db", TestRecover.class.getName() };
        Process p = Runtime.getRuntime().exec(procDef);
        InputStream in = p.getInputStream();
        OutputCatcher catcher = new OutputCatcher(in);
        catcher.start();
        while (true) {
            String s = catcher.readLine(60 * 1000);
            // System.out.println("> " + s);
            if (s == null) {
                fail("No reply from process");
            } else if (s.startsWith("testing...")) {
                int sleep = random.nextInt(10000);
                Thread.sleep(sleep);
                printTime("killing");
                p.destroy();
                p.waitFor();
                break;
            } else if (s.startsWith("error!")) {
                fail("Failed: " + s);
            }
        }
    }
}
Also used : Random(java.util.Random) InputStream(java.io.InputStream) OutputCatcher(org.h2.test.synth.OutputCatcher)

Aggregations

InputStream (java.io.InputStream)1 Random (java.util.Random)1 OutputCatcher (org.h2.test.synth.OutputCatcher)1 OutputCatcher (org.h2.test.utils.OutputCatcher)1