Hi there, we are developing a reporting module that uses specific MySQL functions in queries. When we run the queries in H2 database for integration test it complains the syntax.
I tried to replace the functions for equivalent ones so that both H2 and MySQL can understand. But when I do that the results are not the same in MySQL.
There are some functions that I changed to use in both databases:
date_add() replaced with timestampadd()
datediff() replaced with timestampdiff()
As the module uses MySQL in production I would like to know how to configure project to use MySQL + DbUnit + XML Dataset. May be there are other solutions to do that, If you guys know please let me know
Hi @dkayiwa , when I did what you sggested (overrided useinmemorymethod) I got null pointer exception:
public IntegrationModuleDaoTest() throws ManagedProcessException {
super();
Properties props = getRuntimeProperties();
if (!useInMemoryDatabase()) {
DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
config.setPort(0); // 0 => autom. detect free port
DB db = DB.newEmbeddedDB(config.build());
db.start();
String dbName = "openmrs"; // or just "test"
if (!dbName.equals("test")) { //mysqld out-of-the-box already has a DB named "test"
// in case we need another DB, here's how to create it first
db.createDB(dbName);
}
String url = config.getURL(dbName);
props.setProperty(Environment.URL, url);
props.setProperty(Environment.USER, "root");
props.setProperty(Environment.PASS, "");
}
Context.setRuntimeProperties(props);
}
@Override
public Boolean useInMemoryDatabase() {
return false;
}