qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ai...@apache.org
Subject svn commit: r893315 - in /qpid/trunk/qpid/dotnet/client-010: client/client/ client/transport/ client/transport/network/ client/transport/network/io/ test/ test/Helpers/ test/interop/
Date Tue, 22 Dec 2009 21:00:00 GMT
Author: aidan
Date: Tue Dec 22 20:59:57 2009
New Revision: 893315

URL: http://svn.apache.org/viewvc?rev=893315&view=rev
Log:
QPID-2239: make sure the close() does not hand.

Also handle authentication failures properly, QPID-2240.

Patch by julien.lavigne

Added:
    qpid/trunk/qpid/dotnet/client-010/test/Helpers/
    qpid/trunk/qpid/dotnet/client-010/test/Helpers/ConfigHelpers.cs
    qpid/trunk/qpid/dotnet/client-010/test/interop/ConnectionTests.cs
Modified:
    qpid/trunk/qpid/dotnet/client-010/client/client/Client.cs
    qpid/trunk/qpid/dotnet/client-010/client/client/ClientConnectionDelegate.cs
    qpid/trunk/qpid/dotnet/client-010/client/client/IClient.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/Channel.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/ClientDelegate.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/Connection.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/ConnectionDelegate.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/network/Assembler.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/network/InputHandler.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoReceiver.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoSSLTransport.cs
    qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoTransport.cs
    qpid/trunk/qpid/dotnet/client-010/test/Test.csproj
    qpid/trunk/qpid/dotnet/client-010/test/interop/TestCase.cs

Modified: qpid/trunk/qpid/dotnet/client-010/client/client/Client.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/client/Client.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/client/Client.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/client/Client.cs Tue Dec 22 20:59:57 2009
@@ -34,11 +34,18 @@
         private readonly Object _closeOK;
         private IClosedListener _closedListner;
 
+        public event EventHandler<ExceptionArgs> ExceptionRaised;
+        public event EventHandler ConnectionLost;
 
         public bool IsClosed
         {
             get { return _isClosed; }
-            set { _isClosed = value; }
+            set
+            {
+                _isClosed = value;
+                if(_isClosed && ConnectionLost != null)
+                    ConnectionLost(this, EventArgs.Empty);
+            }
         }
 
         public Object CloseOk
@@ -67,14 +74,20 @@
         {
             _log.Debug(String.Format("Client Connecting to host {0}; port {1}; virtualHost
{2}; username {3}", host,
                                      port, virtualHost, username));
-            ConnectionDelegate connectionDelegate = new ClientConnectionDelegate(this, username,
password);
+            ClientConnectionDelegate connectionDelegate = new ClientConnectionDelegate(this,
username, password);
             ManualResetEvent negotiationComplete = new ManualResetEvent(false);
-            connectionDelegate.setCondition(negotiationComplete);
+            connectionDelegate.SetCondition(negotiationComplete);
             connectionDelegate.VirtualHost = virtualHost;
             _conn = IoTransport.Connect(host, port, connectionDelegate);
             
             _conn.Send(new ProtocolHeader(1, 0, 10));
             negotiationComplete.WaitOne();
+
+            if (connectionDelegate.Exception != null)
+                throw connectionDelegate.Exception;
+
+            connectionDelegate.SetCondition(null);
+
         }
 
         /// <summary>
