You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2010/01/21 16:46:56 UTC
svn commit: r901749 - in
/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src:
main/csharp/ConnectionFactory.cs test/csharp/NMSConnectionFactoryTest.cs
Author: tabish
Date: Thu Jan 21 15:46:56 2010
New Revision: 901749
URL: http://svn.apache.org/viewvc?rev=901749&view=rev
Log:
Fix setting username and password when creating a connection.
Fixes [AMQNET-228]. (See https://issues.apache.org/activemq/browse/AMQNET-228)
Modified:
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs
activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/NMSConnectionFactoryTest.cs
Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs?rev=901749&r1=901748&r2=901749&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/main/csharp/ConnectionFactory.cs Thu Jan 21 15:46:56 2010
@@ -116,8 +116,8 @@
ConfigureConnection(connection);
- connection.UserName = this.connectionUserName;
- connection.Password = this.connectionPassword;
+ connection.UserName = userName;
+ connection.Password = password;
if(this.clientId != null)
{
Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/NMSConnectionFactoryTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/NMSConnectionFactoryTest.cs?rev=901749&r1=901748&r2=901749&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/NMSConnectionFactoryTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/branches/1.2.x/src/test/csharp/NMSConnectionFactoryTest.cs Thu Jan 21 15:46:56 2010
@@ -16,8 +16,12 @@
*/
using System;
+using System.Threading;
using System.Net.Sockets;
using Apache.NMS.Test;
+using Apache.NMS.ActiveMQ.Commands;
+using Apache.NMS.ActiveMQ.Transport;
+using Apache.NMS.ActiveMQ.Transport.Mock;
using NUnit.Framework;
using NUnit.Framework.Extensions;
@@ -26,6 +30,10 @@
[TestFixture]
public class NMSConnectionFactoryTest
{
+ private static String username = "guest";
+ private static String password = "guest";
+ private ConnectionInfo info = null;
+
[RowTest]
[Row("tcp://${activemqhost}:61616")]
[Row("activemq:tcp://${activemqhost}:61616")]
@@ -72,6 +80,38 @@
}
[Test]
+ public void TestConnectionSendsAuthenticationData()
+ {
+ NMSConnectionFactory factory = new NMSConnectionFactory("activemq:mock://localhost:61616");
+ Assert.IsNotNull(factory);
+ Assert.IsNotNull(factory.ConnectionFactory);
+ using(Connection connection = factory.CreateConnection(username, password) as Connection)
+ {
+ Assert.IsNotNull(connection);
+
+ MockTransport transport = (MockTransport) connection.ITransport.Narrow(typeof(MockTransport));
+
+ transport.OutgoingCommand = new CommandHandler(OnOutgoingCommand);
+
+ connection.Start();
+
+ Thread.Sleep(1000);
+
+ Assert.IsNotNull(this.info);
+ Assert.AreEqual(username, info.UserName);
+ Assert.AreEqual(password, info.Password);
+ }
+ }
+
+ public void OnOutgoingCommand(ITransport transport, Command command)
+ {
+ if(command.IsConnectionInfo)
+ {
+ this.info = command as ConnectionInfo;
+ }
+ }
+
+ [Test]
public void TestURIForPrefetchHandling()
{
string uri1 = "activemq:tcp://${activemqhost}:61616" +