Package org.apache.ace.processlauncher.impl

Examples of org.apache.ace.processlauncher.impl.ProcessLauncher


    public void testCallAlreadyRunningProcessCausesExceptionFail() throws Exception {
        String execName = determineJavaExecutable();

        TestProcessStreamListener psl = new TestProcessStreamListener(false /* wantsStdout */);

        ProcessLauncher launcher = createProcessLauncher(psl, null, execName);

        launcher.run();

        try {
            launcher.run(); // should fail!
            fail("Exception expected!");
        }
        catch (IllegalStateException expected) {
            // Ok...
        }
View Full Code Here


        String execName = determineJavaExecutable();

        TestProcessStreamListener psl = new TestProcessStreamListener(false /* wantsStdout */);
        TestProcessLifecycleListener pll = new TestProcessLifecycleListener();

        ProcessLauncher launcher = createProcessLauncher(psl, pll, execName);

        launcher.run();

        assertTrue(pll.m_beforeCalled);

        // Will wait until process is finished and calls our lifecycle method...
        launcher.waitForTermination();

        assertTrue(pll.m_afterCalled);
    }
View Full Code Here

    public void testCallCleanupOnRunningProcessFails() throws Exception {
        String execName = determineJavaExecutable();

        TestProcessStreamListener psl = new TestProcessStreamListener(false /* wantsStdout */);

        ProcessLauncher launcher = createProcessLauncher(psl, null, execName);

        launcher.run();

        try {
            launcher.cleanup(); // should fail!
            fail("Exception expected!");
        }
        catch (IllegalStateException expected) {
            // Ok...
        }
View Full Code Here

    public void testCallCleanupOnTerminatedProcessOk() throws Exception {
        String execName = determineJavaExecutable();

        TestProcessStreamListener psl = new TestProcessStreamListener(false /* wantsStdout */);

        ProcessLauncher launcher = createProcessLauncher(psl, null, execName);

        launcher.run();

        sleep(500);

        launcher.cleanup();
    }
View Full Code Here

    public void testCallExistingExecutableWithoutArgumentOk() throws Exception {
        String execName = determineJavaExecutable();

        TestProcessStreamListener psl = new TestProcessStreamListener(true /* wantsStdout */);

        ProcessLauncher launcher = createProcessLauncher(psl, null, execName);

        launcher.run();
        Integer exitValue = launcher.waitForTermination();

        assertNotNull(exitValue);
        assertEquals(0, exitValue.intValue());
        // Both methods should return the same exit value!
        assertEquals(exitValue, launcher.getExitValue());

        String stdout = psl.slurpStdout();
        assertNotNull(stdout);
        assertTrue(stdout.length() > 0);

View Full Code Here

     */
    public void testCallExistingExecutableWithUnknownArgumentsOk() throws Exception {
        String execName = determineJavaExecutable();
        String execArgs = "-nonExistingArg";

        ProcessLauncher launcher = createProcessLauncher(execName, execArgs);

        launcher.run();
        Integer exitValue = launcher.waitForTermination();

        assertNotNull(exitValue);
        assertFalse(0 == exitValue.intValue());
        // Both methods should return the same exit value!
        assertEquals(exitValue, launcher.getExitValue());
    }
View Full Code Here

        String execName = determineJavaExecutable();
        String execArgs = "-version";

        TestProcessStreamListener psl = new TestProcessStreamListener(true /* wantsStdout */);

        ProcessLauncher launcher = createProcessLauncher(psl, null, execName, execArgs);

        launcher.run();
        Integer exitValue = launcher.waitForTermination();

        assertNotNull(exitValue);
        assertEquals(0, exitValue.intValue());

        String stdout = psl.slurpStdout();
View Full Code Here

     */
    public void testCallNonExistingExecutableOk() throws Exception {
        String execName = "/path/to/java";
        String execArgs = "-version";

        ProcessLauncher launcher = createProcessLauncher(execName, execArgs);

        try {
            launcher.run(); // should fail!
            fail("Exception expected!");
        }
        catch (IOException expected) {
            // Ok...
        }
View Full Code Here

     * Tests that attempting to create a new {@link ProcessLauncher} without a valid launch
     * configuration yields an exception.
     */
    public void testCreateProcessLauncherWithoutLaunchConfigurationFail() {
        try {
            new ProcessLauncher(null);
            fail("Exception expected!");
        }
        catch (IllegalArgumentException expected) {
            // Ok...
        }
View Full Code Here

     */
    public void testGetExitValueWithoutLaunchedProcessReturnsNull() {
        String execName = determineJavaExecutable();
        String execArgs = "-version";

        ProcessLauncher launcher = createProcessLauncher(execName, execArgs);

        assertNull(launcher.getExitValue());
    }
View Full Code Here

TOP

Related Classes of org.apache.ace.processlauncher.impl.ProcessLauncher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.