@@ -93,15 +106,20 @@
         {
             _log.Debug(String.Format("Client Connecting to host {0}; port {1}; virtualHost
{2}; username {3}", host,
                                      port, virtualHost, username));
-            _log.Debug(String.Format("SSL paramters: serverName: {0}; certPath: {1}; rejectUntrusted:
{2}", serverName, certPath, rejectUntrusted));          
-            ConnectionDelegate connectionDelegate = new ClientConnectionDelegate(this, username,
password);
+            _log.Debug(String.Format("SSL paramters: serverName: {0}; certPath: {1}; rejectUntrusted:
{2}", serverName, certPath, rejectUntrusted));
+            ClientConnectionDelegate connectionDelegate = new ClientConnectionDelegate(this,
username, password);
             ManualResetEvent negotiationComplete = new ManualResetEvent(false);
-            connectionDelegate.setCondition(negotiationComplete);
+            connectionDelegate.SetCondition(negotiationComplete);
             connectionDelegate.VirtualHost = virtualHost;
             _conn = IoSSLTransport.Connect(host, port, serverName, certPath, rejectUntrusted,
connectionDelegate);
 
             _conn.Send(new ProtocolHeader(1, 0, 10));
             negotiationComplete.WaitOne();
+
+            if (connectionDelegate.Exception != null)
+                throw connectionDelegate.Exception;
+
+            connectionDelegate.SetCondition(null);
         }
 
         public void Close()
@@ -142,5 +160,11 @@
         }       
 
         #endregion
+
+        public void RaiseException(Exception exception)
+        {
+            if (ExceptionRaised != null)
+                ExceptionRaised(this, new ExceptionArgs(exception));
+        }
     }
 }

Modified: qpid/trunk/qpid/dotnet/client-010/client/client/ClientConnectionDelegate.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/client/ClientConnectionDelegate.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/client/ClientConnectionDelegate.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/client/ClientConnectionDelegate.cs Tue Dec 22
20:59:57 2009
@@ -33,6 +33,7 @@
         private readonly Client _client;
         private string _username;
         private string _password;
+        private Exception _exception;
 
         public ClientConnectionDelegate(Client client, string username, string pasword)
         {
@@ -41,14 +42,24 @@
             _password = pasword;
         }
 
+        public Exception Exception
+        {
+            get { return _exception; }
+        }
+
         public override SessionDelegate GetSessionDelegate()
         {
             return new ClientSessionDelegate();
         }
 
-        public override void Exception(Exception t)
+        public override void RaiseException(Exception exception)
         {
-            throw t;
+            _exception = exception;
+
+            if (_negotiationComplete != null)
+                _negotiationComplete.Set();
+            else
+                _client.RaiseException(exception);
         }
 
         public override void ConnectionStart(Channel context, ConnectionStart mystruct)
@@ -78,7 +89,7 @@
                 catch (Exception e)
                 {
                     throw new SystemException("Error when closing client", e);
-                }
+                } 
             }
         }
 
@@ -86,12 +97,12 @@
         {
             base.ConnectionClose(context, connectionClose);
             ErrorCode errorCode = ErrorCode.GetErrorCode((int) connectionClose.GetReplyCode());
-            if (_client.ClosedListener == null && errorCode.Code != (int) QpidErrorCode.NO_ERROR)
-            {
-                throw new Exception ("Server Closed the connection: Reason " +
-                                       connectionClose.GetReplyText());
-            }           
-                _client.ClosedListener.OnClosed(errorCode, connectionClose.GetReplyText(),
null);                   
+
+            if(_client.ClosedListener != null)
+                _client.ClosedListener.OnClosed(errorCode, connectionClose.GetReplyText(),
null);
+
+            if (errorCode.Code != (int)QpidErrorCode.NO_ERROR)
+                throw new Exception ("Server Closed the connection: Reason " + connectionClose.GetReplyText());
         }
     }
 }

Modified: qpid/trunk/qpid/dotnet/client-010/client/client/IClient.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/client/IClient.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/client/IClient.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/client/IClient.cs Tue Dec 22 20:59:57 2009
@@ -18,6 +18,7 @@
 */
 
 using System;
