Package org.syncany.cli

Examples of org.syncany.cli.CommandLineClient


        "--plugin", "local",
        "--plugin-option", "path=" + clientA.get("repopath"),
        "--no-compression"
    };

    new CommandLineClient(initArgs).start();

    // Run Genlink (on A)   
    String[] cliOutA = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
        "--localdir", clientA.get("localdir"),
        "genlink",
        "--machine-readable"
    }));

    assertEquals("Different number of output lines expected.", 1, cliOutA.length);
    String createdLink = cliOutA[0];

    String[] cliOutB = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
        "--localdir", clientLocalDirB.getAbsolutePath(),
        "connect",
        createdLink
    }));
View Full Code Here


    Map<String, String> connectionSettings = TestConfigUtil.createTestLocalConnectionSettings();
    Map<String, String> clientA = TestCliUtil.createLocalTestEnvAndInit("A", connectionSettings);

    // Run
    TestFileUtil.createRandomFile(new File(clientA.get("localdir"),"file1"), 50L);
    new CommandLineClient(new String[] {
       "--localdir", clientA.get("localdir"),
       "up"
    }).start();
   
    Thread.sleep(1000);
   
    TestFileUtil.deleteFile(new File(clientA.get("localdir"),"file1"));
    new CommandLineClient(new String[] {
       "--localdir", clientA.get("localdir"),
       "up"
    }).start();
       
    Thread.sleep(1000);
   
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
       "--localdir", clientA.get("localdir"),
       "ls",
       "--date=2s"
    }));
   
    assertTrue(cliOut.length >= 1);   
    String fileHistoryId = cliOut[0].split("\\s+")[7];
   
    System.out.println("filehistory id is " + fileHistoryId);
   
    new CommandLineClient(new String[] {
       "--localdir", clientA.get("localdir"),
       "restore",
       "--revision=1",
       "--target=restoredfile",
       fileHistoryId
View Full Code Here

    Map<String, String> connectionSettings = TestConfigUtil.createTestLocalConnectionSettings();
    Map<String, String> clientA = TestCliUtil.createLocalTestEnvAndInit("A", connectionSettings);
    Map<String, String> clientB = TestCliUtil.createLocalTestEnvAndConnect("B", connectionSettings);

    // Round 1: No changes / remote databases expected
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
        "--localdir", clientA.get("localdir"),
        "ls-remote"
    }));

    assertEquals("Different number of output lines expected.", 3, cliOut.length);

    // Round 2: One new database expected
    TestFileUtil.createRandomFile(new File(clientB.get("localdir") + "/file1"), 20 * 1024);
    TestFileUtil.createRandomFile(new File(clientB.get("localdir") + "/file2"), 20 * 1024);

    new CommandLineClient(new String[] {
        "--localdir", clientB.get("localdir"),
        "up",
    }).start();

    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
        "--localdir", clientA.get("localdir"),
        "ls-remote"
    }));

    assertEquals("Different number of output lines expected.", 3, cliOut.length);
View Full Code Here

import org.syncany.tests.util.TestCliUtil;

public class PluginCommandTest
  @Test
  public void testPluginListLocalOnly() throws Exception {
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "plugin", "list", "--local-only"
    }));

    assertTrue(cliOut.length >= 3);   
    TestAssertUtil.assertRegexInLines("\\| Name", cliOut);
View Full Code Here

    TestAssertUtil.assertRegexInLines("local\\s+\\|\\s+Local", cliOut);
  }
 
  @Test
  public void testPluginListRemoteOnly() throws Exception {   
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "plugin", "list", "--remote-only"
    }));

    assertTrue(cliOut.length >= 6);   
    TestAssertUtil.assertRegexInLines("^sftp\\s+\\|\\s+", cliOut);
View Full Code Here

    // Run!
    new File(clientA.get("localdir")+"/somefolder1").mkdir();
    new File(clientA.get("localdir")+"/somefolder2").mkdir();
       
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--loglevel", "OFF",
      "--localdir", clientA.get("localdir"),
      "status"
    }));
   
View Full Code Here

   
    // Run!
    new File(clientA.get("localdir")+"/somefolder1").mkdir();
    new File(clientA.get("localdir")+"/somefolder2").mkdir();
       
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--log", tempLogFile.getAbsolutePath(),
      "--localdir", clientA.get("localdir"),
      "status"
    }));
   
