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();
}
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");
}
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;
}
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();
}
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();
}
Aggregations