+using org.apache.qpid.transport;
 
 namespace org.apache.qpid.client
 {
@@ -49,13 +50,18 @@
         /// <returns>A newly created (suspended) session.</returns>
         IClientSession CreateSession(long expiryInSeconds);
 
+
+        event EventHandler<ExceptionArgs> ExceptionRaised;
+        event EventHandler ConnectionLost;
+
         /// <summary>      
-        /// If the communication layer detects a serious problem with a connection, it
-        //  informs the client's ClosedListener
+        /// If the broker sends a disconnect message, it will notify the ClosedListener
         /// </summary>        
         /// 
         IClosedListener ClosedListener { set; }
 
+
+
         bool IsClosed { get; set; }
 
         /// <summary>

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/Channel.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/Channel.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/Channel.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/Channel.cs Tue Dec 22 20:59:57 2009
@@ -64,7 +64,7 @@
 
         public void Init(Object v, ProtocolHeader hdr)
         {
-            _connection.ConnectionDelegate.init(this, hdr);
+            _connection.ConnectionDelegate.Init(this, hdr);
         }
 
         public void Control(Object v, Method method)
@@ -171,4 +171,4 @@
             return String.Format("{0}:{1}", _connection, _channel);
         }
     }
-}
+}
\ No newline at end of file

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/ClientDelegate.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/ClientDelegate.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/ClientDelegate.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/ClientDelegate.cs Tue Dec 22 20:59:57
2009
@@ -24,7 +24,7 @@
 {
     abstract class ClientDelegate : ConnectionDelegate
     {
-        public override void init(Channel ch, ProtocolHeader hdr)
+        public override void Init(Channel ch, ProtocolHeader hdr)
         {
             if (hdr.Major != 0 && hdr.Minor != 10)
             {

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/Connection.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/Connection.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/Connection.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/Connection.cs Tue Dec 22 20:59:57 2009
@@ -130,7 +130,7 @@
 
         public void On_ReceivedException(Object sender, ExceptionArgs arg)
         {
-            _connDdelegate.Exception(arg.Exception);
+            _connDdelegate.RaiseException(arg.Exception);
         }
 
         public void On_ReceivedClosed(Object sender, EventArgs arg)

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/ConnectionDelegate.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/ConnectionDelegate.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/ConnectionDelegate.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/ConnectionDelegate.cs Tue Dec 22 20:59:57
2009
@@ -35,20 +35,20 @@
         private static readonly Logger log = Logger.Get(typeof(ConnectionDelegate));
         private String _virtualHost;
 
-        private ManualResetEvent _negotiationComplete;
+        protected ManualResetEvent _negotiationComplete;
 
         public abstract SessionDelegate GetSessionDelegate();
 
-        public abstract void Exception(Exception t);
+        public abstract void RaiseException(Exception t);
 
         public abstract void Closed();
 
-        public void setCondition(ManualResetEvent negotiationComplete)
+        public void SetCondition(ManualResetEvent negotiationComplete)
         {
             _negotiationComplete = negotiationComplete;
         }
 
-        public virtual void init(Channel ch, ProtocolHeader hdr)
+        public virtual void Init(Channel ch, ProtocolHeader hdr)
         {
             ch.Connection.Send(new ProtocolHeader((byte)1, hdr.Major, hdr.Minor));
             List<Object> plain = new List<Object>();
@@ -105,4 +105,4 @@
             ch.ConnectionCloseOk();
         }
     }
-}
+}
\ No newline at end of file

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/network/Assembler.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/network/Assembler.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/network/Assembler.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/network/Assembler.cs Tue Dec 22 20:59:57
2009
@@ -42,8 +42,11 @@
 
         // the event raised when a buffer is read from the wire        
         public event EventHandler<ReceivedPayload<IProtocolEvent>> ReceivedEvent;
-        public event EventHandler<ExceptionArgs> ExceptionProcessing;
-        public event EventHandler HandlerClosed;
+        public event EventHandler Closed;
+
+
+        // Not in use : 
+        public event EventHandler<ExceptionArgs> Exception;
 
         event EventHandler<ReceivedPayload<IProtocolEvent>> IReceiver<ReceivedPayload<IProtocolEvent>>.Received
         {
@@ -63,42 +66,6 @@
             }
         }
 
