You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/12/08 16:18:09 UTC

[26/50] [abbrv] stratos git commit: Adding setUp() and having individual test methods for cep and das in ThriftStatisticsPublisherTest

Adding setUp() and having individual test methods for cep and das in  ThriftStatisticsPublisherTest


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/64f05a51
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/64f05a51
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/64f05a51

Branch: refs/heads/master
Commit: 64f05a5196d7e77880945f74a288480d3f1f20d4
Parents: 5435bff
Author: Thanuja <th...@wso2.com>
Authored: Mon Nov 30 17:06:50 2015 +0530
Committer: gayangunarathne <ga...@wso2.com>
Committed: Tue Dec 1 08:57:55 2015 +0530

----------------------------------------------------------------------
 .../test/ThriftStatisticsPublisherTest.java     | 32 +++++++++++++-------
 1 file changed, 21 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/64f05a51/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftStatisticsPublisherTest.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftStatisticsPublisherTest.java b/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftStatisticsPublisherTest.java
index 43cd4c1..c553b1c 100644
--- a/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftStatisticsPublisherTest.java
+++ b/components/org.apache.stratos.common/src/test/java/org/apache/stratos/common/test/ThriftStatisticsPublisherTest.java
@@ -21,8 +21,10 @@ package org.apache.stratos.common.test;
 
 import org.apache.stratos.common.statistics.publisher.ThriftClientConfig;
 import org.apache.stratos.common.statistics.publisher.ThriftStatisticsPublisher;
+import org.junit.Before;
 import org.junit.Test;
 import org.wso2.carbon.databridge.commons.StreamDefinition;
+import org.wso2.carbon.databridge.commons.exception.MalformedStreamDefinitionException;
 
 import java.net.URL;
 
@@ -32,29 +34,37 @@ import static org.junit.Assert.assertEquals;
  * ThriftStatisticsPublisherTest
  */
 public class ThriftStatisticsPublisherTest {
-    /**
-     * Checking whether LoadBalancingDataPublisher is created for cep and das according to thrift-client-config.xml
-     *
-     * @throws Exception
-     */
-    @Test
-    public void createLoadBalancingDataPublisher() throws Exception {
+    private StreamDefinition streamDefinition;
+    private ThriftStatisticsPublisher thriftStatisticsPublisher;
+
+    @Before
+    public void setUp() throws MalformedStreamDefinitionException {
         URL configFileUrl = ThriftClientConfigParserTest.class.getResource("/thrift-client-config.xml");
         System.setProperty(ThriftClientConfig.THRIFT_CLIENT_CONFIG_FILE_PATH, configFileUrl.getPath());
+        streamDefinition = new StreamDefinition("Test", "1.0.0");
+    }
 
-        StreamDefinition streamDefinition = new StreamDefinition("Test", "1.0.0");
-
-        ThriftStatisticsPublisher thriftStatisticsPublisher = new ThriftStatisticsPublisher(streamDefinition,
+    /**
+     * Checking whether LoadBalancingDataPublisher is created for cep according to thrift-client-config.xml
+     */
+    @Test
+    public void createCEPLoadBalancingDataPublisher() {
+        thriftStatisticsPublisher = new ThriftStatisticsPublisher(streamDefinition,
                 ThriftClientConfig.CEP_THRIFT_CLIENT_NAME);
         assertEquals("CEP stats publisher is not enabled", true, thriftStatisticsPublisher.isEnabled());
         assertEquals("No of CEP nodes enabled for stats publishing is not equal to two", 2,
                 thriftStatisticsPublisher.getDataPublisherHolders().size());
+    }
 
+    /**
+     * Checking whether LoadBalancingDataPublisher is created for das according to thrift-client-config.xml
+     */
+    @Test
+    public void createDASLoadBalancingDataPublisher() {
         thriftStatisticsPublisher = new ThriftStatisticsPublisher(streamDefinition,
                 ThriftClientConfig.DAS_THRIFT_CLIENT_NAME);
         assertEquals("DAS stats publisher is not enabled", true, thriftStatisticsPublisher.isEnabled());
         assertEquals("More than one DAS node is enabled for stats publishing", 1,
                 thriftStatisticsPublisher.getDataPublisherHolders().size());
-
     }
 }