use of org.dbunit.JndiDatabaseTester in project microservices by pwillhan.
the class SampleDataImporter method onStartup.
public void onStartup(@Observes @Initialized(ApplicationScoped.class) Object event) throws Exception {
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("testdata.xml");
IDatabaseConnection connection = new JndiDatabaseTester("java:jboss/datasources/ExampleDS").getConnection();
DatabaseOperation.CLEAN_INSERT.execute(connection, new FlatXmlDataSetBuilder().build(input));
if (connection != null) {
try {
connection.close();
} catch (Exception ex) {
ex.printStackTrace(System.err);
}
} else {
System.err.println("Can't import test data, check connection settings!");
}
}
Aggregations