-        event EventHandler<ExceptionArgs> IReceiver<ReceivedPayload<IProtocolEvent>>.Exception
-        {
-            add
-            {
-                lock (m_objectLock)
-                {
-                    ExceptionProcessing += value;
-                }
-            }
-            remove
-            {
-                lock (m_objectLock)
-                {
-                    ExceptionProcessing -= value;
-                }
-            }
-        }
-
-        event EventHandler IReceiver<ReceivedPayload<IProtocolEvent>>.Closed
-        {
-            add
-            {
-                lock (m_objectLock)
-                {
-                    HandlerClosed += value;
-                }
-            }
-            remove
-            {
-                lock (m_objectLock)
-                {
-                    HandlerClosed -= value;
-                }
-            }
-        }
-
         public Assembler()
         {
             segments = new Dictionary<int, List<byte[]>>();
@@ -267,16 +234,21 @@
             log.Debug("Assembler: protocol event:", protevent);
             ReceivedPayload<IProtocolEvent> payload = new ReceivedPayload<IProtocolEvent>();
             payload.Payload = protevent;
-            if (ReceivedEvent != null)
+
+            if (protevent is ConnectionCloseOk)
             {
-                ReceivedEvent(this, payload);
+                if (Closed != null)
+                    Closed(this, EventArgs.Empty);
             }
             else
             {
-                log.Debug("No listener for event: {0}", protevent);
+                if (ReceivedEvent != null)
+                    ReceivedEvent(this, payload);
+                else
+                    log.Debug("No listener for event: {0}", protevent);
             }
         }
 
         #endregion
     }
-}
+}
\ No newline at end of file

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/network/InputHandler.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/network/InputHandler.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/network/InputHandler.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/network/InputHandler.cs Tue Dec 22
20:59:57 2009
@@ -44,7 +44,9 @@
         // the event raised when a buffer is read from the wire        
         public event EventHandler<ReceivedPayload<INetworkEvent>> ReceivedEvent;
         public event EventHandler<ExceptionArgs> ExceptionProcessing;
-        public event EventHandler HandlerClosed;
+
+        // Not in used... This even is never raised in the code => the application will
block on Close() until the timeout is reached 
+        public event EventHandler Closed;
 
         event EventHandler<ReceivedPayload<INetworkEvent>> IReceiver<ReceivedPayload<INetworkEvent>>.Received
         {
@@ -82,24 +84,6 @@
             }
         }
 
-        event EventHandler IReceiver<ReceivedPayload<INetworkEvent>>.Closed
-        {
-            add
-            {
-                lock (m_objectLock)
-                {
-                    HandlerClosed += value;
-                }
-            }
-            remove
-            {
-                lock (m_objectLock)
-                {
-                    HandlerClosed -= value;
-                }
-            }
-        }
-
         private State state;
         private MemoryStream input;
         private int needed;
@@ -279,4 +263,4 @@
 
         #endregion
     }
-}
+}
\ No newline at end of file

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoReceiver.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoReceiver.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoReceiver.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoReceiver.cs Tue Dec 22
20:59:57 2009
@@ -166,10 +166,6 @@
                 }
                 log.Debug("Receiver thread terminating");
             }
-            catch (IOException)
-            {
-                // IOException is thrown when the socket is Closed according to the docs
-            }
             catch (Exception t)
             {
                 if (ExceptionReading != null)
@@ -186,4 +182,4 @@
             }
         }
     }
-}
+}
\ No newline at end of file

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoSSLTransport.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoSSLTransport.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoSSLTransport.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoSSLTransport.cs Tue Dec
22 20:59:57 2009
@@ -62,11 +62,9 @@
             inputHandler.ReceivedEvent += assembler.On_ReceivedEvent;
             // Connection listen to asembler protocol event 
             Receiver.Closed += Connection.On_ReceivedClosed;
+            assembler.Closed += Connection.On_ReceivedClosed;
             Receiver.Exception += Connection.On_ReceivedException;
-            inputHandler.HandlerClosed += Connection.On_ReceivedClosed;
             inputHandler.ExceptionProcessing += Connection.On_ReceivedException;
-            assembler.HandlerClosed += Connection.On_ReceivedClosed;
-            assembler.ExceptionProcessing += Connection.On_ReceivedException;
             assembler.ReceivedEvent += Connection.On_ReceivedEvent;
         }
 

Modified: qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoTransport.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoTransport.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoTransport.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/client/transport/network/io/IoTransport.cs Tue Dec 22
20:59:57 2009
@@ -65,11 +65,9 @@
             inputHandler.ReceivedEvent += assembler.On_ReceivedEvent;            
             // Connection listen to asembler protocol event 
             Receiver.Closed += Connection.On_ReceivedClosed;
+            assembler.Closed += Connection.On_ReceivedClosed;
             Receiver.Exception += Connection.On_ReceivedException;            
-            inputHandler.HandlerClosed += Connection.On_ReceivedClosed;
             inputHandler.ExceptionProcessing += Connection.On_ReceivedException;
-            assembler.HandlerClosed += Connection.On_ReceivedClosed;
-            assembler.ExceptionProcessing += Connection.On_ReceivedException;
             assembler.ReceivedEvent += Connection.On_ReceivedEvent;
          }
 
@@ -140,4 +138,4 @@
 
         #endregion
     }
-}
+}
\ No newline at end of file

Added: qpid/trunk/qpid/dotnet/client-010/test/Helpers/ConfigHelpers.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/test/Helpers/ConfigHelpers.cs?rev=893315&view=auto
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/test/Helpers/ConfigHelpers.cs (added)
+++ qpid/trunk/qpid/dotnet/client-010/test/Helpers/ConfigHelpers.cs Tue Dec 22 20:59:57 2009
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System.Xml;
+using log4net.Config;
+
+namespace test.Helpers
+{
+    class ConfigHelpers
+    {
+        public static Dictionary<string, string> LoadConfig()
+        {
+            Dictionary<string, string> properties = new Dictionary<string, string>();
+
+            XmlConfigurator.Configure(new FileInfo("/log.xml"));
+            // populate default properties
+            properties.Add("Username", "guest");
+            properties.Add("Password", "guest");
+            properties.Add("Host", "localhost");
+            properties.Add("Port", "5672");
+            properties.Add("VirtualHost", "test");
+            //Read the test config file  
+            XmlTextReader reader = new XmlTextReader(Environment.CurrentDirectory + "/Qpid
Test.dll.config");
+            while (reader.Read())
+            {
+                // if node type is an element
+                if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("add"))
+                {
+                    if (properties.ContainsKey(reader.GetAttribute("key")))
+                    {
+                        properties[reader.GetAttribute("key")] = reader.GetAttribute("value");
+                    }
+                    else
+                    {
+                        properties.Add(reader.GetAttribute("key"), reader.GetAttribute("value"));
+                    }
+                }
+            }
+
+            return properties;
+        }
+    }
+}

Modified: qpid/trunk/qpid/dotnet/client-010/test/Test.csproj
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/test/Test.csproj?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/test/Test.csproj (original)
+++ qpid/trunk/qpid/dotnet/client-010/test/Test.csproj Tue Dec 22 20:59:57 2009
@@ -47,6 +47,8 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="interop\ConnectionTests.cs" />
+    <Compile Include="Helpers\ConfigHelpers.cs" />
     <Compile Include="interop\Admin.cs" />
     <Compile Include="interop\ApplicationHeaders.cs" />
     <Compile Include="interop\Message.cs" />
@@ -77,4 +79,4 @@
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>
\ No newline at end of file

