Package org.syncany.operations.up

Examples of org.syncany.operations.up.UpOperationResult


    File symlinkFile = clientA.getLocalFile("symlink-name");
    FileUtil.createSymlink("/etc/hosts", symlinkFile);

    assertTrue("Symlink should exist at " + symlinkFile, symlinkFile.exists());

    UpOperationResult upResult = clientA.up();
    StatusOperationResult statusResult = upResult.getStatusResult();

    // Test 1: Check result sets for inconsistencies
    assertTrue("Status should return changes.", statusResult.getChangeSet().hasChanges());
    assertTrue("File should be uploaded.", upResult.getChangeSet().hasChanges());

    // Test 2: Check database for inconsistencies
    SqlDatabase database = clientA.loadLocalDatabase();

    assertNotNull("File should be uploaded.", database.getFileVersionByPath("symlink-name"));
View Full Code Here


    // Client B creates the exact SAME FILES (here: copies the file tree from A)
    FileUtils.copyDirectory(clientA.getLocalFile("sphinxbase-0.8"), clientB.getLocalFile("sphinxbase-0.8"), true);

    // Now, both upload that
    UpOperationResult upResultA = clientA.upWithForceChecksum(); // (A1)
    assertEquals(UpResultCode.OK_CHANGES_UPLOADED, upResultA.getResultCode());
    assertEquals(8, upResultA.getChangeSet().getNewFiles().size());

    UpOperationResult upResultB = clientB.up(upOperationOptionsWithForce); // (B1)
    assertEquals(UpResultCode.OK_CHANGES_UPLOADED, upResultB.getResultCode());
    assertEquals(8, upResultB.getChangeSet().getNewFiles().size());

    DownOperationResult downResultA = clientA.down();
    assertEquals(DownResultCode.OK_NO_REMOTE_CHANGES, downResultA.getResultCode());
    assertEquals(0, downResultA.getDirtyDatabasesCreated().size());
    assertEquals(false, downResultA.getChangeSet().hasChanges());

    // For peaking (does NOT affect the test)
    FileUtils.copyFile(new File(testConnection.getPath(), "databases/database-B-0000000001"),
        new File(testConnection.getPath(), "databases/TEMP_db-B-0000000001"));

    DownOperationResult downResultB = clientB.down(); // creates DIRTY; deletes (B1)
    assertEquals(DownResultCode.OK_WITH_REMOTE_CHANGES, downResultB.getResultCode());
    assertEquals(1, downResultB.getDirtyDatabasesCreated().size());
    assertEquals(false, downResultB.getChangeSet().hasChanges()); // TODO [low] Shouldn't this be 'true'?

    // For peaking (does NOT affect the test)
    FileUtils.copyDirectory(clientB.getLocalFile(".syncany/db"), clientB.getLocalFile(".syncany/db_WITH_DIRTY_B1"));

    Files.setPosixFilePermissions(clientB.getLocalFile("sphinxbase-0.8").toPath(), PosixFilePermissions.fromString("rwxrwxrwx"));
    UpOperationResult upResultB2 = clientB.up(); // (B2)
    assertEquals(UpResultCode.OK_CHANGES_UPLOADED, upResultB2.getResultCode());
    assertEquals(1, upResultB2.getChangeSet().getChangedFiles().size());

    // For peaking (does NOT affect the test)
    FileUtils.copyDirectory(clientB.getLocalFile(".syncany/db"), clientB.getLocalFile(".syncany/db_DELETED_B1_WITH_B2"));

    clientA.down();
View Full Code Here

    assertEquals(DownResultCode.OK_NO_REMOTE_CHANGES, downOperationResult.getResultCode());

    // 5. Call 'up' again, this uploads previously crashed stuff, and then runs cleanup.
    // The cleanup then removes the old multichunk and the old action files.

    UpOperationResult secondUpResult = clientA.up();
    assertEquals(UpResultCode.OK_CHANGES_UPLOADED, secondUpResult.getResultCode());
    assertEquals(2, repoMultiChunkDir.listFiles().length);
    assertEquals(0, repoActionsDir.listFiles().length);

    // 6. Call 'cleanup' manually (Nothing happens, since transaction was cleaned on second up)
    CleanupOperationResult cleanupOperationResult = clientA.cleanup();
View Full Code Here

    assertNotNull(statusResult);
   
    ChangeSet changes = statusResult.getChangeSet();
   
    assertTrue("Status-Operation should return changes.", changes.hasChanges());
    UpOperationResult upResult = clientB.up();
    StatusOperationResult statusResultFromUp = upResult.getStatusResult();
   
    // Test 1: Check result sets for inconsistencies
    assertTrue("Status should return changes.", statusResultFromUp.getChangeSet().hasChanges());
    assertTrue("File should be uploaded.", upResult.getChangeSet().hasChanges());
   
    // Test 2: Check database for inconsistencies
    SqlDatabase database = clientB.loadLocalDatabase();

    assertNotNull("File should be uploaded.", database.getFileVersionByPath("file1.jpg"));   
