summaryrefslogtreecommitdiff
path: root/dotnet/Qpid.Client.Tests
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2007-01-29 10:46:27 +0000
committerRobert Greig <rgreig@apache.org>2007-01-29 10:46:27 +0000
commit2bcc371558ce0659f53b86046cdf3d5de3b20910 (patch)
treed0c987cfa076eb90edb80620661d69a6e7354d3a /dotnet/Qpid.Client.Tests
parentfe736211136b60bec61c1a22d3765be9142c6b39 (diff)
downloadqpid-python-2bcc371558ce0659f53b86046cdf3d5de3b20910.tar.gz
(Patch supplied by Tomas Restrepo) QPID-291-2.diff applied. Adds SASL capability to the .Net client.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@501001 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet/Qpid.Client.Tests')
-rw-r--r--dotnet/Qpid.Client.Tests/App.config13
-rw-r--r--dotnet/Qpid.Client.Tests/Qpid.Client.Tests.csproj9
-rw-r--r--dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs55
-rw-r--r--dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs23
4 files changed, 88 insertions, 12 deletions
diff --git a/dotnet/Qpid.Client.Tests/App.config b/dotnet/Qpid.Client.Tests/App.config
new file mode 100644
index 0000000000..64c6def5fd
--- /dev/null
+++ b/dotnet/Qpid.Client.Tests/App.config
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+ <configSections>
+ <sectionGroup name="qpid.client">
+ <section name="authentication" type="Qpid.Client.Configuration.AuthenticationConfigurationSectionHandler, Qpid.Client"/>
+ </sectionGroup>
+ </configSections>
+ <qpid.client>
+ <authentication>
+ <add key="TEST" value="Qpid.Client.Tests.Security.TestCallbackHandler, Qpid.Client.Tests"/>
+ </authentication>
+ </qpid.client>
+</configuration>
diff --git a/dotnet/Qpid.Client.Tests/Qpid.Client.Tests.csproj b/dotnet/Qpid.Client.Tests/Qpid.Client.Tests.csproj
index b14f8405c9..5674174f69 100644
--- a/dotnet/Qpid.Client.Tests/Qpid.Client.Tests.csproj
+++ b/dotnet/Qpid.Client.Tests/Qpid.Client.Tests.csproj
@@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -53,6 +54,7 @@
<Compile Include="Common\BaseMessagingTestFixture.cs" />
<Compile Include="requestreply1\ServiceProvidingClient.cs" />
<Compile Include="requestreply1\ServiceRequestingClient.cs" />
+ <Compile Include="Security\CallbackHandlerRegistryTests.cs" />
<Compile Include="undeliverable\UndeliverableTest.cs" />
<Compile Include="url\ConnectionUrlTest.cs" />
</ItemGroup>
@@ -69,6 +71,10 @@
<Project>{77064C42-24D2-4CEB-9EA2-0EF481A43205}</Project>
<Name>Qpid.Common</Name>
</ProjectReference>
+ <ProjectReference Include="..\Qpid.Sasl\Qpid.Sasl.csproj">
+ <Project>{1465B0EE-6452-42A6-AB73-B2F9EABEEE75}</Project>
+ <Name>Qpid.Sasl</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="log4net.config">
@@ -76,6 +82,7 @@
</None>
</ItemGroup>
<ItemGroup>
+ <None Include="App.config" />
<None Include="Qpid.Common.DLL.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -88,4 +95,4 @@
<Target Name="AfterBuild">
</Target>
-->
-</Project> \ No newline at end of file
+</Project>
diff --git a/dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs b/dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs
new file mode 100644
index 0000000000..ec0594263f
--- /dev/null
+++ b/dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+using System;
+using NUnit.Framework;
+using Qpid.Client.Security;
+
+
+namespace Qpid.Client.Tests.Security
+{
+ [TestFixture]
+ public class CallbackRegistryHandlerTests
+ {
+ [Test]
+ public void ParsesConfiguration()
+ {
+ CallbackHandlerRegistry registry = CallbackHandlerRegistry.Instance;
+ Assert.AreEqual(3, registry.Mechanisms.Length);
+ Assert.Contains("TEST", registry.Mechanisms);
+
+ Type handlerType = registry.GetCallbackHandler("TEST");
+ Assert.IsNotNull(handlerType);
+ Assert.AreEqual(typeof(TestCallbackHandler), handlerType);
+ }
+ } // class CallbackRegistryHandlerTests
+
+ public class TestCallbackHandler : IAMQCallbackHandler
+ {
+ public void Initialize(Qpid.Client.Protocol.AMQProtocolSession session)
+ {
+ }
+ public void Handle(Qpid.Sasl.ISaslCallback[] callbacks)
+ {
+ }
+
+ } // class TestCallbackHandler
+
+} // namespace Qpid.Client.Tests.Connection
diff --git a/dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs b/dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs
index 5aa6773e53..d5330898a0 100644
--- a/dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs
+++ b/dotnet/Qpid.Client.Tests/connection/ConnectionTest.cs
@@ -23,13 +23,13 @@ using NUnit.Framework;
using Qpid.Client.qms;
using Qpid.Messaging;
-namespace Qpid.Client.Tests.connection
+namespace Qpid.Client.Tests.Connection
{
[TestFixture]
public class ConnectionTest
{
[Test]
- public void simpleConnection()
+ public void SimpleConnection()
{
ConnectionInfo connectionInfo = new QpidConnectionInfo();
connectionInfo.AddBrokerInfo(new AmqBrokerInfo("amqp", "localhost", 5672, false));
@@ -40,7 +40,7 @@ namespace Qpid.Client.Tests.connection
}
[Test]
- public void passwordFailureConnection()
+ public void PasswordFailureConnection()
{
ConnectionInfo connectionInfo = new QpidConnectionInfo();
connectionInfo.SetPassword("rubbish");
@@ -50,16 +50,17 @@ namespace Qpid.Client.Tests.connection
using (IConnection connection = new AMQConnection(connectionInfo))
{
Console.WriteLine("connection = " + connection);
+ // wrong
+ Assert.Fail("Authentication succeeded but should've failed");
}
}
- catch (AMQException)
+ catch (AMQException e)
{
- Assert.Fail();
-// if (!(e is AMQAuthenticationException))
-// {
-// Assert.Fail("Expected AMQAuthenticationException!");
-// }
- }
+ if (!(e.InnerException is AMQAuthenticationException))
+ {
+ Assert.Fail("Expected AMQAuthenticationException!");
+ }
+ }
}
//
// [Test]
@@ -96,4 +97,4 @@ namespace Qpid.Client.Tests.connection
// }
// }
}
-} \ No newline at end of file
+}