Search in sources :

Example 11 with FileTriggerRouter

use of org.jumpmind.symmetric.model.FileTriggerRouter in project symmetric-ds by JumpMind.

the class FileTriggerTrackerTest method testTakeFullSnapshotRecursive.

@Test
public void testTakeFullSnapshotRecursive() throws Exception {
    FileTrigger fileTrigger = new FileTrigger(directory.getAbsolutePath(), true, null, null);
    Router router = new Router();
    FileTriggerRouter fileTriggerRouter = new FileTriggerRouter(fileTrigger, router);
    FileTriggerTracker tracker = new FileTriggerTracker(fileTriggerRouter, null, null, false, null);
    DirectorySnapshot snapshot = new DirectorySnapshot(fileTriggerRouter);
    tracker.takeFullSnapshot(snapshot);
    assertEquals(4, snapshot.size());
}
Also used : FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) FileTrigger(org.jumpmind.symmetric.model.FileTrigger) FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) Router(org.jumpmind.symmetric.model.Router) Test(org.junit.Test)

Example 12 with FileTriggerRouter

use of org.jumpmind.symmetric.model.FileTriggerRouter in project symmetric-ds by JumpMind.

the class FileTriggerTrackerTest method testTakeFullSnapshotNonRecursive.

@Test
public void testTakeFullSnapshotNonRecursive() throws Exception {
    FileTrigger fileTrigger = new FileTrigger(directory.getAbsolutePath(), false, null, null);
    Router router = new Router();
    FileTriggerRouter fileTriggerRouter = new FileTriggerRouter(fileTrigger, router);
    FileTriggerTracker tracker = new FileTriggerTracker(fileTriggerRouter, null, null, false, null);
    DirectorySnapshot snapshot = new DirectorySnapshot(fileTriggerRouter);
    tracker.takeFullSnapshot(snapshot);
    assertEquals(2, snapshot.size());
}
Also used : FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) FileTrigger(org.jumpmind.symmetric.model.FileTrigger) FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) Router(org.jumpmind.symmetric.model.Router) Test(org.junit.Test)

Example 13 with FileTriggerRouter

use of org.jumpmind.symmetric.model.FileTriggerRouter in project symmetric-ds by JumpMind.

the class FileTriggerTrackerTest method testTakeFullSnapshotIncludes.

@Test
public void testTakeFullSnapshotIncludes() throws Exception {
    FileTrigger fileTrigger = new FileTrigger(directory.getAbsolutePath(), false, "*.txt", null);
    Router router = new Router();
    FileTriggerRouter fileTriggerRouter = new FileTriggerRouter(fileTrigger, router);
    FileTriggerTracker tracker = new FileTriggerTracker(fileTriggerRouter, null, null, false, null);
    DirectorySnapshot snapshot = new DirectorySnapshot(fileTriggerRouter);
    tracker.takeFullSnapshot(snapshot);
    assertEquals(1, snapshot.size());
    assertEquals(snapshot.get(0).getFileName(), FileSyncUtils.getRelativePath(fileInDirectory1, directory));
}
Also used : FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) FileTrigger(org.jumpmind.symmetric.model.FileTrigger) FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) Router(org.jumpmind.symmetric.model.Router) Test(org.junit.Test)

Example 14 with FileTriggerRouter

use of org.jumpmind.symmetric.model.FileTriggerRouter in project symmetric-ds by JumpMind.

the class FileTriggerTrackerTest method testTakeFullSnapshotExcludes.

@Test
public void testTakeFullSnapshotExcludes() throws Exception {
    FileTrigger fileTrigger = new FileTrigger(directory.getAbsolutePath(), false, null, "*.txt");
    Router router = new Router();
    FileTriggerRouter fileTriggerRouter = new FileTriggerRouter(fileTrigger, router);
    FileTriggerTracker tracker = new FileTriggerTracker(fileTriggerRouter, null, null, false, null);
    DirectorySnapshot snapshot = new DirectorySnapshot(fileTriggerRouter);
    tracker.takeFullSnapshot(snapshot);
    assertEquals(1, snapshot.size());
    assertEquals(snapshot.get(0).getFileName(), FileSyncUtils.getRelativePath(fileInDirectory2, directory));
}
Also used : FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) FileTrigger(org.jumpmind.symmetric.model.FileTrigger) FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) Router(org.jumpmind.symmetric.model.Router) Test(org.junit.Test)

Example 15 with FileTriggerRouter

use of org.jumpmind.symmetric.model.FileTriggerRouter in project symmetric-ds by JumpMind.

the class FileSyncTest method testManual.

protected void testManual(ISymmetricEngine rootServer, ISymmetricEngine clientServer) throws Exception {
    IFileSyncService fileSyncService = rootServer.getFileSyncService();
    FileTriggerRouter fileTriggerRouter = fileSyncService.getFileTriggerRouter("all", "server_2_client");
    fileTriggerRouter.setConflictStrategy(FileConflictStrategy.MANUAL);
    fileSyncService.saveFileTriggerRouter(fileTriggerRouter);
    pull("client");
    File allFile1 = new File(allSvrSourceDir, "manual/test.txt");
    allFile1.getParentFile().mkdirs();
    FileUtils.write(allFile1, "server value");
    File allFile1Target = new File(allClntTargetDir, allFile1.getParentFile().getName() + "/" + allFile1.getName());
    allFile1Target.getParentFile().mkdirs();
    FileUtils.write(allFile1Target, "client value");
    pullFiles();
    assertEquals("client value", FileUtils.readFileToString(allFile1Target));
    OutgoingBatches batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
    List<OutgoingBatch> batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
    assertEquals(1, batches.size());
    allFile1Target.delete();
    pullFiles();
    assertEquals("server value", FileUtils.readFileToString(allFile1Target));
    batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
    batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
    assertEquals(0, batches.size());
}
Also used : FileTriggerRouter(org.jumpmind.symmetric.model.FileTriggerRouter) IFileSyncService(org.jumpmind.symmetric.service.IFileSyncService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) OutgoingBatch(org.jumpmind.symmetric.model.OutgoingBatch) File(java.io.File)

Aggregations

FileTriggerRouter (org.jumpmind.symmetric.model.FileTriggerRouter)15 FileTrigger (org.jumpmind.symmetric.model.FileTrigger)8 File (java.io.File)6 Router (org.jumpmind.symmetric.model.Router)6 FileSnapshot (org.jumpmind.symmetric.model.FileSnapshot)5 Test (org.junit.Test)5 IFileSyncService (org.jumpmind.symmetric.service.IFileSyncService)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 IoException (org.jumpmind.exception.IoException)3 Table (org.jumpmind.db.model.Table)2 SymmetricException (org.jumpmind.symmetric.SymmetricException)2 DirectorySnapshot (org.jumpmind.symmetric.file.DirectorySnapshot)2 FileConflictException (org.jumpmind.symmetric.file.FileConflictException)2 CsvData (org.jumpmind.symmetric.io.data.CsvData)2 Data (org.jumpmind.symmetric.model.Data)2 LastEventType (org.jumpmind.symmetric.model.FileSnapshot.LastEventType)2 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)2 OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)2 NoContentException (org.jumpmind.symmetric.transport.NoContentException)2