use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class PostgresBulkDatabaseWriterTest method testInsertCollision.
@Test
public void testInsertCollision() {
if (platform != null && platform instanceof OracleDatabasePlatform) {
platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
String[] values = { getNextId(), "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.0", "2007-02-03 04:05:06.0", "0", "47", "67.89", "-0.0747663" };
CsvData data = new CsvData(DataEventType.INSERT, values);
writeData(data, values);
Assert.assertEquals(1, countRows("test_bulkload_table_1"));
try {
setErrorExpected(true);
List<CsvData> datas = new ArrayList<CsvData>();
datas.add(data);
for (int i = 0; i < 10; i++) {
values = new String[] { getNextId(), "string2", "string not null2", "char2", "char not null2", "2007-01-02 03:20:10.0", "2007-02-03 04:05:06.0", "0", "47", "67.89", "-0.0747663" };
data = new CsvData(DataEventType.INSERT, values);
datas.add(data);
}
// we should collide and rollback
writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
Assert.assertEquals(1, countRows("test_bulkload_table_1"));
} finally {
setErrorExpected(false);
}
}
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class SymmetricPushClient method delete.
public void delete(Table table, String[] pkData) {
writer.start(table);
writer.write(new CsvData(DataEventType.DELETE, pkData, null));
writer.end(table);
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class AbstractBulkDatabaseWriterTest method testInsertAcrossMaxFlush.
@Test
public void testInsertAcrossMaxFlush() {
if (shouldTestRun(platform)) {
platform.getSqlTemplate().update("truncate table " + getTestTable());
List<CsvData> data = new ArrayList<CsvData>();
for (int i = 0; i < 30; i++) {
String[] values = { getNextId(), "stri'ng2", "string not null2", "char2", "char not null2", "2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", encode("string") };
data.add(new CsvData(DataEventType.INSERT, values));
}
Assert.assertEquals(writeData(data), countRows(getTestTable()));
}
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class MsSqlBulkDatabaseWriterTest method testInsertReorderColumns.
@Test
public void testInsertReorderColumns() throws Exception {
if (shouldTestRun(platform)) {
String id = getNextId();
String[] values = { "string with space in it", "string-with-no-space", "string with space in it", "string-with-no-space", "2007-01-02 00:00:00.000", "2007-02-03 04:05:06.000", "0", "47", "67.89", "-0.0747663", encode("string with space in it"), id };
List<CsvData> data = new ArrayList<CsvData>();
data.add(new CsvData(DataEventType.INSERT, (String[]) ArrayUtils.clone(values)));
Table table = (Table) platform.getTableFromCache(getTestTable(), false).clone();
Column firstColumn = table.getColumn(0);
table.removeColumn(firstColumn);
table.addColumn(firstColumn);
writeData(new MsSqlBulkDatabaseWriter(platform, stagingManager, new CommonsDbcpNativeJdbcExtractor(), 1000, false, uncPath, null, null), new TableCsvData(table, data));
values = (String[]) ArrayUtils.remove(values, values.length - 1);
values = (String[]) ArrayUtils.add(values, 0, id);
assertTestTableEquals(id, values);
}
}
use of org.jumpmind.symmetric.io.data.CsvData in project symmetric-ds by JumpMind.
the class SymmetricPushClient method insert.
public void insert(Table table, String[] data) {
writer.start(table);
writer.write(new CsvData(DataEventType.INSERT, data));
writer.end(table);
}
Aggregations