Search in sources :

Example 1 with LockFile

use of org.syncany.tests.integration.scenarios.framework.LockFile in project syncany by syncany.

the class FileLockedScenarioTest method testLockUnlockFile.

@Test
public void testLockUnlockFile() 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 CreateFileTree(), new Executable() {

        @Override
        public void execute() throws Exception {
            clientA.upWithForceChecksum();
            clientB.down();
            assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
            assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
        }
    });
    ClientActions.run(clientA, null, new LockFile(), new Executable() {

        @Override
        public void execute() throws Exception {
            clientA.upWithForceChecksum();
            clientB.down();
            assertEquals(clientA.getLocalFilesExcludeLockedAndNoRead().size(), clientB.getLocalFilesExcludeLockedAndNoRead().size() - 1);
        }
    });
    ClientActions.run(clientA, null, new UnlockFile(), 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 : UnlockFile(org.syncany.tests.integration.scenarios.framework.UnlockFile) LockFile(org.syncany.tests.integration.scenarios.framework.LockFile) TestClient(org.syncany.tests.util.TestClient) CreateFileTree(org.syncany.tests.integration.scenarios.framework.CreateFileTree) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Executable(org.syncany.tests.integration.scenarios.framework.Executable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)1 TransferSettings (org.syncany.plugins.transfer.TransferSettings)1 CreateFileTree (org.syncany.tests.integration.scenarios.framework.CreateFileTree)1 Executable (org.syncany.tests.integration.scenarios.framework.Executable)1 LockFile (org.syncany.tests.integration.scenarios.framework.LockFile)1 UnlockFile (org.syncany.tests.integration.scenarios.framework.UnlockFile)1 TestClient (org.syncany.tests.util.TestClient)1