Search in sources :

Example 6 with ProcessWrapper

use of org.apache.geode.test.process.ProcessWrapper in project geode by apache.

the class GoldenTestCase method createProcessWrapper.

protected final ProcessWrapper createProcessWrapper(final ProcessWrapper.Builder processWrapperBuilder, final Class<?> main) {
    final ProcessWrapper processWrapper = processWrapperBuilder.jvmArguments(JVM_ARGS).mainClass(main).build();
    this.processes.add(processWrapper);
    return processWrapper;
}
Also used : ProcessWrapper(org.apache.geode.test.process.ProcessWrapper)

Example 7 with ProcessWrapper

use of org.apache.geode.test.process.ProcessWrapper in project geode by apache.

the class GoldenTestCase method tearDownGoldenTest.

@After
public final void tearDownGoldenTest() throws Exception {
    try {
        for (ProcessWrapper process : this.processes) {
            process.destroy();
            printProcessOutput(process, true);
        }
    } finally {
        this.processes.clear();
    }
    subTearDown();
}
Also used : ProcessWrapper(org.apache.geode.test.process.ProcessWrapper) After(org.junit.After)

Example 8 with ProcessWrapper

use of org.apache.geode.test.process.ProcessWrapper in project geode by apache.

the class PassJUnitTest method testPass.

/**
   * Process output has no problems and should pass
   */
@Test
public void testPass() throws Exception {
    final String goldenString = "Begin " + name() + ".main" + "\n" + "Press Enter to continue." + "\n" + "End " + name() + ".main" + "\n";
    final ProcessWrapper process = createProcessWrapper(new ProcessWrapper.Builder(), getClass());
    process.execute(createProperties());
    assertTrue(process.isAlive());
    process.waitForOutputToMatch("Begin " + name() + "\\.main");
    process.waitForOutputToMatch("Press Enter to continue\\.");
    process.sendInput();
    process.waitForOutputToMatch("End " + name() + "\\.main");
    process.waitFor();
    assertOutputMatchesGoldenFile(process, goldenString);
    assertFalse(process.isAlive());
    assertFalse(process.getStandardOutReader().isAlive());
    assertFalse(process.getStandardErrorReader().isAlive());
}
Also used : ProcessWrapper(org.apache.geode.test.process.ProcessWrapper) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 9 with ProcessWrapper

use of org.apache.geode.test.process.ProcessWrapper in project geode by apache.

the class FailWithExtraLineInOutputJUnitTest method testFailWithExtraLineInOutput.

/**
   * Process output has an extra line and should fail
   */
@Test
public void testFailWithExtraLineInOutput() throws Exception {
    final String goldenString = "Begin " + name() + ".main" + "\n" + "Press Enter to continue." + "\n" + "End " + name() + ".main" + "\n";
    debug(goldenString, "GOLDEN");
    final ProcessWrapper process = createProcessWrapper(new ProcessWrapper.Builder(), getClass());
    process.execute(createProperties());
    process.waitForOutputToMatch("Begin " + name() + "\\.main");
    process.waitForOutputToMatch("Press Enter to continue\\.");
    process.sendInput();
    process.waitForOutputToMatch("End " + name() + "\\.main");
    process.waitFor();
    try {
        assertOutputMatchesGoldenFile(process.getOutput(), goldenString);
        fail("assertOutputMatchesGoldenFile should have failed due to " + problem());
    } catch (AssertionError expected) {
        assertTrue(expected.getMessage().contains(problem()));
    }
}
Also used : ProcessWrapper(org.apache.geode.test.process.ProcessWrapper) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

ProcessWrapper (org.apache.geode.test.process.ProcessWrapper)9 Test (org.junit.Test)7 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)5 File (java.io.File)1 Builder (org.apache.geode.distributed.ServerLauncher.Builder)1 ServerState (org.apache.geode.distributed.ServerLauncher.ServerState)1 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)1 After (org.junit.After)1 Ignore (org.junit.Ignore)1