Search in sources :

Example 1 with StagingManager

use of org.jumpmind.symmetric.io.stage.StagingManager in project symmetric-ds by JumpMind.

the class MsSqlBulkDatabaseWriterTest method setup.

@BeforeClass
public static void setup() throws Exception {
    if (DbTestUtils.getEnvironmentSpecificProperties(DbTestUtils.ROOT).get(BasicDataSourcePropertyConstants.DB_POOL_DRIVER).equals("net.sourceforge.jtds.jdbc.Driver")) {
        platform = DbTestUtils.createDatabasePlatform(DbTestUtils.ROOT);
        platform.createDatabase(platform.readDatabaseFromXml("/testBulkWriter.xml", true), true, false);
        stagingManager = new StagingManager("target/tmp");
    }
}
Also used : IStagingManager(org.jumpmind.symmetric.io.stage.IStagingManager) StagingManager(org.jumpmind.symmetric.io.stage.StagingManager) BeforeClass(org.junit.BeforeClass)

Example 2 with StagingManager

use of org.jumpmind.symmetric.io.stage.StagingManager in project symmetric-ds by JumpMind.

the class MySqlBulkDatabaseWriterTest method setup.

@BeforeClass
public static void setup() throws Exception {
    if (DbTestUtils.getEnvironmentSpecificProperties(DbTestUtils.ROOT).get(BasicDataSourcePropertyConstants.DB_POOL_DRIVER).equals("com.mysql.jdbc.Driver")) {
        platform = DbTestUtils.createDatabasePlatform(DbTestUtils.ROOT);
        platform.createDatabase(platform.readDatabaseFromXml("/testBulkWriter.xml", true), true, false);
        stagingManager = new StagingManager("tmp");
    }
}
Also used : IStagingManager(org.jumpmind.symmetric.io.stage.IStagingManager) StagingManager(org.jumpmind.symmetric.io.stage.StagingManager) BeforeClass(org.junit.BeforeClass)

Example 3 with StagingManager

use of org.jumpmind.symmetric.io.stage.StagingManager in project symmetric-ds by JumpMind.

the class StagingDataWriterTest method readThenWrite.

public void readThenWrite(long threshold) throws Exception {
    InputStreamReader is = new InputStreamReader(getClass().getResourceAsStream("FileCsvDataWriterTest.1.csv"));
    String origCsv = IOUtils.toString(is);
    is.close();
    StagingManager stagingManager = new StagingManager(DIR.getAbsolutePath());
    ProtocolDataReader reader = new ProtocolDataReader(BatchType.LOAD, "test", origCsv);
    StagingDataWriter writer = new StagingDataWriter(threshold, false, "aaa", "test", stagingManager, new BatchListener());
    DataProcessor processor = new DataProcessor(reader, writer, "test");
    processor.process(new DataContext());
    assertEquals(1, batchesWritten.size());
    assertEquals(convertEol(origCsv), convertEol(batchesWritten.get(0)));
    IStagedResource resource = (IStagedResource) stagingManager.find("test", "aaa", 1);
    assertNotNull(resource);
    if (threshold > origCsv.length()) {
        assertFalse(resource.getFile().exists());
    } else {
        assertTrue(resource.getFile().exists());
    }
    resource.delete();
    assertFalse(resource.getFile().exists());
}
Also used : DataContext(org.jumpmind.symmetric.io.data.DataContext) InputStreamReader(java.io.InputStreamReader) IStagedResource(org.jumpmind.symmetric.io.stage.IStagedResource) ProtocolDataReader(org.jumpmind.symmetric.io.data.reader.ProtocolDataReader) DataProcessor(org.jumpmind.symmetric.io.data.DataProcessor) StagingManager(org.jumpmind.symmetric.io.stage.StagingManager)

Aggregations

StagingManager (org.jumpmind.symmetric.io.stage.StagingManager)3 IStagingManager (org.jumpmind.symmetric.io.stage.IStagingManager)2 BeforeClass (org.junit.BeforeClass)2 InputStreamReader (java.io.InputStreamReader)1 DataContext (org.jumpmind.symmetric.io.data.DataContext)1 DataProcessor (org.jumpmind.symmetric.io.data.DataProcessor)1 ProtocolDataReader (org.jumpmind.symmetric.io.data.reader.ProtocolDataReader)1 IStagedResource (org.jumpmind.symmetric.io.stage.IStagedResource)1