Search in sources :

Example 1 with MsSqlBulkDatabaseWriter

use of org.jumpmind.symmetric.io.MsSqlBulkDatabaseWriter 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);
    }
}
Also used : Table(org.jumpmind.db.model.Table) Column(org.jumpmind.db.model.Column) MsSqlBulkDatabaseWriter(org.jumpmind.symmetric.io.MsSqlBulkDatabaseWriter) ArrayList(java.util.ArrayList) CommonsDbcpNativeJdbcExtractor(org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor) CsvData(org.jumpmind.symmetric.io.data.CsvData) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 Column (org.jumpmind.db.model.Column)1 Table (org.jumpmind.db.model.Table)1 MsSqlBulkDatabaseWriter (org.jumpmind.symmetric.io.MsSqlBulkDatabaseWriter)1 CsvData (org.jumpmind.symmetric.io.data.CsvData)1 Test (org.junit.Test)1 CommonsDbcpNativeJdbcExtractor (org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor)1