CAMEL-11642 - Fixed CS and use ObjectHelper

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

Branch: refs/heads/master
Commit: 6405478479652a6b5b4efabaccbab7d433fcf3a4
Parents: 9c7a8f3
Author: Andrea Cosentino <anco...@gmail.com>
Authored: Mon Aug 7 10:36:40 2017 +0200
Committer: Andrea Cosentino <anco...@gmail.com>
Committed: Mon Aug 7 10:37:19 2017 +0200

----------------------------------------------------------------------
 components/camel-paho/src/main/docs/paho-component.adoc        | 6 +++---
 .../java/org/apache/camel/component/paho/PahoEndpoint.java     | 3 ++-
 .../org/apache/camel/component/paho/PahoComponentTest.java     | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/64054784/components/camel-paho/src/main/docs/paho-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-paho/src/main/docs/paho-component.adoc 
b/components/camel-paho/src/main/docs/paho-component.adoc
index 84083ee..59197c8 100644
--- a/components/camel-paho/src/main/docs/paho-component.adoc
+++ b/components/camel-paho/src/main/docs/paho-component.adoc
@@ -127,8 +127,6 @@ The Paho component supports 4 options which are listed 
below.
 | **brokerUrl** (common) | The URL of the MQTT broker. |  | String
 | **clientId** (common) | MQTT client identifier. |  | String
 | **connectOptions** (advanced) | Client connection options |  | 
MqttConnectOptions
-| **userName** (common) | UserName used for authentication again the MQTT 
broker. |  | String
-| **password** (common) | Password used for authentication again the MQTT 
broker. |  | String
 | **resolveProperty Placeholders** (advanced) | Whether the component should 
resolve property placeholders on itself when starting. Only properties which 
are of String type can use property placeholders. | true | boolean
 |=======================================================================
 // component options: END
@@ -149,7 +147,7 @@ with the following path and query parameters:
 | **topic** | *Required* Name of the topic |  | String
 |=======================================================================
 
-#### Query Parameters (12 parameters):
+#### Query Parameters (14 parameters):
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |=======================================================================
@@ -159,9 +157,11 @@ with the following path and query parameters:
 | **clientId** (common) | MQTT client identifier. |  | String
 | **connectOptions** (common) | Client connection options |  | 
MqttConnectOptions
 | **filePersistenceDirectory** (common) | Base directory used by the file 
persistence provider. |  | String
+| **password** (common) | Password to be used for authentication against the 
MQTT broker |  | String
 | **persistence** (common) | Client persistence to be used - memory or file. | 
MEMORY | PahoPersistence
 | **qos** (common) | Client quality of service level (0-2). | 2 | int
 | **retained** (common) | Retain option | false | boolean
+| **userName** (common) | Username to be used for authentication against the 
MQTT broker |  | String
 | **bridgeErrorHandler** (consumer) | Allows for bridging the consumer to the 
Camel routing Error Handler which mean any exceptions occurred while the 
consumer is trying to pickup incoming messages or the likes will now be 
processed as a message and handled by the routing Error Handler. By default the 
consumer will use the org.apache.camel.spi.ExceptionHandler to deal with 
exceptions that will be logged at WARN or ERROR level and ignored. | false | 
boolean
 | **exceptionHandler** (consumer) | To let the consumer use a custom 
ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this 
options is not in use. By default the consumer will deal with exceptions that 
will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
 | **exchangePattern** (consumer) | Sets the exchange pattern when the consumer 
creates an exchange. |  | ExchangePattern

http://git-wip-us.apache.org/repos/asf/camel/blob/64054784/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
 
b/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
index 3416ea8..8d858d5 100644
--- 
a/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
+++ 
b/components/camel-paho/src/main/java/org/apache/camel/component/paho/PahoEndpoint.java
@@ -28,6 +28,7 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.ObjectHelper;
 import org.eclipse.paho.client.mqttv3.MqttClient;
 import org.eclipse.paho.client.mqttv3.MqttClientPersistence;
 import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
@@ -146,7 +147,7 @@ public class PahoEndpoint extends DefaultEndpoint {
         MqttConnectOptions options = new MqttConnectOptions();
         options.setAutomaticReconnect(autoReconnect);
         
-        if(!"".equals(userName) && !"".equals(password)) {
+        if (ObjectHelper.isNotEmpty(userName) && 
ObjectHelper.isNotEmpty(password)) {
             options.setUserName(userName);
             options.setPassword(password.toCharArray());
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/64054784/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
 
b/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
index f7de2c7..503b79f 100644
--- 
a/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
+++ 
b/components/camel-paho/src/test/java/org/apache/camel/component/paho/PahoComponentTest.java
@@ -217,7 +217,7 @@ public class PahoComponentTest extends CamelTestSupport {
         mock.expectedMessageCount(0);
 
         // When
-        template.sendBody("paho:someRandomQueue?brokerUrl=tcp://localhost:" + 
mqttPort+"&userName=test&password=test", "msg");
+        template.sendBody("paho:someRandomQueue?brokerUrl=tcp://localhost:" + 
mqttPort + "&userName=test&password=test", "msg");
 
         // Then
         mock.assertIsSatisfied();

Reply via email to