<commit_before>package my.buildServer.deployer.agent.scp;

import jetbrains.buildServer.RunBuildException;
import jetbrains.buildServer.util.FileUtil;
import junit.framework.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import javax.swing.*;
import java.io.File;
import java.io.IOException;

/**
 * Created by Kit
 * Date: 21.04.12 - 22:27
 */
public class ScpProcessAdapterTest {

    final String myUsername = "testuser";
    final String myPassword = "<PASSWORD>";
    final String myHost = "192.168.56.102";

    File myWorkingDir = null;

    @BeforeMethod
    public void setUp() throws Exception {
        myWorkingDir = FileUtil.createTempDirectory("test", "workingDir");
    }

    @AfterMethod
    public void tearDown() throws Exception {
        FileUtil.delete(myWorkingDir);
    }

    @Test
    public void testSimpleTransfer() throws Exception {
        final File f = new File(myWorkingDir, "file.txt");
        FileUtil.writeFile(f, "Some sample text");
        String remotePath = "";
        ScpProcessAdapter scpProcess = createScpProcAdapter(f.getName(), remotePath);
        scpProcess.start();
    }

    @Test
    public void testTransferToRelativePath() throws Exception {
        final File f = new File(myWorkingDir, "file.txt");
        FileUtil.writeFile(f, "Some sample text\n");
        String remotePath = "subdir/sub/sub";
        ScpProcessAdapter scpProcess = createScpProcAdapter(f.getName(), remotePath);
        scpProcess.start();
    }

    @Test
    public void testTransferAbsPath() throws Exception {
        final File f = new File(myWorkingDir, "file.txt");
        FileUtil.writeFile(f, "Some sample text\n");
        String remotePath = "/home/testuser/subdir/sub/sub";
        ScpProcessAdapter scpProcess = createScpProcAdapter(f.getName(), remotePath);

        scpProcess.start();
    }

    @Test
    public void testTransferToAbsPath_NotAllowed() throws Exception {
        final File f = new File(myWorkingDir, "file.txt");
        FileUtil.writeFile(f, "Some sample text\n");
        String remotePath = "/dir/sub/sub";
        ScpProcessAdapter scpProcess = createScpProcAdapter(f.getName(), remotePath);
        try {
            scpProcess.start();
            Assert.fail("Should have thrown an exception");
        } catch (RunBuildException e) {
            Assert.assertEquals("mkdir: cannot create directory `/dir': Permission denied\n", e.getCause().getMessage());
        }
    }

    @Test
    public void testMultiTransfer() throws Exception {
        final File dir = new File(myWorkingDir, "dir");
        final File sub1 = new File(dir, "sub1");
        final File sub2 = new File(sub1, "sub2");
        Assert.assertTrue(sub2.mkdirs());

        final File f1 = new File(sub1, "file1.txt");
        FileUtil.writeFile(f1, "Some sample text #1\n");

        final File f2 = new File(sub2, "file2.txt");
        FileUtil.writeFile(f2, "Some sample text #2\n");

        ScpProcessAdapter scpProcess = createScpProcAdapter("dir/sub1", "sub0");
        scpProcess.start();
    }

    private ScpProcessAdapter createScpProcAdapter(String srcPath, String remotePath) {
        return new ScpProcessAdapter(srcPath, myHost + ":" + remotePath, myUsername, myPassword, myWorkingDir);
    }
}
<commit_msg>Fixed test compilation<commit_after>package my.buildServer.deployer.agent.scp;

import jetbrains.buildServer.RunBuildException;
import jetbrains.buildServer.util.FileUtil;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import javax.swing.*;
import java.io.File;
import java.io.IOException;

/**
 * Created by Kit
 * Date: 21.04.12 - 22:27
 */
public class ScpProcessAdapterTest {

    final String myUsername = "testuser";
    final String myPassword = "<PASSWORD>";
    final String myHost = "192.168.56.102";

    File myWorkingDir = null;

    @BeforeMethod
    public void setUp() throws Exception {
        myWorkingDir = FileUtil.createTempDirectory("test", "workingDir");
    }

    @AfterMethod
    public void tearDown() throws Exception {
        FileUtil.delete(myWorkingDir);
    }

    @Test
    public void testSimpleTransfer() throws Exception {
        final File f = new File(myWorkingDir, "file.txt");
        FileUtil.writeFile(f, "Some sample text");
        String remotePath = "";
        ScpProcessAdapter scpProcess = createScpProcAdapter(f.getName(), remotePath);
        scpProcess.start();
    }

    @Test
    public void testTransferToRelativePath() throws Exception {
        final File f = new File(myWorkingDir, "file.txt");
        FileUtil.writeFile(f, "Some sample text\n");
        String remotePath = "subdir/sub/sub";
        ScpProcessAdapter scpProcess = createScpProcAdapter(f.getName(), remotePath);
        scpProcess.start();
    }

    @Test
    public void testTransferAbsPath() throws Exception {
        final File f = new File(myWorkingDir, "file.txt");
        FileUtil.writeFile(f, "Some sample text\n");
        String remotePath = "/home/testuser/subdir/sub/sub";
        ScpProcessAdapter scpProcess = createScpProcAdapter(f.getName(), remotePath);

        scpProcess.start();
    }

    @Test
    public void testTransferToAbsPath_NotAllowed() throws Exception {
        final File f = new File(myWorkingDir, "file.txt");
        FileUtil.writeFile(f, "Some sample text\n");
        String remotePath = "/dir/sub/sub";
        ScpProcessAdapter scpProcess = createScpProcAdapter(f.getName(), remotePath);
        try {
            scpProcess.start();
            Assert.fail("Should have thrown an exception");
        } catch (RunBuildException e) {
            Assert.assertEquals("mkdir: cannot create directory `/dir': Permission denied\n", e.getCause().getMessage());
        }
    }

    @Test
    public void testMultiTransfer() throws Exception {
        final File dir = new File(myWorkingDir, "dir");
        final File sub1 = new File(dir, "sub1");
        final File sub2 = new File(sub1, "sub2");
        Assert.assertTrue(sub2.mkdirs());

        final File f1 = new File(sub1, "file1.txt");
        FileUtil.writeFile(f1, "Some sample text #1\n");

        final File f2 = new File(sub2, "file2.txt");
        FileUtil.writeFile(f2, "Some sample text #2\n");

        ScpProcessAdapter scpProcess = createScpProcAdapter("dir/sub1", "sub0");
        scpProcess.start();
    }

    private ScpProcessAdapter createScpProcAdapter(String srcPath, String remotePath) {
        return new ScpProcessAdapter(srcPath, myHost + ":" + remotePath, myUsername, myPassword, myWorkingDir);
    }
}

{'fraction_non_alphanumeric': 0.11412395709177592, 'fraction_numerical': 0.011620977353992848, 'mean_word_length': 3.100794135613928, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7156409', 'n_tokens_mistral': 2011, 'n_tokens_neox': 1930, 'n_words': 480}