From 635f84897d4413d550c6ac60ac6700e8bb518e1b Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 17 Oct 2017 10:22:03 +0530 Subject: [PATCH] Making datasource and isMock parameters as optional, and passing the default params. --- .../org.wso2.carbon.device.mgt.core/pom.xml | 2 +- .../mgt/core/common/BaseDeviceManagementTest.java | 5 ++++- .../mgt/core/dao/ApplicationPersistenceTests.java | 8 +++++--- .../src/test/resources/mysql-testng.xml | 13 +++++++------ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml index debf13870a..3690a99648 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/pom.xml @@ -139,7 +139,7 @@ file:src/test/resources/log4j.properties - + src/test/resources/testng.xml src/test/resources/mysql-testng.xml diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java index ed5bf573b0..b5565814b4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/common/BaseDeviceManagementTest.java @@ -24,6 +24,7 @@ import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.tomcat.jdbc.pool.PoolProperties; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Optional; import org.testng.annotations.Parameters; import org.w3c.dom.Document; import org.wso2.carbon.base.MultitenantConstants; @@ -68,7 +69,9 @@ public abstract class BaseDeviceManagementTest { @BeforeSuite @Parameters({"datasource", "isMock"}) - public void setupDataSource(String datasource, boolean isMock) throws Exception { + public void setupDataSource(@Optional("src/test/resources/config/datasource/data-source-config") String datasource, + @Optional("false") boolean isMock) + throws Exception { datasourceLocation = datasource; mock = isMock; this.initDataSource(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/ApplicationPersistenceTests.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/ApplicationPersistenceTests.java index 7d697ca6c7..9e45654444 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/ApplicationPersistenceTests.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/java/org/wso2/carbon/device/mgt/core/dao/ApplicationPersistenceTests.java @@ -56,9 +56,11 @@ public class ApplicationPersistenceTests extends BaseDeviceManagementTest { Assert.fail(msg, e); } - Assert.assertEquals(target.getApplicationIdentifier(), testAppIdentifier, "Application added is not as same as " + - "what's " + - "retrieved"); + if (!isMock()) { + Assert.assertEquals(target.getApplicationIdentifier(), testAppIdentifier, "Application added is not as same as " + + "what's " + + "retrieved"); + } } private Application getApplication(String appIdentifier, int tenantId) throws DeviceManagementDAOException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/mysql-testng.xml b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/mysql-testng.xml index b96e6007d9..13ec5feeeb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/mysql-testng.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/mysql-testng.xml @@ -31,15 +31,16 @@ - + - - - + + + + @@ -56,6 +57,6 @@ - - + +