From 84b40f802f7a12be480ec7e2cdcd071a862a8ad0 Mon Sep 17 00:00:00 2001 From: harshanL Date: Tue, 27 Jan 2015 10:33:05 +0530 Subject: [PATCH] Unit test code changes --- .../pom.xml | 5 +++++ .../mobile/impl/common/TestDBConfigurations.java | 4 ++-- .../impl/dao/MobileFeatureDAOTestSuite.java | 16 ++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml index 850525cc3..3fc481638 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml @@ -124,5 +124,10 @@ org.apache.tomcat.wso2 jdbc-pool + + com.h2database.wso2 + h2-database-engine + test + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java index 42a6fcf4d..ab7c18a46 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java @@ -22,12 +22,12 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.List; -@XmlRootElement(name = "DeviceMgtTestDBConfigurations") +@XmlRootElement(name = "TestDataSourceConfigurations") public class TestDBConfigurations { private List dbTypesList; - @XmlElement(name = "DBType") + @XmlElement(name = "Type") public List getDbTypesList() { return dbTypesList; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java index 1d62d1b78..070b3c7b5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/MobileFeatureDAOTestSuite.java @@ -112,12 +112,16 @@ public class MobileFeatureDAOTestSuite { } private void createH2DB(TestDBConfiguration testDBConf) throws Exception { - Class.forName(testDBConf.getDriverClassName()); - conn = DriverManager.getConnection(testDBConf.getConnectionURL()); - stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); - stmt.close(); - conn.close(); + try { + Class.forName(testDBConf.getDriverClassName()); + conn = DriverManager.getConnection(testDBConf.getConnectionURL()); + stmt = conn.createStatement(); + stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); + } finally { + stmt.close(); + conn.close(); + TestUtils.cleanupResources(conn, stmt, null); + } } @Test