Added: qpid/trunk/qpid/dotnet/client-010/test/interop/ConnectionTests.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/test/interop/ConnectionTests.cs?rev=893315&view=auto
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/test/interop/ConnectionTests.cs (added)
+++ qpid/trunk/qpid/dotnet/client-010/test/interop/ConnectionTests.cs Tue Dec 22 20:59:57
2009
@@ -0,0 +1,59 @@
+using System;
+using System.Net.Sockets;
+using NUnit.Framework;
+using org.apache.qpid.client;
+using test.Helpers;
+
+namespace test
+{
+    [TestFixture]
+    public class ConnectionTests
+    {
+        [SetUp]
+        public void Setup()
+        {
+
+        }
+
+        [Test]
+        [ExpectedException(typeof(Exception))]
+        public void should_raise_exception_in_calling_thread_on_authentification_failure()
+        {
+            var properties = ConfigHelpers.LoadConfig();
+
+            var client = new Client();
+            client.Connect(properties["Host"], Convert.ToInt16(properties["Port"]), properties["VirtualHost"],
+                           properties["Username"], "some silly password to make sure the
authentification fail");      
+        }
+
+        [Test]
+        [ExpectedException(typeof(Exception))]
+        public void should_raise_exception_in_calling_thread_on_authentification_failure_with_clodedListener()
+        {
+            var properties = ConfigHelpers.LoadConfig();
+
+            var client = new Client();
+            client.ClosedListener = new FakeListener();
+            client.Connect(properties["Host"], Convert.ToInt16(properties["Port"]), properties["VirtualHost"],
+                           properties["Username"], "some silly password to make sure the
authentification fail");
+        }
+
+        [Test]
+        public void should_not_block_on_close()
+        {
+            var properties = ConfigHelpers.LoadConfig();
+
+            var client = new Client();
+            client.Connect(properties["Host"], Convert.ToInt16(properties["Port"]), properties["VirtualHost"],
+                           properties["Username"], properties["Password"]);
+            client.Close();
+        }
+    }
+
+    public class FakeListener : IClosedListener
+    {
+        public void OnClosed(ErrorCode errorCode, string reason, Exception t)
+        {
+        }
+    }
+}

Modified: qpid/trunk/qpid/dotnet/client-010/test/interop/TestCase.cs
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/dotnet/client-010/test/interop/TestCase.cs?rev=893315&r1=893314&r2=893315&view=diff
==============================================================================
--- qpid/trunk/qpid/dotnet/client-010/test/interop/TestCase.cs (original)
+++ qpid/trunk/qpid/dotnet/client-010/test/interop/TestCase.cs Tue Dec 22 20:59:57 2009
@@ -30,6 +30,7 @@
 using org.apache.qpid.client;
 using org.apache.qpid.transport;
 using org.apache.qpid.transport.util;
+using test.Helpers;
 
 namespace test.interop
 {
@@ -43,35 +44,11 @@
         [TestFixtureSetUp] 
         public void Init()
         {
-            XmlConfigurator.Configure(new FileInfo("/log.xml"));
-            // populate default properties
-            _properties.Add("Username", "guest");
-            _properties.Add("Password", "guest");
-            _properties.Add("Host", "localhost");
-            _properties.Add("Port", "5672");
-            _properties.Add("VirtualHost", "test");
-             //Read the test config file  
-            XmlTextReader reader = new XmlTextReader(Environment.CurrentDirectory + "/Qpid
Test.dll.config");
-            while (reader.Read())
-            {                
-                // if node type is an element
-                if (reader.NodeType == XmlNodeType.Element && reader.Name.Equals("add"))
-                {
-                    if (_properties.ContainsKey(reader.GetAttribute("key")))
-                    {
-                        _properties[reader.GetAttribute("key")] = reader.GetAttribute("value");
-                    }
-                    else
-                    {
-                        _properties.Add(reader.GetAttribute("key"), reader.GetAttribute("value"));
   
-                    }
-                    
-                }               
-            }
+            var properties = ConfigHelpers.LoadConfig();
             // create a client and connect to the broker
             _client = new Client();
-            _client.Connect(Properties["Host"], Convert.ToInt16(Properties["Port"]), Properties["VirtualHost"],
-                           Properties["Username"], Properties["Password"]);           
+            _client.Connect(properties["Host"], Convert.ToInt16(properties["Port"]), properties["VirtualHost"],
+                           properties["Username"], properties["Password"]);           
    
         }
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message