use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class OracleBulkDatabaseWriterTest method testInsertTimestampTZ_timestamp.
@Test
public void testInsertTimestampTZ_timestamp() throws Exception {
if (platform != null && platform instanceof OracleDatabasePlatform) {
NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();
platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
List<CsvData> datas = new ArrayList<CsvData>();
String id = getNextId();
String[] values = { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", "2007-01-02 03:20:10.000", "2007-01-02 03:20:10.000", "2007-01-02 03:20:10.000", "2007-01-02 03:20:10.000" };
CsvData data = new CsvData(DataEventType.INSERT, values);
datas.add(data);
long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
Map<String, Object> rowData = queryForRow(id);
DataSource datasource = (DataSource) platform.getDataSource();
Connection connection = datasource.getConnection();
Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
final String[] EXPECTED_TIMESTAMPTZ = { "2007-01-02 03:20:10.0 America/New_York", "2007-01-02 03:20:10.0 US/Eastern" };
checkTimestampTZ(rowData.get("TIMESTAMPTZ0_VALUE"), oracleConnection, EXPECTED_TIMESTAMPTZ);
checkTimestampTZ(rowData.get("TIMESTAMPTZ3_VALUE"), oracleConnection, EXPECTED_TIMESTAMPTZ);
checkTimestampTZ(rowData.get("TIMESTAMPTZ6_VALUE"), oracleConnection, EXPECTED_TIMESTAMPTZ);
checkTimestampTZ(rowData.get("TIMESTAMPTZ9_VALUE"), oracleConnection, EXPECTED_TIMESTAMPTZ);
Assert.assertEquals(count, countRows("test_bulkload_table_1"));
}
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class OracleBulkDatabaseWriterTest method testInsertTimestampTZ_timestampWithTimeZone.
@Test
public void testInsertTimestampTZ_timestampWithTimeZone() throws Exception {
if (platform != null && platform instanceof OracleDatabasePlatform) {
NativeJdbcExtractor jdbcExtractor = new CommonsDbcpNativeJdbcExtractor();
platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
List<CsvData> datas = new ArrayList<CsvData>();
String id = getNextId();
String[] values = { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", "2007-01-02 03:20:10.123456789 -08:00", "2007-01-02 03:20:10.123456789 -08:00", "2007-01-02 03:20:10.123456789 -08:00", "2007-01-02 03:20:10.123456789 -08:00" };
CsvData data = new CsvData(DataEventType.INSERT, values);
datas.add(data);
long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
Map<String, Object> rowData = queryForRow(id);
DataSource datasource = (DataSource) platform.getDataSource();
Connection connection = datasource.getConnection();
Connection oracleConnection = jdbcExtractor.getNativeConnection(connection);
checkTimestampTZ(rowData.get("TIMESTAMPTZ0_VALUE"), oracleConnection, "2007-01-02 03:20:10.0 -8:00");
checkTimestampTZ(rowData.get("TIMESTAMPTZ3_VALUE"), oracleConnection, "2007-01-02 03:20:10.123 -8:00");
checkTimestampTZ(rowData.get("TIMESTAMPTZ6_VALUE"), oracleConnection, "2007-01-02 03:20:10.123457 -8:00");
checkTimestampTZ(rowData.get("TIMESTAMPTZ9_VALUE"), oracleConnection, "2007-01-02 03:20:10.123456789 -8:00");
Assert.assertEquals(count, countRows("test_bulkload_table_1"));
}
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testStringSpaces.
@Test
public void testStringSpaces() throws Exception {
String[] values = new String[TEST_COLUMNS.length];
values[0] = getNextId();
values[1] = " two spaces before";
if (!(platform instanceof AseDatabasePlatform)) {
values[2] = "two spaces after ";
}
values[3] = " one space before";
values[4] = "one space after ";
writeData(new CsvData(DataEventType.INSERT, values), values);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testInsertDetectTimestampNewerWins.
@Test
public void testInsertDetectTimestampNewerWins() {
Conflict setting = new Conflict();
setting.setConflictId("unit.test");
setting.setDetectType(DetectConflict.USE_TIMESTAMP);
setting.setDetectExpression("time_value");
setting.setResolveRowOnly(true);
setting.setResolveChangesOnly(false);
setting.setResolveType(ResolveConflict.NEWER_WINS);
writerSettings.setDefaultConflictSetting(setting);
String id = getNextId();
String[] originalValues = massageExpectectedResultsForDialect(new String[] { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2012-03-12 07:00:00.000", "0", "47", "67.89", "-0.0747663" });
CsvData data = new CsvData(DataEventType.INSERT, originalValues);
writeData(data, originalValues);
String[] updateShouldNotBeApplied = CollectionUtils.copyOfRange(originalValues, 0, originalValues.length);
updateShouldNotBeApplied[2] = "updated string";
updateShouldNotBeApplied[6] = "2012-03-12 06:00:00.0";
data = new CsvData(DataEventType.INSERT, massageExpectectedResultsForDialect(updateShouldNotBeApplied));
writeData(data, originalValues);
String[] updateShouldBeApplied = CollectionUtils.copyOfRange(originalValues, 0, originalValues.length);
updateShouldBeApplied[2] = "string3";
updateShouldBeApplied[6] = "2012-03-12 08:00:00.000";
data = new CsvData(DataEventType.INSERT, massageExpectectedResultsForDialect(updateShouldBeApplied));
writeData(data, updateShouldBeApplied);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class DatabaseWriterTest method testUpdateDetectTimestampNewerWins.
@Test
public void testUpdateDetectTimestampNewerWins() {
Conflict setting = new Conflict();
setting.setConflictId("unit.test");
setting.setDetectType(DetectConflict.USE_TIMESTAMP);
setting.setDetectExpression("time_value");
setting.setResolveRowOnly(true);
setting.setResolveChangesOnly(true);
setting.setResolveType(ResolveConflict.NEWER_WINS);
writerSettings.setDefaultConflictSetting(setting);
String id = getNextId();
String[] originalValues = massageExpectectedResultsForDialect(new String[] { id, "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.000", "2012-03-12 07:00:00.000", "0", "47", "67.89", "-0.0747663" });
CsvData data = new CsvData(DataEventType.INSERT, originalValues);
writeData(data, originalValues);
String[] updateShouldNotBeApplied = CollectionUtils.copyOfRange(originalValues, 0, originalValues.length);
updateShouldNotBeApplied[2] = "updated string";
updateShouldNotBeApplied[6] = "2012-03-12 06:00:00.0";
data = new CsvData(DataEventType.UPDATE, massageExpectectedResultsForDialect(updateShouldNotBeApplied));
writeData(data, originalValues);
String[] updateShouldBeApplied = CollectionUtils.copyOfRange(originalValues, 0, originalValues.length);
updateShouldBeApplied[2] = "string3";
updateShouldBeApplied[6] = "2012-03-12 08:00:00.000";
data = new CsvData(DataEventType.UPDATE, massageExpectectedResultsForDialect(updateShouldBeApplied));
writeData(data, updateShouldBeApplied);
}
Aggregations