Package org.syncany.tests.util

Examples of org.syncany.tests.util.TestClient


    // Setup
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
   
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
   
    //Create ignore file and reload it
    File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
    TestFileUtil.createFileWithContent(syncanyIgnore, "regex:.*.bak");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
   
    // A new/up
    clientA.createNewFile("ignoredfile.bak")
    clientA.up();
   
    clientB.down();

    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("ignoredfile.bak").exists());
    assertFalse(clientB.getLocalFile("ignoredfile.bak").exists());
   
   
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    TestFileUtil.deleteDirectory(tempDir);
  }
View Full Code Here


    // Setup
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
   
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
   
    //Create ignore file and reload it
    File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
    TestFileUtil.createFileWithContent(syncanyIgnore, "builds");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
   
    // A new/up
    clientA.createNewFolder("builds");
    clientA.createNewFile("builds/test.txt");
    clientA.up();
   
    clientB.down();

    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("builds/test.txt").exists());
    assertFalse(clientB.getLocalFile("builds/test.txt").exists());
   
   
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    TestFileUtil.deleteDirectory(tempDir);
  }
View Full Code Here

    // Setup
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
   
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();   
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
   
    //Create ignore file and reload it
    File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
    TestFileUtil.createFileWithContent(syncanyIgnore, "*.bak\nignoredarchive.r??");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
   
    // A new/up
    clientA.createNewFile("ignoredfile.bak")
    clientA.createNewFile("nonignoredfile.bar");
    clientA.createNewFile("ignoredarchive.r01");   
    clientA.up();
   
    clientB.down();

    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("ignoredfile.bak").exists());
    assertFalse(clientB.getLocalFile("ignoredfile.bak").exists());
    assertTrue(clientA.getLocalFile("nonignoredfile.bar").exists());
    assertTrue(clientB.getLocalFile("nonignoredfile.bar").exists());
    assertTrue(clientA.getLocalFile("ignoredarchive.r01").exists());
    assertFalse(clientB.getLocalFile("ignoredarchive.r01").exists());
   
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    TestFileUtil.deleteDirectory(tempDir);
  }
View Full Code Here

public class ChangedTypeScenarioTest {
  @Test
  public void testChangeTypeToFolder() 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 AbstractClientAction[] {
        new CreateFileTree(),
        new ChangeTypeFileToFolder(),
      },
      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();
  }
View Full Code Here

  @Test
  public void testPluginListLocalOnly() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);

    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginAction.LIST);
    pluginOptions.setListMode(PluginListMode.LOCAL);

    // Run
    PluginOperationResult pluginResult = client.plugin(pluginOptions);
    List<Plugin> pluginList = Plugins.list(); // for comparison only!

    // Test
    assertNotNull(pluginResult);
    assertEquals(PluginResultCode.OK, pluginResult.getResultCode());
    assertEquals(pluginList.size(), pluginResult.getPluginList().size());

    assertEquals(EXPECTED_NUM_PLUGINS, pluginResult.getPluginList().size()); // local and unreliable_local

    for (ExtendedPluginInfo pluginInfo : pluginResult.getPluginList()) {
      assertNull(pluginInfo.getRemotePluginInfo());

      assertNotNull(pluginInfo.getLocalPluginInfo());
      assertNull(pluginInfo.getLocalPluginInfo().getDownloadUrl());
      assertNull(pluginInfo.getLocalPluginInfo().getSha256sum());

      assertNotNull(pluginInfo.getLocalPluginInfo().getPluginId());
      assertNotNull(pluginInfo.getLocalPluginInfo().getPluginVersion());
      // The rest is not important for processing ...

      assertNotNull(Plugins.get(pluginInfo.getLocalPluginInfo().getPluginId()));
    }

    // Tear down
    client.deleteTestData();
  }
View Full Code Here

    // Tests which plugin releases are available. This is difficult because
    // that will change. So we can only test the bare minimum.

    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);

    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginAction.LIST);
    pluginOptions.setListMode(PluginListMode.REMOTE);
    pluginOptions.setSnapshots(false);

    PluginOperationResult pluginResult = client.plugin(pluginOptions);

    assertNotNull(pluginResult);
    assertEquals(PluginResultCode.OK, pluginResult.getResultCode());

    // Tear down
    client.deleteTestData();
  }
View Full Code Here

    // Tests which plugin snapshots are available. This is difficult because
    // that will change. So we can only test the bare minimum.

    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);

    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginAction.LIST);
    pluginOptions.setListMode(PluginListMode.REMOTE);
    pluginOptions.setSnapshots(true);

    PluginOperationResult pluginResult = client.plugin(pluginOptions);

    assertNotNull(pluginResult);
    assertEquals(PluginResultCode.OK, pluginResult.getResultCode());

    // Tear down
    client.deleteTestData();
  }
