{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/125396098","pull_request_review_id":47778573,"id":125396098,"diff_hunk":"@@ -0,0 +1,185 @@\n+/**\n+ * Copyright (c) 2014-2017 by the respective copyright holders.\n+ * All rights reserved. This program and the accompanying materials\n+ * are made available under the terms of the Eclipse Public License v1.0\n+ * which accompanies this distribution, and is available at\n+ * http://www.eclipse.org/legal/epl-v10.html\n+ */\n+package org.eclipse.smarthome.io.transport.mqtt.test;\n+\n+import static org.junit.Assert.*;\n+\n+import java.util.Arrays;\n+\n+import javax.naming.ConfigurationException;\n+\n+import org.eclipse.paho.client.mqttv3.MqttException;\n+import org.eclipse.smarthome.io.transport.mqtt.MqttBrokerConnection;\n+import org.eclipse.smarthome.io.transport.mqtt.MqttConnectionObserver;\n+import org.eclipse.smarthome.io.transport.mqtt.MqttMessageSubscriber;\n+import org.eclipse.smarthome.io.transport.mqtt.MqttWillAndTestament;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.mockito.MockitoAnnotations;\n+\n+/**\n+ * Tests the MqttBrokerConnection class\n+ *\n+ * @author David Graeff - Initial contribution\n+ */\n+public class MqttBrokerConnectionTests {\n+    boolean isConnected = true;\n+\n+    @Before\n+    public void setUp() {\n+        MockitoAnnotations.initMocks(this);\n+    }\n+\n+    @Test\n+    public void testConstructor() {\n+        // Test tcp and ssl URLs\n+        try {\n+            MqttBrokerConnection a = new MqttBrokerConnection(\"name\", \"tcp://123.123.123.123\", false);\n+            MqttBrokerConnection b = new MqttBrokerConnection(\"name\", \"ssl://123.123.123.123\", true);\n+            assertFalse(a.isTextualConfiguredBroker());\n+            assertTrue(b.isTextualConfiguredBroker());\n+        } catch (ConfigurationException e) {\n+            fail(\"Unexpected configuration exception: \" + e.getMessage());\n+        }\n+        // Test an invalid URL\n+        try {\n+            @SuppressWarnings(\"unused\")\n+            MqttBrokerConnection ignored = new MqttBrokerConnection(\"name\", \"unsupported://123.123.123.123\", false);","path":"bundles/io/org.eclipse.smarthome.io.transport.mqtt.test/src/test/java/org/eclipse/smarthome/io/transport/mqtt/test/MqttBrokerConnectionTests.java","position":52,"original_position":52,"commit_id":"3783cdf075d9fb22355bedb5dbf4033c324f0276","original_commit_id":"3783cdf075d9fb22355bedb5dbf4033c324f0276","user":{"login":"htreu","id":1729268,"avatar_url":"https://avatars1.githubusercontent.com/u/1729268?v=3","gravatar_id":"","url":"https://api.github.com/users/htreu","html_url":"https://github.com/htreu","followers_url":"https://api.github.com/users/htreu/followers","following_url":"https://api.github.com/users/htreu/following{/other_user}","gists_url":"https://api.github.com/users/htreu/gists{/gist_id}","starred_url":"https://api.github.com/users/htreu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htreu/subscriptions","organizations_url":"https://api.github.com/users/htreu/orgs","repos_url":"https://api.github.com/users/htreu/repos","events_url":"https://api.github.com/users/htreu/events{/privacy}","received_events_url":"https://api.github.com/users/htreu/received_events","type":"User","site_admin":false},"body":"I guess this is a matter of taste: I would prefer separate tests for these assertions. You may then shorten the test to something like\r\n\r\n```\r\n@Test(expected = ConfigurationException.class)\r\npublic void unsupportedProtocolShouldThrowException() throws Exception {\r\n    new MqttBrokerConnection(\"name\", \"unsupported://123.123.123.123\", false);\r\n}\r\n```","created_at":"2017-07-04T06:18:37Z","updated_at":"2017-07-04T06:46:48Z","html_url":"https://github.com/eclipse/smarthome/pull/3715#discussion_r125396098","pull_request_url":"https://api.github.com/repos/eclipse/smarthome/pulls/3715","_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/125396098"},"html":{"href":"https://github.com/eclipse/smarthome/pull/3715#discussion_r125396098"},"pull_request":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/3715"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/3715","id":126666054,"html_url":"https://github.com/eclipse/smarthome/pull/3715","diff_url":"https://github.com/eclipse/smarthome/pull/3715.diff","patch_url":"https://github.com/eclipse/smarthome/pull/3715.patch","issue_url":"https://api.github.com/repos/eclipse/smarthome/issues/3715","number":3715,"state":"open","locked":false,"title":"[RFC] Mqtt transport: Redesign the service to cover more usecases.","user":{"login":"davidgraeff","id":66436,"avatar_url":"https://avatars1.githubusercontent.com/u/66436?v=3","gravatar_id":"","url":"https://api.github.com/users/davidgraeff","html_url":"https://github.com/davidgraeff","followers_url":"https://api.github.com/users/davidgraeff/followers","following_url":"https://api.github.com/users/davidgraeff/following{/other_user}","gists_url":"https://api.github.com/users/davidgraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/davidgraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidgraeff/subscriptions","organizations_url":"https://api.github.com/users/davidgraeff/orgs","repos_url":"https://api.github.com/users/davidgraeff/repos","events_url":"https://api.github.com/users/davidgraeff/events{/privacy}","received_events_url":"https://api.github.com/users/davidgraeff/received_events","type":"User","site_admin":false},"body":"Fixes #3695 \r\nThis is a request for comments PR, discussion takes places in the linked issue.\r\n\r\n* This will keep the 'old' MqttService API untouched for full backwards compatibility.\r\n* MqttBrokerConnection is exported now.\r\n* Improve comments all over the code.\r\n\r\nMqttService:\r\n* Allows to add / remove / enumerate broker connections, additionally to the existing textual configuration.\r\n* A new interface allows listeners to be notified of added / removed broker connections.\r\n* All proxy methods are deprecated now. The MqttBrokerConnection can be accessed directly.\r\n* Add unit test\r\n\r\nMqttWillAndTestament:\r\n* Introduce an isValid() method and return false if the build method fromString is not provided with all necessary properties.\r\n\r\nMqttSenderChannel:\r\n* Is depreacted now. MqttBrokerConnection.publish() should be used instead.\r\n* The reason: The interface does not allow to implement an async behaviour, because the publisher can not be informed of the success/failure of the operation.\r\n\r\nMqttMessageConsumer:\r\n* is deprecated now and replaced by a slimer MqttMessageSubscriber interface without a forced setTopic and event method.  \r\n\r\nMqttBrokerConnection:\r\n* Reconnection is no longer handled via a fixed 60s interval timer, but fully customizable.\r\n  The default implementation (PeriodicReconnectPolicy) resembles the old behaviour.\r\n* A SSL broker connection no longer uses a non-configurable \"trust all and everything\" SSL context provider, but an interface that have to provide the SSL context provider. A default implementation, again, resembles the old behaviour.\r\n* Remove 'async' configuration option. All communication aspects (connect/disconnect/publish/subscribe) are handled in an async fashion now.\r\n* Add unit test\r\n\r\nSigned-off-by: David Gräff <david.graeff@web.de>","created_at":"2017-06-21T02:10:49Z","updated_at":"2017-07-04T06:46:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e4a6c78ad80aed40cf47782d4063e800a116c59","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/smarthome/pulls/3715/commits","review_comments_url":"https://api.github.com/repos/eclipse/smarthome/pulls/3715/comments","review_comment_url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/smarthome/issues/3715/comments","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/3783cdf075d9fb22355bedb5dbf4033c324f0276","head":{"label":"davidgraeff:mqtt_transport","ref":"mqtt_transport","sha":"3783cdf075d9fb22355bedb5dbf4033c324f0276","user":{"login":"davidgraeff","id":66436,"avatar_url":"https://avatars1.githubusercontent.com/u/66436?v=3","gravatar_id":"","url":"https://api.github.com/users/davidgraeff","html_url":"https://github.com/davidgraeff","followers_url":"https://api.github.com/users/davidgraeff/followers","following_url":"https://api.github.com/users/davidgraeff/following{/other_user}","gists_url":"https://api.github.com/users/davidgraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/davidgraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidgraeff/subscriptions","organizations_url":"https://api.github.com/users/davidgraeff/orgs","repos_url":"https://api.github.com/users/davidgraeff/repos","events_url":"https://api.github.com/users/davidgraeff/events{/privacy}","received_events_url":"https://api.github.com/users/davidgraeff/received_events","type":"User","site_admin":false},"repo":{"id":94952984,"name":"smarthome","full_name":"davidgraeff/smarthome","owner":{"login":"davidgraeff","id":66436,"avatar_url":"https://avatars1.githubusercontent.com/u/66436?v=3","gravatar_id":"","url":"https://api.github.com/users/davidgraeff","html_url":"https://github.com/davidgraeff","followers_url":"https://api.github.com/users/davidgraeff/followers","following_url":"https://api.github.com/users/davidgraeff/following{/other_user}","gists_url":"https://api.github.com/users/davidgraeff/gists{/gist_id}","starred_url":"https://api.github.com/users/davidgraeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidgraeff/subscriptions","organizations_url":"https://api.github.com/users/davidgraeff/orgs","repos_url":"https://api.github.com/users/davidgraeff/repos","events_url":"https://api.github.com/users/davidgraeff/events{/privacy}","received_events_url":"https://api.github.com/users/davidgraeff/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/davidgraeff/smarthome","description":"Eclipse SmartHome™ project","fork":true,"url":"https://api.github.com/repos/davidgraeff/smarthome","forks_url":"https://api.github.com/repos/davidgraeff/smarthome/forks","keys_url":"https://api.github.com/repos/davidgraeff/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davidgraeff/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davidgraeff/smarthome/teams","hooks_url":"https://api.github.com/repos/davidgraeff/smarthome/hooks","issue_events_url":"https://api.github.com/repos/davidgraeff/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/davidgraeff/smarthome/events","assignees_url":"https://api.github.com/repos/davidgraeff/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/davidgraeff/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/davidgraeff/smarthome/tags","blobs_url":"https://api.github.com/repos/davidgraeff/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davidgraeff/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davidgraeff/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/davidgraeff/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davidgraeff/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/davidgraeff/smarthome/languages","stargazers_url":"https://api.github.com/repos/davidgraeff/smarthome/stargazers","contributors_url":"https://api.github.com/repos/davidgraeff/smarthome/contributors","subscribers_url":"https://api.github.com/repos/davidgraeff/smarthome/subscribers","subscription_url":"https://api.github.com/repos/davidgraeff/smarthome/subscription","commits_url":"https://api.github.com/repos/davidgraeff/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/davidgraeff/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/davidgraeff/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/davidgraeff/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/davidgraeff/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/davidgraeff/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davidgraeff/smarthome/merges","archive_url":"https://api.github.com/repos/davidgraeff/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davidgraeff/smarthome/downloads","issues_url":"https://api.github.com/repos/davidgraeff/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/davidgraeff/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/davidgraeff/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/davidgraeff/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davidgraeff/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/davidgraeff/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/davidgraeff/smarthome/deployments","created_at":"2017-06-21T02:07:59Z","updated_at":"2017-06-21T02:08:09Z","pushed_at":"2017-07-03T17:49:23Z","git_url":"git://github.com/davidgraeff/smarthome.git","ssh_url":"git@github.com:davidgraeff/smarthome.git","clone_url":"https://github.com/davidgraeff/smarthome.git","svn_url":"https://github.com/davidgraeff/smarthome","homepage":"https://www.eclipse.org/smarthome/","size":33920,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"d3a24bf75d01ec0b4ff1c3ce900b8085d8b2eca6","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars2.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":15778981,"name":"smarthome","full_name":"eclipse/smarthome","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars2.githubusercontent.com/u/56974?v=3","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/smarthome","description":"Eclipse SmartHome™ project","fork":false,"url":"https://api.github.com/repos/eclipse/smarthome","forks_url":"https://api.github.com/repos/eclipse/smarthome/forks","keys_url":"https://api.github.com/repos/eclipse/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/smarthome/teams","hooks_url":"https://api.github.com/repos/eclipse/smarthome/hooks","issue_events_url":"https://api.github.com/repos/eclipse/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/smarthome/events","assignees_url":"https://api.github.com/repos/eclipse/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/smarthome/tags","blobs_url":"https://api.github.com/repos/eclipse/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/smarthome/languages","stargazers_url":"https://api.github.com/repos/eclipse/smarthome/stargazers","contributors_url":"https://api.github.com/repos/eclipse/smarthome/contributors","subscribers_url":"https://api.github.com/repos/eclipse/smarthome/subscribers","subscription_url":"https://api.github.com/repos/eclipse/smarthome/subscription","commits_url":"https://api.github.com/repos/eclipse/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/smarthome/merges","archive_url":"https://api.github.com/repos/eclipse/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/smarthome/downloads","issues_url":"https://api.github.com/repos/eclipse/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/smarthome/deployments","created_at":"2014-01-09T20:47:19Z","updated_at":"2017-07-03T20:11:56Z","pushed_at":"2017-07-03T17:49:25Z","git_url":"git://github.com/eclipse/smarthome.git","ssh_url":"git@github.com:eclipse/smarthome.git","clone_url":"https://github.com/eclipse/smarthome.git","svn_url":"https://github.com/eclipse/smarthome","homepage":"https://www.eclipse.org/smarthome/","size":33988,"stargazers_count":522,"watchers_count":522,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":504,"mirror_url":null,"open_issues_count":309,"forks":504,"open_issues":309,"watchers":522,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/3715"},"html":{"href":"https://github.com/eclipse/smarthome/pull/3715"},"issue":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/3715"},"comments":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/3715/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/3715/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/3715/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/smarthome/statuses/3783cdf075d9fb22355bedb5dbf4033c324f0276"}}}}
{"actor":{"display_login":"htreu"}}