Search in sources :

Example 1 with TableCsvData

use of org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData in project symmetric-ds by JumpMind.

the class OracleBulkDatabaseWriterTest method testInsert1000Rows.

@Test
public void testInsert1000Rows() {
    if (platform != null && platform instanceof OracleDatabasePlatform) {
        platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
        List<CsvData> datas = new ArrayList<CsvData>();
        for (int i = 0; i < 1000; i++) {
            String[] values = { getNextId(), "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" };
            CsvData data = new CsvData(DataEventType.INSERT, values);
            datas.add(data);
        }
        long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
        Assert.assertEquals(count, countRows("test_bulkload_table_1"));
    }
}
Also used : TableCsvData(org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData) OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) ArrayList(java.util.ArrayList) CsvData(org.jumpmind.symmetric.io.data.CsvData) TableCsvData(org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData) Test(org.junit.Test)

Example 2 with TableCsvData

use of org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData 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);
        }
    }
}
Also used : TableCsvData(org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData) OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) ArrayList(java.util.ArrayList) CsvData(org.jumpmind.symmetric.io.data.CsvData) TableCsvData(org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData) Test(org.junit.Test)

Example 3 with TableCsvData

use of org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData in project symmetric-ds by JumpMind.

the class PostgresBulkDatabaseWriterTest method testInsert1000Rows.

@Test
public void testInsert1000Rows() {
    if (platform != null && platform instanceof PostgreSqlDatabasePlatform) {
        platform.getSqlTemplate().update("truncate table test_bulkload_table_1");
        List<CsvData> datas = new ArrayList<CsvData>();
        for (int i = 0; i < 1000; i++) {
            String[] values = { getNextId(), "stri'ng2", "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);
            datas.add(data);
        }
        long count = writeData(new TableCsvData(platform.getTableFromCache("test_bulkload_table_1", false), datas));
        Assert.assertEquals(count, countRows("test_bulkload_table_1"));
    }
}
Also used : TableCsvData(org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData) ArrayList(java.util.ArrayList) PostgreSqlDatabasePlatform(org.jumpmind.db.platform.postgresql.PostgreSqlDatabasePlatform) CsvData(org.jumpmind.symmetric.io.data.CsvData) TableCsvData(org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData) Test(org.junit.Test)

Example 4 with TableCsvData

use of org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData in project symmetric-ds by JumpMind.

the class OracleBulkDatabaseWriterTest 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.000", "2007-02-03 04:05:06.000", "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.000", "2007-02-03 04:05:06.000", "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);
        }
    }
}
Also used : TableCsvData(org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData) OracleDatabasePlatform(org.jumpmind.db.platform.oracle.OracleDatabasePlatform) ArrayList(java.util.ArrayList) CsvData(org.jumpmind.symmetric.io.data.CsvData) TableCsvData(org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)4 TableCsvData (org.jumpmind.symmetric.io.AbstractWriterTest.TableCsvData)4 CsvData (org.jumpmind.symmetric.io.data.CsvData)4 Test (org.junit.Test)4 OracleDatabasePlatform (org.jumpmind.db.platform.oracle.OracleDatabasePlatform)3 PostgreSqlDatabasePlatform (org.jumpmind.db.platform.postgresql.PostgreSqlDatabasePlatform)1