Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
134 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
future/symmetric3-jdbc/src/test/java/org/jumpmind/symmetric/AbstractDatabaseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.jumpmind.symmetric; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.jumpmind.symmetric.core.io.FileUtils; | ||
import org.jumpmind.symmetric.core.model.Column; | ||
import org.jumpmind.symmetric.core.model.Parameters; | ||
import org.jumpmind.symmetric.core.model.Table; | ||
import org.jumpmind.symmetric.core.model.TypeMap; | ||
import org.jumpmind.symmetric.core.sql.ISqlConnection; | ||
import org.jumpmind.symmetric.jdbc.datasource.DriverDataSourceProperties; | ||
import org.jumpmind.symmetric.jdbc.db.IJdbcDbPlatform; | ||
import org.jumpmind.symmetric.jdbc.db.JdbcDbPlatformFactory; | ||
import org.junit.BeforeClass; | ||
|
||
abstract public class AbstractDatabaseTest { | ||
|
||
static protected DataSource dataSource; | ||
|
||
protected IJdbcDbPlatform getPlatform() { | ||
return JdbcDbPlatformFactory.createPlatform(dataSource, new Parameters()); | ||
} | ||
|
||
@BeforeClass | ||
public static void setupDataSource() { | ||
FileUtils.deleteDirectory("target/h2"); | ||
dataSource = new DriverDataSourceProperties("src/test/resources/test-jdbc.properties") | ||
.getDataSource(); | ||
} | ||
|
||
protected Table buildTestTable() { | ||
IJdbcDbPlatform platform = getPlatform(); | ||
Table table = new Table("TEST", | ||
new Column("TEST_ID", TypeMap.INTEGER, null, true, true, true), | ||
new Column("TEST_TEXT", TypeMap.VARCHAR, "1000", false, false, false)); | ||
ISqlConnection sqlConnection = platform.getSqlConnection(); | ||
String alterSql = platform.getAlterScriptFor(table); | ||
sqlConnection.update(alterSql); | ||
return getPlatform().findTable(table.getTableName()); | ||
} | ||
|
||
protected void insertTestTableRows(int count) { | ||
ISqlConnection sqlConnection = getPlatform().getSqlConnection(); | ||
for (int i = 0; i < count; i++) { | ||
sqlConnection.update("insert into test (test_text) values('the lazy brown fox jumped over " + i + " logs.')"); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...c3-jdbc/src/test/java/org/jumpmind/symmetric/core/process/sql/SqlTableDataReaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.jumpmind.symmetric.core.process.sql; | ||
|
||
import junit.framework.Assert; | ||
|
||
import org.jumpmind.symmetric.AbstractDatabaseTest; | ||
import org.jumpmind.symmetric.core.model.Batch; | ||
import org.jumpmind.symmetric.core.model.Data; | ||
import org.jumpmind.symmetric.core.model.Table; | ||
import org.junit.Test; | ||
|
||
public class SqlTableDataReaderTest extends AbstractDatabaseTest { | ||
|
||
@Test | ||
public void testSimpleTableWithNoCondition() throws Exception { | ||
Table testTable = buildTestTable(); | ||
insertTestTableRows(100); | ||
TableToExtract tableToExtract = new TableToExtract(testTable, ""); | ||
SqlTableDataReader reader = new SqlTableDataReader(getPlatform(), new Batch(), | ||
tableToExtract); | ||
SqlDataContext ctx = reader.createDataContext(); | ||
reader.open(ctx); | ||
Batch batch = reader.nextBatch(ctx); | ||
Assert.assertNotNull(batch); | ||
Table nextTable = reader.nextTable(ctx); | ||
Assert.assertNotNull(nextTable); | ||
Assert.assertEquals(testTable, nextTable); | ||
for (int i = 0; i < 100; i++) { | ||
Data data = reader.nextData(ctx); | ||
Assert.assertNotNull("Null data on the " + i + " element",data); | ||
} | ||
Data data = reader.nextData(ctx); | ||
Assert.assertNull(data); | ||
} | ||
} |
23 changes: 3 additions & 20 deletions
23
future/symmetric3-jdbc/src/test/java/org/jumpmind/symmetric/jdbc/db/JdbcPlatformTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters