From 733ae8ed10c7225502f66d43780bf5cc7ca02caa Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 26 Jan 2015 23:57:06 +0530 Subject: [PATCH] Adding proper dependency exclusions to poms, making MobileFeatureDAOTestSuite use jdbc pooling instead of dbcp and making testdbconfig.xml to be compliant with platform naming standards --- .../pom.xml | 12 +- .../impl/common/TestDBConfiguration.java | 70 +-- .../impl/dao/MobileFeatureDAOTestSuite.java | 423 +++++++++--------- .../src/test/resources/testdbconfig.xml | 16 +- pom.xml | 272 ++++++++++- 5 files changed, 529 insertions(+), 264 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 5180e45ed2..85d7f17e05 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 @@ -90,8 +90,8 @@ org.eclipse.osgi - org.eclipse.equinox - org.eclipse.equinox.common + org.wso2.carbon + org.wso2.carbon.core org.wso2.carbon @@ -111,16 +111,20 @@ org.wso2.carbon - org.wso2.carbon.apimgt.impl + org.wso2.carbon.apimgt.api org.wso2.carbon - org.wso2.carbon.apimgt.core + org.wso2.carbon.apimgt.impl org.testng testng + + org.apache.tomcat.wso2 + jdbc-pool + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java index 3b40007e3e..d4c74ac498 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java @@ -22,69 +22,69 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name = "DBType") +@XmlRootElement(name = "Type") public class TestDBConfiguration { - private String connectionUrl; - private String driverClass; - private String userName; - private String pwd; + private String connectionURL; + private String driverClassName; + private String username; + private String password; @Override public String toString() { - return "TestDBConfiguration{" + - "connectionUrl='" + connectionUrl + '\'' + - ", driverClass='" + driverClass + '\'' + - ", userName='" + userName + '\'' + - ", pwd='" + pwd + '\'' + - ", dbType='" + dbType + '\'' + + return "TestDataSourceConfiguration{" + + "ConnectionURL='" + connectionURL + '\'' + + ", DriverClassName='" + driverClassName + '\'' + + ", Username='" + username + '\'' + + ", Password='" + password + '\'' + + ", Type='" + dbType + '\'' + '}'; } private String dbType; - @XmlElement(name = "connectionurl", nillable = false) - public String getConnectionUrl() { - return connectionUrl; + @XmlElement(name = "ConnectionURL", nillable = false) + public String getConnectionURL() { + return connectionURL; } - public void setConnectionUrl(String connectionUrl) { - this.connectionUrl = connectionUrl; + public void setConnectionURL(String connectionURL) { + this.connectionURL = connectionURL; } - @XmlElement(name = "driverclass", nillable = false) - public String getDriverClass() { - return driverClass; + @XmlElement(name = "DriverClassName", nillable = false) + public String getDriverClassName() { + return driverClassName; } - public void setDriverClass(String driverClass) { - this.driverClass = driverClass; + public void setDriverClassName(String driverClassName) { + this.driverClassName = driverClassName; } - @XmlElement(name = "userName", nillable = false) - public String getUserName() { - return userName; + @XmlElement(name = "Username", nillable = false) + public String getUsername() { + return username; } - public void setUserName(String userName) { - this.userName = userName; + public void setUsername(String username) { + this.username = username; } - @XmlElement(name = "pwd", nillable = false) - public String getPwd() { - return pwd; + @XmlElement(name = "Password", nillable = false) + public String getPassword() { + return password; } - public void setPwd(String pwd) { - this.pwd = pwd; + public void setPassword(String password) { + this.password = password; } - @XmlAttribute(name = "typeName") - public String getDbType() { + @XmlAttribute(name = "name") + public String getType() { return dbType; } - public void setDbType(String dbType) { - this.dbType = dbType; + public void setType(String type) { + this.dbType = type; } } 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 0f94b06a7d..1d62d1b78a 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 @@ -18,9 +18,9 @@ package org.wso2.carbon.device.mgt.mobile.impl.dao; -import org.apache.commons.dbcp.BasicDataSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.tomcat.jdbc.pool.PoolProperties; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Parameters; @@ -36,6 +36,7 @@ import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration; import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations; import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; +import javax.sql.DataSource; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; @@ -46,237 +47,237 @@ import java.util.List; public class MobileFeatureDAOTestSuite { - private static final Log log = LogFactory.getLog(MobileFeatureDAOTestSuite.class); - public static final String MBL_FEATURE_NAME = "Camera"; - private static final String MBL_FEATURE_CODE = "500A"; - public static final String MBL_FEATURE_DESCRIPTION = "Camera enable or disable"; - public static final String MBL_FEATURE_UPDATED_CODE = "501B"; - private TestDBConfiguration testDBConfiguration; - private Connection conn = null; - private Statement stmt = null; - private MobileFeatureDAOImpl mblFeatureDAO; - private int mblFeatureId; + private static final Log log = LogFactory.getLog(MobileFeatureDAOTestSuite.class); + public static final String MBL_FEATURE_NAME = "Camera"; + private static final String MBL_FEATURE_CODE = "500A"; + public static final String MBL_FEATURE_DESCRIPTION = "Camera enable or disable"; + public static final String MBL_FEATURE_UPDATED_CODE = "501B"; + private TestDBConfiguration testDBConfiguration; + private Connection conn = null; + private Statement stmt = null; + private MobileFeatureDAOImpl mblFeatureDAO; + private int mblFeatureId; - @BeforeClass - @Parameters("dbType") - public void setUpDB(String dbTypeStr) throws Exception { + @BeforeClass + @Parameters("dbType") + public void setUpDB(String dbTypeStr) throws Exception { - DBTypes dbType = DBTypes.valueOf(dbTypeStr); - testDBConfiguration = getTestDBConfiguration(dbType); + DBTypes dbType = DBTypes.valueOf(dbTypeStr); + testDBConfiguration = getTestDBConfiguration(dbType); - switch (dbType) { - case H2: - createH2DB(testDBConfiguration); - BasicDataSource testDataSource = new BasicDataSource(); - testDataSource.setDriverClassName(testDBConfiguration.getDriverClass()); - testDataSource.setUrl(testDBConfiguration.getConnectionUrl()); - testDataSource.setUsername(testDBConfiguration.getUserName()); - testDataSource.setPassword(testDBConfiguration.getPwd()); - mblFeatureDAO = new MobileFeatureDAOImpl(testDataSource); - default: - } - } + switch (dbType) { + case H2: + createH2DB(testDBConfiguration); + DataSource testDataSource = new org.apache.tomcat.jdbc.pool.DataSource(); + PoolProperties properties = new PoolProperties(); + properties.setUrl(testDBConfiguration.getConnectionURL()); + properties.setDriverClassName(testDBConfiguration.getDriverClassName()); + properties.setUsername(testDBConfiguration.getUsername()); + properties.setPassword(testDBConfiguration.getPassword()); + mblFeatureDAO = new MobileFeatureDAOImpl(testDataSource); + default: + } + } - private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws - MobileDeviceManagementDAOException, - DeviceManagementException { + private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws + MobileDeviceManagementDAOException, + DeviceManagementException { - File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml"); - Document doc = null; - testDBConfiguration = null; - TestDBConfigurations testDBConfigurations = null; + File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml"); + Document doc = null; + testDBConfiguration = null; + TestDBConfigurations testDBConfigurations = null; - doc = MobileDeviceManagementUtil.convertToDocument(deviceMgtConfig); - JAXBContext testDBContext = null; + doc = MobileDeviceManagementUtil.convertToDocument(deviceMgtConfig); + JAXBContext testDBContext = null; - try { - testDBContext = JAXBContext.newInstance(TestDBConfigurations.class); - Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); - testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc); - } catch (JAXBException e) { - throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e); - } + try { + testDBContext = JAXBContext.newInstance(TestDBConfigurations.class); + Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); + testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc); + } catch (JAXBException e) { + throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e); + } - Iterator itrDBConfigs = - testDBConfigurations.getDbTypesList().iterator(); - while (itrDBConfigs.hasNext()) { - testDBConfiguration = itrDBConfigs.next(); - if (testDBConfiguration.getDbType().equals(dbType.toString())) { - break; - } - } + Iterator itrDBConfigs = + testDBConfigurations.getDbTypesList().iterator(); + while (itrDBConfigs.hasNext()) { + testDBConfiguration = itrDBConfigs.next(); + if (testDBConfiguration.getType().equals(dbType.toString())) { + break; + } + } - return testDBConfiguration; - } + return testDBConfiguration; + } - private void createH2DB(TestDBConfiguration testDBConf) throws Exception { - Class.forName(testDBConf.getDriverClass()); - conn = DriverManager.getConnection(testDBConf.getConnectionUrl()); - stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'"); - stmt.close(); - conn.close(); - } + 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(); + } - @Test - public void addMobileFeatureTest() - throws MobileDeviceManagementDAOException { + @Test + public void addMobileFeatureTest() + throws MobileDeviceManagementDAOException { - MobileFeature mobileFeature = new MobileFeature(); - MobileFeature testMblFeature = new MobileFeature(); - mobileFeature.setCode(MBL_FEATURE_CODE); - mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION); - mobileFeature.setName(MBL_FEATURE_NAME); - boolean added = mblFeatureDAO.addMobileFeature(mobileFeature); - try { - conn = DriverManager.getConnection(testDBConfiguration.getConnectionUrl()); - stmt = conn.createStatement(); - ResultSet resultSet = stmt - .executeQuery( - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = '500A'"); - while (resultSet.next()) { - testMblFeature.setId(resultSet.getInt(1)); - testMblFeature.setCode(resultSet.getString(2)); - testMblFeature.setName(resultSet.getString(3)); - testMblFeature.setDescription(resultSet.getString(4)); - } - conn.close(); - } catch (SQLException e) { - log.error("Error in retrieving Mobile Feature data ", e); - throw new MobileDeviceManagementDAOException("Error in retrieving Mobile Feature data ", - e); - } finally { - TestUtils.cleanupResources(conn, stmt, null); - } - mblFeatureId = testMblFeature.getId(); - Assert.assertTrue(added, "MobileFeature is added"); - Assert.assertEquals(MBL_FEATURE_CODE, testMblFeature.getCode(), - "MobileFeature code has persisted successfully"); - Assert.assertEquals(MBL_FEATURE_NAME, testMblFeature.getName(), - "MobileFeature name has persisted successfully"); - Assert.assertEquals(MBL_FEATURE_DESCRIPTION, testMblFeature.getDescription(), - "MobileFeature description has persisted successfully"); - } + MobileFeature mobileFeature = new MobileFeature(); + MobileFeature testMblFeature = new MobileFeature(); + mobileFeature.setCode(MBL_FEATURE_CODE); + mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION); + mobileFeature.setName(MBL_FEATURE_NAME); + boolean added = mblFeatureDAO.addMobileFeature(mobileFeature); + try { + conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); + stmt = conn.createStatement(); + ResultSet resultSet = stmt + .executeQuery( + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = '500A'"); + while (resultSet.next()) { + testMblFeature.setId(resultSet.getInt(1)); + testMblFeature.setCode(resultSet.getString(2)); + testMblFeature.setName(resultSet.getString(3)); + testMblFeature.setDescription(resultSet.getString(4)); + } + conn.close(); + } catch (SQLException e) { + log.error("Error in retrieving Mobile Feature data ", e); + throw new MobileDeviceManagementDAOException("Error in retrieving Mobile Feature data ", + e); + } finally { + TestUtils.cleanupResources(conn, stmt, null); + } + mblFeatureId = testMblFeature.getId(); + Assert.assertTrue(added, "MobileFeature is added"); + Assert.assertEquals(MBL_FEATURE_CODE, testMblFeature.getCode(), + "MobileFeature code has persisted successfully"); + Assert.assertEquals(MBL_FEATURE_NAME, testMblFeature.getName(), + "MobileFeature name has persisted successfully"); + Assert.assertEquals(MBL_FEATURE_DESCRIPTION, testMblFeature.getDescription(), + "MobileFeature description has persisted successfully"); + } - @Test(dependsOnMethods = { "addMobileFeatureTest" }) - public void getMobileFeatureByCodeTest() - throws MobileDeviceManagementDAOException { + @Test(dependsOnMethods = {"addMobileFeatureTest"}) + public void getMobileFeatureByCodeTest() + throws MobileDeviceManagementDAOException { - MobileFeature mobileFeature = mblFeatureDAO.getMobileFeatureByCode(MBL_FEATURE_CODE); - Assert.assertEquals(MBL_FEATURE_CODE, mobileFeature.getCode(), - "MobileFeature code has retrieved successfully"); - Assert.assertEquals(MBL_FEATURE_NAME, mobileFeature.getName(), - "MobileFeature name has retrieved successfully"); - Assert.assertEquals(MBL_FEATURE_DESCRIPTION, mobileFeature.getDescription(), - "MobileFeature description has retrieved successfully"); - } + MobileFeature mobileFeature = mblFeatureDAO.getMobileFeatureByCode(MBL_FEATURE_CODE); + Assert.assertEquals(MBL_FEATURE_CODE, mobileFeature.getCode(), + "MobileFeature code has retrieved successfully"); + Assert.assertEquals(MBL_FEATURE_NAME, mobileFeature.getName(), + "MobileFeature name has retrieved successfully"); + Assert.assertEquals(MBL_FEATURE_DESCRIPTION, mobileFeature.getDescription(), + "MobileFeature description has retrieved successfully"); + } - @Test(dependsOnMethods = { "addMobileFeatureTest" }) - public void deleteMobileFeatureByCodeTest() - throws MobileDeviceManagementDAOException { - boolean status = mblFeatureDAO.deleteMobileFeatureByCode(MBL_FEATURE_CODE); - try { - conn = DriverManager.getConnection(testDBConfiguration.getConnectionUrl()); - stmt = conn.createStatement(); - ResultSet resultSet = stmt - .executeQuery( - "SELECT FEATURE_ID, CODE FROM MBL_FEATURE WHERE CODE = '500A'"); - while (resultSet.next()) { - status = false; - } - conn.close(); - } catch (SQLException e) { - log.error("Error in deleting Mobile Feature data ", e); - throw new MobileDeviceManagementDAOException("Error in deleting Mobile Feature data ", - e); - } finally { - TestUtils.cleanupResources(conn, stmt, null); - } - Assert.assertTrue(status, "MobileFeature has deleted successfully"); - } + @Test(dependsOnMethods = {"addMobileFeatureTest"}) + public void deleteMobileFeatureByCodeTest() + throws MobileDeviceManagementDAOException { + boolean status = mblFeatureDAO.deleteMobileFeatureByCode(MBL_FEATURE_CODE); + try { + conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); + stmt = conn.createStatement(); + ResultSet resultSet = stmt + .executeQuery( + "SELECT FEATURE_ID, CODE FROM MBL_FEATURE WHERE CODE = '500A'"); + while (resultSet.next()) { + status = false; + } + conn.close(); + } catch (SQLException e) { + log.error("Error in deleting Mobile Feature data ", e); + throw new MobileDeviceManagementDAOException("Error in deleting Mobile Feature data ", + e); + } finally { + TestUtils.cleanupResources(conn, stmt, null); + } + Assert.assertTrue(status, "MobileFeature has deleted successfully"); + } - @Test(dependsOnMethods = { "addMobileFeatureTest" }) - public void getMobileFeatureByIdTest() - throws MobileDeviceManagementDAOException { + @Test(dependsOnMethods = {"addMobileFeatureTest"}) + public void getMobileFeatureByIdTest() + throws MobileDeviceManagementDAOException { - MobileFeature mobileFeature = mblFeatureDAO.getMobileFeatureById(mblFeatureId); - Assert.assertEquals(MBL_FEATURE_CODE, mobileFeature.getCode(), - "MobileFeature code has retrieved successfully"); - Assert.assertEquals(MBL_FEATURE_NAME, mobileFeature.getName(), - "MobileFeature name has retrieved successfully"); - Assert.assertEquals(MBL_FEATURE_DESCRIPTION, mobileFeature.getDescription(), - "MobileFeature description has retrieved successfully"); - } + MobileFeature mobileFeature = mblFeatureDAO.getMobileFeatureById(mblFeatureId); + Assert.assertEquals(MBL_FEATURE_CODE, mobileFeature.getCode(), + "MobileFeature code has retrieved successfully"); + Assert.assertEquals(MBL_FEATURE_NAME, mobileFeature.getName(), + "MobileFeature name has retrieved successfully"); + Assert.assertEquals(MBL_FEATURE_DESCRIPTION, mobileFeature.getDescription(), + "MobileFeature description has retrieved successfully"); + } - @Test(dependsOnMethods = { "addMobileFeatureTest" }) - public void getAllMobileFeaturesTest() - throws MobileDeviceManagementDAOException { + @Test(dependsOnMethods = {"addMobileFeatureTest"}) + public void getAllMobileFeaturesTest() + throws MobileDeviceManagementDAOException { - List mobileFeatures = mblFeatureDAO.getAllMobileFeatures(); - Assert.assertNotNull(mobileFeatures, "MobileFeature list is not null"); - Assert.assertTrue(mobileFeatures.size() > 0, "MobileFeature list has 1 MobileFeature"); - } + List mobileFeatures = mblFeatureDAO.getAllMobileFeatures(); + Assert.assertNotNull(mobileFeatures, "MobileFeature list is not null"); + Assert.assertTrue(mobileFeatures.size() > 0, "MobileFeature list has 1 MobileFeature"); + } - @Test(dependsOnMethods = { "addMobileFeatureTest" }) - public void deleteMobileFeatureByIdTest() - throws MobileDeviceManagementDAOException { - boolean status = mblFeatureDAO.deleteMobileFeatureById(mblFeatureId); - try { - conn = DriverManager.getConnection(testDBConfiguration.getConnectionUrl()); - stmt = conn.createStatement(); - ResultSet resultSet = stmt - .executeQuery( - "SELECT FEATURE_ID, CODE FROM MBL_FEATURE WHERE FEATURE_ID = " + - mblFeatureId); - while (resultSet.next()) { - status = false; - } - conn.close(); - } catch (SQLException e) { - log.error("Error in deleting Mobile Feature data ", e); - throw new MobileDeviceManagementDAOException("Error in deleting Mobile Feature data ", - e); - } finally { - TestUtils.cleanupResources(conn, stmt, null); - } - Assert.assertTrue(status, "MobileFeature has deleted successfully"); - } + @Test(dependsOnMethods = {"addMobileFeatureTest"}) + public void deleteMobileFeatureByIdTest() + throws MobileDeviceManagementDAOException { + boolean status = mblFeatureDAO.deleteMobileFeatureById(mblFeatureId); + try { + conn = DriverManager.getConnection(testDBConfiguration.getConnectionURL()); + ResultSet resultSet = stmt + .executeQuery( + "SELECT FEATURE_ID, CODE FROM MBL_FEATURE WHERE FEATURE_ID = " + + mblFeatureId); + while (resultSet.next()) { + status = false; + } + conn.close(); + } catch (SQLException e) { + log.error("Error in deleting Mobile Feature data ", e); + throw new MobileDeviceManagementDAOException("Error in deleting Mobile Feature data ", + e); + } finally { + TestUtils.cleanupResources(conn, stmt, null); + } + Assert.assertTrue(status, "MobileFeature has deleted successfully"); + } - @Test(dependsOnMethods = { "deleteMobileFeatureByCodeTest", "addMobileFeatureTest" }) - public void updateMobileFeatureTest() - throws MobileDeviceManagementDAOException { + @Test(dependsOnMethods = {"deleteMobileFeatureByCodeTest", "addMobileFeatureTest"}) + public void updateMobileFeatureTest() + throws MobileDeviceManagementDAOException { - MobileFeature mobileFeature = new MobileFeature(); - MobileFeature testMblFeature = new MobileFeature(); - mobileFeature.setCode(MBL_FEATURE_UPDATED_CODE); - mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION); - mobileFeature.setName(MBL_FEATURE_NAME); - mobileFeature.setId(mblFeatureId); - boolean updated = mblFeatureDAO.updateMobileFeature(mobileFeature); - try { - conn = DriverManager.getConnection(testDBConfiguration.getConnectionUrl()); - stmt = conn.createStatement(); - ResultSet resultSet = stmt - .executeQuery( - "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = '" + - MBL_FEATURE_UPDATED_CODE + "'"); - while (resultSet.next()) { - testMblFeature.setId(resultSet.getInt(1)); - testMblFeature.setCode(resultSet.getString(2)); - testMblFeature.setName(resultSet.getString(3)); - testMblFeature.setDescription(resultSet.getString(4)); - } - conn.close(); - } catch (SQLException e) { - log.error("Error in updating Mobile Feature data ", e); - throw new MobileDeviceManagementDAOException("Error in updating Mobile Feature data ", - e); - } finally { - TestUtils.cleanupResources(conn, stmt, null); - } - Assert.assertTrue(updated, "MobileFeature has updated"); - Assert.assertEquals(MBL_FEATURE_UPDATED_CODE, testMblFeature.getCode(), - "MobileFeature data has updated successfully"); - } + MobileFeature mobileFeature = new MobileFeature(); + MobileFeature testMblFeature = new MobileFeature(); + mobileFeature.setCode(MBL_FEATURE_UPDATED_CODE); + mobileFeature.setDescription(MBL_FEATURE_DESCRIPTION); + mobileFeature.setName(MBL_FEATURE_NAME); + mobileFeature.setId(mblFeatureId); + boolean updated = mblFeatureDAO.updateMobileFeature(mobileFeature); + try { + conn = DriverManager.getConnection(testDBConfiguration.getDriverClassName()); + stmt = conn.createStatement(); + ResultSet resultSet = stmt + .executeQuery( + "SELECT FEATURE_ID, CODE, NAME, DESCRIPTION FROM MBL_FEATURE WHERE CODE = '" + + MBL_FEATURE_UPDATED_CODE + "'"); + while (resultSet.next()) { + testMblFeature.setId(resultSet.getInt(1)); + testMblFeature.setCode(resultSet.getString(2)); + testMblFeature.setName(resultSet.getString(3)); + testMblFeature.setDescription(resultSet.getString(4)); + } + conn.close(); + } catch (SQLException e) { + log.error("Error in updating Mobile Feature data ", e); + throw new MobileDeviceManagementDAOException("Error in updating Mobile Feature data ", + e); + } finally { + TestUtils.cleanupResources(conn, stmt, null); + } + Assert.assertTrue(updated, "MobileFeature has updated"); + Assert.assertEquals(MBL_FEATURE_UPDATED_CODE, testMblFeature.getCode(), + "MobileFeature data has updated successfully"); + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testdbconfig.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testdbconfig.xml index d28ebbf8c5..eee04a3245 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testdbconfig.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/test/resources/testdbconfig.xml @@ -14,11 +14,11 @@ ~ under the License. --> - - - jdbc:h2:mem:cdm-mobile-test-db;DB_CLOSE_DELAY=-1 - org.h2.Driver - - - - + + + jdbc:h2:mem:cdm-mobile-test-db;DB_CLOSE_DELAY=-1 + org.h2.Driver + + + + diff --git a/pom.xml b/pom.xml index 114eda3ab6..530e718410 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,6 @@ product - @@ -75,7 +74,6 @@ ${stub.version} test - org.wso2.carbon org.wso2.carbon.user.core @@ -96,6 +94,20 @@ org.wso2.carbon org.wso2.carbon.logging ${carbon.kernel.version} + + + org.apache.log4j.wso2 + log4j + + + commons-logging + commons-logging + + + org.wso2.carbon + org.wso2.carbon.bootstrap + + org.wso2.carbon @@ -125,7 +137,6 @@ ${cdm.core.version} - org.eclipse.osgi @@ -137,21 +148,142 @@ org.eclipse.equinox.common ${eclipse.equinox.common.version} - org.testng testng ${testng.version} + + + junit + junit + + + org.beanshell + bsh + + + org.yaml + snakeyaml + + org.wso2.carbon org.wso2.carbon.utils ${carbon.kernel.version} + + + org.bouncycastle.wso2 + bcprov-jdk15on + + + org.wso2.carbon + org.wso2.carbon.user.api + + + org.wso2.carbon + org.wso2.carbon.queuing + + + org.wso2.carbon + org.wso2.carbon.base + + + org.apache.axis2.wso2 + axis2 + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + + jaxen + jaxen + + + commons-fileupload.wso2 + commons-fileupload + + + org.apache.ant.wso2 + ant + + + org.apache.ant.wso2 + ant + + + commons-httpclient.wso2 + commons-httpclient + + + org.eclipse.equinox + javax.servlet + + + org.wso2.carbon + org.wso2.carbon.registry.api + + org.wso2.carbon org.wso2.carbon.core ${carbon.kernel.version} + + + org.wso2.carbon + org.wso2.carbon.registry.core + + + org.wso2.carbon + org.wso2.carbon.user.core + + + com.hazelcast.wso2 + hazelcast + + + org.bouncycastle.wso2 + bcprov-jdk15on + + + org.apache.tomcat + tomcat-catalina-ha + + + org.apache.httpcomponents.wso2 + httpcore + + + org.apache.neethi.wso2 + neethi + + + org.apache.axis2.wso2 + axis2 + + + commons-collections.wso2 + commons-collections + + + org.eclipse.equinox + org.eclipse.equinox.http.helper + + + org.wso2.carbon + javax.cache.wso2 + + + wsdl4j.wso2 + wsdl4j + + org.wso2.carbon @@ -177,11 +309,134 @@ org.wso2.carbon org.wso2.carbon.apimgt.core ${apim.version} + + + org.wso2.carbon + org.wso2.carbon.mediation.initializer + + + + + org.wso2.carbon + org.wso2.carbon.apimgt.api + ${apim.version} + + + com.googlecode.json-simple.wso2 + json-simple + + org.wso2.carbon org.wso2.carbon.apimgt.impl ${apim.version} + + + org.wso2.carbon + org.wso2.carbon.mediation.initializer + + + org.apache.woden.wso2 + woden + + + org.wso2.carbon + org.wso2.carbon.user.core + + + org.wso2.carbon + org.wso2.carbon.governance.api + + + org.wso2.carbon + org.wso2.carbon.registry.ws.client + + + org.wso2.carbon + org.wso2.carbon.identity.core + + + org.wso2.carbon + org.wso2.carbon.identity.oauth + + + org.wso2.carbon + org.wso2.carbon.apimgt.keymgt.client + + + org.apache.poi + poi-ooxml + + + org.wso2.carbon + org.wso2.carbon.rest.api.stub + + + org.json.wso2 + json + + + com.h2database.wso2 + h2-database-engine + + + org.wso2.carbon + org.wso2.carbon.apimgt.handlers.security.stub + + + org.wso2.carbon + org.wso2.carbon.user.mgt.stub + + + org.wso2.carbon + org.wso2.carbon.um.ws.api + + + org.wso2.carbon + org.wso2.carbon.mediation.dependency.mgt + + + com.google.code.gson + gson + + + org.wso2.carbon + org.wso2.carbon.mediation.registry + + + org.apache.httpcomponents + httpmime + + + org.wso2.carbon + org.wso2.carbon.event.core + + + org.wso2.carbon + org.wso2.carbon.sequences.stub + + + org.wso2.carbon + org.wso2.carbon.mediation.security.stub + + + org.wso2.carbon + org.wso2.carbon.registry.indexing + + + org.wso2.carbon + org.wso2.carbon.apimgt.keymgt.stub + + + org.wso2.carbon + org.wso2.carbon.securevault + + + com.googlecode.json-simple.wso2 + json-simple + + org.apache.tomcat.wso2 @@ -198,7 +453,11 @@ org.wso2.carbon.tomcat ${carbon.kernel.version} - + + org.apache.tomcat.wso2 + jdbc-pool + ${tomcat.jdbc.pooling.version} + @@ -240,8 +499,9 @@ 3.8.1.v20120830-144521 1.2.140.wso2v3 - 1.2.1 + 4.3.0-SNAPSHOT 7.0.52.wso2v5 + 7.0.34.wso2v2