Repository: incubator-edgent
Updated Branches:
  refs/heads/master 2907150c5 -> 4c293470c


[Edgent-227] skip testSsl if can't connect to test.mosquitto.org

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

Branch: refs/heads/master
Commit: c1823274171c983341eab28d5b3df83c48dbd6db
Parents: ec6ccb2
Author: Dale LaBossiere <dlab...@us.ibm.com>
Authored: Tue Feb 28 14:41:17 2017 -0500
Committer: Dale LaBossiere <dlab...@us.ibm.com>
Committed: Tue Feb 28 14:43:48 2017 -0500

----------------------------------------------------------------------
 .../test/connectors/mqtt/MqttOpenTest.java      | 23 ++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/c1823274/connectors/mqtt/src/test/java/org/apache/edgent/test/connectors/mqtt/MqttOpenTest.java
----------------------------------------------------------------------
diff --git 
a/connectors/mqtt/src/test/java/org/apache/edgent/test/connectors/mqtt/MqttOpenTest.java
 
b/connectors/mqtt/src/test/java/org/apache/edgent/test/connectors/mqtt/MqttOpenTest.java
index 63e8274..fd1d894 100644
--- 
a/connectors/mqtt/src/test/java/org/apache/edgent/test/connectors/mqtt/MqttOpenTest.java
+++ 
b/connectors/mqtt/src/test/java/org/apache/edgent/test/connectors/mqtt/MqttOpenTest.java
@@ -53,6 +53,19 @@ public class MqttOpenTest extends MqttStreamsTestManual {
         }
     }
     
+    boolean isSslConnectionOK() {
+      try {
+          URI uri = new URI(getSslServerURI());
+          Socket s = new Socket(uri.getHost(), uri.getPort());
+          s.close();
+          return true;
+      } catch (Exception e) {
+          System.err.println("Unable to connect to MQTT broker 
"+getSslServerURI()+" : "+e.getMessage());
+          // e.printStackTrace();
+          return false;
+      }
+    }
+    
     protected String[] getMqttTopics() {
         String[] topics = super.getMqttTopics();
         for (int i =0 ; i < topics.length; i++) {
@@ -84,9 +97,11 @@ public class MqttOpenTest extends MqttStreamsTestManual {
     @Ignore
     public void testSslClientAuth() {} // we don't have a mosquitto.org 
generated client cert
     
-    // [EDGENT-227] ssl://test.mosquitto.org:8883 is yielding "Connection 
refused"
-    // skip this until we can figure things out
-    @Ignore
-    public void testSsl() {}
+    public void testSsl() {
+      if (!isSslConnectionOK()) {
+        System.err.println("Skipping testSsl()");
+        assumeTrue(false);
+      }
+    }
 
 }

Reply via email to