Search in sources :

Example 21 with CommandLineClient

use of org.syncany.cli.CommandLineClient in project syncany by syncany.

the class LsRemoteCommandTest method testLsRemoteCommand.

@Test
public void testLsRemoteCommand() throws Exception {
    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);
    assertEquals("? database-B-0000000001", cliOut[2]);
    TestCliUtil.deleteTestLocalConfigAndData(clientA);
    TestCliUtil.deleteTestLocalConfigAndData(clientB);
}
Also used : CommandLineClient(org.syncany.cli.CommandLineClient) File(java.io.File) Test(org.junit.Test)

Example 22 with CommandLineClient

use of org.syncany.cli.CommandLineClient in project syncany by syncany.

the class PluginCommandTest method testPluginListLocalOnly.

@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);
    TestAssertUtil.assertRegexInLines("local\\s+\\|\\s+Local", cliOut);
}
Also used : CommandLineClient(org.syncany.cli.CommandLineClient) Test(org.junit.Test)

Example 23 with CommandLineClient

use of org.syncany.cli.CommandLineClient in project syncany by syncany.

the class StatusCommandTest method testStatusCommandWithLogFile.

@Test
public void testStatusCommandWithLogFile() throws Exception {
    // Setup
    Map<String, String> connectionSettings = TestConfigUtil.createTestLocalConnectionSettings();
    Map<String, String> clientA = TestCliUtil.createLocalTestEnvAndInit("A", connectionSettings);
    File tempLogFile = new File(clientA.get("localdir") + "/" + Config.DIR_APPLICATION + "/" + Config.DIR_LOG + "/templogfile");
    // 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" }));
    // Test		
    assertTrue("Log file should exist.", new File(tempLogFile.getAbsolutePath() + ".0").exists());
    assertEquals(5, cliOut.length);
    assertEquals("? .syignore", cliOut[2]);
    assertEquals("? somefolder1", cliOut[3]);
    assertEquals("? somefolder2", cliOut[4]);
    // Cleanup
    TestCliUtil.deleteTestLocalConfigAndData(clientA);
}
Also used : CommandLineClient(org.syncany.cli.CommandLineClient) File(java.io.File) Test(org.junit.Test)

Example 24 with CommandLineClient

use of org.syncany.cli.CommandLineClient in project syncany by syncany.

the class UpdateCommandTest method testUpdateCheckOutdated.

@Test
public void testUpdateCheckOutdated() throws Exception {
    Properties originalAppProperties = (Properties) Client.getApplicationProperties().clone();
    Client.getApplicationProperties().setProperty("applicationVersion", "0.0.1");
    Client.getApplicationProperties().setProperty("applicationVersionFull", "0.0.1-alpha+SNAPSHOT.UNITTESTS");
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] { "update", "check" }));
    assertEquals(4, cliOut.length);
    assertTrue(cliOut[2].contains("new version is available"));
    assertTrue(cliOut[3].contains("ownload"));
    Client.getApplicationProperties().setProperty("applicationVersion", originalAppProperties.getProperty("applicationVersion"));
    Client.getApplicationProperties().setProperty("applicationVersionFull", originalAppProperties.getProperty("applicationVersionFull"));
}
Also used : CommandLineClient(org.syncany.cli.CommandLineClient) Properties(java.util.Properties) Test(org.junit.Test)

Example 25 with CommandLineClient

use of org.syncany.cli.CommandLineClient in project syncany by syncany.

the class UpdateCommandTest method testUpdateCheckUpToDate.

@Test
public void testUpdateCheckUpToDate() throws Exception {
    Properties originalAppProperties = (Properties) Client.getApplicationProperties().clone();
    Client.getApplicationProperties().setProperty("applicationVersion", "13.3.7-alpha");
    Client.getApplicationProperties().setProperty("applicationVersionFull", "13.3.7-alpha+SNAPSHOT.UNITTESTS");
    String[] cliOut = TestCliUtil.runAndCaptureOutput(new CommandLineClient(new String[] { "update", "check" }));
    assertEquals(3, cliOut.length);
    assertTrue(cliOut[2].contains("Up to date"));
    Client.getApplicationProperties().setProperty("applicationVersion", originalAppProperties.getProperty("applicationVersion"));
    Client.getApplicationProperties().setProperty("applicationVersionFull", originalAppProperties.getProperty("applicationVersionFull"));
}
Also used : CommandLineClient(org.syncany.cli.CommandLineClient) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

CommandLineClient (org.syncany.cli.CommandLineClient)26 Test (org.junit.Test)23 File (java.io.File)20 DatabaseRemoteFile (org.syncany.plugins.transfer.files.DatabaseRemoteFile)3 Properties (java.util.Properties)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1