I'm using DBUnit + hsqlDB for database unit testing. Until now, we used hsqldb version 1.8.0.10.
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
<scope>test</scope>
</dependency>
We've some scripts to create the database schema (which create multiple tables). We load + execute these scripts through PreparedStatement. Something basicaly like that:
@Test
public void testMultipleTablesError() throws Exception {
IDatabaseTester databaseTester = new JdbcDatabaseTester("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:test");
Connection connection = databaseTester.getConnection().getConnection();
try {
String scriptDDL = "CREATE TABLE TABLE_A(A VARCHAR(10)); CREATE TABLE TABLE_B(B VARCHAR(10))";
PreparedStatement preparedStatement = connection.prepareStatement(scriptDDL);
preparedStatement.execute();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
connection.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
This works fine with 1.8.0.10. But if we change to hsqldb version 2.3.2 we get an exception when prepare the statment:
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
<scope>test</scope>
</dependency>
Caused by: org.hsqldb.HsqlException: palabra no esperado: CREATE
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
If we change the script to create only one table, it works fine in both version:
String scriptDDL = "CREATE TABLE TABLE_A(A VARCHAR(10))";
Anyone knows if the syntax for create many tables has changed between versions?
Thanks for the help in advance
EDIT: DBUnit version:
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>2.5.0</version>
<scope>test</scope>
</dependency>
Aucun commentaire:
Enregistrer un commentaire