Search in sources :

Example 21 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class PluginOperationTest method testPluginListRemoteOnlyIncludingSnapshots.

@Test
public void testPluginListRemoteOnlyIncludingSnapshots() throws Exception {
    // Tests which plugin snapshots are available. This is difficult because
    // that will change. So we can only test the bare minimum.
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);
    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginOperationAction.LIST);
    pluginOptions.setListMode(PluginListMode.REMOTE);
    pluginOptions.setSnapshots(true);
    PluginOperationResult pluginResult = client.plugin(pluginOptions);
    assertNotNull(pluginResult);
    assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
    // Tear down
    client.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) PluginOperationResult(org.syncany.operations.plugin.PluginOperationResult) PluginOperationOptions(org.syncany.operations.plugin.PluginOperationOptions) Test(org.junit.Test)

Example 22 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class PluginOperationTest method testPluginInstallUrl.

@Test
public void testPluginInstallUrl() throws Exception {
    if (EnvironmentUtil.isWindows()) {
        // Test is Unix-specific.
        return;
    }
    File configDir = setupCleanConfigDir();
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);
    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginOperationAction.LIST);
    pluginOptions.setListMode(PluginListMode.REMOTE);
    pluginOptions.setSnapshots(false);
    PluginOperationResult pluginResult = client.plugin(pluginOptions);
    String pluginDownloadUrl = null;
    for (ExtendedPluginInfo pluginInfo : pluginResult.getPluginList()) {
        if (pluginInfo.getRemotePluginInfo().getPluginId().equals("ftp")) {
            pluginDownloadUrl = pluginInfo.getRemotePluginInfo().getDownloadUrl();
        }
    }
    pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginOperationAction.INSTALL);
    pluginOptions.setPluginId(pluginDownloadUrl);
    pluginResult = client.plugin(pluginOptions);
    assertNotNull(pluginResult);
    assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
    // Only one file should be in here: the jar for ftp.
    assertEquals(1, (new File(configDir, "plugins/lib/")).list().length);
    // Tear down
    client.deleteTestData();
    TestFileUtil.deleteDirectory(configDir);
    System.setProperty("user.home", "/tmp");
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) ExtendedPluginInfo(org.syncany.operations.plugin.ExtendedPluginInfo) TestClient(org.syncany.tests.util.TestClient) PluginOperationResult(org.syncany.operations.plugin.PluginOperationResult) PluginOperationOptions(org.syncany.operations.plugin.PluginOperationOptions) File(java.io.File) Test(org.junit.Test)

Example 23 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class TestConfigUtil method createTestUnreliableInitOperationOptions.

public static InitOperationOptions createTestUnreliableInitOperationOptions(String machineName, List<String> failingOperationPatterns) throws Exception {
    InitOperationOptions initOperationOptions = createTestInitOperationOptions(machineName);
    // createTestInitOperationOptions always returns LocalTransferSettings
    File tempRpoDir = ((LocalTransferSettings) initOperationOptions.getConfigTO().getTransferSettings()).getPath();
    UnreliableLocalTransferSettings transferSettings = Plugins.get("unreliable_local", TransferPlugin.class).createEmptySettings();
    transferSettings.setPath(tempRpoDir);
    transferSettings.setFailingOperationPatterns(failingOperationPatterns);
    initOperationOptions.getConfigTO().setTransferSettings(transferSettings);
    return initOperationOptions;
}
Also used : TransferPlugin(org.syncany.plugins.transfer.TransferPlugin) UnreliableLocalTransferPlugin(org.syncany.plugins.unreliable_local.UnreliableLocalTransferPlugin) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) UnreliableLocalTransferSettings(org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings) InitOperationOptions(org.syncany.operations.init.InitOperationOptions) UnreliableLocalTransferSettings(org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings) File(java.io.File)

Example 24 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class CleanupOperationTest method testCleanupFailsBecauseOfLocalChanges.

@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);
    CleanupOperationOptions cleanupOptions = new CleanupOperationOptions();
    cleanupOptions.setStatusOptions(statusOptions);
    cleanupOptions.setRemoveOldVersions(true);
    // Run
    // A: Create some file versions
    clientA.createNewFile("file.jpg");
    for (int i = 1; i <= 4; i++) {
        clientA.changeFile("file.jpg");
        clientA.upWithForceChecksum();
    }
    // B: Sync down, add something
    clientB.down();
    clientB.changeFile("file.jpg");
    CleanupOperationResult cleanupOperationResult = clientB.cleanup(cleanupOptions);
    assertEquals(CleanupResultCode.NOK_LOCAL_CHANGES, cleanupOperationResult.getResultCode());
    assertEquals(0, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(0, cleanupOperationResult.getRemovedMultiChunksCount());
    assertEquals(0, cleanupOperationResult.getRemovedOldVersionsCount());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : CleanupOperationResult(org.syncany.operations.cleanup.CleanupOperationResult) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) UnreliableLocalTransferSettings(org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) CleanupOperationOptions(org.syncany.operations.cleanup.CleanupOperationOptions) StatusOperationOptions(org.syncany.operations.status.StatusOperationOptions) Test(org.junit.Test)

Example 25 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class CleanupOperationTest method testCleanupManyUpsAfterCleanup.

@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.setRemoveOldVersions(true);
    options.setMinKeepSeconds(0);
    // Run
    // A: Create some file versions
    clientA.createNewFile("file.jpg");
    for (int i = 1; i <= 4; i++) {
        clientA.changeFile("file.jpg");
        clientA.upWithForceChecksum();
    }
    // B: Sync down
    clientB.down();
    // A: Cleanup
    CleanupOperationResult cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(4, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(3, cleanupOperationResult.getRemovedMultiChunksCount());
    assertEquals(1, cleanupOperationResult.getRemovedOldVersionsCount());
    // A: Continue to upload stuff ! <<<<<<<<<<<<<<<<<<<<<
    for (int i = 1; i <= 4; i++) {
        clientA.changeFile("file.jpg");
        clientA.upWithForceChecksum();
    }
    clientA.createNewFile("file2.jpg");
    for (int i = 1; i <= 4; i++) {
        clientA.changeFile("file2.jpg");
        clientA.upWithForceChecksum();
    }
    // B: Sync down
    clientB.down();
    TestAssertUtil.assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : CleanupOperationResult(org.syncany.operations.cleanup.CleanupOperationResult) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) UnreliableLocalTransferSettings(org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) CleanupOperationOptions(org.syncany.operations.cleanup.CleanupOperationOptions) Test(org.junit.Test)

Aggregations

LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)61 Test (org.junit.Test)50 TestClient (org.syncany.tests.util.TestClient)46 File (java.io.File)33 CleanupOperationOptions (org.syncany.operations.cleanup.CleanupOperationOptions)21 UnreliableLocalTransferSettings (org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings)17 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)13 CleanupOperationResult (org.syncany.operations.cleanup.CleanupOperationResult)8 FilenameFilter (java.io.FilenameFilter)7 InitOperationOptions (org.syncany.operations.init.InitOperationOptions)7 UpOperationResult (org.syncany.operations.up.UpOperationResult)7 Random (java.util.Random)6 ConfigTO (org.syncany.config.to.ConfigTO)6 StatusOperationOptions (org.syncany.operations.status.StatusOperationOptions)6 SqlDatabase (org.syncany.database.SqlDatabase)5 PluginOperationOptions (org.syncany.operations.plugin.PluginOperationOptions)5 PluginOperationResult (org.syncany.operations.plugin.PluginOperationResult)5 TimeUnit (org.syncany.operations.cleanup.CleanupOperationOptions.TimeUnit)4 DownOperationResult (org.syncany.operations.down.DownOperationResult)4 InitOperation (org.syncany.operations.init.InitOperation)4