Package com.xebialabs.overthere.util

Examples of com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler


    }

    @Test
    @Assumption(methods = "onUnix")
    public void shouldCaptureLastLineOfSimpleCommandOnUnix() {
        CapturingOverthereExecutionOutputHandler captured = capturingHandler();
        int res = connection.execute(multiHandler(sysoutHandler(), captured), syserrHandler(),
                CmdLine.build("echo", "-n", "line", "that", "does", "not", "end", "in", "a", "newline"));
        assertThat(res, equalTo(0));
        if (captured.getOutputLines().size() > 1) {
            // When using ssh_interactive_sudo, the output may be proceeded by the password prompt and possibly even the
            // sudo warning message.
            assertThat(captured.getOutputLines().get(captured.getOutputLines().size() - 2), containsString("assword"));
            assertThat(captured.getOutputLines().get(captured.getOutputLines().size() - 1), containsString("line that does not end in a newline"));
        } else {
            assertThat(captured.getOutputLines().size(), equalTo(1));
            assertThat(captured.getOutput(), containsString("line that does not end in a newline"));
        }
    }
View Full Code Here


    }

    @Test
    @Assumption(methods = "onWindows")
    public void shouldExecuteSimpleCommandOnWindows() {
        CapturingOverthereExecutionOutputHandler captured = capturingHandler();
        int res = connection.execute(multiHandler(loggingOutputHandler(logger), captured), loggingErrorHandler(logger), CmdLine.build("ipconfig"));
        assertThat(res, equalTo(0));
        assertThat(captured.getOutput(), not(containsString("ipconfig")));
        assertThat(captured.getOutput(), containsString("Windows IP Configuration"));
    }
View Full Code Here

    @Test
    @Assumption(methods = {"onWindows", "notSftpCygwin"})
    public void shouldExecuteSimpleCommandInWorkingDirectoryOnWindowsNotWithSftpCygwin() {
        connection.setWorkingDirectory(connection.getFile("C:\\WINDOWS"));
        CapturingOverthereExecutionOutputHandler captured = capturingHandler();
        int res = connection.execute(multiHandler(loggingOutputHandler(logger), captured), loggingErrorHandler(logger), CmdLine.build("cd"));
        assertThat(res, equalTo(0));
        assertThat(captured.getOutput().toUpperCase(), containsString("C:\\WINDOWS"));
    }
View Full Code Here

    @Test
    @Assumption(methods = {"onWindows", "onlySftpCygwin"})
    public void shouldExecuteSimpleCommandInWorkingDirectoryOnWindowsWithSftpCygwin() {
        connection.setWorkingDirectory(connection.getFile("C:\\WINDOWS"));
        CapturingOverthereExecutionOutputHandler captured = capturingHandler();
        int res = connection.execute(multiHandler(loggingOutputHandler(logger), captured), loggingErrorHandler(logger), CmdLine.build("pwd"));
        assertThat(res, equalTo(0));
        assertThat(captured.getOutput().toLowerCase(), containsString("/cygdrive/c/windows"));
    }
View Full Code Here

    }

    @Test
    @Assumption(methods = {"onWindows"})
    public void shouldExecuteCommandWithArgumentOnWindows() {
        CapturingOverthereExecutionOutputHandler capturingHandler = capturingHandler();
        int res = connection.execute(multiHandler(loggingOutputHandler(logger), capturingHandler), loggingErrorHandler(logger), CmdLine.build("ipconfig", "/all"));
        assertThat(res, equalTo(0));
        assertThat(capturingHandler.getOutput(), containsString("Windows IP Configuration"));
    }
View Full Code Here

    @Assumption(methods = {"onWindows"})
    public void shouldExecuteBatchFileOnWindows() throws IOException {
        OverthereFile scriptToRun = connection.getTempFile("helloworld.bat");
        writeData(scriptToRun, ("@echo Hello World").getBytes("UTF-8"));

        CapturingOverthereExecutionOutputHandler capturingHandler = capturingHandler();
        int res = connection.execute(multiHandler(loggingOutputHandler(logger), capturingHandler), loggingErrorHandler(logger), CmdLine.build(scriptToRun.getPath()));
        assertThat(res, equalTo(0));
        assertThat(capturingHandler.getOutput(), containsString("Hello World"));
    }
View Full Code Here

        writeData(fileToType, content.getBytes("UTF-8"));
        OverthereFile scriptToRun = connection.getTempFile("helloworld.bat");
        writeData(scriptToRun, ("@type %1").getBytes("UTF-8"));


        CapturingOverthereExecutionOutputHandler capturingHandler = capturingHandler();
        int res = connection.execute(multiHandler(loggingOutputHandler(logger), capturingHandler), loggingErrorHandler(logger), CmdLine.build(scriptToRun.getPath(), fileToType.getPath()));
        assertThat(res, equalTo(0));
        assertThat(capturingHandler.getOutput(), containsString(content));
    }
View Full Code Here

    public void canExecuteCommand() {
        OverthereFile tempFile = connection.getTempFile("afile");
        OverthereUtils.write("Some text", "UTF-8", tempFile);
        String lsCommand = connection.getHostOperatingSystem() == UNIX ? "ls" : "dir";
        CmdLine commandLine = CmdLine.build(lsCommand, tempFile.getParentFile().getPath());
        CapturingOverthereExecutionOutputHandler handler = capturingHandler();

        int res = connection.execute(handler, syserrHandler(), commandLine);
        assertThat(res, equalTo(0));
        assertThat(handler.getOutputLines().contains(tempFile.getName()), equalTo(true));
    }
View Full Code Here

TOP

Related Classes of com.xebialabs.overthere.util.CapturingOverthereExecutionOutputHandler

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.