use of org.jumpmind.symmetric.db.ISymmetricDialect 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.db.ISymmetricDialect in project symmetric-ds by JumpMind.
the class AbstractTriggerRouterServiceTest method test10DisableTriggers.
@Test
public void test10DisableTriggers() throws Exception {
ISymmetricDialect dbDialect = getDbDialect();
ISqlTemplate jdbcTemplate = getSqlTemplate();
ISqlTransaction transaction = jdbcTemplate.startSqlTransaction();
try {
dbDialect.disableSyncTriggers(transaction, null);
int count = insert(INSERT1_VALUES, transaction, dbDialect);
dbDialect.enableSyncTriggers(transaction);
transaction.commit();
assertTrue(count == 1);
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);
} finally {
transaction.close();
}
}
use of org.jumpmind.symmetric.db.ISymmetricDialect 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.db.ISymmetricDialect in project symmetric-ds by JumpMind.
the class AbstractRouterServiceTest method insert.
protected void insert(final String tableName, final int count, boolean transactional, final String node2disable, final String routingVarcharFieldValue, final boolean rollback) {
ISymmetricDialect dialect = getDbDialect();
IDatabasePlatform platform = dialect.getPlatform();
String columnName = platform.alterCaseToMatchDatabaseDefaultCase("ROUTING_VARCHAR");
ISqlTransaction transaction = null;
try {
transaction = platform.getSqlTemplate().startSqlTransaction();
if (node2disable != null) {
dialect.disableSyncTriggers(transaction, node2disable);
}
transaction.prepare(String.format("insert into %s (%s) values(?)", tableName, columnName));
for (int i = 0; i < count; i++) {
transaction.addRow(i, new Object[] { routingVarcharFieldValue }, new int[] { Types.VARCHAR });
if (!transactional) {
transaction.commit();
}
}
if (node2disable != null) {
dialect.enableSyncTriggers(transaction);
}
if (rollback) {
transaction.rollback();
} else {
transaction.flush();
transaction.commit();
}
} finally {
if (transaction != null) {
transaction.close();
}
}
}
use of org.jumpmind.symmetric.db.ISymmetricDialect in project symmetric-ds by JumpMind.
the class RouterServiceTest method setup.
@Before
public void setup() {
ISymmetricEngine engine = mock(ISymmetricEngine.class);
IParameterService parameterService = mock(IParameterService.class);
ISymmetricDialect symmetricDialect = mock(ISymmetricDialect.class);
IDatabasePlatform databasePlatform = mock(IDatabasePlatform.class);
IExtensionService extensionService = mock(IExtensionService.class);
when(databasePlatform.getDatabaseInfo()).thenReturn(new DatabaseInfo());
when(symmetricDialect.getPlatform()).thenReturn(databasePlatform);
when(engine.getDatabasePlatform()).thenReturn(databasePlatform);
when(engine.getParameterService()).thenReturn(parameterService);
when(engine.getSymmetricDialect()).thenReturn(symmetricDialect);
when(engine.getExtensionService()).thenReturn(extensionService);
routerService = new RouterService(engine);
}
Aggregations