From f2943f956c1b9664c4b0aa40c15507c8b3c0d756 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 10 Oct 2017 22:07:01 +0530 Subject: [PATCH 1/3] adding depends on methods to test case to make sure the execution order. --- .../data/publisher/DataPublisherConfigTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java index 24dbbdfa5ce..19cc27539e4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java @@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.analytics.data.publisher.config.InvalidConfigu import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import java.io.File; +import java.lang.reflect.Field; import java.net.URL; /** @@ -33,12 +34,13 @@ public class DataPublisherConfigTest extends BaseAnalyticsDataPublisherTest { @Test(description = "Validating the behaviour od getInstance of the config before calling the init", expectedExceptions = InvalidConfigurationStateException.class) - public void testGetInstanceWithoutInit() { + public void testGetInstanceWithoutInit() throws NoSuchFieldException, IllegalAccessException { AnalyticsConfiguration.getInstance(); } @Test(description = "Validating the behaviour od getInstance of the config before calling the init", - expectedExceptions = DataPublisherConfigurationException.class) + expectedExceptions = DataPublisherConfigurationException.class, + dependsOnMethods = "testGetInstanceWithoutInit") public void testInitWithInvalidConfig() throws DataPublisherConfigurationException { ClassLoader classLoader = this.getClass().getClassLoader(); URL invalidConfig = classLoader.getResource("carbon-home/repository/conf/etc/" + @@ -51,7 +53,8 @@ public class DataPublisherConfigTest extends BaseAnalyticsDataPublisherTest { @Test(description = "Validating the behaviour od getInstance of the config before calling the init", - expectedExceptions = DataPublisherConfigurationException.class) + expectedExceptions = DataPublisherConfigurationException.class, + dependsOnMethods = "testInitWithInvalidConfig") public void testInitWithInvalidXML() throws DataPublisherConfigurationException { ClassLoader classLoader = this.getClass().getClassLoader(); URL invalidConfig = classLoader.getResource("carbon-home/repository/conf/etc/" + @@ -63,7 +66,8 @@ public class DataPublisherConfigTest extends BaseAnalyticsDataPublisherTest { } - @Test(description = "Validating the init method with all required params", dependsOnMethods = "testInitWithInvalidXML") + @Test(description = "Validating the init method with all required params", + dependsOnMethods = "testInitWithInvalidXML") public void testInitWithValidConfig() throws DataPublisherConfigurationException { AnalyticsConfiguration.init(); AnalyticsConfiguration analyticsConfiguration = AnalyticsConfiguration.getInstance(); From bbdc8763116387a1a95c91d63481c02ab66674f5 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 10 Oct 2017 22:07:55 +0530 Subject: [PATCH 2/3] Removing unused import. --- .../mgt/analytics/data/publisher/DataPublisherConfigTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java index 19cc27539e4..cc94f1597f7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java @@ -24,7 +24,6 @@ import org.wso2.carbon.device.mgt.analytics.data.publisher.config.InvalidConfigu import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException; import java.io.File; -import java.lang.reflect.Field; import java.net.URL; /** From a5c222866487fe2b971afaec1784358040e7f7c2 Mon Sep 17 00:00:00 2001 From: sinthuja Date: Tue, 10 Oct 2017 22:09:46 +0530 Subject: [PATCH 3/3] removing unnecessary exceptions from testcase method. --- .../mgt/analytics/data/publisher/DataPublisherConfigTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java index cc94f1597f7..da1a4436768 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/test/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DataPublisherConfigTest.java @@ -33,7 +33,7 @@ public class DataPublisherConfigTest extends BaseAnalyticsDataPublisherTest { @Test(description = "Validating the behaviour od getInstance of the config before calling the init", expectedExceptions = InvalidConfigurationStateException.class) - public void testGetInstanceWithoutInit() throws NoSuchFieldException, IllegalAccessException { + public void testGetInstanceWithoutInit() { AnalyticsConfiguration.getInstance(); }