Package org.syncany.tests.util

Examples of org.syncany.tests.util.TestClient


*/   
public class AllFilePossibilitiesScenarioTest
  @Test
  public void testAllPossibilities() throws Exception {   
    final TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    final TestClient clientA = new TestClient("A", testConnection);
    final TestClient clientB = new TestClient("B", testConnection);
   
    ClientActions.run(clientA,
      new Executable() {
        @Override
        public void execute() throws Exception {
          // Nothing.
         }     
      },
      new AbstractClientAction[] {
        new CreateFileTree(),
       
        new ChangeContentWithoutFileSize(),
        new ChangeFileSize(),
        new ChangeLastModifiedDate(),
        new ChangePermissionsOfFile(),
        new ChangePermissionsOfFolder(),
        new ChangeSymlinkTarget(),   
        new ChangeTypeFileToFolder(),
        new ChangeTypeFileToSymlinkWithNonExistingTarget(),
        new ChangeTypeFileToSymlinkWithTargetFile(),
        new ChangeTypeFileToSymlinkWithTargetFolder(),
        new ChangeTypeSymlinkWithNonExistingTargetToFile(),
        new ChangeTypeSymlinkWithTargetFileToFile(),
        new ChangeTypeSymlinkWithTargetFolderToFile(),
        new ChangeTypeSymlinkWithNonExistingTargetToFolder(),
        new ChangeTypeSymlinkWithTargetFileToFolder(),
        new ChangeTypeSymlinkWithTargetFolderToFolder(),
        new ChangeTypeFolderToFile(),
        new ChangeTypeFolderToSymlinkWithNonExistingTarget(),
        new ChangeTypeFolderToSymlinkWithTargetFile(),
        new ChangeTypeFolderToSymlinkWithTargetFolder(),
        new CreateFile(),
        new CreateFolder(),
        new CreateSymlinkToFile(),
        new CreateSymlinkToFolder(),
        new CreateSymlinkToNonExisting(),
        new DeleteFile(),
        new DeleteFolder(),       
        new MoveFileToOtherFolder(),
        new MoveFileWithinFolder(),
        new MoveFolderToOtherFolder(),
        new MoveFolderWithinFolder(),
       
        //new LockFile() and new UnlockFile() are not compatible with these tests
      },
      new Executable() {
        @Override
        public void execute() throws Exception {
          clientA.upWithForceChecksum();   
         
          clientB.down();
          assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
          assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());         
        }     
      }
    );
   
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here


  }
 
  @Test
  public void testChangeTypeSymlinkWithTargetFileToFolder() throws Exception {   
    final TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    final TestClient clientA = new TestClient("A", testConnection);
    final TestClient clientB = new TestClient("B", testConnection);
   
    ClientActions.run(clientA, null, new CreateFileTree(), null);
    ClientActions.run(clientA, null, new ChangeTypeFileToSymlinkWithTargetFolder(), null);
   
    clientA.upWithForceChecksum();   
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());         
   
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

  @Test
  public void testEmptyFileCreateAndSync() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
   
    // A
    clientA.createNewFile("A-file1.jpg", 100);
    clientA.up();   

    // B
    clientB.createNewFile("A-file1.jpg", 150);
    clientB.up();
   
    // A, A should win
    clientA.down();
    assertEquals(clientA.getLocalFile("A-file1.jpg").length(), 100);

    // B, B should have conflicting file and updated on A's file
    clientB.down();
    assertConflictingFileExists("A-file1.jpg", clientB.getLocalFilesExcludeLockedAndNoRead());
    assertFileEquals(clientA.getLocalFile("A-file1.jpg"), clientB.getLocalFile("A-file1.jpg"));
    assertEquals(clientB.getLocalFile("A-file1.jpg").length(), 100);
   
    // B
    clientB.up();
       
    // A, should retrieve B's conflicting copy
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());       
   
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

public class ManySyncUpsLargeFileScenarioTest {
  @Test
  public void testManySyncUpsWithLargeFile() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
   
    // Cause Cleanup with a moderately large file
    for (int i=1; i<=16; i++) {
      clientA.createNewFile("file"+i, 600181);
      TestFileUtil.changeRandomPartOfBinaryFile(clientA.getLocalFile("file"+i));
      if (i > 2) {
        TestFileUtil.changeRandomPartOfBinaryFile(clientA.getLocalFile("file"+ (i-1)));
        TestFileUtil.changeRandomPartOfBinaryFile(clientA.getLocalFile("file1"));
      }
      clientA.up();   
    }
   
    clientB.down();
   
    for (int i=1; i<=16; i++) {
      assertTrue(clientA.getLocalFile("file" + i).exists());
      assertTrue(clientB.getLocalFile("file" + i).exists());
    }
   
