use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class AbstractTriggerRouterServiceTest method test11BinaryColumnTypesForOracle.
@Test
public void test11BinaryColumnTypesForOracle() {
ISymmetricDialect dialect = getDbDialect();
if (DatabaseNamesConstants.ORACLE.equals(dialect.getName())) {
getSqlTemplate().update(CREATE_ORACLE_BINARY_TYPE);
TriggerRouter trouter = new TriggerRouter();
Trigger trigger = trouter.getTrigger();
trigger.setSourceTableName("test_oracle_binary_types");
trigger.setChannelId(TestConstants.TEST_CHANNEL_ID);
Router router = trouter.getRouter();
router.getNodeGroupLink().setSourceNodeGroupId(TestConstants.TEST_ROOT_NODE_GROUP);
router.getNodeGroupLink().setTargetNodeGroupId(TestConstants.TEST_ROOT_NODE_GROUP);
getTriggerRouterService().saveTriggerRouter(trouter);
ITriggerRouterService triggerService = getTriggerRouterService();
triggerService.syncTriggers();
Assert.assertEquals("Some triggers must have failed to build.", 0, triggerService.getFailedTriggers().size());
getSqlTemplate().update(INSERT_ORACLE_BINARY_TYPE_1);
String csvString = getNextDataRow();
Assert.assertEquals(EXPECTED_INSERT_ORALCE_BINARY_TYPE_1, csvString);
}
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class AbstractTriggerRouterServiceTest method test12BinaryColumnTypesForPostgres.
@Test
public void test12BinaryColumnTypesForPostgres() {
ISymmetricDialect dialect = getDbDialect();
if (DatabaseNamesConstants.POSTGRESQL.equals(dialect.getName())) {
getSqlTemplate().update(DROP_POSTGRES_BINARY_TYPE);
getSqlTemplate().update(CREATE_POSTGRES_BINARY_TYPE);
TriggerRouter trouter = new TriggerRouter();
Trigger trigger = trouter.getTrigger();
trigger.setSourceTableName("test_postgres_binary_types");
trigger.setChannelId(TestConstants.TEST_CHANNEL_ID);
Router router = trouter.getRouter();
router.getNodeGroupLink().setSourceNodeGroupId(TestConstants.TEST_ROOT_NODE_GROUP);
router.getNodeGroupLink().setTargetNodeGroupId(TestConstants.TEST_ROOT_NODE_GROUP);
getTriggerRouterService().saveTriggerRouter(trouter);
ITriggerRouterService triggerService = getTriggerRouterService();
triggerService.syncTriggers();
Assert.assertEquals("Some triggers must have failed to build.", 0, triggerService.getFailedTriggers().size());
// new SerialBlob("test 1 2 3".getBytes())
ISqlTransaction transaction = getSqlTemplate().startSqlTransaction();
try {
getSqlTemplate().update(INSERT_POSTGRES_BINARY_TYPE_1, "test 1 2 3".getBytes());
transaction.commit();
} finally {
transaction.close();
}
String csvString = getNextDataRow();
Assert.assertEquals(EXPECTED_INSERT_POSTGRES_BINARY_TYPE_1, csvString);
}
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method testSyncIncomingBatch.
public void testSyncIncomingBatch() throws Exception {
resetBatches();
TriggerRouter trigger1 = getTestRoutingTableTrigger(TEST_TABLE_1);
trigger1.getTrigger().setSyncOnIncomingBatch(true);
trigger1.getRouter().setRouterExpression(null);
trigger1.getRouter().setRouterType(null);
getTriggerRouterService().saveTriggerRouter(trigger1);
NodeChannel testChannel = getConfigurationService().getNodeChannel(TestConstants.TEST_CHANNEL_ID, false);
testChannel.setMaxBatchToSend(1000);
testChannel.setMaxBatchSize(50);
testChannel.setBatchAlgorithm("default");
getConfigurationService().saveChannel(testChannel, true);
getTriggerRouterService().syncTriggers();
insert(TEST_TABLE_1, 10, true, NODE_GROUP_NODE_1.getNodeId());
getRouterService().routeData(true);
OutgoingBatches batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false);
filterForChannels(batches, testChannel);
Assert.assertEquals("Should have been 0. We did the insert as if the data had come from node 1.", 0, batches.getBatches().size());
batches = getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_3.getNodeId(), false);
filterForChannels(batches, testChannel);
Assert.assertEquals(1, batches.getBatches().size());
resetBatches();
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method testColumnMatchOnNull.
public void testColumnMatchOnNull() {
NodeChannel testChannel = getConfigurationService().getNodeChannel(TestConstants.TEST_CHANNEL_ID, false);
TriggerRouter trigger = getTestRoutingTableTrigger(TEST_TABLE_1);
trigger.getRouter().setRouterType("column");
trigger.getRouter().setRouterExpression("ROUTING_VARCHAR=NULL");
getTriggerRouterService().saveTriggerRouter(trigger);
getTriggerRouterService().syncTriggers();
resetBatches();
update(TEST_TABLE_1, "Not Routed");
Assert.assertEquals(0, countBatchesForChannel(getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel));
getRouterService().routeData(true);
Assert.assertEquals(0, countBatchesForChannel(getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel));
resetBatches();
update(TEST_TABLE_1, null);
Assert.assertEquals(0, countBatchesForChannel(getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel));
getRouterService().routeData(true);
Assert.assertEquals(1, countBatchesForChannel(getOutgoingBatchService().getOutgoingBatches(NODE_GROUP_NODE_1.getNodeId(), false), testChannel));
}
use of org.jumpmind.symmetric.model.TriggerRouter in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method setUpDefaultTriggerRouterForTable1.
protected void setUpDefaultTriggerRouterForTable1() {
TriggerRouter triggerRouter = getTestRoutingTableTrigger(TEST_TABLE_1);
triggerRouter.getRouter().setRouterType("default");
triggerRouter.getRouter().setRouterExpression(null);
getTriggerRouterService().saveTriggerRouter(triggerRouter);
NodeChannel testChannel = getConfigurationService().getNodeChannel(TestConstants.TEST_CHANNEL_ID, false);
testChannel.setMaxBatchToSend(1000);
testChannel.setMaxBatchSize(50);
testChannel.setBatchAlgorithm("default");
getConfigurationService().saveChannel(testChannel, true);
getTriggerRouterService().syncTriggers();
}
Aggregations