View Full Code Here

  public void testLsCommand() throws Exception {
    Map<String, String> connectionSettings = TestConfigUtil.createTestLocalConnectionSettings();
    Map<String, String> clientA = TestCliUtil.createLocalTestEnvAndInit("A", connectionSettings);

    // No lines expected
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--localdir", clientA.get("localdir"),
      "ls"
    }));

    assertEquals("Different number of output lines expected.", 1, cliOut.length);
    assertEquals("", StringUtil.join(cliOut, ""));

    // Create some files
    TestFileUtil.createRandomFile(new File(clientA.get("localdir")+"/file1"), 20*1024);
    TestFileUtil.createRandomFile(new File(clientA.get("localdir")+"/file2"), 20*1024);
   
    new File(clientA.get("localdir")+"/folder/subfolder").mkdirs();
    TestFileUtil.createRandomFile(new File(clientA.get("localdir")+"/folder/fileinfolder"), 20*1024);
    TestFileUtil.createRandomFile(new File(clientA.get("localdir")+"/folder/subfolder/fileinsubfolder"), 20*1024);
   
    new CommandLineClient(new String[] {
       "--localdir", clientA.get("localdir"),
       "up", "--force-checksum"
    }).start();
 
    TestFileUtil.changeRandomPartOfBinaryFile(new File(clientA.get("localdir")+"/folder/subfolder/fileinsubfolder"));
    TestFileUtil.changeRandomPartOfBinaryFile(new File(clientA.get("localdir")+"/file2"));
   
    Thread.sleep(1500);
    Date beforeSecondUpTime = new Date();
   
    new CommandLineClient(new String[] {
       "--localdir", clientA.get("localdir"),
       "up", "--force-checksum"
    }).start();
   
    // Check 'ls' output
    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--localdir", clientA.get("localdir"),
      "ls"
    }));
   
    assertEquals("Different number of output lines expected.", 3, cliOut.length);
    assertTrue(cliOut[0].contains("1 file1"));
    assertTrue(cliOut[1].contains("2 file2"));
    assertTrue(cliOut[2].contains("1 folder"));
   
    // Check 'ls --recursive' output
    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--localdir", clientA.get("localdir"),
      "ls", "--recursive"
    }));
   
    assertEquals("Different number of output lines expected.", 6, cliOut.length);
    assertTrue(cliOut[0].contains("1 file1"));
    assertTrue(cliOut[1].contains("2 file2"));
    assertTrue(cliOut[2].contains("1 folder"));
    assertTrue(cliOut[3].contains("1 folder/fileinfolder"));
    assertTrue(cliOut[4].contains("1 folder/subfolder"));
    assertTrue(cliOut[5].contains("2 folder/subfolder/fileinsubfolder"));
   
    // Check 'ls --versions --recursive' output
    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--localdir", clientA.get("localdir"),
      "ls", "--versions", "--recursive"
    }));
   
    assertEquals("Different number of output lines expected.", 8, cliOut.length);
    assertTrue(cliOut[0].contains("1 file1"));
    assertTrue(cliOut[1].contains("1 file2"));
    assertTrue(cliOut[2].contains("2 file2"));
    assertTrue(cliOut[3].contains("1 folder"));
    assertTrue(cliOut[4].contains("1 folder/fileinfolder"));
    assertTrue(cliOut[5].contains("1 folder/subfolder"));
    assertTrue(cliOut[6].contains("1 folder/subfolder/fileinsubfolder"));
    assertTrue(cliOut[7].contains("2 folder/subfolder/fileinsubfolder"));
   
    // Check 'ls --versions --group' output
    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--localdir", clientA.get("localdir"),
      "ls", "--versions", "--group"
    }));
   
    assertEquals("Different number of output lines expected.", 9, cliOut.length);
   
    assertTrue(cliOut[0].contains(", file1"));
    assertTrue(cliOut[1].contains("1 file1"));
    assertEquals("", cliOut[2].trim());
    assertTrue(cliOut[3].contains(", file2"));
    assertTrue(cliOut[4].contains("1 file2"));
    assertTrue(cliOut[5].contains("2 file2"));
    assertEquals("", cliOut[6].trim());
    assertTrue(cliOut[7].contains(", folder"));
    assertTrue(cliOut[8].contains("1 folder"));
   
    // Check 'ls --types=d' output
    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--localdir", clientA.get("localdir"),
      "ls", "--types=d"
    }));
   
    assertEquals("Different number of output lines expected.", 1, cliOut.length);    
    assertTrue(cliOut[0].contains("folder"));
   
    // Check 'ls --date=..' output
    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--localdir", clientA.get("localdir"),
      "ls", "--date", new SimpleDateFormat("yy-MM-dd HH:mm:ss").format(beforeSecondUpTime)
    }));
   
    assertEquals("Different number of output lines expected.", 3, cliOut.length);    
    assertTrue(cliOut[0].contains("1 file1"));
    assertTrue(cliOut[1].contains("1 file2"));
    assertTrue(cliOut[2].contains("folder"));
   
    // Check 'ls folder/' output
    cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] {
      "--localdir", clientA.get("localdir"),
      "ls", "folder/"
    }));
   
    assertEquals("Different number of output lines expected.", 2, cliOut.length);    
View Full Code Here

        "--plugin-option", "path=" + clientA.get("repopath"),
        "--no-encryption",
        "--no-compression"
    };

    new CommandLineClient(initArgs).start();

    assertTrue(tempDir.exists());
    assertTrue(new File(tempDir + "/.syncany").exists());
    assertTrue(new File(tempDir + "/.syncany/syncany").exists());
    assertTrue(new File(tempDir + "/.syncany/config.xml").exists());
View Full Code Here

    systemInMock.provideText(StringUtil.join(new String[] {
        "local",
        clientA.get("repopath")
    }, "\n") + "\n");

    new CommandLineClient(initArgs).start();

    assertTrue(tempDir.exists());
    assertTrue(new File(tempDir + "/.syncany").exists());
    assertTrue(new File(tempDir + "/.syncany/syncany").exists());
    assertTrue(new File(tempDir + "/.syncany/config.xml").exists());
View Full Code Here

TOP

Related Classes of org.syncany.cli.CommandLineClient

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.