Package org.syncany.plugins.local

Examples of org.syncany.plugins.local.LocalTransferSettings


    }

    File configDir = setupCleanConfigDir();

    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);

    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginAction.INSTALL);
    pluginOptions.setPluginId("ftp");
View Full Code Here


    }

    File configDir = setupCleanConfigDir();

    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);

    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginAction.LIST);
    pluginOptions.setListMode(PluginListMode.REMOTE);
View Full Code Here

    // Get Masterkey
    SaltedSecretKey masterKey = getMasterKey();
    configTO.setMasterKey(masterKey);

    LocalTransferSettings localConnection = (LocalTransferSettings) connection;
    // Create connection TO
    Map<String, String> localConnectionSettings = new HashMap<String, String>();
    localConnectionSettings.put("path", localConnection.getPath().getAbsolutePath());

    configTO.setTransferSettings(connection);

    // Create
    Config config = new Config(tempLocalDir, configTO, repoTO);
View Full Code Here

    // Get Masterkey
    SaltedSecretKey masterKey = getMasterKey();
    configTO.setMasterKey(masterKey);

    // Generic connection settings wont work anymore, because they are plugin dependent now.
    LocalTransferSettings transferSettings = Plugins.get("local", TransferPlugin.class).createEmptySettings();
    transferSettings.setPath(tempRepoDir);

    configTO.setTransferSettings(transferSettings);

    InitOperationOptions operationOptions = new InitOperationOptions();
View Full Code Here

    return initOperationOptions;
  }

  public static TransferSettings createTestLocalConnection() throws Exception {
    TransferPlugin plugin = Plugins.get("local", TransferPlugin.class);
    LocalTransferSettings conn = plugin.createEmptySettings();

    File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", conn));
    conn.setPath(tempRepoDir);

    // TODO [medium] : possible problem
    plugin.createTransferManager(conn, null).init(true);

    return conn;
View Full Code Here

    deleteTestLocalConnection(config);
  }

  private static void deleteTestLocalConnection(Config config) {
    LocalTransferSettings connection = (LocalTransferSettings) config.getConnection();
    TestFileUtil.deleteDirectory(connection.getPath());
  }
View Full Code Here

public class Issue247ScenarioTest {
  @Test
  public void testIssue247() throws Exception {   
    // Setup
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();   
   
    TestClient clientDzHome = new TestClient("Dz", testConnection);
    TestClient clientUxWork = new TestClient("Ux", testConnection);
       
    UpOperationOptions upOptionsWithForce = new UpOperationOptions();
View Full Code Here

  }

  @Test
  public void testEasyCleanup() 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);
    options.setRemoveOldVersions(true);
    options.setKeepVersionsCount(2);

    // Run

    // A: Create some file versions
    clientA.createNewFile("someotherfile.jpg"); // These two files' chunks will be in one multichunk
    clientA.createNewFile("file.jpg"); // Only one of the chunks will be needed after cleanup!
                      // The multichunk will be 50% useless
    for (int i = 1; i <= 4; i++) {
      clientA.changeFile("file.jpg");
      clientA.upWithForceChecksum();
    }

    clientA.createNewFile("otherfile.txt");
    for (int i = 1; i <= 3; i++) {
      clientA.changeFile("otherfile.txt");
      clientA.upWithForceChecksum();
    }

    clientA.createNewFile("deletedfile.txt");
    for (int i = 1; i <= 3; i++) {
      clientA.changeFile("deletedfile.txt");
      clientA.upWithForceChecksum();
    }
    clientA.deleteFile("deletedfile.txt");
    clientA.upWithForceChecksum();

    java.sql.Connection databaseConnectionA = DatabaseConnectionFactory.createConnection(clientA.getDatabaseFile());
    assertEquals("12", TestSqlUtil.runSqlSelect("select count(*) from fileversion", databaseConnectionA));
    assertEquals("11", TestSqlUtil.runSqlSelect("select count(*) from chunk", databaseConnectionA));
    assertEquals("10", TestSqlUtil.runSqlSelect("select count(*) from multichunk", databaseConnectionA));
    assertEquals("11", TestSqlUtil.runSqlSelect("select count(*) from filecontent", databaseConnectionA));
    assertEquals("4", TestSqlUtil.runSqlSelect("select count(distinct id) from filehistory", databaseConnectionA));

    // B: Sync down by other client
    clientB.down();

    java.sql.Connection databaseConnectionB = DatabaseConnectionFactory.createConnection(clientB.getDatabaseFile());
    assertEquals("12", TestSqlUtil.runSqlSelect("select count(*) from fileversion", databaseConnectionB));
    assertEquals("11", TestSqlUtil.runSqlSelect("select count(*) from chunk", databaseConnectionB));
    assertEquals("10", TestSqlUtil.runSqlSelect("select count(*) from multichunk", databaseConnectionB));
    assertEquals("11", TestSqlUtil.runSqlSelect("select count(*) from filecontent", databaseConnectionB));
    assertEquals("4", TestSqlUtil.runSqlSelect("select count(distinct id) from filehistory", databaseConnectionB));

    // A: Cleanup this mess (except for two) <<<< This is the interesting part!!! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    CleanupOperationResult cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(5, cleanupOperationResult.getRemovedMultiChunks().size());
    assertEquals(3, cleanupOperationResult.getRemovedOldVersionsCount());

    // 2 versions for "file.jpg", 2 versions for "otherfile.txt" and one version for "someotherfile.jpg"
    assertEquals("5", TestSqlUtil.runSqlSelect("select count(*) from fileversion", databaseConnectionA));
    assertEquals("7", TestSqlUtil.runSqlSelect("select sum(version) from fileversion where path='file.jpg'", databaseConnectionA)); // 3+4
    assertEquals("5", TestSqlUtil.runSqlSelect("select sum(version) from fileversion where path='otherfile.txt'", databaseConnectionA)); // 2+3
    assertEquals("1", TestSqlUtil.runSqlSelect("select sum(version) from fileversion where path='someotherfile.jpg'", databaseConnectionA));

    // 5 chunks remain; one was obsolete so we removed it!
    assertEquals("5", TestSqlUtil.runSqlSelect("select count(*) from chunk", databaseConnectionA));

    // 6 chunks in 5 multichunks
    assertEquals("5", TestSqlUtil.runSqlSelect("select count(*) from multichunk", databaseConnectionA));
    assertEquals("5", TestSqlUtil.runSqlSelect("select count(*) from filecontent", databaseConnectionA));
    assertEquals("3", TestSqlUtil.runSqlSelect("select count(distinct id) from filehistory", databaseConnectionA));

    // Test the repo
    assertEquals(5, new File(testConnection.getPath() + "/multichunks/").list().length);
    assertEquals(12, new File(testConnection.getPath() + "/databases/").list().length);

    // B: Sync down cleanup
    clientB.down();
    TestAssertUtil.assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());

View Full Code Here

  }

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

    StatusOperationOptions statusOptions = new StatusOperationOptions();
    statusOptions.setForceChecksum(true);
View Full Code Here

  }

  @Test
  public void testCleanupFailsBecauseOfRemoteChanges() 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

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.