diff options
| author | Aidan Skinner <aidan@apache.org> | 2009-12-22 20:59:57 +0000 |
|---|---|---|
| committer | Aidan Skinner <aidan@apache.org> | 2009-12-22 20:59:57 +0000 |
| commit | f48bcd1fb3b49d7a8d6aaa9fad87e54510cfe146 (patch) | |
| tree | a004039f15ea31a163f6baad5f8c3f5a7d1701dd /dotnet/client-010/test/interop | |
| parent | 776e96bff80f750ab19c5e40c98bac3754818884 (diff) | |
| download | qpid-python-f48bcd1fb3b49d7a8d6aaa9fad87e54510cfe146.tar.gz | |
QPID-2239: make sure the close() does not hand.
Also handle authentication failures properly, QPID-2240.
Patch by julien.lavigne
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@893315 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/client-010/test/interop')
| -rw-r--r-- | dotnet/client-010/test/interop/ConnectionTests.cs | 59 | ||||
| -rw-r--r-- | dotnet/client-010/test/interop/TestCase.cs | 31 |
2 files changed, 63 insertions, 27 deletions
diff --git a/dotnet/client-010/test/interop/ConnectionTests.cs b/dotnet/client-010/test/interop/ConnectionTests.cs new file mode 100644 index 0000000000..0c2ea8a648 --- /dev/null +++ b/dotnet/client-010/test/interop/ConnectionTests.cs @@ -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) + { + } + } +} diff --git a/dotnet/client-010/test/interop/TestCase.cs b/dotnet/client-010/test/interop/TestCase.cs index 99f81d9ff7..867f082000 100644 --- a/dotnet/client-010/test/interop/TestCase.cs +++ b/dotnet/client-010/test/interop/TestCase.cs @@ -30,6 +30,7 @@ using NUnit.Framework; 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 @@ namespace test.interop [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"]); } |
