Search in sources :

Example 41 with NodeChannel

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

the class SimpleIntegrationTest method test14SuspendIgnorePullRemoteLocalComboBatches.

@Test(timeout = 120000)
public void test14SuspendIgnorePullRemoteLocalComboBatches() throws Exception {
    // test suspend / ignore with remote database specifying the suspends
    // and ignores
    logTestRunning();
    Date date = DateUtils.parseDate("2009-09-30", new String[] { "yyyy-MM-dd" });
    Order order = new Order("442", 100, "C", date);
    serverTestService.insertOrder(order);
    clientPull();
    IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService();
    OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertNotNull(clientTestService.getOrder(order.getOrderId()));
    assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
    IConfigurationService rootConfigurationService = getServer().getConfigurationService();
    IConfigurationService clientConfigurationService = getClient().getConfigurationService();
    // suspend on remote
    NodeChannel c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(true);
    rootConfigurationService.saveNodeChannel(c, true);
    // ignore on local
    c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setIgnoreEnabled(true);
    clientConfigurationService.saveNodeChannel(c, true);
    order = new Order("443", 100, "C", date);
    serverTestService.insertOrder(order);
    clientPull();
    batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
    assertNull(clientTestService.getOrder(order.getOrderId()));
    // ignore on remote
    c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setIgnoreEnabled(true);
    c.setSuspendEnabled(false);
    rootConfigurationService.saveNodeChannel(c, true);
    // suspend on local
    c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setIgnoreEnabled(false);
    c.setSuspendEnabled(true);
    clientConfigurationService.saveNodeChannel(c, true);
    order = new Order("444", 100, "C", date);
    clientPull();
    batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
    assertNull(clientTestService.getOrder(order.getOrderId()));
    // Cleanup!
    c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(false);
    c.setIgnoreEnabled(false);
    rootConfigurationService.saveNodeChannel(c, true);
    c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(false);
    c.setIgnoreEnabled(false);
    clientConfigurationService.saveNodeChannel(c, true);
    clientPull();
}
Also used : FixMethodOrder(org.junit.FixMethodOrder) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) Date(java.util.Date) Test(org.junit.Test)

Example 42 with NodeChannel

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

the class SimpleIntegrationTest method test13SuspendIgnorePullRemoteBatches.

@Test(timeout = 120000)
public void test13SuspendIgnorePullRemoteBatches() throws Exception {
    // test suspend / ignore with remote database specifying the suspends
    // and ignores
    logTestRunning();
    clientPull();
    Date date = DateUtils.parseDate("2009-09-30", new String[] { "yyyy-MM-dd" });
    Order order = new Order("42", 100, "C", date);
    serverTestService.insertOrder(order);
    clientPull();
    IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService();
    OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertNotNull(clientTestService.getOrder(order.getOrderId()));
    assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
    // Suspend the channel...
    IConfigurationService rootConfigurationService = getServer().getConfigurationService();
    NodeChannel c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(true);
    rootConfigurationService.saveNodeChannel(c, true);
    date = DateUtils.parseDate("2009-09-30", new String[] { "yyyy-MM-dd" });
    order = new Order("43", 100, "C", date);
    serverTestService.insertOrder(order);
    clientPull();
    batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertEquals("There should be 1 outgoing batch", 1, batches.getBatches().size());
    assertNull(clientTestService.getOrder(order.getOrderId()));
    c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setIgnoreEnabled(true);
    rootConfigurationService.saveNodeChannel(c, true);
    // ignore
    clientPull();
    batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertNull(clientTestService.getOrder(order.getOrderId()));
    assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
    // Cleanup!
    c = rootConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(false);
    c.setIgnoreEnabled(false);
    rootConfigurationService.saveNodeChannel(c, true);
    clientPull();
    batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
    assertNull(clientTestService.getOrder(order.getOrderId()));
}
Also used : FixMethodOrder(org.junit.FixMethodOrder) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) Date(java.util.Date) Test(org.junit.Test)

Example 43 with NodeChannel

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

the class SimpleIntegrationTest method test23IgnoreNodeChannel.

