Package org.syncany.plugins.local

Examples of org.syncany.plugins.local.LocalTransferSettings


  }

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

    CleanupOperationOptions options = new CleanupOperationOptions();
    options.setMergeRemoteFiles(false);
View Full Code Here


  }

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

    CleanupOperationOptions options = new CleanupOperationOptions();
    options.setMergeRemoteFiles(false);
View Full Code Here

  }

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

    CleanupOperationOptions removeOldCleanupOperationOptions = new CleanupOperationOptions();
    removeOldCleanupOperationOptions.setMergeRemoteFiles(false);
View Full Code Here

  }

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

    CleanupOperationOptions options = new CleanupOperationOptions();
    options.setMergeRemoteFiles(true);
    options.setRemoveOldVersions(true);
View Full Code Here

  }

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

    CleanupOperationOptions options = new CleanupOperationOptions();
    options.setMergeRemoteFiles(true);
    options.setRemoveOldVersions(false);
View Full Code Here

  }

  @Test
  public void testIssue58_3() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();

    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    TestClient clientC = new TestClient("C", testConnection);
View Full Code Here

  @Test
  public void testIssue58_4() throws Exception {
    // Test for https://github.com/syncany/syncany/issues/58#issuecomment-43472118

    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();

    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    TestClient clientC = new TestClient("C", testConnection);

    CleanupOperationOptions cleanupOptionsKeep1 = new CleanupOperationOptions();
    cleanupOptionsKeep1.setMergeRemoteFiles(true);
    cleanupOptionsKeep1.setRemoveOldVersions(true);
    cleanupOptionsKeep1.setKeepVersionsCount(1);

    StatusOperationOptions statusOptionsForceChecksum = new StatusOperationOptions();
    statusOptionsForceChecksum.setForceChecksum(true);

    UpOperationOptions upNoCleanupForceChecksum = new UpOperationOptions();
    upNoCleanupForceChecksum.setStatusOptions(statusOptionsForceChecksum);

    UpOperationOptions upWithCleanupKeep1ForceChecksum = new UpOperationOptions();
    upWithCleanupKeep1ForceChecksum.setStatusOptions(statusOptionsForceChecksum);

    clientB.createNewFile("fileB");
    clientB.up(upNoCleanupForceChecksum);

    clientA.down();
    TestFileUtil.copyFile(clientB.getLocalFile("fileB"), clientA.getLocalFile("fileBcopy"));
    clientA.up(upNoCleanupForceChecksum);

    for (int i = 0; i < 30; i++) {
      clientB.down();
      clientB.changeFile("fileB");
      clientB.up(upNoCleanupForceChecksum);
    }

    FileUtils.copyDirectory(testConnection.getPath(), new File(testConnection.getPath() + "_1_before_cleanup"));
    FileUtils.copyDirectory(clientB.getConfig().getDatabaseDir(), new File(clientB.getConfig().getAppDir(), "1_before_cleanup"));

    CleanupOperationOptions cleanupMergeAndRemoveOldFiles = new CleanupOperationOptions();
    cleanupMergeAndRemoveOldFiles.setMergeRemoteFiles(true);
    cleanupMergeAndRemoveOldFiles.setRemoveOldVersions(true);
    clientB.cleanup(cleanupMergeAndRemoveOldFiles);

    FileUtils.copyDirectory(testConnection.getPath(), new File(testConnection.getPath() + "_2_after_cleanup"));
    FileUtils.copyDirectory(clientB.getConfig().getDatabaseDir(), new File(clientB.getConfig().getAppDir(), "2_after_cleanup"));

    clientC.down(); // <<< "Cannot determine file content for checksum X"

    // Tear down
View Full Code Here

  @Test
  public void testIssue58_5() throws Exception {
    // Test for https://github.com/syncany/syncany/issues/58#issuecomment-43472118

    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();

    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    TestClient clientC = new TestClient("C", testConnection);
    TestClient clientD = new TestClient("D", testConnection);
    TestClient clientE = new TestClient("E", testConnection);

    CleanupOperationOptions cleanupOptionsKeep1 = new CleanupOperationOptions();
    cleanupOptionsKeep1.setMergeRemoteFiles(true);
    cleanupOptionsKeep1.setRemoveOldVersions(true);
    cleanupOptionsKeep1.setKeepVersionsCount(1);

    StatusOperationOptions statusOptionsForceChecksum = new StatusOperationOptions();
    statusOptionsForceChecksum.setForceChecksum(true);

    UpOperationOptions upNoCleanupForceChecksum = new UpOperationOptions();
    upNoCleanupForceChecksum.setStatusOptions(statusOptionsForceChecksum);

    UpOperationOptions upWithCleanupKeep1ForceChecksum = new UpOperationOptions();
    upWithCleanupKeep1ForceChecksum.setStatusOptions(statusOptionsForceChecksum);

    // First round

    clientB.createNewFile("fileA");
    clientB.up(upNoCleanupForceChecksum);

    clientA.down();
    TestFileUtil.copyFile(clientA.getLocalFile("fileA"), clientA.getLocalFile("fileAcopy"));
    clientA.up(upNoCleanupForceChecksum);

    clientA.down();

    for (int i = 0; i < 30; i++) {
      clientA.down();
      clientA.changeFile("fileA");
      clientA.up(upNoCleanupForceChecksum);
    }

    // First cleanup

    FileUtils.copyDirectory(testConnection.getPath(), new File(testConnection.getPath() + "_1_before_cleanup"));
    FileUtils.copyDirectory(clientA.getConfig().getDatabaseDir(), new File(clientA.getConfig().getAppDir(), "1_before_cleanup"));

    CleanupOperationOptions cleanupMergeAndRemoveOldFiles = new CleanupOperationOptions();
    cleanupMergeAndRemoveOldFiles.setMergeRemoteFiles(true);
    cleanupMergeAndRemoveOldFiles.setRemoveOldVersions(true);
    clientA.cleanup(cleanupMergeAndRemoveOldFiles);

    FileUtils.copyDirectory(testConnection.getPath(), new File(testConnection.getPath() + "_2_after_cleanup"));
    FileUtils.copyDirectory(clientA.getConfig().getDatabaseDir(), new File(clientA.getConfig().getAppDir(), "2_after_cleanup"));

    clientC.down(); // If this doesn't crash that's a win!

    // Second round

    for (int i = 0; i < 30; i++) {
      clientB.down();
      clientB.changeFile("fileA");
      clientB.up(upNoCleanupForceChecksum);
    }

    // Second cleanup

    FileUtils.copyDirectory(testConnection.getPath(), new File(testConnection.getPath() + "_3_before_cleanup"));
    FileUtils.copyDirectory(clientB.getConfig().getDatabaseDir(), new File(clientB.getConfig().getAppDir(), "3_before_cleanup"));

    clientB.cleanup(cleanupMergeAndRemoveOldFiles);

    FileUtils.copyDirectory(testConnection.getPath(), new File(testConnection.getPath() + "_4_after_cleanup"));
    FileUtils.copyDirectory(clientB.getConfig().getDatabaseDir(), new File(clientB.getConfig().getAppDir(), "4_after_cleanup"));

    clientD.down(); // If this doesn't crash that's a win!

    // Third round

    for (int i = 0; i < 30; i++) {
      clientB.down();
      clientB.changeFile("fileA");
      clientB.up(upNoCleanupForceChecksum);
    }

    clientB.deleteFile("fileAcopy"); // < Remove original checksum from first DBV
    clientB.up(upNoCleanupForceChecksum);

    // Third cleanup

    FileUtils.copyDirectory(testConnection.getPath(), new File(testConnection.getPath() + "_5_before_cleanup"));
    FileUtils.copyDirectory(clientB.getConfig().getDatabaseDir(), new File(clientB.getConfig().getAppDir(), "5_before_cleanup"));

    clientB.cleanup(cleanupMergeAndRemoveOldFiles);

    FileUtils.copyDirectory(testConnection.getPath(), new File(testConnection.getPath() + "_6_after_cleanup"));
    FileUtils.copyDirectory(clientB.getConfig().getDatabaseDir(), new File(clientB.getConfig().getAppDir(), "6_after_cleanup"));

    clientE.down(); // If this doesn't crash that's a win!

    // Tear down
View Full Code Here

public class ManySyncUpsAndDatabaseFileCleanupScenarioTest {
  @Test
  public void testManySyncUpsAndDatabaseFileCleanup() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
   
    // ROUND 1: many sync up (no cleanup expected here)   
    for (int i=1; i<=15; i++) {
      clientA.createNewFile("file"+i, 1);
      clientA.up();   
    }
   
    for (int i=1; i<=15; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
    }

    // ROUND 2: 1x sync up (cleanup expected!)
    clientA.createNewFile("file16", 1);
    clientA.up();   
   
    clientA.cleanup(); // Force cleanup

    for (int i=1; i<=15; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
   
    for (int i=16; i<=16; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
    }
   
    // ROUND 3: many sync up (no cleanup expected here)   
    for (int i=17; i<=30; i++) {
      clientA.createNewFile("file"+i, 1);
      clientA.up();   
    }
   
    for (int i=1; i<=15; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
   
    for (int i=16; i<=30; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
    }   
   
    // ROUND 4: 1x sync up (cleanup expected!)
    clientA.createNewFile("file31", 1);
    clientA.up();   
   
    CleanupOperationOptions options = new CleanupOperationOptions();
   
    options.setForce(true);
   
    clientA.cleanup(options); // Force cleanup

    for (int i=1; i<=30; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file should NOT exist: "+expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
    
    for (int i=31; i<=31; i++) {
      DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
      File expectedDatabaseFile = new File(testConnection.getPath()+"/databases/"+expectedDatabaseRemoteFile.getName());
     
      assertTrue("Database file SHOULD exist: "+expectedDatabaseFile, expectedDatabaseFile.exists());
   
   
    // Tear down
View Full Code Here

    final String fooTest = "foo-test";
    final String bazTest = "baz";
    final int numberTest = 1234;

    final DummyTransferSettings ts = new DummyTransferSettings();
    final LocalTransferSettings lts = new LocalTransferSettings();
    final ConfigTO conf = TestConfigUtil.createTestInitOperationOptions("syncanytest").getConfigTO();

    conf.setTransferSettings(ts);

    ts.foo = fooTest;
    ts.baz = bazTest;
    ts.number = numberTest;
    lts.setPath(File.createTempFile("aaa", "bbb"));
    ts.subsettings = lts;

    assertTrue(ts.isValid());

    Serializer serializer = new Persister();
View Full Code Here

TOP

Related Classes of org.syncany.plugins.local.LocalTransferSettings

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.