@Override protected void tearDown() throws Exception { if (setupDB) { try { sqlx("SHUTDOWN"); db.disconnect(); db = null; } catch (Exception ex) { System.err.println( "Shutdown failed. Test case probably modified the database connection! Retrying..."); DataSourceCollection<SPDataSource> dscol = new PlDotIni(); dscol.read(new File("pl.regression.ini")); db.setDataSource(dscol.getDataSource("regression_test", JDBCDataSource.class)); sqlx("SHUTDOWN"); db.disconnect(); db = null; } } }
/** * Looks up and returns an SPDataSource that represents the testing database. Uses a PL.INI file * located in the current working directory, called "pl.regression.ini" and creates a connection * to the database called "regression_test". * * <p>You are welcome to override this method in order to provide your own pl.ini and/or your own * data source to the {@link #setUp()} method. * * <p>FIXME: Need to parameterise this so that we can test each supported database platform! * * @throws IOException * @throws SQLObjectException */ protected JDBCDataSource getJDBCDataSource() throws IOException { plini.read(new File("pl.regression.ini")); return plini.getDataSource("regression_test", JDBCDataSource.class); }