I am trying to use dbunit-express in my java project to create some tables and functions on postgress in Junit tests.
I use this driver :
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
The java class...
@Rule
public EmbeddedDbTesterRule testDb = new EmbeddedDbTesterRule(); // with this you don't neet to call onSetup
@Test
public void testIt() throws Exception {
try {
DatabaseCreator databaseCreator = new DatabaseCreator();
databaseCreator.setDdlFile("HistoryTables.ddl");
databaseCreator.doCreateDbSchemaFromDdl(testDb.getSqlConnection());
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
But I get this error...
org.postgresql.util.PSQLException: ERROR: unterminated dollar-quoted string at or near "$BODY$
The function looks like this.
CREATE OR REPLACE FUNCTION product_history()
RETURNS trigger AS
$BODY$
BEGIN
INSERT INTO product_history (id, product_id, edit_ts, name, print_provider_id, description)
VALUES (nextval('product_history_sequence'), OLD.id, now(), OLD.name, OLD.print_provider_id, OLD.description);
RETURN NULL;
END;
$BODY$
LANGUAGE plpgsql;
The create works fine in PGAdmin 1.14.3 and in DBVisualizer 9.0.8