use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class SimpleIntegrationTest method test12SuspendIgnorePushLocalBatches.
@Test(timeout = 120000)
public void test12SuspendIgnorePushLocalBatches() throws Exception {
// test suspend / ignore with local database specifying the suspends
// and ignores
logTestRunning();
Date date = DateUtils.parseDate("2007-01-03", new String[] { "yyyy-MM-dd" });
Order order = new Order("105", 100, null, date);
order.getOrderDetails().add(new OrderDetail("105", 1, "STK", "110000065", 3, new BigDecimal("3.33")));
assertNull(serverTestService.getOrder(order.getOrderId()));
clientTestService.insertOrder(order);
clientPush();
assertNotNull(serverTestService.getOrder(order.getOrderId()));
IConfigurationService clientConfigurationService = getClient().getConfigurationService();
IOutgoingBatchService clientOutgoingBatchService = getClient().getOutgoingBatchService();
NodeChannel c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setSuspendEnabled(true);
clientConfigurationService.saveNodeChannel(c, true);
order = new Order("106", 100, null, date);
order.getOrderDetails().add(new OrderDetail("106", 1, "STK", "110000065", 3, new BigDecimal("3.33")));
clientPush();
OutgoingBatches batches = clientOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_ROOT_NODE.getNodeId(), false);
assertEquals("There should be no outgoing batches since suspended locally", 0, batches.getBatches().size());
assertNull(serverTestService.getOrder(order.getOrderId()));
c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setIgnoreEnabled(true);
clientConfigurationService.saveNodeChannel(c, true);
clientPush();
batches = clientOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_ROOT_NODE.getNodeId(), false);
assertEquals("There should be no outgoing batches since suspended locally", 0, batches.getBatches().size());
assertNull(serverTestService.getOrder(order.getOrderId()));
// Cleanup!
c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
c.setSuspendEnabled(false);
c.setIgnoreEnabled(false);
clientConfigurationService.saveNodeChannel(c, true);
clientPush();
}
use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class AbstractIntegrationTest method assertNoPendingBatchesOnServer.
protected void assertNoPendingBatchesOnServer() {
IOutgoingBatchService outgoingBatchService = getServer().getOutgoingBatchService();
OutgoingBatches batches = outgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
}
use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class FileSyncTest method testUpdateManual.
protected void testUpdateManual(ISymmetricEngine rootServer, ISymmetricEngine clientServer) throws Exception {
OutgoingBatches batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
List<OutgoingBatch> batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());
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/test2.txt");
allFile1.getParentFile().mkdirs();
FileUtils.write(allFile1, "base value");
File allFile1Target = new File(allClntTargetDir, allFile1.getParentFile().getName() + "/" + allFile1.getName());
allFile1Target.getParentFile().mkdirs();
pullFiles();
assertEquals("base value", FileUtils.readFileToString(allFile1Target));
batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());
FileUtils.write(allFile1, "new value", true);
pullFiles();
assertEquals("base valuenew value", FileUtils.readFileToString(allFile1Target));
batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());
}
use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class FileSyncTest method testCreateAndUpdateInSameBatch.
protected void testCreateAndUpdateInSameBatch(ISymmetricEngine rootServer, ISymmetricEngine clientServer) throws Exception {
OutgoingBatches batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
List<OutgoingBatch> batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());
File allFile1 = new File(allSvrSourceDir, "createAndUpdate/test.txt");
allFile1.getParentFile().mkdirs();
FileUtils.write(allFile1, "create value ");
trackChangesOnServer();
FileUtils.write(allFile1, "plus update", true);
trackChangesOnServer();
File allFile1Target = new File(allClntTargetDir, allFile1.getParentFile().getName() + "/" + allFile1.getName());
allFile1Target.getParentFile().mkdirs();
pullFiles();
batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());
assertTrue(allFile1Target.exists());
assertEquals("create value plus update", FileUtils.readFileToString(allFile1Target));
}
use of org.jumpmind.symmetric.model.OutgoingBatches in project symmetric-ds by JumpMind.
the class NonDmlEventsTest method testRoutingOfReloadEvents.
protected void testRoutingOfReloadEvents(ISymmetricEngine rootServer, ISymmetricEngine clientServer) throws Exception {
rootServer.getParameterService().saveParameter(ParameterConstants.REST_API_ENABLED, true, "unit_test");
rootServer.getRegistrationService().openRegistration(clientServer.getParameterService().getNodeGroupId(), "2");
rootServer.getRegistrationService().openRegistration(clientServer.getParameterService().getNodeGroupId(), "3");
RestService restService = getRegServer().getRestService();
/* register a few more nodes to make sure that when we insert reload events they are only routed to the node we want */
restService.postRegisterNode("2", clientServer.getParameterService().getNodeGroupId(), DatabaseNamesConstants.H2, "1.2", "host2");
restService.postRegisterNode("3", clientServer.getParameterService().getNodeGroupId(), DatabaseNamesConstants.H2, "1.2", "host2");
rootServer.route();
assertEquals(0, rootServer.getOutgoingBatchService().countOutgoingBatchesUnsent(Constants.CHANNEL_RELOAD));
Table serverTable = rootServer.getDatabasePlatform().readTableFromDatabase(null, null, "NODE_SPECIFIC");
assertNotNull(serverTable);
assertTrue(rootServer.getDataService().reloadTable(clientServer.getNodeService().findIdentityNodeId(), null, null, serverTable.getName()).startsWith("Successfully created"));
rootServer.route();
assertEquals(0, rootServer.getOutgoingBatchService().getOutgoingBatches("2", true).getBatchesForChannel(Constants.CHANNEL_RELOAD).size());
assertEquals(0, rootServer.getOutgoingBatchService().getOutgoingBatches("3", true).getBatchesForChannel(Constants.CHANNEL_RELOAD).size());
OutgoingBatches batches = rootServer.getOutgoingBatchService().getOutgoingBatches(clientServer.getNodeService().findIdentityNodeId(), true);
assertEquals(1, batches.getBatchesForChannel(Constants.CHANNEL_RELOAD).size());
}
Aggregations