Search in sources :

Example 11 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class IgnoredFileScenarioTest method testIgnoredDirectory.

@Test
public void testIgnoredDirectory() throws Exception {
    // Scenario: A ignores files with a regular expression, creates it then ups, B should not have the file
    // Setup 
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    //Create ignore file and reload it
    File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
    TestFileUtil.createFileWithContent(syncanyIgnore, "builds");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
    // A new/up
    clientA.createNewFolder("builds");
    clientA.createNewFile("builds/test.txt");
    clientA.up();
    clientB.down();
    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("builds/test.txt").exists());
    assertFalse(clientB.getLocalFile("builds/test.txt").exists());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    TestFileUtil.deleteDirectory(tempDir);
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) File(java.io.File) Test(org.junit.Test)

Example 12 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class IgnoredFileScenarioTest method testIgnoredFileBasicRecursive.

@Test
public void testIgnoredFileBasicRecursive() throws Exception {
    // Scenario: A ignores a file, creates it then ups, B should not have the file
    // Setup
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    //Create ignore file and reload it
    File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
    TestFileUtil.createFileWithContent(syncanyIgnore, "ignoredfile.txt");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
    // A new/up
    clientA.createNewFile("ignoredfile.txt");
    clientA.createNewFile("nonignoredfile.txt");
    clientA.createNewFolder("sub");
    clientA.createNewFileInFolder("ignoredfile.txt", "sub");
    clientA.up();
    clientB.down();
    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("ignoredfile.txt").exists());
    assertTrue(clientA.getLocalFile("nonignoredfile.txt").exists());
    assertTrue(clientA.getLocalFile("sub").exists());
    assertTrue(clientA.getLocalFileInFolder("ignoredfile.txt", "sub").exists());
    assertFalse(clientB.getLocalFile("ignoredfile.txt").exists());
    assertTrue(clientB.getLocalFile("nonignoredfile.txt").exists());
    assertTrue(clientB.getLocalFile("sub").exists());
    assertFalse(clientB.getLocalFileInFolder("ignoredfile.txt", "sub").exists());
    //Delete ignore file and reload patterns
    TestFileUtil.deleteFile(syncanyIgnore);
    clientA.getConfig().getIgnoredFiles().loadPatterns();
    clientA.up();
    clientB.down();
    // All files should be synced
    assertTrue(clientA.getLocalFile("ignoredfile.txt").exists());
    assertTrue(clientA.getLocalFile("nonignoredfile.txt").exists());
    assertTrue(clientA.getLocalFile("sub").exists());
    assertTrue(clientA.getLocalFileInFolder("ignoredfile.txt", "sub").exists());
    assertTrue(clientB.getLocalFile("ignoredfile.txt").exists());
    assertTrue(clientB.getLocalFile("nonignoredfile.txt").exists());
    assertTrue(clientB.getLocalFile("sub").exists());
    assertTrue(clientB.getLocalFileInFolder("ignoredfile.txt", "sub").exists());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    TestFileUtil.deleteDirectory(tempDir);
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) File(java.io.File) Test(org.junit.Test)

Example 13 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class IgnoredFileScenarioTest method testIgnoredFileRegex.

@Test
public void testIgnoredFileRegex() throws Exception {
    // Scenario: A ignores files with a regular expression, creates it then ups, B should not have the file
    // Setup 
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    //Create ignore file and reload it
    File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
    TestFileUtil.createFileWithContent(syncanyIgnore, "regex:.*.bak");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
    // A new/up
    clientA.createNewFile("ignoredfile.bak");
    clientA.up();
    clientB.down();
    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("ignoredfile.bak").exists());
    assertFalse(clientB.getLocalFile("ignoredfile.bak").exists());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    TestFileUtil.deleteDirectory(tempDir);
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) File(java.io.File) Test(org.junit.Test)

Example 14 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class IgnoredFileScenarioTest method testIgnoredFileBasic.

@Test
public void testIgnoredFileBasic() throws Exception {
    // Scenario: A ignores a file, creates it then ups, B should not have the file
    // Setup
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    //Create ignore file and reload it
    File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
    TestFileUtil.createFileWithContent(syncanyIgnore, "ignoredfile.txt");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
    // A new/up
    clientA.createNewFile("ignoredfile.txt");
    clientA.createNewFile("nonignoredfile.txt");
    clientA.up();
    clientB.down();
    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("ignoredfile.txt").exists());
    assertTrue(clientA.getLocalFile("nonignoredfile.txt").exists());
    assertFalse(clientB.getLocalFile("ignoredfile.txt").exists());
    assertTrue(clientB.getLocalFile("nonignoredfile.txt").exists());
    //Delete ignore file and reload patterns
    TestFileUtil.deleteFile(syncanyIgnore);
    clientA.getConfig().getIgnoredFiles().loadPatterns();
    clientA.up();
    clientB.down();
    // All files should be synced
    assertTrue(clientA.getLocalFile("ignoredfile.txt").exists());
    assertTrue(clientA.getLocalFile("nonignoredfile.txt").exists());
    assertTrue(clientB.getLocalFile("ignoredfile.txt").exists());
    assertTrue(clientB.getLocalFile("nonignoredfile.txt").exists());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    TestFileUtil.deleteDirectory(tempDir);
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) File(java.io.File) Test(org.junit.Test)

Example 15 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class Issue200ScenarioTest method testIssue200.

@Test
public void testIssue200() throws Exception {
    // Setup 
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Run 
    clientA.createNewFolder("folder");
    clientA.createNewFile("folder/file");
    clientA.upWithForceChecksum();
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientA.changeFile("folder/file");
    clientA.upWithForceChecksum();
    clientB.deleteFile("folder/file");
    clientB.down();
    assertTrue(clientB.getLocalFile("folder/file").exists());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Aggregations

TransferSettings (org.syncany.plugins.transfer.TransferSettings)78 Test (org.junit.Test)67 TestClient (org.syncany.tests.util.TestClient)65 File (java.io.File)20 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)10 TransferPlugin (org.syncany.plugins.transfer.TransferPlugin)7 SqlDatabase (org.syncany.database.SqlDatabase)5 DownOperationResult (org.syncany.operations.down.DownOperationResult)4 StatusOperationResult (org.syncany.operations.status.StatusOperationResult)4 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)4 UpOperationResult (org.syncany.operations.up.UpOperationResult)4 CreateFileTree (org.syncany.tests.integration.scenarios.framework.CreateFileTree)4 IOException (java.io.IOException)3 RandomAccessFile (java.io.RandomAccessFile)3 Path (java.nio.file.Path)3 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)3 Config (org.syncany.config.Config)3 ConfigTO (org.syncany.config.to.ConfigTO)3 PartialFileHistory (org.syncany.database.PartialFileHistory)3 FileHistoryId (org.syncany.database.PartialFileHistory.FileHistoryId)3