    clientA.deleteTestData()
    clientB.deleteTestData();
  }
View Full Code Here

public class SingleFileNoConflictsScenarioTest {
  @Test
  public void testSingleClientLocalBackupAndRestoreNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    TestClient clientA1 = new TestClient("A", testConnection);
    TestClient clientA2 = new TestClient("A", testConnection); // same client!

    // Create files and upload
    clientA1.createNewFiles();   
    clientA1.up();
   
    // Download and reconstruct
    clientA2.down();   
    assertFileListEquals(clientA1.getLocalFilesExcludeLockedAndNoRead(), clientA2.getLocalFilesExcludeLockedAndNoRead());
   
    // Cleanup
    clientA1.deleteTestData();
    clientA2.deleteTestData();
  }
View Full Code Here

 
  @Test
  public void testSingleFileNewNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);

    // Create files and upload
    clientA.createNewFile("file");   
    clientA.up();
   
    clientB.down();
    assertFileEquals(clientA.getLocalFile("file"), clientB.getLocalFile("file"));   
   
    // Cleanup
    clientA.deleteTestData();
    clientB.deleteTestData();
  }   
View Full Code Here

 
  @Test
  public void testSingleFileMoveNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);

    // Create files and upload
    clientA.createNewFile("file");   
    clientA.up();
   
    clientB.down();
    assertFileEquals(clientA.getLocalFile("file"), clientB.getLocalFile("file"));
   
    clientB.moveFile("file", "moved");
    clientB.up();
   
    clientA.down();
    assertFalse("Originally moved file should not exist.", clientA.getLocalFile("file").exists());
    assertFileEquals(clientA.getLocalFile("moved"), clientB.getLocalFile("moved"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
   
    // Cleanup
    clientA.deleteTestData();
    clientB.deleteTestData();
 
View Full Code Here

 
  @Test
  public void testSingleFileDeleteNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);

    // Create files and upload
    clientA.createNewFile("file");   
    clientA.up();
   
    clientB.down();
    assertFileEquals(clientA.getLocalFile("file"), clientB.getLocalFile("file"));
   
    clientB.deleteFile("file");
    clientB.up();
   
    clientA.down();
    assertFalse("Deleted file should not exist.", clientA.getLocalFile("file").exists());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
   
    // Cleanup
    clientA.deleteTestData();
    clientB.deleteTestData();
  }   
View Full Code Here

 
  @Test
  public void testSingleFileChangeNoConflicts() throws Exception {   
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);    

    // Create files and upload
    clientA.createNewFile("file");   
    clientA.upWithForceChecksum();
   
    clientB.down();
    assertFileEquals(clientA.getLocalFile("file"), clientB.getLocalFile("file"));
   
    clientB.changeFile("file");
    clientB.upWithForceChecksum();
   
    clientA.down();
    assertFileEquals(clientA.getLocalFile("file"), clientB.getLocalFile("file"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());   
   
    // Cleanup
    clientA.deleteTestData();
    clientB.deleteTestData();
  }     
View Full Code Here

  @Test
  public void testComplexNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    TestClient clientC = new TestClient("C", testConnection);   
   
    // Test
    clientA.createNewFile("1");
    clientA.upWithForceChecksum();
   
    clientB.down();
    assertFileEquals(clientA.getLocalFile("1"), clientB.getLocalFile("1"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
   
    clientA.moveFile("1", "2");
    assertFileEquals(clientA.getLocalFile("2"), clientB.getLocalFile("1"));
   
    clientA.upWithForceChecksum();
    clientA.upWithForceChecksum();
   
    clientB.down();
    assertFileEquals(clientA.getLocalFile("2"), clientB.getLocalFile("2"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
   
    clientC.down();
    assertFileEquals(clientA.getLocalFile("2"), clientC.getLocalFile("2"));
    assertFileEquals(clientB.getLocalFile("2"), clientC.getLocalFile("2"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
    assertFileListEquals(clientB.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
   
    clientC.createNewFile("3");
    clientC.changeFile("2");
    clientC.upWithForceChecksum();
   
    clientA.down();
    assertFileEquals(clientC.getLocalFile("3"), clientA.getLocalFile("3"));
    assertFileListEquals(clientC.getLocalFilesExcludeLockedAndNoRead(), clientA.getLocalFilesExcludeLockedAndNoRead());
   
    clientB.down();
    assertFileEquals(clientC.getLocalFile("3"), clientB.getLocalFile("3"));
    assertFileListEquals(clientC.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
   
    clientC.down();   
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
   
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    clientC.deleteTestData();
  }
View Full Code Here

TOP

Related Classes of org.syncany.tests.util.TestClient

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.