You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2016/01/20 23:06:17 UTC

[04/18] storm git commit: use constants in integration test instead of duplicate strings

use constants in integration test instead of duplicate strings


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

Branch: refs/heads/1.x-branch
Commit: bd11b59ce3b46d1ccd2ccf5f94851ddf8ebafc21
Parents: 8910210
Author: P. Taylor Goetz <pt...@gmail.com>
Authored: Wed Jan 6 15:44:59 2016 -0500
Committer: P. Taylor Goetz <pt...@gmail.com>
Committed: Wed Jan 6 15:44:59 2016 -0500

----------------------------------------------------------------------
 .../apache/storm/mqtt/StormMqttIntegrationTest.java   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/bd11b59c/external/storm-mqtt/core/src/test/java/org/apache/storm/mqtt/StormMqttIntegrationTest.java
----------------------------------------------------------------------
diff --git a/external/storm-mqtt/core/src/test/java/org/apache/storm/mqtt/StormMqttIntegrationTest.java b/external/storm-mqtt/core/src/test/java/org/apache/storm/mqtt/StormMqttIntegrationTest.java
index 37a1cf5..f07ee6d 100644
--- a/external/storm-mqtt/core/src/test/java/org/apache/storm/mqtt/StormMqttIntegrationTest.java
+++ b/external/storm-mqtt/core/src/test/java/org/apache/storm/mqtt/StormMqttIntegrationTest.java
@@ -52,6 +52,10 @@ public class StormMqttIntegrationTest implements Serializable{
     private static BrokerService broker;
     static boolean spoutActivated = false;
 
+    private static final String TEST_TOPIC = "/mqtt-topology";
+    private static final String RESULT_TOPIC = "/integration-result";
+    private static final String RESULT_PAYLOAD = "Storm MQTT Spout";
+
     public static class TestSpout extends MqttSpout{
         public TestSpout(MqttMessageMapper type, MqttOptions options){
             super(type, options);
@@ -109,7 +113,7 @@ public class StormMqttIntegrationTest implements Serializable{
         options.setCleanConnection(false);
         MqttPublisher publisher = new MqttPublisher(options, true);
         publisher.connectMqtt("MqttPublisher");
-        publisher.publish(new MqttMessage("/mqtt-topology", "test".getBytes()));
+        publisher.publish(new MqttMessage(TEST_TOPIC, "test".getBytes()));
 
         LOG.info("published message");
 
@@ -118,8 +122,8 @@ public class StormMqttIntegrationTest implements Serializable{
         LOG.info("Payload: " + new String(message.getPayload()));
         message.ack();
 
-        Assert.assertArrayEquals(message.getPayload(), "hello mqtt".getBytes());
-        Assert.assertEquals(message.getTopic(), "/integration-result");
+        Assert.assertArrayEquals(message.getPayload(), RESULT_PAYLOAD.getBytes());
+        Assert.assertEquals(message.getTopic(), RESULT_TOPIC);
         cluster.shutdown();
     }
 
@@ -127,7 +131,7 @@ public class StormMqttIntegrationTest implements Serializable{
         TopologyBuilder builder = new TopologyBuilder();
 
         MqttOptions options = new MqttOptions();
-        options.setTopics(Arrays.asList("/mqtt-topology"));
+        options.setTopics(Arrays.asList(TEST_TOPIC));
         options.setCleanConnection(false);
         TestSpout spout = new TestSpout(new StringMessageMapper(), options);
 
@@ -135,7 +139,7 @@ public class StormMqttIntegrationTest implements Serializable{
             @Override
             public MqttMessage toMessage(ITuple tuple) {
                 LOG.info("Received: " + tuple);
-                return new MqttMessage("/integration-result", "hello mqtt".getBytes());
+                return new MqttMessage(RESULT_TOPIC, RESULT_PAYLOAD.getBytes());
             }
         });