You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by mi...@apache.org on 2019/10/05 06:56:55 UTC
[activemq-nms-amqp] branch master updated: AMQNET-620: Initialize
ConnectionFactory properly with System.Uri overload
This is an automated email from the ASF dual-hosted git repository.
michaelpearce pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-nms-amqp.git
The following commit(s) were added to refs/heads/master by this push:
new 04c0b21 AMQNET-620: Initialize ConnectionFactory properly with System.Uri overload
new 6761c1f Merge pull request #44 from HavretGC/connection_factory_uri_overload_fix
04c0b21 is described below
commit 04c0b219faf22e11393e74f19a4d4122ed955257
Author: Havret <h4...@gmail.com>
AuthorDate: Fri Oct 4 09:29:58 2019 +0200
AMQNET-620: Initialize ConnectionFactory properly with System.Uri overload
ConnectionFactory was not initialized properly with constructor that takes System.Uri as a parameter. Additional properties that were specified in broker uri (like username or password) were not applied on connection factory.
---
src/NMS.AMQP/NmsConnectionFactory.cs | 2 +-
test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs | 30 ++++++++++++++++++++--
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/src/NMS.AMQP/NmsConnectionFactory.cs b/src/NMS.AMQP/NmsConnectionFactory.cs
index ecb238a..eff1e4f 100644
--- a/src/NMS.AMQP/NmsConnectionFactory.cs
+++ b/src/NMS.AMQP/NmsConnectionFactory.cs
@@ -58,7 +58,7 @@ namespace Apache.NMS.AMQP
public NmsConnectionFactory(Uri brokerUri)
{
- this.brokerUri = brokerUri;
+ BrokerUri = brokerUri;
}
private IdGenerator ClientIdGenerator
diff --git a/test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs b/test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs
index 229b62a..a86bb1e 100644
--- a/test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs
+++ b/test/Apache-NMS-AMQP-Test/ConnectionFactoryTest.cs
@@ -66,10 +66,36 @@ namespace NMS.AMQP.Test
}
[Test]
+ public void TestSetPropertiesFromStringUri()
+ {
+ string baseUri = "amqp://localhost:1234";
+ string configuredUri = baseUri +
+ "?nms.username=user" +
+ "&nms.password=password" +
+ "&nms.clientId=client" +
+ "&nms.connectionIdPrefix=ID:TEST" +
+ "&nms.clientIDPrefix=clientId" +
+ "&nms.requestTimeout=1000" +
+ "&nms.sendTimeout=1000" +
+ "&nms.localMessageExpiry=false";
+
+ NmsConnectionFactory factory = new NmsConnectionFactory(configuredUri);
+
+ Assert.AreEqual("user", factory.UserName);
+ Assert.AreEqual("password", factory.Password);
+ Assert.AreEqual("client", factory.ClientId);
+ Assert.AreEqual("ID:TEST", factory.ConnectionIdPrefix);
+ Assert.AreEqual("clientId", factory.ClientIdPrefix);
+ Assert.AreEqual(1000, factory.RequestTimeout);
+ Assert.AreEqual(1000, factory.SendTimeout);
+ Assert.IsFalse(factory.LocalMessageExpiry);
+ }
+
+ [Test]
public void TestSetPropertiesFromUri()
{
string baseUri = "amqp://localhost:1234";
- string configured = baseUri +
+ string configuredUri = baseUri +
"?nms.username=user" +
"&nms.password=password" +
"&nms.clientId=client" +
@@ -79,7 +105,7 @@ namespace NMS.AMQP.Test
"&nms.sendTimeout=1000" +
"&nms.localMessageExpiry=false";
- NmsConnectionFactory factory = new NmsConnectionFactory(configured);
+ NmsConnectionFactory factory = new NmsConnectionFactory(new Uri(configuredUri));
Assert.AreEqual("user", factory.UserName);
Assert.AreEqual("password", factory.Password);