Search in sources :

Example 61 with TriggerRouter

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

the class AbstractTriggerRouterServiceTest method test09ExcludedColumnsFunctionality.

@Test
public void test09ExcludedColumnsFunctionality() throws Exception {
    ITriggerRouterService service = getTriggerRouterService();
    ISqlTemplate jdbcTemplate = getSqlTemplate();
    assertEquals(1, jdbcTemplate.update("update sym_trigger set excluded_column_names='BOOLEAN_VALUE', last_update_time=? " + TEST_TRIGGER_WHERE_CLAUSE, new Object[] { new Date(System.currentTimeMillis() + 60000) }));
    service.syncTriggers();
    TriggerRouter triggerRouter = service.getTriggerRouterForTableForCurrentNode(null, null, TEST_TRIGGERS_TABLE, true).iterator().next();
    assertEquals(jdbcTemplate.queryForInt("select count(*) from sym_trigger_hist where trigger_id='" + triggerRouter.getTrigger().getTriggerId() + "' and inactive_time is null"), 1, "We expected only one active record in the trigger_hist table for " + TEST_TRIGGERS_TABLE);
    assertEquals(1, insert(INSERT2_VALUES, jdbcTemplate, getDbDialect()));
    String csvString = getNextDataRow();
    // DB2 captures decimal differently
    csvString = csvString.replaceFirst("\"00001\\.\"", "\"1\"");
    // Informix captures decimal differently
    csvString = csvString.replaceFirst("\"1.0000000000000000\"", "\"1\"");
    // ASA captures decimal differently
    csvString = csvString.replaceFirst("\"1.000000\"", "\"1\"");
    boolean match = csvString.endsWith(EXPECTED_INSERT2_CSV_ENDSWITH);
    assertTrue(match, "Received " + csvString + ", Expected the string to end with " + EXPECTED_INSERT2_CSV_ENDSWITH);
}
Also used : ISqlTemplate(org.jumpmind.db.sql.ISqlTemplate) ITriggerRouterService(org.jumpmind.symmetric.service.ITriggerRouterService) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Date(java.util.Date) Test(org.junit.Test)

Example 62 with TriggerRouter

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

the class RouterServiceTest method testNotProducesCommonBatchesSameTablesTwoChannelsMultipleRoutersSameTableIncomingOnAnotherChannel.

@Test
public void testNotProducesCommonBatchesSameTablesTwoChannelsMultipleRoutersSameTableIncomingOnAnotherChannel() {
    List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>();
    Trigger tableTrigger1 = new Trigger("a", CHANNEL_2_TEST.getChannelId(), true);
    Trigger tableTrigger2 = new Trigger("a", "anotherchannel");
    triggerRouters.add(new TriggerRouter(tableTrigger1, new Router("test", SOURCE_NODE_GROUP, TARGET_NODE_GROUP, "default")));
    triggerRouters.add(new TriggerRouter(tableTrigger2, new Router("test", TARGET_NODE_GROUP, SOURCE_NODE_GROUP, "default")));
    assertTrue(!routerService.producesCommonBatches(CHANNEL_2_TEST, SOURCE_NODE_GROUP, triggerRouters));
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) ArrayList(java.util.ArrayList) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Example 63 with TriggerRouter

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

the class RouterServiceTest method testNotProducesCommonBatchesMultipleTablesTwoChannelsMultipleRoutersSyncOnIncoming.

@Test
public void testNotProducesCommonBatchesMultipleTablesTwoChannelsMultipleRoutersSyncOnIncoming() {
    List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>();
    Trigger tableTrigger = new Trigger("a", CHANNEL_2_TEST.getChannelId(), true);
    triggerRouters.add(new TriggerRouter(tableTrigger, new Router("test", SOURCE_NODE_GROUP, TARGET_NODE_GROUP, "default")));
    triggerRouters.add(new TriggerRouter(tableTrigger, new Router("test", TARGET_NODE_GROUP, SOURCE_NODE_GROUP, "default")));
    assertTrue(!routerService.producesCommonBatches(CHANNEL_2_TEST, SOURCE_NODE_GROUP, triggerRouters));
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) ArrayList(java.util.ArrayList) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Example 64 with TriggerRouter

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

the class RouterServiceTest method testProducesCommonBatchesOneTableOneChannelDefaultRouter.

@Test
public void testProducesCommonBatchesOneTableOneChannelDefaultRouter() {
    List<TriggerRouter> triggerRouters = new ArrayList<TriggerRouter>();
    triggerRouters.add(new TriggerRouter(new Trigger("a", CHANNEL_2_TEST.getChannelId()), new Router("test", SOURCE_NODE_GROUP, TARGET_NODE_GROUP, "default")));
    assertTrue(routerService.producesCommonBatches(CHANNEL_2_TEST, SOURCE_NODE_GROUP, triggerRouters));
}
Also used : Trigger(org.jumpmind.symmetric.model.Trigger) ArrayList(java.util.ArrayList) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Router(org.jumpmind.symmetric.model.Router) TriggerRouter(org.jumpmind.symmetric.model.TriggerRouter) Test(org.junit.Test)

Aggregations

TriggerRouter (org.jumpmind.symmetric.model.TriggerRouter)64 ArrayList (java.util.ArrayList)22 Trigger (org.jumpmind.symmetric.model.Trigger)20 Router (org.jumpmind.symmetric.model.Router)18 NodeChannel (org.jumpmind.symmetric.model.NodeChannel)14 TriggerHistory (org.jumpmind.symmetric.model.TriggerHistory)13 ITriggerRouterService (org.jumpmind.symmetric.service.ITriggerRouterService)12 Test (org.junit.Test)12 List (java.util.List)10 Node (org.jumpmind.symmetric.model.Node)8 NodeGroupLink (org.jumpmind.symmetric.model.NodeGroupLink)7 OutgoingBatches (org.jumpmind.symmetric.model.OutgoingBatches)7 Table (org.jumpmind.db.model.Table)6 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 Data (org.jumpmind.symmetric.model.Data)5 TableReloadRequest (org.jumpmind.symmetric.model.TableReloadRequest)5 ConfigurationChangedDataRouter (org.jumpmind.symmetric.route.ConfigurationChangedDataRouter)4 FileSyncDataRouter (org.jumpmind.symmetric.route.FileSyncDataRouter)4