View Full Code Here

    File configDir = setupCleanConfigDir();

    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);

    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginAction.INSTALL);
    pluginOptions.setPluginId("ftp");

    PluginOperationResult pluginResult = client.plugin(pluginOptions);

    assertNotNull(pluginResult);
    assertEquals(PluginResultCode.OK, pluginResult.getResultCode());

    // Only one file should be in here: the jar for ftp.
    assertEquals(1, (new File(configDir, "plugins/lib/")).list().length);

    // Tear down
    client.deleteTestData();
    TestFileUtil.deleteDirectory(configDir);
    System.setProperty("user.home", "/tmp");
  }
View Full Code Here

    File configDir = setupCleanConfigDir();

    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient client = new TestClient("A", testConnection);

    PluginOperationOptions pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginAction.LIST);
    pluginOptions.setListMode(PluginListMode.REMOTE);
    pluginOptions.setSnapshots(false);

    PluginOperationResult pluginResult = client.plugin(pluginOptions);

    String pluginDownloadUrl = null;
    for (ExtendedPluginInfo pluginInfo : pluginResult.getPluginList()) {
      if (pluginInfo.getRemotePluginInfo().getPluginId().equals("ftp")) {
        pluginDownloadUrl = pluginInfo.getRemotePluginInfo().getDownloadUrl();
      }
    }

    pluginOptions = new PluginOperationOptions();
    pluginOptions.setAction(PluginAction.INSTALL);
    pluginOptions.setPluginId(pluginDownloadUrl);

    pluginResult = client.plugin(pluginOptions);

    assertNotNull(pluginResult);
    assertEquals(PluginResultCode.OK, pluginResult.getResultCode());

    // Only one file should be in here: the jar for ftp.
    assertEquals(1, (new File(configDir, "plugins/lib/")).list().length);

    // Tear down
    client.deleteTestData();
    TestFileUtil.deleteDirectory(configDir);
    System.setProperty("user.home", "/tmp");
  }
View Full Code Here

  public void testIssue247() throws Exception {   
    // Setup
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();   
   
    TestClient clientDzHome = new TestClient("Dz", testConnection);
    TestClient clientUxWork = new TestClient("Ux", testConnection);
       
    UpOperationOptions upOptionsWithForce = new UpOperationOptions();
    upOptionsWithForce.setForceUploadEnabled(true);

    // home -- generate some database versions so that the cleanup/merge will have something to merge   
    clientDzHome.createNewFile("someotherfile0.xml");
    clientDzHome.upWithForceChecksum();

    for (int i=0; i<30; i++) {
      clientDzHome.changeFile("someotherfile0.xml");
      clientDzHome.upWithForceChecksum();     
    }
   
    // home
    clientDzHome.createNewFile("config.xml"); // <<<<< This is the file/checksum causing the issue
    clientDzHome.upWithForceChecksum();

    TestFileUtil.copyFile(clientDzHome.getLocalFile("config.xml"), new File(tempDir, "config.xml")); // Make a copy (for later)   

    // work
    clientUxWork.down();

    clientUxWork.changeFile("config.xml");
    clientUxWork.upWithForceChecksum();
   
    clientUxWork.createNewFile("someotherfile1.xml");
    clientUxWork.upWithForceChecksum();
   
    clientUxWork.createNewFile("someotherfile2.xml");
    clientUxWork.upWithForceChecksum();
   
    clientUxWork.createNewFile("someotherfile3.xml");
    clientUxWork.upWithForceChecksum();
   
    // home
    clientDzHome.down();
   
    clientDzHome.changeFile("config.xml");
    clientDzHome.upWithForceChecksum();
   
    clientDzHome.changeFile("config.xml");
    clientDzHome.upWithForceChecksum();

    // work
    clientUxWork.down();

    CleanupOperationOptions cleanupOptions = new CleanupOperationOptions();
    cleanupOptions.setKeepVersionsCount(2);
   
    clientUxWork.cleanup(cleanupOptions);
       
    // home
    clientDzHome.down();
   
    clientDzHome.deleteFile("config.xml"); // Recreate problematic config.xml/checksum
    TestFileUtil.copyFile(new File(tempDir, "config.xml"), clientDzHome.getLocalFile("config.xml"));
   
    clientDzHome.upWithForceChecksum();
   
    // work
    clientUxWork.down();
   
    // Tear down
    TestFileUtil.deleteDirectory(tempDir);
   
    clientUxWork.deleteTestData();
    clientDzHome.deleteTestData();
  }   
View Full Code Here

TOP

Related Classes of org.syncany.tests.util.TestClient

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.