@Override @Before public void setUp() throws Exception { super.setUp(); try { initializeDatabase(); } finally { m_installerDb.closeConnection(); } }
protected void initializeDatabase() throws Exception { // Create a ByteArrayOutputSteam to effectively throw away output. resetOutputStream(); m_installerDb.setDatabaseName(getTestDatabase()); m_installerDb.setDataSource(getDataSource()); m_installerDb.setAdminDataSource(getAdminDataSource()); m_installerDb.setPostgresOpennmsUser(getAdminUser()); m_installerDb.setCreateSqlLocation( ConfigurationTestUtils.getFileForConfigFile("create.sql").getAbsolutePath()); m_installerDb.setStoredProcedureDirectory( ConfigurationTestUtils.getFileForConfigFile("getPercentAvailabilityInWindow.sql") .getParentFile() .getAbsolutePath()); // m_installerDb.setDebug(true); m_installerDb.readTables(); m_installerDb.createSequences(); m_installerDb.updatePlPgsql(); m_installerDb.addStoredProcedures(); /* * Here's an example of an iplike function that always returns true. * CREATE OR REPLACE FUNCTION iplike(text, text) RETURNS bool AS ' BEGIN RETURN true; END; ' LANGUAGE 'plpgsql'; * * Found this in BaseIntegrationTestCase. */ if (m_setupIpLike) { m_installerDb.setPostgresIpLikeLocation(null); m_installerDb.updateIplike(); } m_installerDb.createTables(); if (m_insertData) { m_installerDb.insertData(); } }
public void resetOutputStream() { m_outputStream = new ByteArrayOutputStream(); m_installerDb.setOutputStream(new PrintStream(m_outputStream)); }