Source:
<code><START> public DatabaseUpgradeTestUtil(String initialDatabasePath) throws IOException, SQLException { <END> InputStream databaseInputStream = getClass().getResourceAsStream(initialDatabasePath); tempDir = File.createTempFile("openmrs-tests-temp-", ""); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); tempDBFile = new File(tempDir, "openmrs.h2.db"); tempDBFile.delete(); try { tempDBFile.createNewFile(); } catch (IOException e) { tempDir.delete(); throw e; } tempDBFile.deleteOnExit(); FileOutputStream tempDBOutputStream = new FileOutputStream(tempDBFile); try { IOUtils.copy(databaseInputStream, tempDBOutputStream); databaseInputStream.close(); tempDBOutputStream.close(); } catch (IOException e) { tempDBFile.delete(); tempDir.delete(); throw e; } finally { IOUtils.closeQuietly(databaseInputStream); IOUtils.closeQuietly(tempDBOutputStream); } String databaseUrl = tempDir.getAbsolutePath().replace("\\", "/") + "/openmrs"; connection = DriverManager.getConnection("jdbc:h2:" + databaseUrl + ";AUTO_RECONNECT=TRUE;DB_CLOSE_DELAY=-1", "sa", "sa"); connection.setAutoCommit(true); try { liqubaseConnection = DatabaseFactory.getInstance().findCorrectDatabaseImplementation( new JdbcConnection(connection)); liqubaseConnection.setDatabaseChangeLogTableName("LIQUIBASECHANGELOG"); liqubaseConnection.setDatabaseChangeLogLockTableName("LIQUIBASECHANGELOGLOCK"); liqubaseConnection.checkDatabaseChangeLogTable(false, null, null); } catch (LiquibaseException e) { tempDir.delete(); tempDBFile.delete(); throw new SQLException(e); } try { dbUnitConnection = new DatabaseConnection(connection); dbUnitConnection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory()); } catch (DatabaseUnitException e) { tempDir.delete(); tempDBFile.delete(); throw new SQLException(e); } }</code><technical_language>long run tests load database for test</technical_language>

Target:
public DatabaseUpgradeTestUtil(String initialDatabasePath) throws IOException, SQLException { InputStream databaseInputStream = getClass().getResourceAsStream(initialDatabasePath); tempDir = File.createTempFile("openmrs-tests-temp-", ""); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); tempDBFile = new File(tempDir, "openmrs.h2.db"); tempDBFile.delete(); try { tempDBFile.createNewFile(); } catch (IOException e) { tempDir.delete(); throw e; } tempDBFile.deleteOnExit(); FileOutputStream tempDBOutputStream = new FileOutputStream(tempDBFile); try { IOUtils.copy(databaseInputStream, tempDBOutputStream); databaseInputStream.close(); tempDBOutputStream.close(); } catch (IOException e) { tempDBFile.delete(); tempDir.delete(); throw e; } finally { IOUtils.closeQuietly(databaseInputStream); IOUtils.closeQuietly(tempDBOutputStream); } String databaseUrl = tempDir.getAbsolutePath().replace("\\", "/") + "/openmrs"; connection = DriverManager.getConnection("jdbc:h2:" + databaseUrl + ";AUTO_RECONNECT=TRUE;DB_CLOSE_DELAY=-1", "sa", "sa"); connection.setAutoCommit(true); try { liqubaseConnection = DatabaseFactory.getInstance().findCorrectDatabaseImplementation( new JdbcConnection(connection)); liqubaseConnection.setDatabaseChangeLogTableName("LIQUIBASECHANGELOG"); liqubaseConnection.setDatabaseChangeLogLockTableName("LIQUIBASECHANGELOGLOCK"); } catch (LiquibaseException e) { tempDir.delete(); tempDBFile.delete(); throw new SQLException(e); } try { dbUnitConnection = new DatabaseConnection(connection); dbUnitConnection.getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY, new H2DataTypeFactory()); } catch (DatabaseUnitException e) { tempDir.delete(); tempDBFile.delete(); throw new SQLException(e); } }