Search in sources :

Example 26 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class SingleFolderNoConflictsScenarioTest method testFolderEmptyMoveNoConflicts.

@Test
public void testFolderEmptyMoveNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Create files and upload
    clientA.createNewFolder("folder");
    clientA.up();
    clientB.down();
    clientB.moveFile("folder", "moved");
    clientB.up();
    clientA.down();
    assertFileEquals(clientA.getLocalFile("moved"), clientB.getLocalFile("moved"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    // Cleanup
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Example 27 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class AbstractInitOperation method createTransferManagerFromNullConfig.

protected TransferManager createTransferManagerFromNullConfig(ConfigTO configTo) throws IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException, StorageException {
    // Init plugin and transfer manager
    TransferPlugin plugin = Plugins.get(configTo.getTransferSettings().getType(), TransferPlugin.class);
    TransferSettings transferSettings = configTo.getTransferSettings();
    transferSettings.setUserInteractionListener(listener);
    TransferManager transferManager = plugin.createTransferManager(transferSettings, config);
    // constructor is not visible and config seems to be null at this point, hence we cannot use the build method here
    Constructor<TransferManagerBuilder> tmbConstructor = TransferManagerBuilder.class.getDeclaredConstructor(Config.class, TransferManager.class);
    tmbConstructor.setAccessible(true);
    return tmbConstructor.newInstance(config, transferManager).withFeature(ReadAfterWriteConsistent.class).asDefault();
}
Also used : TransferPlugin(org.syncany.plugins.transfer.TransferPlugin) TransferManager(org.syncany.plugins.transfer.TransferManager) ReadAfterWriteConsistent(org.syncany.plugins.transfer.features.ReadAfterWriteConsistent) TransferSettings(org.syncany.plugins.transfer.TransferSettings) TransferManagerBuilder(org.syncany.plugins.transfer.TransferManagerFactory.TransferManagerBuilder)

Example 28 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class FileSystemActionReconciliatorTest method testFileSystemActionReconDeleteNonExistingFolder.

@Test
public void testFileSystemActionReconDeleteNonExistingFolder() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    Config testConfigA = clientA.getConfig();
    // - Create first database version
    clientA.createNewFolder("new folder/some subfolder");
    clientA.upWithForceChecksum();
    // Delete this!
    clientA.deleteFile("new folder/some subfolder");
    // - Create new version (delete folder)
    TestSqlDatabase sqlDatabaseA = new TestSqlDatabase(testConfigA);
    PartialFileHistory folderFileHistoryWithLastVersion = sqlDatabaseA.getFileHistoryWithLastVersion("new folder/some subfolder");
    FileVersion deletedFolderVersion = folderFileHistoryWithLastVersion.getLastVersion().clone();
    deletedFolderVersion.setStatus(FileStatus.DELETED);
    deletedFolderVersion.setVersion(deletedFolderVersion.getVersion() + 1);
    PartialFileHistory deletedFolderVersionHistory = new PartialFileHistory(folderFileHistoryWithLastVersion.getFileHistoryId());
    deletedFolderVersionHistory.addFileVersion(deletedFolderVersion);
    DatabaseVersion winnersDatabaseVersion = TestDatabaseUtil.createDatabaseVersion(sqlDatabaseA.getLastDatabaseVersionHeader());
    winnersDatabaseVersion.addFileHistory(deletedFolderVersionHistory);
    // - Create memory database with this version
    MemoryDatabase winnersDatabase = new MemoryDatabase();
    winnersDatabase.addDatabaseVersion(winnersDatabaseVersion);
    // Run! Finally!
    DownOperationResult outDownOperationResult = new DownOperationResult();
    FileSystemActionReconciliator fileSystemActionReconciliator = new FileSystemActionReconciliator(testConfigA, outDownOperationResult.getChangeSet());
    List<FileSystemAction> fileSystemActions = fileSystemActionReconciliator.determineFileSystemActions(winnersDatabase);
    assertNotNull(fileSystemActions);
    assertEquals(0, fileSystemActions.size());
    // Tear down
    clientA.deleteTestData();
}
Also used : Config(org.syncany.config.Config) DownOperationResult(org.syncany.operations.down.DownOperationResult) FileSystemAction(org.syncany.operations.down.actions.FileSystemAction) TestClient(org.syncany.tests.util.TestClient) FileVersion(org.syncany.database.FileVersion) MemoryDatabase(org.syncany.database.MemoryDatabase) TestSqlDatabase(org.syncany.tests.util.TestSqlDatabase) TransferSettings(org.syncany.plugins.transfer.TransferSettings) PartialFileHistory(org.syncany.database.PartialFileHistory) DatabaseVersion(org.syncany.database.DatabaseVersion) FileSystemActionReconciliator(org.syncany.operations.down.FileSystemActionReconciliator) Test(org.junit.Test)

Example 29 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class ChangedTypeScenarioTest method testChangeTypeToFolder.

@Test
public void testChangeTypeToFolder() 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 AbstractClientAction[] { new CreateFileTree(), new ChangeTypeFileToFolder() }, 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();
}
Also used : TestClient(org.syncany.tests.util.TestClient) CreateFileTree(org.syncany.tests.integration.scenarios.framework.CreateFileTree) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Executable(org.syncany.tests.integration.scenarios.framework.Executable) ChangeTypeFileToFolder(org.syncany.tests.integration.scenarios.framework.ChangeTypeFileToFolder) Test(org.junit.Test)

Example 30 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class CreateSimilarFileParallelScenarioTest method testEmptyFileCreateAndSync.

@Test
public void testEmptyFileCreateAndSync() throws Exception {
    // Setup 
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // A
    clientA.createNewFile("A-file1.jpg", 100);
    clientA.up();
    // B
    clientB.createNewFile("A-file1.jpg", 150);
    clientB.up();
    // A, A should win
    clientA.down();
    assertEquals(clientA.getLocalFile("A-file1.jpg").length(), 100);
    // B, B should have conflicting file and updated on A's file
    clientB.down();
    assertConflictingFileExists("A-file1.jpg", clientB.getLocalFilesExcludeLockedAndNoRead());
    assertFileEquals(clientA.getLocalFile("A-file1.jpg"), clientB.getLocalFile("A-file1.jpg"));
    assertEquals(clientB.getLocalFile("A-file1.jpg").length(), 100);
    // B
    clientB.up();
    // A, should retrieve B's conflicting copy
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Aggregations

TransferSettings (org.syncany.plugins.transfer.TransferSettings)78 Test (org.junit.Test)67 TestClient (org.syncany.tests.util.TestClient)65 File (java.io.File)20 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)10 TransferPlugin (org.syncany.plugins.transfer.TransferPlugin)7 SqlDatabase (org.syncany.database.SqlDatabase)5 DownOperationResult (org.syncany.operations.down.DownOperationResult)4 StatusOperationResult (org.syncany.operations.status.StatusOperationResult)4 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)4 UpOperationResult (org.syncany.operations.up.UpOperationResult)4 CreateFileTree (org.syncany.tests.integration.scenarios.framework.CreateFileTree)4 IOException (java.io.IOException)3 RandomAccessFile (java.io.RandomAccessFile)3 Path (java.nio.file.Path)3 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)3 Config (org.syncany.config.Config)3 ConfigTO (org.syncany.config.to.ConfigTO)3 PartialFileHistory (org.syncany.database.PartialFileHistory)3 FileHistoryId (org.syncany.database.PartialFileHistory.FileHistoryId)3