Package com.xebialabs.overthere

Examples of com.xebialabs.overthere.OverthereFile


        return connection.getFile(dir.getPath() + connection.getHostOperatingSystem().getFileSeparator());
    }

    private void populateSourceDirectory(OverthereFile srcDir) {
        srcDir.mkdir();
        OverthereFile fileInSrcDir = srcDir.getFile(SOURCE_FILE_NAME);
        writeData(fileInSrcDir, SOURCE_FILE_CONTENTS);
    }
View Full Code Here


        writeData(fileInSrcDir, SOURCE_FILE_CONTENTS);
    }

    private void populateExistentDestinationDirectory(OverthereFile dstDir) {
        dstDir.mkdir();
        OverthereFile otherFileInDestDir = dstDir.getFile(OTHER_DEST_FILE_NAME);
        writeData(otherFileInDestDir, OTHER_DEST_FILE_CONTENT);
    }
View Full Code Here

    @Test
    public void shouldCopyFileWithSpaceInNameToNonTempLocation() throws IOException {
        File fileWithSpaces = temp.newFile("I have spaces.txt");
        writeRandomBytes(fileWithSpaces, 100);

        OverthereFile dir = connection.getTempFile("dir");
        OverthereFile targetDir = connection.getFile(dir.getPath() + "/newDir");
        targetDir.mkdirs();

        OverthereFile targetFile = connection.getFile(targetDir.getPath() + "/" + fileWithSpaces.getName());

        LocalFile.valueOf(fileWithSpaces).copyTo(targetFile);
        try {
            assertThat(targetFile.exists(), is(true));
        } finally {
            // When using a sudo connection, the target folder has different rights to the temp folder it was created in.
            targetDir.deleteRecursively();
        }
    }
View Full Code Here

        }
    }

    @Test
    public void shouldTruncateExistingTargetFileOnCopyFromLocal() throws Exception {
        final OverthereFile existingDestination = connection.getFile(connection.getTempFile("existing").getPath());
        writeData(existingDestination, "**********\n**********\n**********\n**********\n**********\n".getBytes());

        final OverthereFile newSource = getLocalConnection().getTempFile("newContents");
        writeData(newSource, "++++++++++".getBytes());

        newSource.copyTo(existingDestination);

        byte[] bytes = readFile(existingDestination);
        assertThat(bytes.length, equalTo(10));
        assertThat(bytes, equalTo("++++++++++".getBytes()));
    }
View Full Code Here

    }

    @Test
    @Assumption(methods = "onWindows")
    public void shouldListFilesOnWindows() {
        OverthereFile folder = connection.getFile("C:\\overthere");
        List<OverthereFile> filesInFolder = folder.listFiles();

        OverthereFile expectedFile = connection.getFile("C:\\overthere\\temp");
        assertThat(filesInFolder.contains(expectedFile), equalTo(true));
    }
View Full Code Here

    }

    @Test
    @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

    @Test
    @Assumption(methods = {"onWindows"})
    public void shouldExecuteBatchFileWithArgumentsOnWindows() throws IOException {
        String content = "Hello from the file just uploaded";
        OverthereFile fileToType = connection.getTempFile("hello world.txt");
        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

    }

    @Test
    @Assumption(methods = {"onWindows", "supportsProcess", "notSftpCygwin", "notSftpWinsshd"})
    public void shouldStartProcessInteractiveCommandOnWindows() throws IOException, InterruptedException {
        OverthereFile scriptToRun = connection.getTempFile("echo.ps1");
        writeData(scriptToRun, ("Write-Host \"Enter your name the prompt\"\n" +
                "$name = [Console]::In.ReadLine()\n" +
                "Write-Host \"Hi $name\"").getBytes("UTF-8"));

        OverthereProcess process = connection.startProcess(CmdLine.build("powershell.exe", "-ExecutionPolicy", "Unrestricted", "-File", scriptToRun.getPath()));
        try {
            OutputStream stdin = process.getStdin();
            BufferedReader stdout = new BufferedReader(new InputStreamReader(process.getStdout()));

            waitForPrompt(stdout, "name");
View Full Code Here

    }

    @Test
    @Assumption(methods = {"onWindows"})
    public void shouldNormalizeWindowsPathWithForwardSlashes() {
        OverthereFile file = connection.getFile("C:/Windows/System32");
        assertThat(file.getPath(), equalTo("C:\\Windows\\System32"));
    }
View Full Code Here

    @Test
    public void shouldWriteLargeFile() throws IOException {
        byte[] expected = generateRandomBytes(LARGE_FILE_SIZE);

        OverthereFile remoteLargeFile = connection.getTempFile("large.dat");
        OverthereUtils.write(expected, remoteLargeFile);

        byte[] actual = readFile(remoteLargeFile);
        assertThat("Data read is not identical to data written", Arrays.equals(actual, expected), equalTo(true));
    }
View Full Code Here

TOP

Related Classes of com.xebialabs.overthere.OverthereFile

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.