View Full Code Here

        if (downResult.getResultCode() == DownResultCode.OK_WITH_REMOTE_CHANGES) {
          // TODO [low] Do something?
        }
       
        // Run up
        UpOperationResult upOperationResult = new UpOperation(config, options.getUpOptions()).execute();

        if (upOperationResult.getResultCode() == UpResultCode.OK_CHANGES_UPLOADED && upOperationResult.getChangeSet().hasChanges()) {
          upCount.incrementAndGet();
          notifyChanges = true;
        }   

        CleanupOperationResult cleanupOperationResult = new CleanupOperation(config, options.getCleanupOptions()).execute();
View Full Code Here

    writeFileThread.start();

    Thread.sleep(50);

    logger.log(Level.SEVERE, "Started clientA.up()");
    UpOperationResult upResult = clientA.up();
    StatusOperationResult statusResult = upResult.getStatusResult();
    logger.log(Level.SEVERE, "Ended clientA.up()");

    writeFileThread.join();

    // Test 1: Check result sets for inconsistencies
    assertTrue("Status command expected to return changes.", statusResult.getChangeSet().hasChanges());
    assertFalse("File should NOT be uploaded while still writing (no half-file upload).", upResult.getChangeSet().hasChanges());

    // Test 2: Check database for inconsistencies
    SqlDatabase database = clientA.loadLocalDatabase();

    assertNull("File should NOT be uploaded while still writing (no half-file upload).", database.getFileVersionByPath("large-test-file"));
View Full Code Here

    clientC.createNewFile("file3.jpg"); // Client C: No down!
    clientC.up(cUpOptionsWithForce);   
   
    // A tries to upload, this fails due to C's unknown database
    clientA.createNewFile("file4.jpg");
    UpOperationResult aUpResult = clientA.upWithForceChecksum(); //
    assertEquals("Expected to fail, because db-C-1 has not been looked at", UpResultCode.NOK_UNKNOWN_DATABASES, aUpResult.getResultCode());
    assertFalse(clientA.getLocalFile("file2.jpg").exists());
    assertFalse(clientA.getLocalFile("file3.jpg").exists());
   
    // A downloads C's changes, no file changes are expected
    DownOperationResult aDownResult = clientA.down();
    assertEquals("Expected to succeed with remote changes (a new database file, but no file changes!).", DownResultCode.OK_WITH_REMOTE_CHANGES, aDownResult.getResultCode());
    assertTrue(clientA.getLocalFile("file2.jpg").exists());
    assertFalse(clientA.getLocalFile("file3.jpg").exists());
   
    // TODO [low] Add assert: "no file changes are expected"
   
    // A uploads again, this time it should succeed, because C's file is in knowndbs.list
    aUpResult = clientA.upWithForceChecksum();
    assertEquals("Expected to succeed, because db-C-1 has already been looked at", UpResultCode.OK_CHANGES_UPLOADED, aUpResult.getResultCode());
   
    // C calls down and up, to sync its changes
    clientC.down(); // Adds dirty database
    assertSqlResultEquals(clientC.getDatabaseFile(), "select count(*) from databaseversion where status='DIRTY'", "1");
   
View Full Code Here

  }
 
  @Override
  public int execute(String[] operationArgs) throws Exception {
    UpOperationOptions operationOptions = parseOptions(operationArgs);
    UpOperationResult operationResult = client.up(operationOptions);

    printResults(operationResult);

    return 0;
  }
View Full Code Here

    return statusCommand.parseOptions(operationArgs);
  }

  @Override
  public void printResults(OperationResult operationResult) {
    UpOperationResult concreteOperationResult = (UpOperationResult)operationResult;
   
    if (concreteOperationResult.getResultCode() == UpResultCode.NOK_UNKNOWN_DATABASES) {
      out.println("Sync up skipped, because there are remote changes.");
    }
    else if (concreteOperationResult.getResultCode() == UpResultCode.OK_CHANGES_UPLOADED) {
      ChangeSet changeSet = concreteOperationResult.getChangeSet();

      for (String newFile : changeSet.getNewFiles()) {
        out.println("A " + newFile);
      }
View Full Code Here

    // Tear down
    clientA.deleteTestData();
  }

  private void runUpAndTestForConsistentDatabase(TransferSettings connection, TestClient client) throws Exception {
    UpOperationResult upResult = client.up();
    StatusOperationResult statusResult = upResult.getStatusResult();

    // Test 1: Check result sets for inconsistencies
    assertTrue("Status command expected to return changes.", statusResult.getChangeSet().hasChanges());
    assertTrue("File should be uploaded while it is read-only.", upResult.getChangeSet().hasChanges());

    // Test 2: Check database for inconsistencies
    SqlDatabase database = client.loadLocalDatabase();
    assertNotNull("There should be a new database version, because files should have been added.", database.getLastDatabaseVersionHeader());
View Full Code Here

TOP

Related Classes of org.syncany.operations.up.UpOperationResult

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.