Package org.syncany.operations.init

Examples of org.syncany.operations.init.InitOperationResult


  public void testConnectOperationSuccess() throws Exception {
    // A.init()
    InitOperationOptions initOperationOptionsA = TestConfigUtil.createTestInitOperationOptions("A");
    InitOperation initOperationA = new InitOperation(initOperationOptionsA, null);

    InitOperationResult initOperationResultA = initOperationA.execute();

    String connectLinkA = initOperationResultA.getGenLinkResult().getShareLink();
    assertNotNull(connectLinkA);

    // B.connect()
    File localDirB = TestFileUtil.createTempDirectoryInSystemTemp(TestConfigUtil.createUniqueName("clientB", initOperationOptionsA));
    File localConnectDirB = new File(localDirB, Config.DIR_APPLICATION);
View Full Code Here


  public void testConnectOperationFailureNoConnection() throws Exception {
    // A.init()
    InitOperationOptions initOperationOptionsA = TestConfigUtil.createTestInitOperationOptions("A");
    InitOperation initOperationA = new InitOperation(initOperationOptionsA, null);

    InitOperationResult initOperationResultA = initOperationA.execute();

    String connectLinkA = initOperationResultA.getGenLinkResult().getShareLink();
    assertNotNull(connectLinkA);

    // B.connect()
    File localDirB = TestFileUtil.createTempDirectoryInSystemTemp(TestConfigUtil.createUniqueName("client-B", initOperationOptionsA));
    File localConnectDirB = new File(localDirB, Config.DIR_APPLICATION);
View Full Code Here

  @Test
  public void testInitOperation() throws Exception {
    InitOperationOptions operationOptions = TestConfigUtil.createTestInitOperationOptions("A");
    InitOperation op = new InitOperation(operationOptions, null);
    InitOperationResult res = op.execute();
    File repoDir = ((LocalTransferSettings) operationOptions.getConfigTO().getTransferSettings()).getPath();
    File localDir = new File(operationOptions.getLocalDir(), ".syncany");

    // Test the repository
    assertTrue((new File(repoDir, "databases").exists()));
    assertTrue((new File(repoDir, "syncany").exists()));
    assertTrue((new File(repoDir, "multichunks").exists()));
    assertEquals((new File(repoDir, "master").exists()), TestConfigUtil.getCrypto());

    // Test the local folder
    assertTrue((new File(localDir, Config.DIR_DATABASE).exists()));
    assertTrue((new File(localDir, Config.DIR_CACHE).exists()));
    assertTrue((new File(localDir, Config.FILE_CONFIG).exists()));
    assertTrue((new File(localDir, Config.DIR_LOG).exists()));
    assertTrue((new File(localDir, Config.FILE_REPO).exists()));
    assertEquals((new File(localDir, Config.FILE_MASTER).exists()), TestConfigUtil.getCrypto());

    // Test the existance of generated link
    String link = res.getGenLinkResult().getShareLink();
    assertNotNull(link);

    TestFileUtil.deleteDirectory(repoDir);
    TestFileUtil.deleteDirectory(operationOptions.getLocalDir());
  }
View Full Code Here

    boolean performOperation = true;

    operationOptions = parseOptions(operationArgs);

    while (retryNeeded && performOperation) {
      InitOperationResult operationResult = client.init(operationOptions, this);
      printResults(operationResult);

      retryNeeded = operationResult.getResultCode() != InitResultCode.OK;

      if (retryNeeded) {
        performOperation = isInteractive && askRetryConnection();

        if (performOperation) {
View Full Code Here

    }
  }

  @Override
  public void printResults(OperationResult operationResult) {
    InitOperationResult concreteOperationResult = (InitOperationResult) operationResult;

    if (concreteOperationResult.getResultCode() == InitResultCode.OK) {
      out.println();
      out.println("Repository created, and local folder initialized. To share the same repository");
      out.println("with others, you can share this link:");

      printLink(concreteOperationResult.getGenLinkResult(), false);

      if (concreteOperationResult.isAddedToDaemon()) {
        out.println("To automatically sync this folder, simply restart the daemon with 'sy daemon restart'.");
        out.println();
      }
    }
    else if (concreteOperationResult.getResultCode() == InitResultCode.NOK_TEST_FAILED) {
      StorageTestResult testResult = concreteOperationResult.getTestResult();
      out.println();

      if (testResult.isRepoFileExists()) {
        out.println("ERROR: Repository cannot be initialized, because it already exists ('syncany' file");
        out.println("       exists). Are you sure that you want to create a new repo?  Use 'sy connect'");
        out.println("       to connect to an existing repository.");
      }
      else if (!testResult.isTargetCanConnect()) {
        out.println("ERROR: Repository cannot be initialized, because the connection to the storage backend failed.");
        out.println("       Possible reasons for this could be connectivity issues (are you connect to the Internet?),");
        out.println("       or invalid user credentials (are username/password valid?).");
      }
      else if (!testResult.isTargetExists()) {
        if (!operationOptions.isCreateTarget()) {
          out.println("ERROR: Repository cannot be initialized, because the target does not exist and");
          out.println("       the --create-target/-t option has not been enabled. Either create the target");
          out.println("       manually or retry with the --create-target/-t option.");
        }
        else {
          out.println("ERROR: Repository cannot be initialized, because the target does not exist and");
          out.println("       it cannot be created. Please check your permissions or create the target manually.");
        }
      }
      else if (!testResult.isTargetCanWrite()) {
        out.println("ERROR: Repository cannot be initialized, because the target is not writable. This is probably");
        out.println("       a permission issue (does the user have write permissions to the target?).");
      }
      else {
        out.println("ERROR: Repository cannot be initialized.");
      }

      out.println();
      printTestResult(testResult);
    }
    else {
      out.println();
      out.println("ERROR: Cannot connect to repository. Unknown error code: " + concreteOperationResult.getResultCode());
      out.println();
    }
  }
View Full Code Here

TOP

Related Classes of org.syncany.operations.init.InitOperationResult

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.