Package org.syncany.tests.util

Examples of org.syncany.tests.util.TestClient


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

    // Run
    clientA.createNewFile("FILENAME-FOR-WINDOWS");
    clientA.createNewFile("filename-for-windows");
    clientA.createNewFile("Filename-For-Windows");
    clientA.upWithForceChecksum();
    assertEquals("There should be three files.", 3, clientA.getLocalFilesExcludeLockedAndNoRead().size());

    clientB.down();
    assertEquals("There should be three files.", 3, clientB.getLocalFilesExcludeLockedAndNoRead().size());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());

    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here


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

    // Run
    clientA.createNewFile("Exposé"); // Non-ASCII
    clientA.createNewFile("這是一個測試"); // Non-ASCII
    clientA.createNewFile("One&Two"); // & is not allowed in XML
    clientA.upWithForceChecksum();
    assertEquals("There should be three files.", 3, clientA.getLocalFilesExcludeLockedAndNoRead().size());

    clientB.down();
    assertEquals("There should be three files.", 3, clientB.getLocalFilesExcludeLockedAndNoRead().size());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());

    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

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

    // Run!
    clientA.createNewFile("locked-file");
    RandomAccessFile lockedFile = new RandomAccessFile(clientA.getLocalFile("locked-file"), "rw");
    FileLock lockedFileLock = lockedFile.getChannel().lock();

    runUpAndTestForEmptyDatabase(testConnection, clientA);

    // Tear down
    lockedFileLock.release();
    lockedFile.close();

    clientA.deleteTestData();
  }
View Full Code Here

      return; // Not possible in windows
    }

    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);

    // Run
    File noReadPermissionFile = clientA.createNewFile("no-read-permission-file");
    Path filePath = Paths.get(noReadPermissionFile.getAbsolutePath());

    Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();
    perms.add(PosixFilePermission.OWNER_READ);
    perms.add(PosixFilePermission.GROUP_READ);
    perms.add(PosixFilePermission.OTHERS_READ);
    Files.setPosixFilePermissions(filePath, perms);

    runUpAndTestForConsistentDatabase(testConnection, clientA);

    // Tear down
    clientA.deleteTestData();
  }
View Full Code Here

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

    // Run
    File noReadPermissionFile = clientA.createNewFile("no-read-permission-file");
    noReadPermissionFile.setWritable(false, false);

    runUpAndTestForConsistentDatabase(testConnection, clientA);

    // Tear down
    clientA.deleteTestData();
  }
View Full Code Here

  @Test
  public void testLongRunningNewAndDeleteFilesNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
   
    // Disable logging
    logger.log(Level.INFO, "NOTE: This test can take several minutes!");
    logger.log(Level.INFO, "Disabling console logging for this test; Too much output/overhead.");
   
    Logging.disableLogging();
   
    // Run
    for (int round=1; round<30; round++) {
     
      // A
      for (int i=1; i<100; i++) { clientA.createNewFile("A-file-with-size-"+i+".jpg", i);
      clientA.up()
     
      // B
      clientB.down();           
      assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
      assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
   
      for (int i=1; i<100; i++) { clientB.changeFile("A-file-with-size-"+i+".jpg"); }
      clientB.up()
     
      // A
      clientA.down();           
      assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
      assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
   
      for (int i=1; i<100; i++) { clientA.deleteFile("A-file-with-size-"+i+".jpg"); }
      clientA.up()
     
      // B
      clientB.down();           
      assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
      assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());     
    }

    fail("No asserts yet.");
   
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

  }

  @Test
  public void testLockUnlockFile() 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(), new Executable() {
      @Override
      public void execute() throws Exception {
        clientA.upWithForceChecksum();

        clientB.down();
        assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
      }
    });

    ClientActions.run(clientA, null, new LockFile(), new Executable() {
      @Override
      public void execute() throws Exception {
        clientA.upWithForceChecksum();

        clientB.down();
        assertEquals(clientA.getLocalFilesExcludeLockedAndNoRead().size(), clientB.getLocalFilesExcludeLockedAndNoRead().size() - 1);
      }
    });

    ClientActions.run(clientA, null, new UnlockFile(), 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

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

    // Run
    clientA.createNewFile("file1.jpg");
    clientA.upWithForceChecksum();
   
    FileUtils.copyFile(clientA.getLocalFile("file1.jpg"), clientB.getLocalFile("file1.jpg"));
    clientB.getLocalFile("file1.jpg").setLastModified(123456789);
   
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
   
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
 
View Full Code Here

 
  private void testLargeFile(long size) throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);     
   
    Logging.disableLogging();
   
    logln("NOTE: This test can take several minutes!");
    logln("Disabling console logging for this test; Too much output/overhead.");
    logln("");   
   
    // A   
    logln("Creating large file for scenario ("+((long) size/1024L/1024L)+" MB) ...");
    clientA.createNewFile("A-large-file.zip", size)
    logln("Done creating large file. Now creating checksum ...");   
    String checksumFileA = StringUtil.toHex(TestFileUtil.createChecksum(clientA.getLocalFile("A-large-file.zip")));
    logln("Done. Checksum is: "+checksumFileA)
   
    logln("clientA.up() started.");
    clientA.up();   
    logln("clientA.up() completed.");

    logln("Freeing up space, deleting file at client A ...");
    clientA.deleteFile("A-large-file.zip");
    logln("Deleting done.");   
   
    // B
    logln("clientB.down(); started.");
    clientB.down();
    logln("clientB.down(); completed.");
    String checksumFileB = StringUtil.toHex(TestFileUtil.createChecksum(clientB.getLocalFile("A-large-file.zip")));
    logln("Done. Checksum is: "+checksumFileB)
   
    logln("Freeing up space, deleting file at client B ...");
    clientB.deleteFile("A-large-file.zip");
    logln("Deleting done.");       
   
    try {
      assertEquals("File checksum should be equal. ", checksumFileA, checksumFileB);
      assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    }
    finally {
      // Tear down
      clientA.deleteTestData();
      clientB.deleteTestData();
   
  } 
View Full Code Here

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

    for (int i=0; i<10000; i++) {
      clientA.createNewFile("file"+i, 100+i);
    }
   
    clientA.up(); // This has caused a heap space exception
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
   
    // Tear down
    clientA.deleteTestData();
    clientB.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.