From: <tk...@hy...> - 2008-03-11 06:23:30
|
Author: tkeeney Date: 2008-03-10 23:23:22 -0700 (Mon, 10 Mar 2008) New Revision: 8169 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=8169 Modified: trunk/src/org/hyperic/util/unittest/server/BaseServerTestCase.java Log: The datasource file should be read from the unittest jboss configuration (the same configuration we use to start the server). Modified: trunk/src/org/hyperic/util/unittest/server/BaseServerTestCase.java =================================================================== --- trunk/src/org/hyperic/util/unittest/server/BaseServerTestCase.java 2008-03-11 05:24:18 UTC (rev 8168) +++ trunk/src/org/hyperic/util/unittest/server/BaseServerTestCase.java 2008-03-11 06:23:22 UTC (rev 8169) @@ -116,7 +116,10 @@ protected final Connection getConnection(boolean forRestore) throws UnitTestDBException { try { - File file = new File("server/default/deploy/hq-ds.xml"); + String deployDir = + getJBossHomeDir()+"/server/"+JBOSS_UNIT_TEST_CONFIGURATION+"/deploy/"; + + File file = new File(deployDir, "hq-ds.xml"); Document doc = new SAXBuilder().build(file); Element element = doc.getRootElement().getChild("local-tx-datasource"); @@ -210,13 +213,8 @@ protected final void startServer() throws Exception { if (server == null || !server.isStarted()) { - String jbossHomeDir = System.getenv(JBOSS_HOME_DIR_ENV_VAR); + String jbossHomeDir = getJBossHomeDir(); - if (jbossHomeDir == null) { - throw new IllegalStateException("The "+JBOSS_HOME_DIR_ENV_VAR+ - " environment variable was not set"); - } - server = new ServerLifecycle(new File(jbossHomeDir), JBOSS_UNIT_TEST_CONFIGURATION); server.startServer(); @@ -233,4 +231,15 @@ } } + private String getJBossHomeDir() { + String jbossHomeDir = System.getenv(JBOSS_HOME_DIR_ENV_VAR); + + if (jbossHomeDir == null) { + throw new IllegalStateException("The "+JBOSS_HOME_DIR_ENV_VAR+ + " environment variable was not set"); + } + + return jbossHomeDir; + } + } |