@Test(timeout = 120000)
public void test23IgnoreNodeChannel() {
    logTestRunning();
    INodeService rootNodeService = getServer().getNodeService();
    IConfigurationService rootConfigService = getServer().getConfigurationService();
    rootNodeService.ignoreNodeChannelForExternalId(true, TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_ROOT_NODE_GROUP, TestConstants.TEST_ROOT_EXTERNAL_ID);
    rootConfigService.clearCache();
    NodeChannel channel = rootConfigService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_ROOT_EXTERNAL_ID, false);
    assertNotNull(channel);
    assertTrue(channel.isIgnoreEnabled());
    assertFalse(channel.isSuspendEnabled());
    Customer customer = new Customer(201, "Charlie Dude", true, "300 Grub Street", "New York", "NY", 90009, new Date(), new Date(), THIS_IS_A_TEST, BINARY_DATA);
    serverTestService.insertCustomer(customer);
    clientPull();
    assertNull(clientTestService.getCustomer(customer.getCustomerId()));
    rootNodeService.ignoreNodeChannelForExternalId(false, TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_ROOT_NODE_GROUP, TestConstants.TEST_ROOT_EXTERNAL_ID);
    rootConfigService.clearCache();
    clientPull();
    assertNull(clientTestService.getCustomer(customer.getCustomerId()));
    getClient().getConfigurationService().clearCache();
}
Also used : INodeService(org.jumpmind.symmetric.service.INodeService) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) Date(java.util.Date) Test(org.junit.Test)

Example 44 with NodeChannel

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

the class SimpleIntegrationTest method test16SuspendIgnorePullLocalBatches.

@Test(timeout = 120000)
public void test16SuspendIgnorePullLocalBatches() throws Exception {
    // test suspend / ignore with local database specifying suspends and
    // ignores
    logTestRunning();
    // Should not sync when status = null
    Date date = DateUtils.parseDate("2009-09-30", new String[] { "yyyy-MM-dd" });
    Order order = new Order("44", 100, "C", date);
    serverTestService.insertOrder(order);
    clientPull();
    IOutgoingBatchService rootOutgoingBatchService = getServer().getOutgoingBatchService();
    OutgoingBatches batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertNotNull(clientTestService.getOrder(order.getOrderId()));
    assertEquals("There should be no outgoing batches", 0, batches.getBatches().size());
    // Suspend the channel...
    IConfigurationService clientConfigurationService = getClient().getConfigurationService();
    NodeChannel c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(true);
    clientConfigurationService.saveNodeChannel(c, true);
    order = new Order("45", 100, "C", date);
    serverTestService.insertOrder(order);
    clientPull();
    batches = rootOutgoingBatchService.getOutgoingBatches(TestConstants.TEST_CLIENT_NODE.getNodeId(), false);
    assertNull(clientTestService.getOrder(order.getOrderId()));
    assertEquals("There should be 1 outgoing batches", 1, batches.getBatches().size());
    c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setIgnoreEnabled(true);
    clientConfigurationService.saveNodeChannel(c, true);
    // ignore
    clientPull();
    assertNoPendingBatchesOnServer();
    c = clientConfigurationService.getNodeChannel(TestConstants.TEST_CHANNEL_ID, TestConstants.TEST_CLIENT_EXTERNAL_ID, false);
    c.setSuspendEnabled(false);
    c.setIgnoreEnabled(false);
    clientConfigurationService.saveNodeChannel(c, true);
    clientPull();
}
Also used : FixMethodOrder(org.junit.FixMethodOrder) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) OutgoingBatches(org.jumpmind.symmetric.model.OutgoingBatches) NodeChannel(org.jumpmind.symmetric.model.NodeChannel) Date(java.util.Date) Test(org.junit.Test)

Aggregations

NodeChannel (org.jumpmind.symmetric.model.NodeChannel)44 Test (org.junit.Test)15 Node (org.jumpmind.symmetric.model.Node)14 OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)14 TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)14 HashSet (java.util.HashSet)12 Data (org.jumpmind.symmetric.model.Data)10 Table (org.jumpmind.db.model.Table)9 DataMetaData (org.jumpmind.symmetric.model.DataMetaData)9 Router (org.jumpmind.symmetric.model.Router)9 TriggerHistory (org.jumpmind.symmetric.model.TriggerHistory)9 Date (java.util.Date)7 IConfigurationService (org.jumpmind.symmetric.service.IConfigurationService)7 ArrayList (java.util.ArrayList)6 IOutgoingBatchService (org.jumpmind.symmetric.service.IOutgoingBatchService)6 OutgoingBatch (org.jumpmind.symmetric.model.OutgoingBatch)5 FixMethodOrder (org.junit.FixMethodOrder)5 List (java.util.List)3 BigDecimal (java.math.BigDecimal)2 SQLException (java.sql.SQLException)2