Search in sources :

Example 1 with ConflictException

use of org.jumpmind.symmetric.io.data.writer.ConflictException in project symmetric-ds by JumpMind.

the class DbExportImportTest method importSymXmlData.

@Test
public void importSymXmlData() throws Exception {
    final String FILE = "/test-dbimport-1-sym_xml-1.xml";
    ISymmetricEngine engine = getSymmetricEngine();
    recreateImportTable();
    assertCountDbImportTableRecords(0);
    DbImport importCsv = new DbImport(engine.getDatabasePlatform());
    importCsv.setFormat(DbImport.Format.SYM_XML);
    importCsv.importTables(getClass().getResourceAsStream(FILE));
    assertCountDbImportTableRecords(2);
    try {
        importCsv.importTables(getClass().getResourceAsStream(FILE));
        Assert.fail("Expected a sql exception");
    } catch (ConflictException ex) {
    }
    assertCountDbImportTableRecords(2);
    recreateImportTable();
    importCsv.setReplaceRows(true);
    importCsv.importTables(getClass().getResourceAsStream(FILE));
    assertCountDbImportTableRecords(2);
}
Also used : ConflictException(org.jumpmind.symmetric.io.data.writer.ConflictException) DbImport(org.jumpmind.symmetric.io.data.DbImport) AbstractServiceTest(org.jumpmind.symmetric.service.impl.AbstractServiceTest) Test(org.junit.Test)

Aggregations

DbImport (org.jumpmind.symmetric.io.data.DbImport)1 ConflictException (org.jumpmind.symmetric.io.data.writer.ConflictException)1 AbstractServiceTest (org.jumpmind.symmetric.service.impl.AbstractServiceTest)1 Test (org.junit.Test)1