summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan Skinner <aidan@apache.org>2009-12-03 23:55:48 +0000
committerAidan Skinner <aidan@apache.org>2009-12-03 23:55:48 +0000
commitde0e81996d63d8a8b7f92d835d2bbdeaf5cccae0 (patch)
tree8dbde527e8f656849ed83981359c8dcd2512395c
parente769aed97fa119033e38d829be25135a4ea08a52 (diff)
downloadqpid-python-de0e81996d63d8a8b7f92d835d2bbdeaf5cccae0.tar.gz
Fix eol style property
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@886998 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/dotnet/Qpid.Buffer.Tests/Properties/AssemblyInfo.cs112
-rw-r--r--qpid/dotnet/Qpid.Buffer.Tests/SimpleByteBufferTests.cs666
-rw-r--r--qpid/dotnet/Qpid.Buffer.Tests/SlicedByteBufferTests.cs266
-rw-r--r--qpid/dotnet/Qpid.Buffer/IByteBufferAllocator.cs100
-rw-r--r--qpid/dotnet/Qpid.Buffer/SimpleByteBuffer.cs240
-rw-r--r--qpid/dotnet/Qpid.Buffer/SlicedByteBuffer.cs172
-rw-r--r--qpid/dotnet/Qpid.Client.Tests/BrokerDetails/BrokerDetailsTest.cs130
-rw-r--r--qpid/dotnet/Qpid.Client.Tests/Channel/ChannelMessageCreationTests.cs158
-rw-r--r--qpid/dotnet/Qpid.Client.Tests/Messages/MessageFactoryRegistryTests.cs228
-rw-r--r--qpid/dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs132
-rw-r--r--qpid/dotnet/Qpid.Client.Tests/interop/TopicListener.cs422
-rw-r--r--qpid/dotnet/Qpid.Client.Tests/interop/TopicPublisher.cs416
-rw-r--r--qpid/dotnet/Qpid.Client/Client/AMQAuthenticationException.cs78
-rw-r--r--qpid/dotnet/Qpid.Client/Client/AMQNoConsumersException.cs90
-rw-r--r--qpid/dotnet/Qpid.Client/Client/AMQNoRouteException.cs92
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Configuration/AuthenticationConfigurationSectionHandler.cs168
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Handler/QueueDeleteOkMethodHandler.cs88
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Handler/QueuePurgeOkMethodHandler.cs88
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Protocol/DefaultTimeouts.cs94
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs258
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Security/IAMQCallbackHandler.cs70
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Security/UsernamePasswordCallbackHandler.cs112
-rw-r--r--qpid/dotnet/Qpid.Client/Client/SslOptions.cs162
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Transport/IStreamFilter.cs76
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Transport/IoHandler.cs644
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Transport/ProtocolDecoderOutput.cs120
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/BlockingSocketTransport.cs300
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ByteChannel.cs184
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ISocketConnector.cs68
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SocketConnector.cs142
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SslSocketConnector.cs214
-rw-r--r--qpid/dotnet/Qpid.Client/Client/Util/FlowControlQueue.cs196
-rw-r--r--qpid/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs170
-rw-r--r--qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs540
-rw-r--r--qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs120
-rw-r--r--qpid/dotnet/Qpid.Common/AMQInvalidArgumentException.cs92
-rw-r--r--qpid/dotnet/Qpid.Common/AMQInvalidRoutingKeyException.cs92
-rw-r--r--qpid/dotnet/Qpid.Common/Collections/ConsumerProducerQueue.cs226
-rw-r--r--qpid/dotnet/Qpid.Common/Framing/AMQType.cs1400
-rw-r--r--qpid/dotnet/Qpid.Common/Framing/AMQTypeMap.cs150
-rw-r--r--qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs152
-rw-r--r--qpid/dotnet/Qpid.Common/Protocol/AMQConstant.cs200
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/Properties/AssemblyInfo.cs106
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/framework/Assertion.cs76
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/framework/Circuit.cs202
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/framework/FrameworkBaseCase.cs562
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/framework/Publisher.cs128
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/framework/Receiver.cs158
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/framework/TestClientDetails.cs168
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/framework/TestModel.cs1312
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.cs168
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs4
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs360
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/interop/InteropClientTestCase.cs174
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase1DummyRun.cs178
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase2BasicP2P.cs410
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase3BasicPubSub.cs488
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs758
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs522
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs474
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/CommitRollbackTest.cs522
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/ConnectionTest.cs146
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs332
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/HeadersExchangeTest.cs564
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/MandatoryMessageTest.cs298
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/ProducerMultiConsumerTest.cs334
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/SslConnectionTest.cs128
-rw-r--r--qpid/dotnet/Qpid.Integration.Tests/testcases/SustainedTest.cs218
-rw-r--r--qpid/dotnet/Qpid.Messaging/ICloseable.cs76
-rw-r--r--qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/AnonymousSaslClientTests.cs144
-rw-r--r--qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/CramMD5SaslClientTests.cs180
-rw-r--r--qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/DigestSaslClientTests.cs498
-rw-r--r--qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/ExternalSaslClientTests.cs142
-rw-r--r--qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/PlainSaslClientTests.cs176
-rw-r--r--qpid/dotnet/Qpid.Sasl.Tests/SaslTests.cs266
-rw-r--r--qpid/dotnet/Qpid.Sasl.Tests/TestClientFactory.cs150
-rw-r--r--qpid/dotnet/Qpid.Sasl/Callbacks.cs278
-rw-r--r--qpid/dotnet/Qpid.Sasl/Configuration/SaslConfiguration.cs180
-rw-r--r--qpid/dotnet/Qpid.Sasl/Configuration/SaslConfigurationSectionHandler.cs168
-rw-r--r--qpid/dotnet/Qpid.Sasl/DefaultClientFactory.cs198
-rw-r--r--qpid/dotnet/Qpid.Sasl/ISaslCallbackHandler.cs70
-rw-r--r--qpid/dotnet/Qpid.Sasl/ISaslClient.cs84
-rw-r--r--qpid/dotnet/Qpid.Sasl/ISaslClientFactory.cs80
-rw-r--r--qpid/dotnet/Qpid.Sasl/MD5HMAC.cs230
-rw-r--r--qpid/dotnet/Qpid.Sasl/Mechanisms/AnonymousSaslClient.cs138
-rw-r--r--qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs184
-rw-r--r--qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5SaslClient.cs182
-rw-r--r--qpid/dotnet/Qpid.Sasl/Mechanisms/DigestSaslClient.cs1152
-rw-r--r--qpid/dotnet/Qpid.Sasl/Mechanisms/ExternalSaslClient.cs138
-rw-r--r--qpid/dotnet/Qpid.Sasl/Mechanisms/PlainSaslClient.cs162
-rw-r--r--qpid/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs114
-rw-r--r--qpid/dotnet/Qpid.Sasl/Sasl.cs230
-rw-r--r--qpid/dotnet/Qpid.Sasl/SaslClient.cs290
-rw-r--r--qpid/dotnet/Qpid.Sasl/SaslException.cs112
-rw-r--r--qpid/dotnet/Qpid.Sasl/SaslProperties.cs84
-rw-r--r--qpid/dotnet/TestClient/Program.cs60
-rw-r--r--qpid/dotnet/TestClient/Properties/AssemblyInfo.cs106
-rw-r--r--qpid/dotnet/TopicListener/Program.cs60
-rw-r--r--qpid/dotnet/TopicListener/Properties/AssemblyInfo.cs106
-rw-r--r--qpid/dotnet/TopicPublisher/Program.cs60
-rw-r--r--qpid/dotnet/TopicPublisher/Properties/AssemblyInfo.cs106
101 files changed, 12211 insertions, 12211 deletions
diff --git a/qpid/dotnet/Qpid.Buffer.Tests/Properties/AssemblyInfo.cs b/qpid/dotnet/Qpid.Buffer.Tests/Properties/AssemblyInfo.cs
index 30fb588a74..2f49033c2d 100644
--- a/qpid/dotnet/Qpid.Buffer.Tests/Properties/AssemblyInfo.cs
+++ b/qpid/dotnet/Qpid.Buffer.Tests/Properties/AssemblyInfo.cs
@@ -1,56 +1,56 @@
-/*
- *
- * 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.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Apache.Qpid.Buffer.Tests")]
-[assembly: AssemblyDescription("Built from svn revision number: ")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache.Qpid.Buffer.Tests")]
-[assembly: AssemblyCopyright("Apache Software Foundation")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("9d967d0b-9454-4f00-8f53-fa86fd62b696")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("0.5.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+/*
+ *
+ * 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Apache.Qpid.Buffer.Tests")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache.Qpid.Buffer.Tests")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("9d967d0b-9454-4f00-8f53-fa86fd62b696")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("0.5.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/Qpid.Buffer.Tests/SimpleByteBufferTests.cs b/qpid/dotnet/Qpid.Buffer.Tests/SimpleByteBufferTests.cs
index 9af8801627..b028bdb1ee 100644
--- a/qpid/dotnet/Qpid.Buffer.Tests/SimpleByteBufferTests.cs
+++ b/qpid/dotnet/Qpid.Buffer.Tests/SimpleByteBufferTests.cs
@@ -1,333 +1,333 @@
-/*
- *
- * 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 NUnit.Framework;
-using Apache.Qpid.Buffer;
-
-namespace Apache.Qpid.Buffer.Tests
-{
- /// <summary>
- /// Tests for the SimpleByteBuffer class
- /// </summary>
- [TestFixture]
- public class SimpleByteBufferTests
- {
- [Test]
- public void CanCreateNewBuffer()
- {
- const int size = 10;
- ByteBuffer buffer = ByteBuffer.Allocate(size);
- Assert.AreEqual(size, buffer.Capacity);
- Assert.AreEqual(0, buffer.Position);
- Assert.AreEqual(size, buffer.Remaining);
- Assert.AreEqual(true, buffer.HasRemaining);
- }
-
- [Test]
- public void CanWrapArray()
- {
- byte[] array = new byte[10];
- for ( int i=0; i < array.Length; i++ )
- {
- array[i] = (byte) i;
- }
- ByteBuffer buffer = ByteBuffer.Wrap(array);
- // the buffer should be the same size,
- // and positioned at the end
- Assert.AreEqual(array.Length, buffer.Capacity);
- Assert.AreEqual(array.Length, buffer.Position);
- Assert.AreEqual(array.Length, buffer.Limit);
- }
-
- #region Base Read/Write tests
- //
- // Base Read/Write tests
- //
- [Test]
- public void CanReadWriteBytes()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
- buffer.Rewind();
- Assert.AreEqual(0x01, buffer.GetByte());
- Assert.AreEqual(0x02, buffer.GetByte());
- Assert.AreEqual(0x03, buffer.GetByte());
- }
-
- [Test]
- [ExpectedException(typeof(BufferUnderflowException))]
- public void ThrowOnReadByteWithNoSpace()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(1);
- buffer.Put((byte)0x01);
- buffer.GetByte();
- }
-
- [Test]
- [ExpectedException(typeof(BufferOverflowException))]
- public void ThrowOnWriteByteWithNoSpace()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(1);
- buffer.Put((byte)0x01).Put((byte)0x02);
- }
-
- #endregion Base Read/Write tests
-
- #region Other Buffer Operations
- //
- // Other Buffer Operations
- //
-
- [Test]
- public void CanFlipBuffer()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
- buffer.Flip();
- Assert.AreEqual(10, buffer.Capacity);
- Assert.AreEqual(3, buffer.Limit);
- Assert.AreEqual(0, buffer.Position);
- Assert.AreEqual(3, buffer.Remaining);
- }
-
- [Test]
- public void CanCompactBuffer()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
- buffer.Flip();
- buffer.Position = 1;
- buffer.Compact();
- Assert.AreEqual(10, buffer.Capacity);
- Assert.AreEqual(10, buffer.Limit);
- Assert.AreEqual(2, buffer.Position);
- Assert.AreEqual(8, buffer.Remaining);
- buffer.Rewind();
- Assert.AreEqual((byte)0x02, buffer.GetByte());
- Assert.AreEqual((byte)0x03, buffer.GetByte());
- }
-
- [Test]
- public void CanClearBuffer()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
- buffer.Flip();
- buffer.Position = 2;
- buffer.Clear();
- Assert.AreEqual(10, buffer.Capacity);
- Assert.AreEqual(10, buffer.Limit);
- Assert.AreEqual(0, buffer.Position);
- Assert.AreEqual(10, buffer.Remaining);
- }
-
- [Test]
- public void CanExpandBuffer()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
- buffer.Flip();
- buffer.Position = 2;
- int pos = buffer.Position;
- buffer.Expand(20);
-
- Assert.AreEqual(pos, buffer.Position);
- Assert.IsTrue(buffer.Remaining >= 20);
- buffer.Rewind();
- Assert.AreEqual(0x01, buffer.GetByte());
- }
-
- [Test]
- public void CanAutoExpand()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(2);
- buffer.IsAutoExpand = true;
- // should cause autoexpand
- buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
- Assert.IsTrue(buffer.Capacity > 2);
- }
-
- [Test]
- public void CanGetArray()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
- buffer.Flip();
-
- byte[] array = buffer.Array;
- for ( int i=0; i < buffer.Limit; i++ )
- {
- Assert.AreEqual(buffer.GetByte(), array[i]);
- }
- }
-
- [Test]
- public void CanSkip()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Skip(4);
- Assert.AreEqual(4, buffer.Position);
- }
-
- #endregion // Base Read/Write tests
-
- #region Typed Accessors
- //
- // Typed Accessors
- //
- [Test]
- public void CanReadWriteSByte()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- sbyte value = -12;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetSByte());
- }
- [Test]
- public void CanReadWriteUInt16()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- ushort value = 41233;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetUInt16());
- }
- [Test]
- public void CanReadWriteInt16()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- short value = -21233;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetInt16());
- }
- [Test]
- public void CanReadWriteUInt32()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- uint value = 41233211;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetUInt32());
- }
- [Test]
- public void CanReadWriteInt32()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- int value = -22221233;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetInt32());
- }
- [Test]
- public void CanReadWriteUInt64()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- ulong value = 41233218871;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetUInt64());
- }
- [Test]
- public void CanReadWriteInt64()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- long value = -9887335411;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetInt64());
- }
- [Test]
- public void CanReadWriteFloat()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- float value = -1.2331f;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetFloat());
- }
-
- [Test]
- public void CanReadWriteDouble()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- double value = -1.2331E12;
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetDouble());
- }
-
- [Test]
- public void CanReadWriteChar()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- char value = 'H';
- buffer.Put(value);
- buffer.Flip();
- Assert.AreEqual(value, buffer.GetChar());
- }
-
- [Test]
- public void CanReadWriteByteArray()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Put(new byte[] { 0x01, 0x02, 0x03});
- buffer.Flip();
- byte[] data = new byte[3];
- buffer.GetBytes(data);
- Assert.AreEqual(0x01, data[0]);
- Assert.AreEqual(0x02, data[1]);
- Assert.AreEqual(0x03, data[2]);
- }
-
- [Test]
- public void CanReadWriteByteArrayWithOffset()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(10);
- buffer.Put(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 }, 1, 4);
- buffer.Flip();
- byte[] data = new byte[3];
- buffer.GetBytes(data, 2, 1);
- Assert.AreEqual(0x00, data[0]);
- Assert.AreEqual(0x00, data[1]);
- Assert.AreEqual(0x02, data[2]);
- }
-
- [Test]
- public void CanWriteByteBuffer()
- {
- ByteBuffer buffer1 = ByteBuffer.Allocate(10);
- buffer1.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
- buffer1.Flip();
-
- ByteBuffer buffer2 = ByteBuffer.Allocate(10);
- buffer2.Put(buffer1);
- buffer2.Flip();
- Assert.AreEqual(buffer1.Limit, buffer2.Limit);
- Assert.AreEqual(0x01, buffer2.GetByte());
- }
- #endregion // Typed Accessors
-
- } // class SimpleByteBufferTests
-}
-
-
+/*
+ *
+ * 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 NUnit.Framework;
+using Apache.Qpid.Buffer;
+
+namespace Apache.Qpid.Buffer.Tests
+{
+ /// <summary>
+ /// Tests for the SimpleByteBuffer class
+ /// </summary>
+ [TestFixture]
+ public class SimpleByteBufferTests
+ {
+ [Test]
+ public void CanCreateNewBuffer()
+ {
+ const int size = 10;
+ ByteBuffer buffer = ByteBuffer.Allocate(size);
+ Assert.AreEqual(size, buffer.Capacity);
+ Assert.AreEqual(0, buffer.Position);
+ Assert.AreEqual(size, buffer.Remaining);
+ Assert.AreEqual(true, buffer.HasRemaining);
+ }
+
+ [Test]
+ public void CanWrapArray()
+ {
+ byte[] array = new byte[10];
+ for ( int i=0; i < array.Length; i++ )
+ {
+ array[i] = (byte) i;
+ }
+ ByteBuffer buffer = ByteBuffer.Wrap(array);
+ // the buffer should be the same size,
+ // and positioned at the end
+ Assert.AreEqual(array.Length, buffer.Capacity);
+ Assert.AreEqual(array.Length, buffer.Position);
+ Assert.AreEqual(array.Length, buffer.Limit);
+ }
+
+ #region Base Read/Write tests
+ //
+ // Base Read/Write tests
+ //
+ [Test]
+ public void CanReadWriteBytes()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
+ buffer.Rewind();
+ Assert.AreEqual(0x01, buffer.GetByte());
+ Assert.AreEqual(0x02, buffer.GetByte());
+ Assert.AreEqual(0x03, buffer.GetByte());
+ }
+
+ [Test]
+ [ExpectedException(typeof(BufferUnderflowException))]
+ public void ThrowOnReadByteWithNoSpace()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(1);
+ buffer.Put((byte)0x01);
+ buffer.GetByte();
+ }
+
+ [Test]
+ [ExpectedException(typeof(BufferOverflowException))]
+ public void ThrowOnWriteByteWithNoSpace()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(1);
+ buffer.Put((byte)0x01).Put((byte)0x02);
+ }
+
+ #endregion Base Read/Write tests
+
+ #region Other Buffer Operations
+ //
+ // Other Buffer Operations
+ //
+
+ [Test]
+ public void CanFlipBuffer()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
+ buffer.Flip();
+ Assert.AreEqual(10, buffer.Capacity);
+ Assert.AreEqual(3, buffer.Limit);
+ Assert.AreEqual(0, buffer.Position);
+ Assert.AreEqual(3, buffer.Remaining);
+ }
+
+ [Test]
+ public void CanCompactBuffer()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
+ buffer.Flip();
+ buffer.Position = 1;
+ buffer.Compact();
+ Assert.AreEqual(10, buffer.Capacity);
+ Assert.AreEqual(10, buffer.Limit);
+ Assert.AreEqual(2, buffer.Position);
+ Assert.AreEqual(8, buffer.Remaining);
+ buffer.Rewind();
+ Assert.AreEqual((byte)0x02, buffer.GetByte());
+ Assert.AreEqual((byte)0x03, buffer.GetByte());
+ }
+
+ [Test]
+ public void CanClearBuffer()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
+ buffer.Flip();
+ buffer.Position = 2;
+ buffer.Clear();
+ Assert.AreEqual(10, buffer.Capacity);
+ Assert.AreEqual(10, buffer.Limit);
+ Assert.AreEqual(0, buffer.Position);
+ Assert.AreEqual(10, buffer.Remaining);
+ }
+
+ [Test]
+ public void CanExpandBuffer()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
+ buffer.Flip();
+ buffer.Position = 2;
+ int pos = buffer.Position;
+ buffer.Expand(20);
+
+ Assert.AreEqual(pos, buffer.Position);
+ Assert.IsTrue(buffer.Remaining >= 20);
+ buffer.Rewind();
+ Assert.AreEqual(0x01, buffer.GetByte());
+ }
+
+ [Test]
+ public void CanAutoExpand()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(2);
+ buffer.IsAutoExpand = true;
+ // should cause autoexpand
+ buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
+ Assert.IsTrue(buffer.Capacity > 2);
+ }
+
+ [Test]
+ public void CanGetArray()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
+ buffer.Flip();
+
+ byte[] array = buffer.Array;
+ for ( int i=0; i < buffer.Limit; i++ )
+ {
+ Assert.AreEqual(buffer.GetByte(), array[i]);
+ }
+ }
+
+ [Test]
+ public void CanSkip()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Skip(4);
+ Assert.AreEqual(4, buffer.Position);
+ }
+
+ #endregion // Base Read/Write tests
+
+ #region Typed Accessors
+ //
+ // Typed Accessors
+ //
+ [Test]
+ public void CanReadWriteSByte()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ sbyte value = -12;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetSByte());
+ }
+ [Test]
+ public void CanReadWriteUInt16()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ ushort value = 41233;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetUInt16());
+ }
+ [Test]
+ public void CanReadWriteInt16()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ short value = -21233;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetInt16());
+ }
+ [Test]
+ public void CanReadWriteUInt32()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ uint value = 41233211;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetUInt32());
+ }
+ [Test]
+ public void CanReadWriteInt32()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ int value = -22221233;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetInt32());
+ }
+ [Test]
+ public void CanReadWriteUInt64()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ ulong value = 41233218871;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetUInt64());
+ }
+ [Test]
+ public void CanReadWriteInt64()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ long value = -9887335411;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetInt64());
+ }
+ [Test]
+ public void CanReadWriteFloat()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ float value = -1.2331f;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetFloat());
+ }
+
+ [Test]
+ public void CanReadWriteDouble()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ double value = -1.2331E12;
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetDouble());
+ }
+
+ [Test]
+ public void CanReadWriteChar()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ char value = 'H';
+ buffer.Put(value);
+ buffer.Flip();
+ Assert.AreEqual(value, buffer.GetChar());
+ }
+
+ [Test]
+ public void CanReadWriteByteArray()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Put(new byte[] { 0x01, 0x02, 0x03});
+ buffer.Flip();
+ byte[] data = new byte[3];
+ buffer.GetBytes(data);
+ Assert.AreEqual(0x01, data[0]);
+ Assert.AreEqual(0x02, data[1]);
+ Assert.AreEqual(0x03, data[2]);
+ }
+
+ [Test]
+ public void CanReadWriteByteArrayWithOffset()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(10);
+ buffer.Put(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 }, 1, 4);
+ buffer.Flip();
+ byte[] data = new byte[3];
+ buffer.GetBytes(data, 2, 1);
+ Assert.AreEqual(0x00, data[0]);
+ Assert.AreEqual(0x00, data[1]);
+ Assert.AreEqual(0x02, data[2]);
+ }
+
+ [Test]
+ public void CanWriteByteBuffer()
+ {
+ ByteBuffer buffer1 = ByteBuffer.Allocate(10);
+ buffer1.Put((byte)0x01).Put((byte)0x02).Put((byte)0x03);
+ buffer1.Flip();
+
+ ByteBuffer buffer2 = ByteBuffer.Allocate(10);
+ buffer2.Put(buffer1);
+ buffer2.Flip();
+ Assert.AreEqual(buffer1.Limit, buffer2.Limit);
+ Assert.AreEqual(0x01, buffer2.GetByte());
+ }
+ #endregion // Typed Accessors
+
+ } // class SimpleByteBufferTests
+}
+
+
diff --git a/qpid/dotnet/Qpid.Buffer.Tests/SlicedByteBufferTests.cs b/qpid/dotnet/Qpid.Buffer.Tests/SlicedByteBufferTests.cs
index 071aa23830..7dec7c390f 100644
--- a/qpid/dotnet/Qpid.Buffer.Tests/SlicedByteBufferTests.cs
+++ b/qpid/dotnet/Qpid.Buffer.Tests/SlicedByteBufferTests.cs
@@ -1,133 +1,133 @@
-/*
- *
- * 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 Apache.Qpid.Buffer;
-
-namespace Apache.Qpid.Buffer.Tests
-{
- /// <summary>
- /// Tests for the SlicedByteBuffer class
- /// </summary>
- [TestFixture]
- public class SlicedByteBufferTests
- {
- private ByteBuffer _baseBuffer;
-
- [SetUp]
- public void Setup()
- {
- const int size = 50;
- _baseBuffer = ByteBuffer.Allocate(size);
- for ( byte b = 0; b < 10; b++ )
- {
- _baseBuffer.Put(b);
- }
- _baseBuffer.Flip();
- }
-
- [Test]
- public void CanSliceBuffer()
- {
- _baseBuffer.Position = 5;
-
- ByteBuffer slice = _baseBuffer.Slice();
- Assert.AreEqual(5, slice.Capacity);
- Assert.AreEqual(0, slice.Position);
- Assert.AreEqual(5, slice.Remaining);
- Assert.AreEqual(5, slice.Limit);
- }
-
- [Test]
- public void CanReadWriteSlice()
- {
- _baseBuffer.Position = 5;
-
- ByteBuffer slice = _baseBuffer.Slice();
- slice.Put((byte) 0xFF).Put((byte) 0xF0).Put((byte) 0xA0);
- slice.Flip();
-
- Assert.AreEqual(3, slice.Limit);
- Assert.AreEqual(0xFF, slice.GetByte());
- Assert.AreEqual(0xF0, slice.GetByte());
- Assert.AreEqual(0xA0, slice.GetByte());
- }
-
- [Test]
- public void WriteModifiesBaseBufferOnCorrectPosition()
- {
- _baseBuffer.Position = 5;
-
- ByteBuffer slice = _baseBuffer.Slice();
- slice.Put((byte) 0xFF);
- slice.Flip();
- // reading the _baseBuffer at position 5 should yield 0xFF
- _baseBuffer.Position = 5;
- Assert.AreEqual(0xFF, _baseBuffer.GetByte());
-
- }
-
- [Test]
- public void CanReadWriteByteArray()
- {
- _baseBuffer.Position = 5;
-
- ByteBuffer slice = _baseBuffer.Slice();
- byte[] data = {0xFF, 0xF0, 0xF2, 0xEE, 0x23};
- slice.Put(data, 2, 2);
- slice.Flip();
-
- Assert.AreEqual(2, slice.Limit);
- Assert.AreEqual(0xF2, slice.GetByte());
- Assert.AreEqual(0xEE, slice.GetByte());
- }
-
- [Test]
- [ExpectedException(typeof(BufferOverflowException))]
- public void ThrowWhenWritePastLimit()
- {
- _baseBuffer.Position = 5;
-
- ByteBuffer slice = _baseBuffer.Slice();
- slice.Put(0x01).Put(0x02);
- }
-
-
- [Test]
- [ExpectedException(typeof(NotSupportedException))]
- public void ThrowOnCompact()
- {
- // we don't support compacting
- ByteBuffer slice = _baseBuffer.Slice();
- slice.Compact();
- }
-
- [Test]
- [ExpectedException(typeof(NotSupportedException))]
- public void ThrowOnResize()
- {
- // we don't support resizing
- ByteBuffer slice = _baseBuffer.Slice();
- slice.Expand(50);
- }
- } // class SlicedByteBufferTests
-}
+/*
+ *
+ * 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 Apache.Qpid.Buffer;
+
+namespace Apache.Qpid.Buffer.Tests
+{
+ /// <summary>
+ /// Tests for the SlicedByteBuffer class
+ /// </summary>
+ [TestFixture]
+ public class SlicedByteBufferTests
+ {
+ private ByteBuffer _baseBuffer;
+
+ [SetUp]
+ public void Setup()
+ {
+ const int size = 50;
+ _baseBuffer = ByteBuffer.Allocate(size);
+ for ( byte b = 0; b < 10; b++ )
+ {
+ _baseBuffer.Put(b);
+ }
+ _baseBuffer.Flip();
+ }
+
+ [Test]
+ public void CanSliceBuffer()
+ {
+ _baseBuffer.Position = 5;
+
+ ByteBuffer slice = _baseBuffer.Slice();
+ Assert.AreEqual(5, slice.Capacity);
+ Assert.AreEqual(0, slice.Position);
+ Assert.AreEqual(5, slice.Remaining);
+ Assert.AreEqual(5, slice.Limit);
+ }
+
+ [Test]
+ public void CanReadWriteSlice()
+ {
+ _baseBuffer.Position = 5;
+
+ ByteBuffer slice = _baseBuffer.Slice();
+ slice.Put((byte) 0xFF).Put((byte) 0xF0).Put((byte) 0xA0);
+ slice.Flip();
+
+ Assert.AreEqual(3, slice.Limit);
+ Assert.AreEqual(0xFF, slice.GetByte());
+ Assert.AreEqual(0xF0, slice.GetByte());
+ Assert.AreEqual(0xA0, slice.GetByte());
+ }
+
+ [Test]
+ public void WriteModifiesBaseBufferOnCorrectPosition()
+ {
+ _baseBuffer.Position = 5;
+
+ ByteBuffer slice = _baseBuffer.Slice();
+ slice.Put((byte) 0xFF);
+ slice.Flip();
+ // reading the _baseBuffer at position 5 should yield 0xFF
+ _baseBuffer.Position = 5;
+ Assert.AreEqual(0xFF, _baseBuffer.GetByte());
+
+ }
+
+ [Test]
+ public void CanReadWriteByteArray()
+ {
+ _baseBuffer.Position = 5;
+
+ ByteBuffer slice = _baseBuffer.Slice();
+ byte[] data = {0xFF, 0xF0, 0xF2, 0xEE, 0x23};
+ slice.Put(data, 2, 2);
+ slice.Flip();
+
+ Assert.AreEqual(2, slice.Limit);
+ Assert.AreEqual(0xF2, slice.GetByte());
+ Assert.AreEqual(0xEE, slice.GetByte());
+ }
+
+ [Test]
+ [ExpectedException(typeof(BufferOverflowException))]
+ public void ThrowWhenWritePastLimit()
+ {
+ _baseBuffer.Position = 5;
+
+ ByteBuffer slice = _baseBuffer.Slice();
+ slice.Put(0x01).Put(0x02);
+ }
+
+
+ [Test]
+ [ExpectedException(typeof(NotSupportedException))]
+ public void ThrowOnCompact()
+ {
+ // we don't support compacting
+ ByteBuffer slice = _baseBuffer.Slice();
+ slice.Compact();
+ }
+
+ [Test]
+ [ExpectedException(typeof(NotSupportedException))]
+ public void ThrowOnResize()
+ {
+ // we don't support resizing
+ ByteBuffer slice = _baseBuffer.Slice();
+ slice.Expand(50);
+ }
+ } // class SlicedByteBufferTests
+}
diff --git a/qpid/dotnet/Qpid.Buffer/IByteBufferAllocator.cs b/qpid/dotnet/Qpid.Buffer/IByteBufferAllocator.cs
index 0f457df065..74944f7e69 100644
--- a/qpid/dotnet/Qpid.Buffer/IByteBufferAllocator.cs
+++ b/qpid/dotnet/Qpid.Buffer/IByteBufferAllocator.cs
@@ -1,50 +1,50 @@
-/*
- *
- * 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;
-
-namespace Apache.Qpid.Buffer
-{
- /// <summary>
- /// Allocates <see cref="ByteBuffer"/>'s and manages them. Please
- /// implement this interface if you need more advanced memory management scheme
- /// </summary>
- public interface IByteBufferAllocator : IDisposable
- {
- /// <summary>
- /// Returns the buffer which is capable of the specified size.
- /// </summary>
- /// <param name="capacity">The capacity of the buffer</param>
- /// <returns>A new buffer</returns>
- ByteBuffer Allocate(int capacity);
-
- /// <summary>
- /// Wrap the specified byte array in a new buffer
- /// </summary>
- /// <param name="src">Source array</param>
- /// <returns>A new buffer</returns>
- ByteBuffer Wrap(byte[] src);
-
- } // interface IByteBufferAllocator
-}
-
-
-
+/*
+ *
+ * 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;
+
+namespace Apache.Qpid.Buffer
+{
+ /// <summary>
+ /// Allocates <see cref="ByteBuffer"/>'s and manages them. Please
+ /// implement this interface if you need more advanced memory management scheme
+ /// </summary>
+ public interface IByteBufferAllocator : IDisposable
+ {
+ /// <summary>
+ /// Returns the buffer which is capable of the specified size.
+ /// </summary>
+ /// <param name="capacity">The capacity of the buffer</param>
+ /// <returns>A new buffer</returns>
+ ByteBuffer Allocate(int capacity);
+
+ /// <summary>
+ /// Wrap the specified byte array in a new buffer
+ /// </summary>
+ /// <param name="src">Source array</param>
+ /// <returns>A new buffer</returns>
+ ByteBuffer Wrap(byte[] src);
+
+ } // interface IByteBufferAllocator
+}
+
+
+
diff --git a/qpid/dotnet/Qpid.Buffer/SimpleByteBuffer.cs b/qpid/dotnet/Qpid.Buffer/SimpleByteBuffer.cs
index d3b7245cb1..956c59aa45 100644
--- a/qpid/dotnet/Qpid.Buffer/SimpleByteBuffer.cs
+++ b/qpid/dotnet/Qpid.Buffer/SimpleByteBuffer.cs
@@ -1,120 +1,120 @@
-/*
- *
- * 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;
-
-namespace Apache.Qpid.Buffer
-{
- internal sealed class SimpleByteBuffer : ByteBuffer
- {
- private byte[] _buffer;
-
- public override int Capacity
- {
- get { return _buffer.Length; }
- }
-
- public override byte[] Array
- {
- get { return _buffer; }
- }
-
- /// <summary>
- /// Initialize a new instance with the desired size
- /// </summary>
- /// <param name="desiredSize">Initial Length of the array</param>
- internal SimpleByteBuffer(int desiredSize)
- {
- _buffer = new byte[desiredSize];
- Position = 0;
- Limit = Capacity;
- }
-
- /// <summary>
- /// Initialize a new instance with the data from
- /// an underlying array
- /// </summary>
- /// <param name="buffer">Initial data</param>
- /// <remarks>The original array is copied during construction and is not modified</remarks>
- internal SimpleByteBuffer(byte[] buffer)
- {
- _buffer = (byte[])buffer.Clone();
- // position at end
- Position = Limit = Capacity;
- }
-
- protected override void DoWrite(int position, byte value)
- {
- // available space is already handled by base class
- _buffer[position] = value;
- }
-
- protected override void DoWrite(int position, byte[] src, int offset, int length)
- {
- // available space is already handled by base class
- for ( int i = 0; i < length; i++ )
- {
- _buffer[position+i] = src[offset+i];
- }
- }
-
- protected override byte DoReadByte(int position)
- {
- return _buffer[position];
- }
-
- protected override void DoReadBytes(int position, byte[] dest, int offset, int length)
- {
- System.Array.Copy(_buffer, position, dest, offset, length);
- }
-
- protected override void DoCompact()
- {
- if ( Remaining > 0 )
- {
- if ( Position > 0 )
- {
- System.Array.Copy(_buffer, Position, _buffer, 0, Remaining);
- }
- Position = Remaining;
- } else
- {
- Position = 0;
- }
- Limit = Capacity;
- }
-
- protected override void DoResize(int newSize)
- {
- if ( newSize < Capacity )
- throw new NotSupportedException("Cannot resize a buffer to make it smaller");
-
- int newCapacity = 1;
- while ( newCapacity < newSize )
- {
- newCapacity <<= 1;
- }
-
- byte[] newBuffer = new byte[newCapacity];
- System.Array.Copy(_buffer, newBuffer, _buffer.Length);
- _buffer = newBuffer;
- }
- } // class SimpleByteBuffer
-}
+/*
+ *
+ * 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;
+
+namespace Apache.Qpid.Buffer
+{
+ internal sealed class SimpleByteBuffer : ByteBuffer
+ {
+ private byte[] _buffer;
+
+ public override int Capacity
+ {
+ get { return _buffer.Length; }
+ }
+
+ public override byte[] Array
+ {
+ get { return _buffer; }
+ }
+
+ /// <summary>
+ /// Initialize a new instance with the desired size
+ /// </summary>
+ /// <param name="desiredSize">Initial Length of the array</param>
+ internal SimpleByteBuffer(int desiredSize)
+ {
+ _buffer = new byte[desiredSize];
+ Position = 0;
+ Limit = Capacity;
+ }
+
+ /// <summary>
+ /// Initialize a new instance with the data from
+ /// an underlying array
+ /// </summary>
+ /// <param name="buffer">Initial data</param>
+ /// <remarks>The original array is copied during construction and is not modified</remarks>
+ internal SimpleByteBuffer(byte[] buffer)
+ {
+ _buffer = (byte[])buffer.Clone();
+ // position at end
+ Position = Limit = Capacity;
+ }
+
+ protected override void DoWrite(int position, byte value)
+ {
+ // available space is already handled by base class
+ _buffer[position] = value;
+ }
+
+ protected override void DoWrite(int position, byte[] src, int offset, int length)
+ {
+ // available space is already handled by base class
+ for ( int i = 0; i < length; i++ )
+ {
+ _buffer[position+i] = src[offset+i];
+ }
+ }
+
+ protected override byte DoReadByte(int position)
+ {
+ return _buffer[position];
+ }
+
+ protected override void DoReadBytes(int position, byte[] dest, int offset, int length)
+ {
+ System.Array.Copy(_buffer, position, dest, offset, length);
+ }
+
+ protected override void DoCompact()
+ {
+ if ( Remaining > 0 )
+ {
+ if ( Position > 0 )
+ {
+ System.Array.Copy(_buffer, Position, _buffer, 0, Remaining);
+ }
+ Position = Remaining;
+ } else
+ {
+ Position = 0;
+ }
+ Limit = Capacity;
+ }
+
+ protected override void DoResize(int newSize)
+ {
+ if ( newSize < Capacity )
+ throw new NotSupportedException("Cannot resize a buffer to make it smaller");
+
+ int newCapacity = 1;
+ while ( newCapacity < newSize )
+ {
+ newCapacity <<= 1;
+ }
+
+ byte[] newBuffer = new byte[newCapacity];
+ System.Array.Copy(_buffer, newBuffer, _buffer.Length);
+ _buffer = newBuffer;
+ }
+ } // class SimpleByteBuffer
+}
diff --git a/qpid/dotnet/Qpid.Buffer/SlicedByteBuffer.cs b/qpid/dotnet/Qpid.Buffer/SlicedByteBuffer.cs
index c27b7949b6..890e2a3c7a 100644
--- a/qpid/dotnet/Qpid.Buffer/SlicedByteBuffer.cs
+++ b/qpid/dotnet/Qpid.Buffer/SlicedByteBuffer.cs
@@ -1,86 +1,86 @@
-/*
- *
- * 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;
-
-namespace Apache.Qpid.Buffer
-{
- internal sealed class SlicedByteBuffer : ByteBuffer
- {
- private ByteBuffer _buffer;
- private int _capacity;
- private int _startPos;
-
- public override int Capacity
- {
- get { return _capacity; }
- }
-
- public override byte[] Array
- {
- get { return _buffer.Array; }
- }
-
- /// <summary>
- /// Initialize a new instance
- /// </summary>
- /// <param name="buffer">Underlying byte buffer</param>
- internal SlicedByteBuffer(ByteBuffer buffer)
- {
- _buffer = buffer;
- _startPos = buffer.Position;
- Position = 0;
- _capacity = buffer.Remaining;
- Limit = Capacity;
- // cannot autoexpand
- IsAutoExpand = false;
- }
-
- protected override void DoWrite(int position, byte value)
- {
- _buffer.Put(_startPos + position, value);
- }
-
- protected override void DoWrite(int position, byte[] src, int offset, int length)
- {
- _buffer.Put(_startPos + position, src, offset, length);
- }
-
- protected override byte DoReadByte(int position)
- {
- return _buffer.GetByte(_startPos + position);
- }
-
- protected override void DoReadBytes(int position, byte[] dest, int offset, int length)
- {
- _buffer.GetBytes(_startPos + position, dest, offset, length);
- }
-
- protected override void DoCompact()
- {
- throw new NotSupportedException();
- }
-
- protected override void DoResize(int newSize)
- {
- throw new NotSupportedException();
- }
- } // class SlicedByteBuffer
-}
+/*
+ *
+ * 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;
+
+namespace Apache.Qpid.Buffer
+{
+ internal sealed class SlicedByteBuffer : ByteBuffer
+ {
+ private ByteBuffer _buffer;
+ private int _capacity;
+ private int _startPos;
+
+ public override int Capacity
+ {
+ get { return _capacity; }
+ }
+
+ public override byte[] Array
+ {
+ get { return _buffer.Array; }
+ }
+
+ /// <summary>
+ /// Initialize a new instance
+ /// </summary>
+ /// <param name="buffer">Underlying byte buffer</param>
+ internal SlicedByteBuffer(ByteBuffer buffer)
+ {
+ _buffer = buffer;
+ _startPos = buffer.Position;
+ Position = 0;
+ _capacity = buffer.Remaining;
+ Limit = Capacity;
+ // cannot autoexpand
+ IsAutoExpand = false;
+ }
+
+ protected override void DoWrite(int position, byte value)
+ {
+ _buffer.Put(_startPos + position, value);
+ }
+
+ protected override void DoWrite(int position, byte[] src, int offset, int length)
+ {
+ _buffer.Put(_startPos + position, src, offset, length);
+ }
+
+ protected override byte DoReadByte(int position)
+ {
+ return _buffer.GetByte(_startPos + position);
+ }
+
+ protected override void DoReadBytes(int position, byte[] dest, int offset, int length)
+ {
+ _buffer.GetBytes(_startPos + position, dest, offset, length);
+ }
+
+ protected override void DoCompact()
+ {
+ throw new NotSupportedException();
+ }
+
+ protected override void DoResize(int newSize)
+ {
+ throw new NotSupportedException();
+ }
+ } // class SlicedByteBuffer
+}
diff --git a/qpid/dotnet/Qpid.Client.Tests/BrokerDetails/BrokerDetailsTest.cs b/qpid/dotnet/Qpid.Client.Tests/BrokerDetails/BrokerDetailsTest.cs
index 8e8d8ced3b..56269c0f9d 100644
--- a/qpid/dotnet/Qpid.Client.Tests/BrokerDetails/BrokerDetailsTest.cs
+++ b/qpid/dotnet/Qpid.Client.Tests/BrokerDetails/BrokerDetailsTest.cs
@@ -1,65 +1,65 @@
-/*
- *
- * 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 System.Net;
-using NUnit.Framework;
-using Apache.Qpid.Client.Qms;
-
-namespace Apache.Qpid.Client.Tests.BrokerDetails
-{
- [TestFixture]
- public class BrokerDetailsTest
- {
-
- [Test]
- public void ValidateBrokerInfoEqualsMethod()
- {
- AmqBrokerInfo broker = new AmqBrokerInfo("amqp", "localhost", 5672, true);
- AmqBrokerInfo broker1 = new AmqBrokerInfo("Amqp", "localhost", 5672, true);
-
- Assert.IsTrue(broker.Equals(broker1),"The two AmqBrokerInfo objects are not equals");
- Console.WriteLine(string.Format("The object broker: {0} and broker1: {1} are equals", broker, broker1));
- }
-
- [Test]
- public void ValidateBrokerInfoWithDifferentSSL()
- {
- AmqBrokerInfo broker = new AmqBrokerInfo("amqp", "localhost", 5672, true);
- AmqBrokerInfo broker1 = new AmqBrokerInfo("amqp", "localhost", 5672, false);
-
- Assert.IsFalse(broker.Equals(broker1), "The two AmqBrokerInfo objects are equals");
- Console.WriteLine(string.Format("The object broker: {0} and broker1: {1} are not equals", broker, broker1));
- }
-
- [Test]
- public void ValidateBrokerInfoFromToString()
- {
- String url = "tcp://localhost:5672?timeout='200',immediatedelivery='true'";
-
- AmqBrokerInfo broker = new AmqBrokerInfo(url);
- AmqBrokerInfo broker1 = new AmqBrokerInfo(broker.ToString());
-
- Assert.AreEqual(broker.GetOption("timeout"), broker1.GetOption("timeout"));
- Assert.AreEqual(broker.GetOption("immediatedelivery"), broker1.GetOption("immediatedelivery"));
- }
-
- }
-}
+/*
+ *
+ * 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 System.Net;
+using NUnit.Framework;
+using Apache.Qpid.Client.Qms;
+
+namespace Apache.Qpid.Client.Tests.BrokerDetails
+{
+ [TestFixture]
+ public class BrokerDetailsTest
+ {
+
+ [Test]
+ public void ValidateBrokerInfoEqualsMethod()
+ {
+ AmqBrokerInfo broker = new AmqBrokerInfo("amqp", "localhost", 5672, true);
+ AmqBrokerInfo broker1 = new AmqBrokerInfo("Amqp", "localhost", 5672, true);
+
+ Assert.IsTrue(broker.Equals(broker1),"The two AmqBrokerInfo objects are not equals");
+ Console.WriteLine(string.Format("The object broker: {0} and broker1: {1} are equals", broker, broker1));
+ }
+
+ [Test]
+ public void ValidateBrokerInfoWithDifferentSSL()
+ {
+ AmqBrokerInfo broker = new AmqBrokerInfo("amqp", "localhost", 5672, true);
+ AmqBrokerInfo broker1 = new AmqBrokerInfo("amqp", "localhost", 5672, false);
+
+ Assert.IsFalse(broker.Equals(broker1), "The two AmqBrokerInfo objects are equals");
+ Console.WriteLine(string.Format("The object broker: {0} and broker1: {1} are not equals", broker, broker1));
+ }
+
+ [Test]
+ public void ValidateBrokerInfoFromToString()
+ {
+ String url = "tcp://localhost:5672?timeout='200',immediatedelivery='true'";
+
+ AmqBrokerInfo broker = new AmqBrokerInfo(url);
+ AmqBrokerInfo broker1 = new AmqBrokerInfo(broker.ToString());
+
+ Assert.AreEqual(broker.GetOption("timeout"), broker1.GetOption("timeout"));
+ Assert.AreEqual(broker.GetOption("immediatedelivery"), broker1.GetOption("immediatedelivery"));
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client.Tests/Channel/ChannelMessageCreationTests.cs b/qpid/dotnet/Qpid.Client.Tests/Channel/ChannelMessageCreationTests.cs
index c27aa9a503..f4f217c2a0 100644
--- a/qpid/dotnet/Qpid.Client.Tests/Channel/ChannelMessageCreationTests.cs
+++ b/qpid/dotnet/Qpid.Client.Tests/Channel/ChannelMessageCreationTests.cs
@@ -1,79 +1,79 @@
-/*
- *
- * 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 log4net;
-using NUnit.Framework;
-using Apache.Qpid.Client;
-using Apache.Qpid.Client.Message;
-using Apache.Qpid.Messaging;
-
-namespace Apache.Qpid.Client.Tests.Channel
-{
- /// <summary>
- /// Test that channels can create messages correctly
- /// </summary>
- [TestFixture]
- public class ChannelMessageCreationTests
- {
- [Test]
- public void CanCreateTextMessage()
- {
- IChannel channel = AmqChannel.CreateDisconnectedChannel();
- ITextMessage msg = channel.CreateTextMessage();
- Assert.IsNotNull(msg);
- }
- [Test]
- public void CanCreateTextMessageWithContent()
- {
- IChannel channel = AmqChannel.CreateDisconnectedChannel();
- const string CONTENT = "1234567890";
- ITextMessage msg = channel.CreateTextMessage(CONTENT);
- Assert.IsNotNull(msg);
- Assert.AreEqual(CONTENT, msg.Text);
- }
- [Test]
- public void CanCreateBytesMessage()
- {
- IChannel channel = AmqChannel.CreateDisconnectedChannel();
- IBytesMessage msg = channel.CreateBytesMessage();
- Assert.IsNotNull(msg);
- }
- [Test]
- public void CanCreateMessage()
- {
- IChannel channel = AmqChannel.CreateDisconnectedChannel();
- IMessage msg = channel.CreateMessage();
- Assert.IsNotNull(msg);
- }
- [Test]
- public void CanCreateMessageFromMimeType()
- {
- IChannel channel = AmqChannel.CreateDisconnectedChannel();
- IMessage msg = channel.CreateMessage("text/xml");
- Assert.IsNotNull(msg);
- Assert.IsInstanceOfType(typeof(ITextMessage), msg);
- }
- }
-} // namespace Apache.Qpid.Client.Tests.Channel
-
-
+/*
+ *
+ * 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 log4net;
+using NUnit.Framework;
+using Apache.Qpid.Client;
+using Apache.Qpid.Client.Message;
+using Apache.Qpid.Messaging;
+
+namespace Apache.Qpid.Client.Tests.Channel
+{
+ /// <summary>
+ /// Test that channels can create messages correctly
+ /// </summary>
+ [TestFixture]
+ public class ChannelMessageCreationTests
+ {
+ [Test]
+ public void CanCreateTextMessage()
+ {
+ IChannel channel = AmqChannel.CreateDisconnectedChannel();
+ ITextMessage msg = channel.CreateTextMessage();
+ Assert.IsNotNull(msg);
+ }
+ [Test]
+ public void CanCreateTextMessageWithContent()
+ {
+ IChannel channel = AmqChannel.CreateDisconnectedChannel();
+ const string CONTENT = "1234567890";
+ ITextMessage msg = channel.CreateTextMessage(CONTENT);
+ Assert.IsNotNull(msg);
+ Assert.AreEqual(CONTENT, msg.Text);
+ }
+ [Test]
+ public void CanCreateBytesMessage()
+ {
+ IChannel channel = AmqChannel.CreateDisconnectedChannel();
+ IBytesMessage msg = channel.CreateBytesMessage();
+ Assert.IsNotNull(msg);
+ }
+ [Test]
+ public void CanCreateMessage()
+ {
+ IChannel channel = AmqChannel.CreateDisconnectedChannel();
+ IMessage msg = channel.CreateMessage();
+ Assert.IsNotNull(msg);
+ }
+ [Test]
+ public void CanCreateMessageFromMimeType()
+ {
+ IChannel channel = AmqChannel.CreateDisconnectedChannel();
+ IMessage msg = channel.CreateMessage("text/xml");
+ Assert.IsNotNull(msg);
+ Assert.IsInstanceOfType(typeof(ITextMessage), msg);
+ }
+ }
+} // namespace Apache.Qpid.Client.Tests.Channel
+
+
diff --git a/qpid/dotnet/Qpid.Client.Tests/Messages/MessageFactoryRegistryTests.cs b/qpid/dotnet/Qpid.Client.Tests/Messages/MessageFactoryRegistryTests.cs
index 1211196541..4db3c91cb5 100644
--- a/qpid/dotnet/Qpid.Client.Tests/Messages/MessageFactoryRegistryTests.cs
+++ b/qpid/dotnet/Qpid.Client.Tests/Messages/MessageFactoryRegistryTests.cs
@@ -1,114 +1,114 @@
-/*
- *
- * 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 log4net;
-using NUnit.Framework;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Message;
-
-namespace Apache.Qpid.Client.Tests.Messages
-{
- /// <summary>
- /// Ensure a factory creates messages correctly
- /// </summary>
- [TestFixture]
- public class MessageFactoryRegistryTests
- {
- const string TEXT_PLAIN = "text/plain";
- const string TEXT_XML = "text/xml";
- const string OCTET_STREAM = "application/octet-stream";
-
- /// <summary>
- /// Check default registry can create text/plain messages
- /// </summary>
- [Test]
- public void CanCreateTextPlain()
- {
- MessageFactoryRegistry registry =
- MessageFactoryRegistry.NewDefaultRegistry();
-
- IMessage message = registry.CreateMessage(TEXT_PLAIN);
- Assert.IsNotNull(message);
- Assert.AreEqual(TEXT_PLAIN, message.ContentType);
- Assert.IsInstanceOfType(typeof(QpidTextMessage), message);
- }
- /// <summary>
- /// Check default registry can create text/xml messages
- /// </summary>
- [Test]
- public void CanCreateTextXml()
- {
- MessageFactoryRegistry registry =
- MessageFactoryRegistry.NewDefaultRegistry();
-
- IMessage message = registry.CreateMessage(TEXT_XML);
- Assert.IsNotNull(message);
- Assert.AreEqual(TEXT_XML, message.ContentType);
- Assert.IsInstanceOfType(typeof(QpidTextMessage), message);
- }
- /// <summary>
- /// Check default registry can create application/octet-stream messages
- /// </summary>
- [Test]
- public void CanCreateBinary()
- {
- MessageFactoryRegistry registry =
- MessageFactoryRegistry.NewDefaultRegistry();
-
- IMessage message = registry.CreateMessage(OCTET_STREAM);
- Assert.IsNotNull(message);
- Assert.AreEqual(OCTET_STREAM, message.ContentType);
- Assert.IsInstanceOfType(typeof(QpidBytesMessage), message);
- }
- /// <summary>
- /// Check default registry can create messages for unknown types
- /// </summary>
- [Test]
- public void CanCreateUnknownType()
- {
- MessageFactoryRegistry registry =
- MessageFactoryRegistry.NewDefaultRegistry();
-
- const string OTHER = "application/unknown";
- IMessage message = registry.CreateMessage(OTHER);
- Assert.IsNotNull(message);
- Assert.AreEqual(OTHER, message.ContentType);
- Assert.IsInstanceOfType(typeof(QpidBytesMessage), message);
- }
- /// <summary>
- /// Check that text messages default to UTF-8 encoding
- /// </summary>
- [Test]
- public void TextMessagesDefaultToUTF8Encoding()
- {
- MessageFactoryRegistry registry =
- MessageFactoryRegistry.NewDefaultRegistry();
-
- IMessage message = registry.CreateMessage(TEXT_PLAIN);
- Assert.AreEqual("utf-8", message.ContentEncoding.ToLower());
- }
-
- }
-} // namespace Apache.Qpid.Client.Tests.Messages
-
-
+/*
+ *
+ * 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 log4net;
+using NUnit.Framework;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Message;
+
+namespace Apache.Qpid.Client.Tests.Messages
+{
+ /// <summary>
+ /// Ensure a factory creates messages correctly
+ /// </summary>
+ [TestFixture]
+ public class MessageFactoryRegistryTests
+ {
+ const string TEXT_PLAIN = "text/plain";
+ const string TEXT_XML = "text/xml";
+ const string OCTET_STREAM = "application/octet-stream";
+
+ /// <summary>
+ /// Check default registry can create text/plain messages
+ /// </summary>
+ [Test]
+ public void CanCreateTextPlain()
+ {
+ MessageFactoryRegistry registry =
+ MessageFactoryRegistry.NewDefaultRegistry();
+
+ IMessage message = registry.CreateMessage(TEXT_PLAIN);
+ Assert.IsNotNull(message);
+ Assert.AreEqual(TEXT_PLAIN, message.ContentType);
+ Assert.IsInstanceOfType(typeof(QpidTextMessage), message);
+ }
+ /// <summary>
+ /// Check default registry can create text/xml messages
+ /// </summary>
+ [Test]
+ public void CanCreateTextXml()
+ {
+ MessageFactoryRegistry registry =
+ MessageFactoryRegistry.NewDefaultRegistry();
+
+ IMessage message = registry.CreateMessage(TEXT_XML);
+ Assert.IsNotNull(message);
+ Assert.AreEqual(TEXT_XML, message.ContentType);
+ Assert.IsInstanceOfType(typeof(QpidTextMessage), message);
+ }
+ /// <summary>
+ /// Check default registry can create application/octet-stream messages
+ /// </summary>
+ [Test]
+ public void CanCreateBinary()
+ {
+ MessageFactoryRegistry registry =
+ MessageFactoryRegistry.NewDefaultRegistry();
+
+ IMessage message = registry.CreateMessage(OCTET_STREAM);
+ Assert.IsNotNull(message);
+ Assert.AreEqual(OCTET_STREAM, message.ContentType);
+ Assert.IsInstanceOfType(typeof(QpidBytesMessage), message);
+ }
+ /// <summary>
+ /// Check default registry can create messages for unknown types
+ /// </summary>
+ [Test]
+ public void CanCreateUnknownType()
+ {
+ MessageFactoryRegistry registry =
+ MessageFactoryRegistry.NewDefaultRegistry();
+
+ const string OTHER = "application/unknown";
+ IMessage message = registry.CreateMessage(OTHER);
+ Assert.IsNotNull(message);
+ Assert.AreEqual(OTHER, message.ContentType);
+ Assert.IsInstanceOfType(typeof(QpidBytesMessage), message);
+ }
+ /// <summary>
+ /// Check that text messages default to UTF-8 encoding
+ /// </summary>
+ [Test]
+ public void TextMessagesDefaultToUTF8Encoding()
+ {
+ MessageFactoryRegistry registry =
+ MessageFactoryRegistry.NewDefaultRegistry();
+
+ IMessage message = registry.CreateMessage(TEXT_PLAIN);
+ Assert.AreEqual("utf-8", message.ContentEncoding.ToLower());
+ }
+
+ }
+} // namespace Apache.Qpid.Client.Tests.Messages
+
+
diff --git a/qpid/dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs b/qpid/dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs
index 1345511cbf..f1446a9aa6 100644
--- a/qpid/dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs
+++ b/qpid/dotnet/Qpid.Client.Tests/Security/CallbackHandlerRegistryTests.cs
@@ -1,66 +1,66 @@
-/*
- *
- * 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 Apache.Qpid.Client.Security;
-
-
-namespace Apache.Qpid.Client.Tests.Security
-{
- [TestFixture]
- public class CallbackRegistryHandlerTests
- {
- [Test]
- public void ParsesConfiguration()
- {
- CallbackHandlerRegistry registry = CallbackHandlerRegistry.Instance;
- Assert.AreEqual(4, registry.Mechanisms.Length);
- Assert.Contains("TEST", registry.Mechanisms);
-
- Type handlerType = registry.GetCallbackHandler("TEST");
- Assert.IsNotNull(handlerType);
- Assert.AreEqual(typeof(TestCallbackHandler), handlerType);
- }
-
- [Test]
- public void MechanimsInOrder()
- {
- CallbackHandlerRegistry registry = CallbackHandlerRegistry.Instance;
- Assert.AreEqual(4, registry.Mechanisms.Length);
- Assert.AreEqual("TEST", registry.Mechanisms[0]);
- Assert.AreEqual("EXTERNAL", registry.Mechanisms[1]);
- Assert.AreEqual("CRAM-MD5", registry.Mechanisms[2]);
- Assert.AreEqual("PLAIN", registry.Mechanisms[3]);
- }
- } // class CallbackRegistryHandlerTests
-
- public class TestCallbackHandler : IAMQCallbackHandler
- {
- public void Initialize(Qpid.Client.Protocol.AMQProtocolSession session)
- {
- }
- public void Handle(Qpid.Sasl.ISaslCallback[] callbacks)
- {
- }
-
- } // class TestCallbackHandler
-
-} // namespace Apache.Qpid.Client.Tests.Connection
+/*
+ *
+ * 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 Apache.Qpid.Client.Security;
+
+
+namespace Apache.Qpid.Client.Tests.Security
+{
+ [TestFixture]
+ public class CallbackRegistryHandlerTests
+ {
+ [Test]
+ public void ParsesConfiguration()
+ {
+ CallbackHandlerRegistry registry = CallbackHandlerRegistry.Instance;
+ Assert.AreEqual(4, registry.Mechanisms.Length);
+ Assert.Contains("TEST", registry.Mechanisms);
+
+ Type handlerType = registry.GetCallbackHandler("TEST");
+ Assert.IsNotNull(handlerType);
+ Assert.AreEqual(typeof(TestCallbackHandler), handlerType);
+ }
+
+ [Test]
+ public void MechanimsInOrder()
+ {
+ CallbackHandlerRegistry registry = CallbackHandlerRegistry.Instance;
+ Assert.AreEqual(4, registry.Mechanisms.Length);
+ Assert.AreEqual("TEST", registry.Mechanisms[0]);
+ Assert.AreEqual("EXTERNAL", registry.Mechanisms[1]);
+ Assert.AreEqual("CRAM-MD5", registry.Mechanisms[2]);
+ Assert.AreEqual("PLAIN", registry.Mechanisms[3]);
+ }
+ } // class CallbackRegistryHandlerTests
+
+ public class TestCallbackHandler : IAMQCallbackHandler
+ {
+ public void Initialize(Qpid.Client.Protocol.AMQProtocolSession session)
+ {
+ }
+ public void Handle(Qpid.Sasl.ISaslCallback[] callbacks)
+ {
+ }
+
+ } // class TestCallbackHandler
+
+} // namespace Apache.Qpid.Client.Tests.Connection
diff --git a/qpid/dotnet/Qpid.Client.Tests/interop/TopicListener.cs b/qpid/dotnet/Qpid.Client.Tests/interop/TopicListener.cs
index 13141d52b8..b355abb28d 100644
--- a/qpid/dotnet/Qpid.Client.Tests/interop/TopicListener.cs
+++ b/qpid/dotnet/Qpid.Client.Tests/interop/TopicListener.cs
@@ -1,211 +1,211 @@
-/*
- *
- * 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 log4net;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-
-namespace Apache.Qpid.Client.Tests.interop
-{
- public class TopicListener
- {
- private static ILog log = LogManager.GetLogger(typeof(TopicListener));
-
- /// <summary> The default AMQ connection URL to use for tests. </summary>
- const string DEFAULT_URI = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'";
-
- /// <summary> Holds the routing key for the topic to receive test messages on. </summary>
- public static string CONTROL_ROUTING_KEY = "topic_control";
-
- /// <summary> Holds the routing key for the queue to send reports to. </summary>
- public static string RESPONSE_ROUTING_KEY = "response";
-
- /// <summary> Holds the connection to listen on. </summary>
- private IConnection connection;
-
- /// <summary> Holds the channel for all test messages.</summary>
- private IChannel channel;
-
- /// <summary> Holds the producer to send report messages on. </summary>
- private IMessagePublisher publisher;
-
- /// <summary> Holds a flag to indicate that a timer has begun on the first message. Reset when report is sent. </summary> */
- private bool init;
-
- /// <summary> Holds the count of messages received by this listener. </summary> */
- private int count;
-
- /// <summary> Creates a topic listener using the specified broker URL. </summary>
- ///
- /// <param name="connectionUri">The broker URL to listen on.</param>
- TopicListener(string connectionUri)
- {
- log.Debug("TopicListener(string connectionUri = " + connectionUri + "): called");
-
- // Create a connection to the broker.
- IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
- connection = new AMQConnection(connectionInfo);
-
- // Establish a session on the broker.
- channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1);
-
- // Set up a queue to listen for test messages on.
- string topicQueueName = channel.GenerateUniqueName();
- channel.DeclareQueue(topicQueueName, false, true, true);
-
- // Set this listener up to listen for incoming messages on the test topic queue.
- channel.Bind(topicQueueName, ExchangeNameDefaults.TOPIC, CONTROL_ROUTING_KEY);
- IMessageConsumer consumer = channel.CreateConsumerBuilder(topicQueueName)
- .Create();
- consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
-
- // Set up this listener with a producer to send the reports on.
- publisher = channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.DIRECT)
- .WithRoutingKey(RESPONSE_ROUTING_KEY)
- .Create();
-
- connection.Start();
- Console.WriteLine("Waiting for messages...");
- }
-
- public static void Main(String[] argv)
- {
- // Create an instance of this listener with the command line parameters.
- new TopicListener(DEFAULT_URI);
- }
-
- /// <summary>
- /// Handles all message received by this listener. Test messages are counted, report messages result in a report being sent and
- /// shutdown messages result in this listener being terminated.
- /// </summary>
- ///
- /// <param name="message">The received message.</param>
- public void OnMessage(IMessage message)
- {
- log.Debug("public void onMessage(Message message = " + message + "): called");
-
- // Take the start time of the first message if this is the first message.
- if (!init)
- {
- count = 0;
- init = true;
- }
-
- // Check if the message is a control message telling this listener to shut down.
- if (IsShutdown(message))
- {
- log.Debug("Got a shutdown message.");
- Shutdown();
- }
- // Check if the message is a report request message asking this listener to respond with the message count.
- else if (IsReport(message))
- {
- log.Debug("Got a report request message.");
-
- // Send the message count report.
- SendReport();
-
- // Reset the initialization flag so that the next message is considered to be the first.
- init = false;
- }
- // Otherwise it is an ordinary test message, so increment the message count.
- else
- {
- count++;
- }
- }
-
- /// <summary> Checks a message to see if it is a shutdown control message. </summary>
- ///
- /// <param name="m">The message to check.</param>
- ///
- /// <returns><tt>true</tt> if it is a shutdown control message, <tt>false</tt> otherwise.</returns>
- private bool IsShutdown(IMessage m)
- {
- bool result = CheckTextField(m, "TYPE", "TERMINATION_REQUEST");
-
- //log.Debug("isShutdown = " + result);
-
- return result;
- }
-
- /// <summary> Checks a message to see if it is a report request control message. </summary>
- ///
- /// <param name="m">The message to check.</param>
- ///
- /// <returns><tt>true</tt> if it is a report request control message, <tt>false</tt> otherwise.</returns>
- private bool IsReport(IMessage m)
- {
- bool result = CheckTextField(m, "TYPE", "REPORT_REQUEST");
-
- //log.Debug("isReport = " + result);
-
- return result;
- }
-
- /// <summary> Checks whether or not a text field on a message has the specified value. </summary>
- ///
- /// <param name="e">The message to check.</param>
- /// <param name="e">The name of the field to check.</param>
- /// <param name="e">The expected value of the field to compare with.</param>
- ///
- /// <returns> <tt>true</tt>If the specified field has the specified value, <tt>fals</tt> otherwise. </returns>
- private static bool CheckTextField(IMessage m, string fieldName, string value)
- {
- /*log.Debug("private static boolean checkTextField(Message m = " + m + ", String fieldName = " + fieldName
- + ", String value = " + value + "): called");*/
-
- string comp = m.Headers.GetString(fieldName);
-
- return (comp != null) && comp == value;
- }
-
- /// <summary> Stops the message consumer and closes the connection. </summary>
- private void Shutdown()
- {
- connection.Stop();
- channel.Dispose();
- connection.Dispose();
- }
-
- /// <summary> Sends the report message to the response location. </summary>
- private void SendReport()
- {
- string report = "Received " + count + ".";
-
- IMessage reportMessage = channel.CreateTextMessage(report);
-
- reportMessage.Headers.SetBoolean("BOOLEAN", false);
- //reportMessage.Headers.SetByte("BYTE", 5);
- reportMessage.Headers.SetDouble("DOUBLE", 3.141);
- reportMessage.Headers.SetFloat("FLOAT", 1.0f);
- reportMessage.Headers.SetInt("INT", 1);
- reportMessage.Headers.SetLong("LONG", 1);
- reportMessage.Headers.SetString("STRING", "hello");
- reportMessage.Headers.SetShort("SHORT", 2);
-
- publisher.Send(reportMessage);
-
- Console.WriteLine("Sent report: " + report);
- }
- }
-}
+/*
+ *
+ * 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 log4net;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+
+namespace Apache.Qpid.Client.Tests.interop
+{
+ public class TopicListener
+ {
+ private static ILog log = LogManager.GetLogger(typeof(TopicListener));
+
+ /// <summary> The default AMQ connection URL to use for tests. </summary>
+ const string DEFAULT_URI = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'";
+
+ /// <summary> Holds the routing key for the topic to receive test messages on. </summary>
+ public static string CONTROL_ROUTING_KEY = "topic_control";
+
+ /// <summary> Holds the routing key for the queue to send reports to. </summary>
+ public static string RESPONSE_ROUTING_KEY = "response";
+
+ /// <summary> Holds the connection to listen on. </summary>
+ private IConnection connection;
+
+ /// <summary> Holds the channel for all test messages.</summary>
+ private IChannel channel;
+
+ /// <summary> Holds the producer to send report messages on. </summary>
+ private IMessagePublisher publisher;
+
+ /// <summary> Holds a flag to indicate that a timer has begun on the first message. Reset when report is sent. </summary> */
+ private bool init;
+
+ /// <summary> Holds the count of messages received by this listener. </summary> */
+ private int count;
+
+ /// <summary> Creates a topic listener using the specified broker URL. </summary>
+ ///
+ /// <param name="connectionUri">The broker URL to listen on.</param>
+ TopicListener(string connectionUri)
+ {
+ log.Debug("TopicListener(string connectionUri = " + connectionUri + "): called");
+
+ // Create a connection to the broker.
+ IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
+ connection = new AMQConnection(connectionInfo);
+
+ // Establish a session on the broker.
+ channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1);
+
+ // Set up a queue to listen for test messages on.
+ string topicQueueName = channel.GenerateUniqueName();
+ channel.DeclareQueue(topicQueueName, false, true, true);
+
+ // Set this listener up to listen for incoming messages on the test topic queue.
+ channel.Bind(topicQueueName, ExchangeNameDefaults.TOPIC, CONTROL_ROUTING_KEY);
+ IMessageConsumer consumer = channel.CreateConsumerBuilder(topicQueueName)
+ .Create();
+ consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
+
+ // Set up this listener with a producer to send the reports on.
+ publisher = channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.DIRECT)
+ .WithRoutingKey(RESPONSE_ROUTING_KEY)
+ .Create();
+
+ connection.Start();
+ Console.WriteLine("Waiting for messages...");
+ }
+
+ public static void Main(String[] argv)
+ {
+ // Create an instance of this listener with the command line parameters.
+ new TopicListener(DEFAULT_URI);
+ }
+
+ /// <summary>
+ /// Handles all message received by this listener. Test messages are counted, report messages result in a report being sent and
+ /// shutdown messages result in this listener being terminated.
+ /// </summary>
+ ///
+ /// <param name="message">The received message.</param>
+ public void OnMessage(IMessage message)
+ {
+ log.Debug("public void onMessage(Message message = " + message + "): called");
+
+ // Take the start time of the first message if this is the first message.
+ if (!init)
+ {
+ count = 0;
+ init = true;
+ }
+
+ // Check if the message is a control message telling this listener to shut down.
+ if (IsShutdown(message))
+ {
+ log.Debug("Got a shutdown message.");
+ Shutdown();
+ }
+ // Check if the message is a report request message asking this listener to respond with the message count.
+ else if (IsReport(message))
+ {
+ log.Debug("Got a report request message.");
+
+ // Send the message count report.
+ SendReport();
+
+ // Reset the initialization flag so that the next message is considered to be the first.
+ init = false;
+ }
+ // Otherwise it is an ordinary test message, so increment the message count.
+ else
+ {
+ count++;
+ }
+ }
+
+ /// <summary> Checks a message to see if it is a shutdown control message. </summary>
+ ///
+ /// <param name="m">The message to check.</param>
+ ///
+ /// <returns><tt>true</tt> if it is a shutdown control message, <tt>false</tt> otherwise.</returns>
+ private bool IsShutdown(IMessage m)
+ {
+ bool result = CheckTextField(m, "TYPE", "TERMINATION_REQUEST");
+
+ //log.Debug("isShutdown = " + result);
+
+ return result;
+ }
+
+ /// <summary> Checks a message to see if it is a report request control message. </summary>
+ ///
+ /// <param name="m">The message to check.</param>
+ ///
+ /// <returns><tt>true</tt> if it is a report request control message, <tt>false</tt> otherwise.</returns>
+ private bool IsReport(IMessage m)
+ {
+ bool result = CheckTextField(m, "TYPE", "REPORT_REQUEST");
+
+ //log.Debug("isReport = " + result);
+
+ return result;
+ }
+
+ /// <summary> Checks whether or not a text field on a message has the specified value. </summary>
+ ///
+ /// <param name="e">The message to check.</param>
+ /// <param name="e">The name of the field to check.</param>
+ /// <param name="e">The expected value of the field to compare with.</param>
+ ///
+ /// <returns> <tt>true</tt>If the specified field has the specified value, <tt>fals</tt> otherwise. </returns>
+ private static bool CheckTextField(IMessage m, string fieldName, string value)
+ {
+ /*log.Debug("private static boolean checkTextField(Message m = " + m + ", String fieldName = " + fieldName
+ + ", String value = " + value + "): called");*/
+
+ string comp = m.Headers.GetString(fieldName);
+
+ return (comp != null) && comp == value;
+ }
+
+ /// <summary> Stops the message consumer and closes the connection. </summary>
+ private void Shutdown()
+ {
+ connection.Stop();
+ channel.Dispose();
+ connection.Dispose();
+ }
+
+ /// <summary> Sends the report message to the response location. </summary>
+ private void SendReport()
+ {
+ string report = "Received " + count + ".";
+
+ IMessage reportMessage = channel.CreateTextMessage(report);
+
+ reportMessage.Headers.SetBoolean("BOOLEAN", false);
+ //reportMessage.Headers.SetByte("BYTE", 5);
+ reportMessage.Headers.SetDouble("DOUBLE", 3.141);
+ reportMessage.Headers.SetFloat("FLOAT", 1.0f);
+ reportMessage.Headers.SetInt("INT", 1);
+ reportMessage.Headers.SetLong("LONG", 1);
+ reportMessage.Headers.SetString("STRING", "hello");
+ reportMessage.Headers.SetShort("SHORT", 2);
+
+ publisher.Send(reportMessage);
+
+ Console.WriteLine("Sent report: " + report);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client.Tests/interop/TopicPublisher.cs b/qpid/dotnet/Qpid.Client.Tests/interop/TopicPublisher.cs
index a96c1f327b..4fd0419e9c 100644
--- a/qpid/dotnet/Qpid.Client.Tests/interop/TopicPublisher.cs
+++ b/qpid/dotnet/Qpid.Client.Tests/interop/TopicPublisher.cs
@@ -1,208 +1,208 @@
-/*
- *
- * 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 System.Threading;
-using log4net;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-
-namespace Apache.Qpid.Client.Tests.interop
-{
- public class TopicPublisher
- {
- private static ILog log = LogManager.GetLogger(typeof(TopicPublisher));
-
- /// <summary> The default AMQ connection URL to use for tests. </summary>
- const string DEFAULT_URI = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'";
-
- /// <summary> Holds the default test timeout for broker communications before tests give up. </summary>
- const int TIMEOUT = 10000;
-
- /// <summary> Holds the routing key for the topic to receive test messages on. </summary>
- const string CONTROL_ROUTING_KEY = "topic_control";
-
- /// <summary> Holds the routing key for the queue to send reports to. </summary>
- const string RESPONSE_ROUTING_KEY = "response";
-
- /// <summary> Holds the number of messages to send in each test run. </summary>
- private int numMessages;
-
- /// <summary> Holds the number of subscribers listening to the messsages. </summary>
- private int numSubscribers;
-
- /// <summary> A monitor used to wait for all reports to arrive back from consumers on. </summary>
- private AutoResetEvent allReportsReceivedEvt = new AutoResetEvent(false);
-
- /// <summary> Holds the connection to listen on. </summary>
- private IConnection connection;
-
- /// <summary> Holds the channel for all test messages.</summary>
- private IChannel channel;
-
- /// <summary> Holds the producer to send test messages on. </summary>
- private IMessagePublisher publisher;
-
- /// <summary>
- /// Creates a topic publisher that will send the specifed number of messages and expect the specifed number of report back from test
- /// subscribers.
- /// </summary>
- ///
- /// <param name="connectionUri">The broker URL.</param>
- /// <param name="numMessages">The number of messages to send in each test.</param>
- /// <param name="numSubscribers">The number of subscribes that are expected to reply with a report.</param>
- TopicPublisher(string connectionUri, int numMessages, int numSubscribers)
- {
- log.Debug("TopicPublisher(string connectionUri = " + connectionUri + ", int numMessages = "+ numMessages +
- ", int numSubscribers = " + numSubscribers + "): called");
-
- // Create a connection to the broker.
- IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
- connection = new AMQConnection(connectionInfo);
-
- // Establish a session on the broker.
- channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1);
-
- // Set up a queue to listen for reports on.
- string responseQueueName = channel.GenerateUniqueName();
- channel.DeclareQueue(responseQueueName, false, true, true);
-
- // Set this listener up to listen for reports on the response queue.
- channel.Bind(responseQueueName, ExchangeNameDefaults.DIRECT, RESPONSE_ROUTING_KEY);
- //channel.Bind(responseQueueName, "<<default>>", RESPONSE_ROUTING_KEY);
- IMessageConsumer consumer = channel.CreateConsumerBuilder(responseQueueName)
- .Create();
- consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
-
- // Set up this listener with a producer to send the test messages and report requests on.
- publisher = channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.TOPIC)
- .WithRoutingKey(CONTROL_ROUTING_KEY)
- .Create();
-
- // Keep the test parameters.
- this.numMessages = numMessages;
- this.numSubscribers = numSubscribers;
-
- connection.Start();
- Console.WriteLine("Sending messages and waiting for reports...");
- }
-
- /// <summary>
- /// Start a test subscriber. The broker URL must be specified as the first command line argument.
- /// </summary>
- ///
- /// <param name="argv">The command line arguments, broker URL first.</param>
- public static void Main(String[] argv)
- {
- // Create an instance of this publisher with the command line parameters.
- TopicPublisher publisher = new TopicPublisher(DEFAULT_URI, 1, 1);
-
- // Publish the test messages.
- publisher.DoTest();
- }
-
- /// <summary>
- /// Sends the test messages and waits for all subscribers to reply with a report.
- /// </summary>
- public void DoTest()
- {
- log.Debug("public void DoTest(): called");
-
- // Create a test message to send.
- IMessage testMessage = channel.CreateTextMessage("test");
-
- // Send the desired number of test messages.
- for (int i = 0; i < numMessages; i++)
- {
- publisher.Send(testMessage);
- }
-
- log.Debug("Sent " + numMessages + " test messages.");
-
- // Send the report request.
- IMessage reportRequestMessage = channel.CreateTextMessage("Report request message.");
- reportRequestMessage.Headers["TYPE"] = "REPORT_REQUEST";
-
- reportRequestMessage.Headers.SetBoolean("BOOLEAN", false);
- //reportRequestMessage.Headers.SetByte("BYTE", 5);
- reportRequestMessage.Headers.SetDouble("DOUBLE", 3.141);
- reportRequestMessage.Headers.SetFloat("FLOAT", 1.0f);
- reportRequestMessage.Headers.SetInt("INT", 1);
- reportRequestMessage.Headers.SetLong("LONG", 1);
- reportRequestMessage.Headers.SetString("STRING", "hello");
- reportRequestMessage.Headers.SetShort("SHORT", 2);
-
- publisher.Send(reportRequestMessage);
-
- log.Debug("Sent the report request message, waiting for all replies...");
-
- // Wait until all the reports come in.
- allReportsReceivedEvt.WaitOne(TIMEOUT, true);
-
- // Check if all reports were really received or if the timeout occurred.
- if (numSubscribers == 0)
- {
- log.Debug("Got all reports.");
- }
- else
- {
- log.Debug("Waiting for reports timed out, still waiting for " + numSubscribers + ".");
- }
-
- // Send the termination request.
- IMessage terminationRequestMessage = channel.CreateTextMessage("Termination request message.");
- terminationRequestMessage.Headers["TYPE"] = "TERMINATION_REQUEST";
- publisher.Send(terminationRequestMessage);
-
- log.Debug("Sent the termination request message.");
-
- // Close all message producers and consumers and the connection to the broker.
- Shutdown();
- }
-
- /// <summary>
- /// Handles all report messages from subscribers. This decrements the count of subscribers that are still to reply, until this becomes
- /// zero, at which time waiting threads are notified of this event.
- /// </summary>
- ///
- /// <param name="message">The received report message.</param>
- public void OnMessage(IMessage message)
- {
- log.Debug("public void OnMessage(IMessage message = " + message + "): called");
-
- // Decrement the count of expected messages and release the wait monitor when this becomes zero.
- if (--numSubscribers == 0)
- {
- log.Debug("Got reports from all subscribers.");
- allReportsReceivedEvt.Set();
- }
- }
-
- /// <summary> Stops the message consumers and closes the connection. </summary>
- private void Shutdown()
- {
- connection.Stop();
- publisher.Dispose();
- channel.Dispose();
- connection.Dispose();
- }
- }
-}
+/*
+ *
+ * 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 System.Threading;
+using log4net;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+
+namespace Apache.Qpid.Client.Tests.interop
+{
+ public class TopicPublisher
+ {
+ private static ILog log = LogManager.GetLogger(typeof(TopicPublisher));
+
+ /// <summary> The default AMQ connection URL to use for tests. </summary>
+ const string DEFAULT_URI = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'";
+
+ /// <summary> Holds the default test timeout for broker communications before tests give up. </summary>
+ const int TIMEOUT = 10000;
+
+ /// <summary> Holds the routing key for the topic to receive test messages on. </summary>
+ const string CONTROL_ROUTING_KEY = "topic_control";
+
+ /// <summary> Holds the routing key for the queue to send reports to. </summary>
+ const string RESPONSE_ROUTING_KEY = "response";
+
+ /// <summary> Holds the number of messages to send in each test run. </summary>
+ private int numMessages;
+
+ /// <summary> Holds the number of subscribers listening to the messsages. </summary>
+ private int numSubscribers;
+
+ /// <summary> A monitor used to wait for all reports to arrive back from consumers on. </summary>
+ private AutoResetEvent allReportsReceivedEvt = new AutoResetEvent(false);
+
+ /// <summary> Holds the connection to listen on. </summary>
+ private IConnection connection;
+
+ /// <summary> Holds the channel for all test messages.</summary>
+ private IChannel channel;
+
+ /// <summary> Holds the producer to send test messages on. </summary>
+ private IMessagePublisher publisher;
+
+ /// <summary>
+ /// Creates a topic publisher that will send the specifed number of messages and expect the specifed number of report back from test
+ /// subscribers.
+ /// </summary>
+ ///
+ /// <param name="connectionUri">The broker URL.</param>
+ /// <param name="numMessages">The number of messages to send in each test.</param>
+ /// <param name="numSubscribers">The number of subscribes that are expected to reply with a report.</param>
+ TopicPublisher(string connectionUri, int numMessages, int numSubscribers)
+ {
+ log.Debug("TopicPublisher(string connectionUri = " + connectionUri + ", int numMessages = "+ numMessages +
+ ", int numSubscribers = " + numSubscribers + "): called");
+
+ // Create a connection to the broker.
+ IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
+ connection = new AMQConnection(connectionInfo);
+
+ // Establish a session on the broker.
+ channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1);
+
+ // Set up a queue to listen for reports on.
+ string responseQueueName = channel.GenerateUniqueName();
+ channel.DeclareQueue(responseQueueName, false, true, true);
+
+ // Set this listener up to listen for reports on the response queue.
+ channel.Bind(responseQueueName, ExchangeNameDefaults.DIRECT, RESPONSE_ROUTING_KEY);
+ //channel.Bind(responseQueueName, "<<default>>", RESPONSE_ROUTING_KEY);
+ IMessageConsumer consumer = channel.CreateConsumerBuilder(responseQueueName)
+ .Create();
+ consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
+
+ // Set up this listener with a producer to send the test messages and report requests on.
+ publisher = channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.TOPIC)
+ .WithRoutingKey(CONTROL_ROUTING_KEY)
+ .Create();
+
+ // Keep the test parameters.
+ this.numMessages = numMessages;
+ this.numSubscribers = numSubscribers;
+
+ connection.Start();
+ Console.WriteLine("Sending messages and waiting for reports...");
+ }
+
+ /// <summary>
+ /// Start a test subscriber. The broker URL must be specified as the first command line argument.
+ /// </summary>
+ ///
+ /// <param name="argv">The command line arguments, broker URL first.</param>
+ public static void Main(String[] argv)
+ {
+ // Create an instance of this publisher with the command line parameters.
+ TopicPublisher publisher = new TopicPublisher(DEFAULT_URI, 1, 1);
+
+ // Publish the test messages.
+ publisher.DoTest();
+ }
+
+ /// <summary>
+ /// Sends the test messages and waits for all subscribers to reply with a report.
+ /// </summary>
+ public void DoTest()
+ {
+ log.Debug("public void DoTest(): called");
+
+ // Create a test message to send.
+ IMessage testMessage = channel.CreateTextMessage("test");
+
+ // Send the desired number of test messages.
+ for (int i = 0; i < numMessages; i++)
+ {
+ publisher.Send(testMessage);
+ }
+
+ log.Debug("Sent " + numMessages + " test messages.");
+
+ // Send the report request.
+ IMessage reportRequestMessage = channel.CreateTextMessage("Report request message.");
+ reportRequestMessage.Headers["TYPE"] = "REPORT_REQUEST";
+
+ reportRequestMessage.Headers.SetBoolean("BOOLEAN", false);
+ //reportRequestMessage.Headers.SetByte("BYTE", 5);
+ reportRequestMessage.Headers.SetDouble("DOUBLE", 3.141);
+ reportRequestMessage.Headers.SetFloat("FLOAT", 1.0f);
+ reportRequestMessage.Headers.SetInt("INT", 1);
+ reportRequestMessage.Headers.SetLong("LONG", 1);
+ reportRequestMessage.Headers.SetString("STRING", "hello");
+ reportRequestMessage.Headers.SetShort("SHORT", 2);
+
+ publisher.Send(reportRequestMessage);
+
+ log.Debug("Sent the report request message, waiting for all replies...");
+
+ // Wait until all the reports come in.
+ allReportsReceivedEvt.WaitOne(TIMEOUT, true);
+
+ // Check if all reports were really received or if the timeout occurred.
+ if (numSubscribers == 0)
+ {
+ log.Debug("Got all reports.");
+ }
+ else
+ {
+ log.Debug("Waiting for reports timed out, still waiting for " + numSubscribers + ".");
+ }
+
+ // Send the termination request.
+ IMessage terminationRequestMessage = channel.CreateTextMessage("Termination request message.");
+ terminationRequestMessage.Headers["TYPE"] = "TERMINATION_REQUEST";
+ publisher.Send(terminationRequestMessage);
+
+ log.Debug("Sent the termination request message.");
+
+ // Close all message producers and consumers and the connection to the broker.
+ Shutdown();
+ }
+
+ /// <summary>
+ /// Handles all report messages from subscribers. This decrements the count of subscribers that are still to reply, until this becomes
+ /// zero, at which time waiting threads are notified of this event.
+ /// </summary>
+ ///
+ /// <param name="message">The received report message.</param>
+ public void OnMessage(IMessage message)
+ {
+ log.Debug("public void OnMessage(IMessage message = " + message + "): called");
+
+ // Decrement the count of expected messages and release the wait monitor when this becomes zero.
+ if (--numSubscribers == 0)
+ {
+ log.Debug("Got reports from all subscribers.");
+ allReportsReceivedEvt.Set();
+ }
+ }
+
+ /// <summary> Stops the message consumers and closes the connection. </summary>
+ private void Shutdown()
+ {
+ connection.Stop();
+ publisher.Dispose();
+ channel.Dispose();
+ connection.Dispose();
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/AMQAuthenticationException.cs b/qpid/dotnet/Qpid.Client/Client/AMQAuthenticationException.cs
index 6382eaaf39..7bb64e3fff 100644
--- a/qpid/dotnet/Qpid.Client/Client/AMQAuthenticationException.cs
+++ b/qpid/dotnet/Qpid.Client/Client/AMQAuthenticationException.cs
@@ -1,39 +1,39 @@
-/*
- *
- * 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 System.Runtime.Serialization;
-
-namespace Apache.Qpid.Client
-{
- [Serializable]
- public class AMQAuthenticationException : AMQException
- {
- public AMQAuthenticationException(int error, String message)
- : base(error, message)
- {
- }
-
- protected AMQAuthenticationException(SerializationInfo info, StreamingContext ctxt)
- : base(info, ctxt)
- {
- }
- }
-}
+/*
+ *
+ * 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 System.Runtime.Serialization;
+
+namespace Apache.Qpid.Client
+{
+ [Serializable]
+ public class AMQAuthenticationException : AMQException
+ {
+ public AMQAuthenticationException(int error, String message)
+ : base(error, message)
+ {
+ }
+
+ protected AMQAuthenticationException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/AMQNoConsumersException.cs b/qpid/dotnet/Qpid.Client/Client/AMQNoConsumersException.cs
index 0d93176734..5c9dd86c53 100644
--- a/qpid/dotnet/Qpid.Client/Client/AMQNoConsumersException.cs
+++ b/qpid/dotnet/Qpid.Client/Client/AMQNoConsumersException.cs
@@ -1,45 +1,45 @@
-/*
- *
- * 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 System.Runtime.Serialization;
-using Apache.Qpid.Common;
-using Apache.Qpid.Protocol;
-
-namespace Apache.Qpid.Client
-{
- [Serializable]
- public class AMQNoConsumersException : AMQUndeliveredException
- {
- public AMQNoConsumersException(string message)
- : this(message, null)
- {
- }
-
- public AMQNoConsumersException(string message, object bounced)
- : base(AMQConstant.NO_CONSUMERS.Code, message, bounced)
- {
- }
- protected AMQNoConsumersException(SerializationInfo info, StreamingContext ctxt)
- : base(info, ctxt)
- {
- }
- }
-}
+/*
+ *
+ * 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 System.Runtime.Serialization;
+using Apache.Qpid.Common;
+using Apache.Qpid.Protocol;
+
+namespace Apache.Qpid.Client
+{
+ [Serializable]
+ public class AMQNoConsumersException : AMQUndeliveredException
+ {
+ public AMQNoConsumersException(string message)
+ : this(message, null)
+ {
+ }
+
+ public AMQNoConsumersException(string message, object bounced)
+ : base(AMQConstant.NO_CONSUMERS.Code, message, bounced)
+ {
+ }
+ protected AMQNoConsumersException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/AMQNoRouteException.cs b/qpid/dotnet/Qpid.Client/Client/AMQNoRouteException.cs
index bde3cdd989..5868d78f32 100644
--- a/qpid/dotnet/Qpid.Client/Client/AMQNoRouteException.cs
+++ b/qpid/dotnet/Qpid.Client/Client/AMQNoRouteException.cs
@@ -1,46 +1,46 @@
-/*
- *
- * 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 System.Runtime.Serialization;
-using Apache.Qpid.Common;
-using Apache.Qpid.Protocol;
-
-namespace Apache.Qpid.Client
-{
- [Serializable]
- public class AMQNoRouteException : AMQUndeliveredException
- {
- public AMQNoRouteException(string message)
- : this(message, null)
- {
- }
-
- public AMQNoRouteException(string message, object bounced)
- : base(AMQConstant.NO_ROUTE.Code, message, bounced)
- {
- }
-
- protected AMQNoRouteException(SerializationInfo info, StreamingContext ctxt)
- : base(info, ctxt)
- {
- }
- }
-}
+/*
+ *
+ * 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 System.Runtime.Serialization;
+using Apache.Qpid.Common;
+using Apache.Qpid.Protocol;
+
+namespace Apache.Qpid.Client
+{
+ [Serializable]
+ public class AMQNoRouteException : AMQUndeliveredException
+ {
+ public AMQNoRouteException(string message)
+ : this(message, null)
+ {
+ }
+
+ public AMQNoRouteException(string message, object bounced)
+ : base(AMQConstant.NO_ROUTE.Code, message, bounced)
+ {
+ }
+
+ protected AMQNoRouteException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Configuration/AuthenticationConfigurationSectionHandler.cs b/qpid/dotnet/Qpid.Client/Client/Configuration/AuthenticationConfigurationSectionHandler.cs
index ae9225a53a..8d289fa956 100644
--- a/qpid/dotnet/Qpid.Client/Client/Configuration/AuthenticationConfigurationSectionHandler.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Configuration/AuthenticationConfigurationSectionHandler.cs
@@ -1,84 +1,84 @@
-/*
- *
- * 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 System.Collections;
-using System.Collections.Specialized;
-using System.Configuration;
-using System.Text;
-
-using Apache.Qpid.Client.Security;
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Client.Configuration
-{
- public class AuthenticationConfigurationSectionHandler
- : IConfigurationSectionHandler
- {
-
- public object Create(object parent, object configContext, System.Xml.XmlNode section)
- {
- NameValueSectionHandler handler = new NameValueSectionHandler();
- OrderedHashTable schemes = new OrderedHashTable();
-
- NameValueCollection options = (NameValueCollection)
- handler.Create(parent, configContext, section);
-
- if ( options != null )
- {
- foreach ( string key in options.Keys )
- {
- Type type = Type.GetType(options[key]);
- if ( type == null )
- throw new ConfigurationException(string.Format("Type '{0}' not found", key));
- if ( !typeof(IAMQCallbackHandler).IsAssignableFrom(type) )
- throw new ConfigurationException(string.Format("Type '{0}' does not implement IAMQCallbackHandler", key));
-
- schemes.Add(key, type);
- }
- }
-
- return schemes;
- }
-
- } // class AuthenticationConfigurationSectionHandler
-
- public class OrderedHashTable : Hashtable
- {
- private ArrayList _keys = new ArrayList();
-
- public IList OrderedKeys
- {
- get { return _keys; }
- }
-
- public override void Add(object key, object value)
- {
- base.Add(key, value);
- _keys.Add(key);
- }
- public override void Remove(object key)
- {
- base.Remove(key);
- _keys.Remove(key);
- }
- }
-} // namespace Apache.Qpid.Client.Configuration
+/*
+ *
+ * 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 System.Collections;
+using System.Collections.Specialized;
+using System.Configuration;
+using System.Text;
+
+using Apache.Qpid.Client.Security;
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Client.Configuration
+{
+ public class AuthenticationConfigurationSectionHandler
+ : IConfigurationSectionHandler
+ {
+
+ public object Create(object parent, object configContext, System.Xml.XmlNode section)
+ {
+ NameValueSectionHandler handler = new NameValueSectionHandler();
+ OrderedHashTable schemes = new OrderedHashTable();
+
+ NameValueCollection options = (NameValueCollection)
+ handler.Create(parent, configContext, section);
+
+ if ( options != null )
+ {
+ foreach ( string key in options.Keys )
+ {
+ Type type = Type.GetType(options[key]);
+ if ( type == null )
+ throw new ConfigurationException(string.Format("Type '{0}' not found", key));
+ if ( !typeof(IAMQCallbackHandler).IsAssignableFrom(type) )
+ throw new ConfigurationException(string.Format("Type '{0}' does not implement IAMQCallbackHandler", key));
+
+ schemes.Add(key, type);
+ }
+ }
+
+ return schemes;
+ }
+
+ } // class AuthenticationConfigurationSectionHandler
+
+ public class OrderedHashTable : Hashtable
+ {
+ private ArrayList _keys = new ArrayList();
+
+ public IList OrderedKeys
+ {
+ get { return _keys; }
+ }
+
+ public override void Add(object key, object value)
+ {
+ base.Add(key, value);
+ _keys.Add(key);
+ }
+ public override void Remove(object key)
+ {
+ base.Remove(key);
+ _keys.Remove(key);
+ }
+ }
+} // namespace Apache.Qpid.Client.Configuration
diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/QueueDeleteOkMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/QueueDeleteOkMethodHandler.cs
index 7290d758f8..70aa3e1078 100644
--- a/qpid/dotnet/Qpid.Client/Client/Handler/QueueDeleteOkMethodHandler.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Handler/QueueDeleteOkMethodHandler.cs
@@ -1,44 +1,44 @@
-/*
- *
- * 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 log4net;
-using Apache.Qpid.Client.Message;
-using Apache.Qpid.Client.Protocol;
-using Apache.Qpid.Client.State;
-using Apache.Qpid.Framing;
-
-namespace Apache.Qpid.Client.Handler
-{
- public class QueueDeleteOkMethodHandler : IStateAwareMethodListener
- {
-
- private static readonly ILog _logger = LogManager.GetLogger(typeof(QueueDeleteOkMethodHandler));
-
- public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt)
- {
- QueueDeleteOkBody body = (QueueDeleteOkBody)evt.Method;
- if (body != null)
- {
- _logger.InfoFormat("Received Queue.Delete-Ok message, message count {0}", body.MessageCount);
- }
- }
-
- }
-}
+/*
+ *
+ * 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 log4net;
+using Apache.Qpid.Client.Message;
+using Apache.Qpid.Client.Protocol;
+using Apache.Qpid.Client.State;
+using Apache.Qpid.Framing;
+
+namespace Apache.Qpid.Client.Handler
+{
+ public class QueueDeleteOkMethodHandler : IStateAwareMethodListener
+ {
+
+ private static readonly ILog _logger = LogManager.GetLogger(typeof(QueueDeleteOkMethodHandler));
+
+ public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt)
+ {
+ QueueDeleteOkBody body = (QueueDeleteOkBody)evt.Method;
+ if (body != null)
+ {
+ _logger.InfoFormat("Received Queue.Delete-Ok message, message count {0}", body.MessageCount);
+ }
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Handler/QueuePurgeOkMethodHandler.cs b/qpid/dotnet/Qpid.Client/Client/Handler/QueuePurgeOkMethodHandler.cs
index 8bde707b00..22db70575d 100644
--- a/qpid/dotnet/Qpid.Client/Client/Handler/QueuePurgeOkMethodHandler.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Handler/QueuePurgeOkMethodHandler.cs
@@ -1,44 +1,44 @@
-/*
- *
- * 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 log4net;
-using Apache.Qpid.Client.Message;
-using Apache.Qpid.Client.Protocol;
-using Apache.Qpid.Client.State;
-using Apache.Qpid.Framing;
-
-namespace Apache.Qpid.Client.Handler
-{
- public class QueuePurgeOkMethodHandler : IStateAwareMethodListener
- {
-
- private static readonly ILog _logger = LogManager.GetLogger(typeof(QueuePurgeOkMethodHandler));
-
- public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt)
- {
- QueuePurgeOkBody body = (QueuePurgeOkBody)evt.Method;
- if (body != null)
- {
- _logger.InfoFormat("Received Queue.Purge-Ok message, message count {0}", body.MessageCount);
- }
- }
-
- }
-}
+/*
+ *
+ * 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 log4net;
+using Apache.Qpid.Client.Message;
+using Apache.Qpid.Client.Protocol;
+using Apache.Qpid.Client.State;
+using Apache.Qpid.Framing;
+
+namespace Apache.Qpid.Client.Handler
+{
+ public class QueuePurgeOkMethodHandler : IStateAwareMethodListener
+ {
+
+ private static readonly ILog _logger = LogManager.GetLogger(typeof(QueuePurgeOkMethodHandler));
+
+ public void MethodReceived(AMQStateManager stateManager, AMQMethodEvent evt)
+ {
+ QueuePurgeOkBody body = (QueuePurgeOkBody)evt.Method;
+ if (body != null)
+ {
+ _logger.InfoFormat("Received Queue.Purge-Ok message, message count {0}", body.MessageCount);
+ }
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Protocol/DefaultTimeouts.cs b/qpid/dotnet/Qpid.Client/Client/Protocol/DefaultTimeouts.cs
index 6841b46f54..2f23a1571d 100644
--- a/qpid/dotnet/Qpid.Client/Client/Protocol/DefaultTimeouts.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Protocol/DefaultTimeouts.cs
@@ -1,47 +1,47 @@
-/*
- *
- * 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 System.Text;
-
-namespace Apache.Qpid.Client.Protocol
-{
- /// <summary>
- /// Default timeout values for the protocol
- /// </summary>
- sealed class DefaultTimeouts
- {
- /// <summary>
- /// Maximum number of milliseconds to wait for a state change
- /// in the protocol's state machine
- /// </summary>
- public const int MaxWaitForState = 30* 1000;
- /// <summary>
- /// Maximum number of milliseconds to wait for a reply
- /// frame when doing synchronous writer to the broker
- /// </summary>
- public const int MaxWaitForSyncWriter = 30 * 1000;
-
- private DefaultTimeouts()
- {
- }
- }
-}
+/*
+ *
+ * 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 System.Text;
+
+namespace Apache.Qpid.Client.Protocol
+{
+ /// <summary>
+ /// Default timeout values for the protocol
+ /// </summary>
+ sealed class DefaultTimeouts
+ {
+ /// <summary>
+ /// Maximum number of milliseconds to wait for a state change
+ /// in the protocol's state machine
+ /// </summary>
+ public const int MaxWaitForState = 30* 1000;
+ /// <summary>
+ /// Maximum number of milliseconds to wait for a reply
+ /// frame when doing synchronous writer to the broker
+ /// </summary>
+ public const int MaxWaitForSyncWriter = 30 * 1000;
+
+ private DefaultTimeouts()
+ {
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs b/qpid/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs
index 22f1c9d89b..9ac0381850 100644
--- a/qpid/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Security/CallbackHandlerRegistry.cs
@@ -1,129 +1,129 @@
-/*
- *
- * 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 System.Collections;
-using System.Configuration;
-using System.Text;
-using Apache.Qpid.Sasl;
-using Apache.Qpid.Sasl.Mechanisms;
-
-using Apache.Qpid.Client.Configuration;
-
-namespace Apache.Qpid.Client.Security
-{
-
- /// <summary>
- /// Helper class to map SASL mechanisms to our
- /// internal ISaslCallbackHandler implementations.
- /// </summary>
- /// <remarks>
- /// The set of configured callback handlers and their order
- /// controls the selection of the SASL mechanism used for authentication.
- /// <para>
- /// You can either replace the default handler for CRAM-MD5 and PLAIN
- /// authentication (the two default options) using the application
- /// configuration file. Configuration is done by especifying the SASL
- /// mechanism name (e.g PLAIN) and the type implementing the callback handler
- /// used to provide any data required by the mechanism like username and password.
- /// </para>
- /// <para>
- /// Callback handler types should implement the IAMQCallbackHandler interface.
- /// </para>
- /// <para>
- /// New callbacks or authentication mechanisms can be configured like this:
- /// </para>
- /// <example><![CDATA[
- /// <configuration>
- /// <configSections>
- /// <sectionGroup name="qpid.client">
- /// <section name="authentication" type="Apache.Qpid.Client.Configuration.AuthenticationConfigurationSectionHandler, Apache.Qpid.Client"/>
- /// </sectionGroup>
- /// </configSections>
- /// <qpid.client>
- /// <authentication>
- /// <add key="TEST" value="Apache.Qpid.Client.Tests.Security.TestCallbackHandler, Apache.Qpid.Client.Tests"/>
- /// </authentication>
- /// </qpid.client>
- /// </configuration>
- /// ]]></example>
- /// </remarks>
- public sealed class CallbackHandlerRegistry
- {
- private static CallbackHandlerRegistry _instance =
- new CallbackHandlerRegistry();
- private OrderedHashTable _mechanism2HandlerMap;
- private string[] _mechanisms;
-
- public static CallbackHandlerRegistry Instance
- {
- get { return _instance; }
- }
-
- public string[] Mechanisms
- {
- get { return _mechanisms; }
- }
-
- private CallbackHandlerRegistry()
- {
- _mechanism2HandlerMap = (OrderedHashTable)
- ConfigurationSettings.GetConfig("qpid.client/authentication");
-
- // configure default options if not available
- if ( _mechanism2HandlerMap == null )
- _mechanism2HandlerMap = new OrderedHashTable();
-
- if ( !_mechanism2HandlerMap.Contains(ExternalSaslClient.Mechanism) )
- _mechanism2HandlerMap.Add(ExternalSaslClient.Mechanism, typeof(UsernamePasswordCallbackHandler));
- if ( !_mechanism2HandlerMap.Contains(CramMD5SaslClient.Mechanism) )
- _mechanism2HandlerMap.Add(CramMD5SaslClient.Mechanism, typeof(UsernamePasswordCallbackHandler));
- if ( !_mechanism2HandlerMap.Contains(CramMD5HexSaslClient.Mechanism) )
- _mechanism2HandlerMap.Add(CramMD5HexSaslClient.Mechanism, typeof(UsernamePasswordCallbackHandler));
- if ( !_mechanism2HandlerMap.Contains(PlainSaslClient.Mechanism) )
- _mechanism2HandlerMap.Add(PlainSaslClient.Mechanism, typeof(UsernamePasswordCallbackHandler));
-
- _mechanisms = new string[_mechanism2HandlerMap.Count];
- _mechanism2HandlerMap.OrderedKeys.CopyTo(_mechanisms, 0);
- }
-
- public bool IsSupportedMechanism(string mechanism)
- {
- return _mechanism2HandlerMap.Contains(mechanism);
- }
-
- public string ChooseMechanism(string mechanisms)
- {
- IList mechs = mechanisms.Split(' ');
- foreach ( string supportedMech in _mechanisms )
- {
- if ( mechs.Contains(supportedMech) )
- return supportedMech;
- }
- return null;
- }
-
- public Type GetCallbackHandler(string mechanism)
- {
- return (Type)_mechanism2HandlerMap[mechanism];
- }
- }
-}
+/*
+ *
+ * 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 System.Collections;
+using System.Configuration;
+using System.Text;
+using Apache.Qpid.Sasl;
+using Apache.Qpid.Sasl.Mechanisms;
+
+using Apache.Qpid.Client.Configuration;
+
+namespace Apache.Qpid.Client.Security
+{
+
+ /// <summary>
+ /// Helper class to map SASL mechanisms to our
+ /// internal ISaslCallbackHandler implementations.
+ /// </summary>
+ /// <remarks>
+ /// The set of configured callback handlers and their order
+ /// controls the selection of the SASL mechanism used for authentication.
+ /// <para>
+ /// You can either replace the default handler for CRAM-MD5 and PLAIN
+ /// authentication (the two default options) using the application
+ /// configuration file. Configuration is done by especifying the SASL
+ /// mechanism name (e.g PLAIN) and the type implementing the callback handler
+ /// used to provide any data required by the mechanism like username and password.
+ /// </para>
+ /// <para>
+ /// Callback handler types should implement the IAMQCallbackHandler interface.
+ /// </para>
+ /// <para>
+ /// New callbacks or authentication mechanisms can be configured like this:
+ /// </para>
+ /// <example><![CDATA[
+ /// <configuration>
+ /// <configSections>
+ /// <sectionGroup name="qpid.client">
+ /// <section name="authentication" type="Apache.Qpid.Client.Configuration.AuthenticationConfigurationSectionHandler, Apache.Qpid.Client"/>
+ /// </sectionGroup>
+ /// </configSections>
+ /// <qpid.client>
+ /// <authentication>
+ /// <add key="TEST" value="Apache.Qpid.Client.Tests.Security.TestCallbackHandler, Apache.Qpid.Client.Tests"/>
+ /// </authentication>
+ /// </qpid.client>
+ /// </configuration>
+ /// ]]></example>
+ /// </remarks>
+ public sealed class CallbackHandlerRegistry
+ {
+ private static CallbackHandlerRegistry _instance =
+ new CallbackHandlerRegistry();
+ private OrderedHashTable _mechanism2HandlerMap;
+ private string[] _mechanisms;
+
+ public static CallbackHandlerRegistry Instance
+ {
+ get { return _instance; }
+ }
+
+ public string[] Mechanisms
+ {
+ get { return _mechanisms; }
+ }
+
+ private CallbackHandlerRegistry()
+ {
+ _mechanism2HandlerMap = (OrderedHashTable)
+ ConfigurationSettings.GetConfig("qpid.client/authentication");
+
+ // configure default options if not available
+ if ( _mechanism2HandlerMap == null )
+ _mechanism2HandlerMap = new OrderedHashTable();
+
+ if ( !_mechanism2HandlerMap.Contains(ExternalSaslClient.Mechanism) )
+ _mechanism2HandlerMap.Add(ExternalSaslClient.Mechanism, typeof(UsernamePasswordCallbackHandler));
+ if ( !_mechanism2HandlerMap.Contains(CramMD5SaslClient.Mechanism) )
+ _mechanism2HandlerMap.Add(CramMD5SaslClient.Mechanism, typeof(UsernamePasswordCallbackHandler));
+ if ( !_mechanism2HandlerMap.Contains(CramMD5HexSaslClient.Mechanism) )
+ _mechanism2HandlerMap.Add(CramMD5HexSaslClient.Mechanism, typeof(UsernamePasswordCallbackHandler));
+ if ( !_mechanism2HandlerMap.Contains(PlainSaslClient.Mechanism) )
+ _mechanism2HandlerMap.Add(PlainSaslClient.Mechanism, typeof(UsernamePasswordCallbackHandler));
+
+ _mechanisms = new string[_mechanism2HandlerMap.Count];
+ _mechanism2HandlerMap.OrderedKeys.CopyTo(_mechanisms, 0);
+ }
+
+ public bool IsSupportedMechanism(string mechanism)
+ {
+ return _mechanism2HandlerMap.Contains(mechanism);
+ }
+
+ public string ChooseMechanism(string mechanisms)
+ {
+ IList mechs = mechanisms.Split(' ');
+ foreach ( string supportedMech in _mechanisms )
+ {
+ if ( mechs.Contains(supportedMech) )
+ return supportedMech;
+ }
+ return null;
+ }
+
+ public Type GetCallbackHandler(string mechanism)
+ {
+ return (Type)_mechanism2HandlerMap[mechanism];
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Security/IAMQCallbackHandler.cs b/qpid/dotnet/Qpid.Client/Client/Security/IAMQCallbackHandler.cs
index 2560c1d96b..6ff45be04a 100644
--- a/qpid/dotnet/Qpid.Client/Client/Security/IAMQCallbackHandler.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Security/IAMQCallbackHandler.cs
@@ -1,35 +1,35 @@
-/*
- *
- * 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 System.Text;
-using Apache.Qpid.Client.Protocol;
-using Apache.Qpid.Sasl;
-
-namespace Apache.Qpid.Client.Security
-{
- public interface IAMQCallbackHandler : ISaslCallbackHandler
- {
- void Initialize(AMQProtocolSession session);
- }
-
-}
-
-
+/*
+ *
+ * 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 System.Text;
+using Apache.Qpid.Client.Protocol;
+using Apache.Qpid.Sasl;
+
+namespace Apache.Qpid.Client.Security
+{
+ public interface IAMQCallbackHandler : ISaslCallbackHandler
+ {
+ void Initialize(AMQProtocolSession session);
+ }
+
+}
+
+
diff --git a/qpid/dotnet/Qpid.Client/Client/Security/UsernamePasswordCallbackHandler.cs b/qpid/dotnet/Qpid.Client/Client/Security/UsernamePasswordCallbackHandler.cs
index 489d4d1665..743ade77c9 100644
--- a/qpid/dotnet/Qpid.Client/Client/Security/UsernamePasswordCallbackHandler.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Security/UsernamePasswordCallbackHandler.cs
@@ -1,56 +1,56 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-using Apache.Qpid.Client.Protocol;
-using Apache.Qpid.Sasl;
-
-namespace Apache.Qpid.Client.Security
-{
- internal class UsernamePasswordCallbackHandler : IAMQCallbackHandler
- {
- private AMQProtocolSession _session;
-
- public void Initialize(AMQProtocolSession session)
- {
- if ( session == null )
- throw new ArgumentNullException("session");
-
- _session = session;
- }
-
- public void Handle(ISaslCallback[] callbacks)
- {
- foreach ( ISaslCallback cb in callbacks )
- {
- if ( cb is NameCallback )
- {
- ((NameCallback)cb).Text = _session.Username;
- } else if ( cb is PasswordCallback )
- {
- ((PasswordCallback)cb).Text = _session.Password;
- }
- }
- }
- }
-}
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+using Apache.Qpid.Client.Protocol;
+using Apache.Qpid.Sasl;
+
+namespace Apache.Qpid.Client.Security
+{
+ internal class UsernamePasswordCallbackHandler : IAMQCallbackHandler
+ {
+ private AMQProtocolSession _session;
+
+ public void Initialize(AMQProtocolSession session)
+ {
+ if ( session == null )
+ throw new ArgumentNullException("session");
+
+ _session = session;
+ }
+
+ public void Handle(ISaslCallback[] callbacks)
+ {
+ foreach ( ISaslCallback cb in callbacks )
+ {
+ if ( cb is NameCallback )
+ {
+ ((NameCallback)cb).Text = _session.Username;
+ } else if ( cb is PasswordCallback )
+ {
+ ((PasswordCallback)cb).Text = _session.Password;
+ }
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/SslOptions.cs b/qpid/dotnet/Qpid.Client/Client/SslOptions.cs
index d637101000..4630121828 100644
--- a/qpid/dotnet/Qpid.Client/Client/SslOptions.cs
+++ b/qpid/dotnet/Qpid.Client/Client/SslOptions.cs
@@ -1,81 +1,81 @@
-/*
- *
- * 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 System.Security.Cryptography.X509Certificates;
-
-namespace Apache.Qpid.Client
-{
- /// <summary>
- /// Configures SSL-related options to connect to an AMQP broker.
- /// </summary>
- /// <remarks>
- /// If the server certificate is not trusted by the client,
- /// connection will fail. However, you can set the
- /// <see cref="IgnoreValidationErrors"/> property to true
- /// to ignore any certificate verification errors for debugging purposes.
- /// </remarks>
- public class SslOptions
- {
- private X509Certificate _clientCertificate;
- private bool _ignoreValidationErrors;
-
- /// <summary>
- /// Certificate to present to the broker to authenticate
- /// this client connection
- /// </summary>
- public X509Certificate ClientCertificate
- {
- get { return _clientCertificate; }
- }
-
- /// <summary>
- /// If true, the validity of the broker certificate
- /// will not be verified on connection
- /// </summary>
- public bool IgnoreValidationErrors
- {
- get { return _ignoreValidationErrors; }
- }
-
- /// <summary>
- /// Initialize a new instance with default values
- /// (No client certificate, don't ignore validation errors)
- /// </summary>
- public SslOptions()
- {
- }
-
- /// <summary>
- /// Initialize a new instance
- /// </summary>
- /// <param name="clientCertificate">
- /// Certificate to use to authenticate the client to the broker
- /// </param>
- /// <param name="ignoreValidationErrors">
- /// If true, ignore any validation errors when validating the server certificate
- /// </param>
- public SslOptions(X509Certificate clientCertificate, bool ignoreValidationErrors)
- {
- _clientCertificate = clientCertificate;
- _ignoreValidationErrors = ignoreValidationErrors;
- }
- }
-}
+/*
+ *
+ * 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 System.Security.Cryptography.X509Certificates;
+
+namespace Apache.Qpid.Client
+{
+ /// <summary>
+ /// Configures SSL-related options to connect to an AMQP broker.
+ /// </summary>
+ /// <remarks>
+ /// If the server certificate is not trusted by the client,
+ /// connection will fail. However, you can set the
+ /// <see cref="IgnoreValidationErrors"/> property to true
+ /// to ignore any certificate verification errors for debugging purposes.
+ /// </remarks>
+ public class SslOptions
+ {
+ private X509Certificate _clientCertificate;
+ private bool _ignoreValidationErrors;
+
+ /// <summary>
+ /// Certificate to present to the broker to authenticate
+ /// this client connection
+ /// </summary>
+ public X509Certificate ClientCertificate
+ {
+ get { return _clientCertificate; }
+ }
+
+ /// <summary>
+ /// If true, the validity of the broker certificate
+ /// will not be verified on connection
+ /// </summary>
+ public bool IgnoreValidationErrors
+ {
+ get { return _ignoreValidationErrors; }
+ }
+
+ /// <summary>
+ /// Initialize a new instance with default values
+ /// (No client certificate, don't ignore validation errors)
+ /// </summary>
+ public SslOptions()
+ {
+ }
+
+ /// <summary>
+ /// Initialize a new instance
+ /// </summary>
+ /// <param name="clientCertificate">
+ /// Certificate to use to authenticate the client to the broker
+ /// </param>
+ /// <param name="ignoreValidationErrors">
+ /// If true, ignore any validation errors when validating the server certificate
+ /// </param>
+ public SslOptions(X509Certificate clientCertificate, bool ignoreValidationErrors)
+ {
+ _clientCertificate = clientCertificate;
+ _ignoreValidationErrors = ignoreValidationErrors;
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Transport/IStreamFilter.cs b/qpid/dotnet/Qpid.Client/Client/Transport/IStreamFilter.cs
index 7195b3ab04..e0e890fc5a 100644
--- a/qpid/dotnet/Qpid.Client/Client/Transport/IStreamFilter.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Transport/IStreamFilter.cs
@@ -1,38 +1,38 @@
-/*
- *
- * 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.IO;
-
-namespace Apache.Qpid.Client.Transport
-{
- /// <summary>
- /// Defines a way to introduce an arbitrary filtering
- /// stream into the stream chain managed by <see cref="IoHandler"/>
- /// </summary>
- public interface IStreamFilter
- {
- /// <summary>
- /// Creates a new filtering stream on top of another
- /// </summary>
- /// <param name="lowerStream">Next stream on the stack</param>
- /// <returns>A new filtering stream</returns>
- Stream CreateFilterStream(Stream lowerStream);
- }
-}
+/*
+ *
+ * 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.IO;
+
+namespace Apache.Qpid.Client.Transport
+{
+ /// <summary>
+ /// Defines a way to introduce an arbitrary filtering
+ /// stream into the stream chain managed by <see cref="IoHandler"/>
+ /// </summary>
+ public interface IStreamFilter
+ {
+ /// <summary>
+ /// Creates a new filtering stream on top of another
+ /// </summary>
+ /// <param name="lowerStream">Next stream on the stack</param>
+ /// <returns>A new filtering stream</returns>
+ Stream CreateFilterStream(Stream lowerStream);
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Transport/IoHandler.cs b/qpid/dotnet/Qpid.Client/Client/Transport/IoHandler.cs
index 9ac513069e..0475236d92 100644
--- a/qpid/dotnet/Qpid.Client/Client/Transport/IoHandler.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Transport/IoHandler.cs
@@ -1,322 +1,322 @@
-/*
- *
- * 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 System.IO;
-using System.Threading;
-using log4net;
-using Apache.Qpid.Buffer;
-using Apache.Qpid.Client.Protocol;
-
-namespace Apache.Qpid.Client.Transport
-{
- /// <summary>
- /// Responsible for reading and writing
- /// ByteBuffers from/to network streams, and handling
- /// the stream filters
- /// </summary>
- public class IoHandler : IByteChannel, IDisposable
- {
- private static readonly ILog _log = LogManager.GetLogger(typeof(IoHandler));
- private const int DEFAULT_BUFFER_SIZE = 32 * 1024;
-
- private Stream _topStream;
- private IProtocolListener _protocolListener;
- private int _readBufferSize;
-
- public int ReadBufferSize
- {
- get { return _readBufferSize; }
- set { _readBufferSize = value; }
- }
-
- /// <summary>
- /// Initialize a new instance
- /// </summary>
- /// <param name="stream">Underlying network stream</param>
- /// <param name="protocolListener">Protocol listener to report exceptions to</param>
- public IoHandler(Stream stream, IProtocolListener protocolListener)
- {
- if ( stream == null )
- throw new ArgumentNullException("stream");
- if ( protocolListener == null )
- throw new ArgumentNullException("protocolListener");
-
- // initially, the stream at the top of the filter
- // chain is the underlying network stream
- _topStream = stream;
- _protocolListener = protocolListener;
- _readBufferSize = DEFAULT_BUFFER_SIZE;
- }
-
- /// <summary>
- /// Adds a new filter on the top of the chain
- /// </summary>
- /// <param name="filter">Stream filter to put on top of the chain</param>
- /// <remarks>
- /// This should *only* be called during initialization. We don't
- /// support changing the filter change after the first read/write
- /// has been done and it's not thread-safe to boot!
- /// </remarks>
- public void AddFilter(IStreamFilter filter)
- {
- _topStream = filter.CreateFilterStream(_topStream);
- }
-
- #region IByteChannel Implementation
- //
- // IByteChannel Implementation
- //
-
- /// <summary>
- /// Read a <see cref="ByteBuffer"/> from the underlying
- /// network stream and any configured filters
- /// </summary>
- /// <returns>A ByteBuffer, if available</returns>
- public ByteBuffer Read()
- {
- byte[] bytes = AllocateBuffer();
-
- int numOctets = _topStream.Read(bytes, 0, bytes.Length);
-
- return WrapByteArray(bytes, numOctets);
- }
-
- /// <summary>
- /// Begin an asynchronous read operation
- /// </summary>
- /// <param name="callback">Callback method to call when read operation completes</param>
- /// <param name="state">State object</param>
- /// <returns>An <see cref="System.IAsyncResult"/> object</returns>
- public IAsyncResult BeginRead(AsyncCallback callback, object state)
- {
- byte[] bytes = AllocateBuffer();
- ReadData rd = new ReadData(callback, state, bytes);
-
- // only put a callback if the caller wants one.
- AsyncCallback myCallback = null;
- if ( callback != null )
- myCallback = new AsyncCallback(OnAsyncReadDone);
-
- IAsyncResult result = _topStream.BeginRead(
- bytes, 0, bytes.Length, myCallback,rd
- );
- return new WrappedAsyncResult(result, bytes);
- }
-
- /// <summary>
- /// End an asynchronous read operation
- /// </summary>
- /// <param name="result">The <see cref="System.IAsyncResult"/> object returned from <see cref="BeginRead"/></param>
- /// <returns>The <see cref="ByteBuffer"/> read</returns>
- public ByteBuffer EndRead(IAsyncResult result)
- {
- WrappedAsyncResult theResult = (WrappedAsyncResult)result;
- int bytesRead = _topStream.EndRead(theResult.InnerResult);
- return WrapByteArray(theResult.Buffer, bytesRead);
- }
-
- /// <summary>
- /// Write a <see cref="ByteBuffer"/> to the underlying network
- /// stream, going through any configured filters
- /// </summary>
- /// <param name="buffer"></param>
- public void Write(ByteBuffer buffer)
- {
- try
- {
- _topStream.Write(buffer.Array, buffer.Position, buffer.Limit); // FIXME
- }
- catch (Exception e)
- {
- _log.Warn("Write caused exception", e);
- _protocolListener.OnException(e);
- }
- }
-
- /// <summary>
- /// Begin an asynchronous write operation
- /// </summary>
- /// <param name="buffer">Buffer to write</param>
- /// <param name="callback">A callback to call when the operation completes</param>
- /// <param name="state">State object</param>
- /// <returns>An <see cref="System.IAsyncResult"/> object</returns>
- public IAsyncResult BeginWrite(ByteBuffer buffer, AsyncCallback callback, object state)
- {
- try
- {
- return _topStream.BeginWrite(
- buffer.Array, buffer.Position, buffer.Limit,
- callback, state
- );
- } catch ( Exception e )
- {
- _log.Error("BeginWrite caused exception", e);
- // not clear if an exception here should be propagated? we still
- // need to propagate it upwards anyway!
- _protocolListener.OnException(e);
- throw;
- }
- }
-
- /// <summary>
- /// End an asynchronous write operation
- /// </summary>
- /// <param name="result">The <see cref="System.IAsyncResult"/> object returned by <see cref="BeginWrite"/></param>
- public void EndWrite(IAsyncResult result)
- {
- try
- {
- _topStream.EndWrite(result);
- } catch ( Exception e )
- {
- _log.Error("EndWrite caused exception", e);
- // not clear if an exception here should be propagated?
- _protocolListener.OnException(e);
- //throw;
- }
- }
- #endregion // IByteChannel Implementation
-
- #region IDisposable Implementation
- //
- // IDisposable Implementation
- //
-
- public void Dispose()
- {
- if ( _topStream != null )
- {
- _topStream.Close();
- }
- }
-
- #endregion // IDisposable Implementation
-
- #region Private and Helper Classes/Methods
- //
- // Private and Helper Classes/Methods
- //
-
- private byte[] AllocateBuffer()
- {
- return new byte[ReadBufferSize];
- }
-
- private static ByteBuffer WrapByteArray(byte[] bytes, int size)
- {
- ByteBuffer byteBuffer = ByteBuffer.Wrap(bytes);
- byteBuffer.Limit = size;
- byteBuffer.Flip();
-
- return byteBuffer;
- }
-
-
- private static void OnAsyncReadDone(IAsyncResult result)
- {
- ReadData rd = (ReadData) result.AsyncState;
- IAsyncResult wrapped = new WrappedAsyncResult(result, rd.Buffer);
- rd.Callback(wrapped);
- }
-
- class ReadData
- {
- private object _state;
- private AsyncCallback _callback;
- private byte[] _buffer;
-
- public object State
- {
- get { return _state; }
- }
-
- public AsyncCallback Callback
- {
- get { return _callback; }
- }
-
- public byte[] Buffer
- {
- get { return _buffer; }
- }
-
- public ReadData(AsyncCallback callback, object state, byte[] buffer)
- {
- _callback = callback;
- _state = state;
- _buffer = buffer;
- }
- }
-
- class WrappedAsyncResult : IAsyncResult
- {
- private IAsyncResult _innerResult;
- private byte[] _buffer;
-
- #region IAsyncResult Properties
- //
- // IAsyncResult Properties
- //
- public bool IsCompleted
- {
- get { return _innerResult.IsCompleted; }
- }
-
- public WaitHandle AsyncWaitHandle
- {
- get { return _innerResult.AsyncWaitHandle; }
- }
-
- public object AsyncState
- {
- get { return _innerResult.AsyncState; }
- }
-
- public bool CompletedSynchronously
- {
- get { return _innerResult.CompletedSynchronously; }
- }
- #endregion // IAsyncResult Properties
-
- public IAsyncResult InnerResult
- {
- get { return _innerResult; }
- }
- public byte[] Buffer
- {
- get { return _buffer; }
- }
-
- public WrappedAsyncResult(IAsyncResult result, byte[] buffer)
- {
- if ( result == null )
- throw new ArgumentNullException("result");
- if ( buffer == null )
- throw new ArgumentNullException("buffer");
-
- _innerResult = result;
- _buffer = buffer;
- }
- }
-
- #endregion // Private and Helper Classes/Methods
- }
-}
+/*
+ *
+ * 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 System.IO;
+using System.Threading;
+using log4net;
+using Apache.Qpid.Buffer;
+using Apache.Qpid.Client.Protocol;
+
+namespace Apache.Qpid.Client.Transport
+{
+ /// <summary>
+ /// Responsible for reading and writing
+ /// ByteBuffers from/to network streams, and handling
+ /// the stream filters
+ /// </summary>
+ public class IoHandler : IByteChannel, IDisposable
+ {
+ private static readonly ILog _log = LogManager.GetLogger(typeof(IoHandler));
+ private const int DEFAULT_BUFFER_SIZE = 32 * 1024;
+
+ private Stream _topStream;
+ private IProtocolListener _protocolListener;
+ private int _readBufferSize;
+
+ public int ReadBufferSize
+ {
+ get { return _readBufferSize; }
+ set { _readBufferSize = value; }
+ }
+
+ /// <summary>
+ /// Initialize a new instance
+ /// </summary>
+ /// <param name="stream">Underlying network stream</param>
+ /// <param name="protocolListener">Protocol listener to report exceptions to</param>
+ public IoHandler(Stream stream, IProtocolListener protocolListener)
+ {
+ if ( stream == null )
+ throw new ArgumentNullException("stream");
+ if ( protocolListener == null )
+ throw new ArgumentNullException("protocolListener");
+
+ // initially, the stream at the top of the filter
+ // chain is the underlying network stream
+ _topStream = stream;
+ _protocolListener = protocolListener;
+ _readBufferSize = DEFAULT_BUFFER_SIZE;
+ }
+
+ /// <summary>
+ /// Adds a new filter on the top of the chain
+ /// </summary>
+ /// <param name="filter">Stream filter to put on top of the chain</param>
+ /// <remarks>
+ /// This should *only* be called during initialization. We don't
+ /// support changing the filter change after the first read/write
+ /// has been done and it's not thread-safe to boot!
+ /// </remarks>
+ public void AddFilter(IStreamFilter filter)
+ {
+ _topStream = filter.CreateFilterStream(_topStream);
+ }
+
+ #region IByteChannel Implementation
+ //
+ // IByteChannel Implementation
+ //
+
+ /// <summary>
+ /// Read a <see cref="ByteBuffer"/> from the underlying
+ /// network stream and any configured filters
+ /// </summary>
+ /// <returns>A ByteBuffer, if available</returns>
+ public ByteBuffer Read()
+ {
+ byte[] bytes = AllocateBuffer();
+
+ int numOctets = _topStream.Read(bytes, 0, bytes.Length);
+
+ return WrapByteArray(bytes, numOctets);
+ }
+
+ /// <summary>
+ /// Begin an asynchronous read operation
+ /// </summary>
+ /// <param name="callback">Callback method to call when read operation completes</param>
+ /// <param name="state">State object</param>
+ /// <returns>An <see cref="System.IAsyncResult"/> object</returns>
+ public IAsyncResult BeginRead(AsyncCallback callback, object state)
+ {
+ byte[] bytes = AllocateBuffer();
+ ReadData rd = new ReadData(callback, state, bytes);
+
+ // only put a callback if the caller wants one.
+ AsyncCallback myCallback = null;
+ if ( callback != null )
+ myCallback = new AsyncCallback(OnAsyncReadDone);
+
+ IAsyncResult result = _topStream.BeginRead(
+ bytes, 0, bytes.Length, myCallback,rd
+ );
+ return new WrappedAsyncResult(result, bytes);
+ }
+
+ /// <summary>
+ /// End an asynchronous read operation
+ /// </summary>
+ /// <param name="result">The <see cref="System.IAsyncResult"/> object returned from <see cref="BeginRead"/></param>
+ /// <returns>The <see cref="ByteBuffer"/> read</returns>
+ public ByteBuffer EndRead(IAsyncResult result)
+ {
+ WrappedAsyncResult theResult = (WrappedAsyncResult)result;
+ int bytesRead = _topStream.EndRead(theResult.InnerResult);
+ return WrapByteArray(theResult.Buffer, bytesRead);
+ }
+
+ /// <summary>
+ /// Write a <see cref="ByteBuffer"/> to the underlying network
+ /// stream, going through any configured filters
+ /// </summary>
+ /// <param name="buffer"></param>
+ public void Write(ByteBuffer buffer)
+ {
+ try
+ {
+ _topStream.Write(buffer.Array, buffer.Position, buffer.Limit); // FIXME
+ }
+ catch (Exception e)
+ {
+ _log.Warn("Write caused exception", e);
+ _protocolListener.OnException(e);
+ }
+ }
+
+ /// <summary>
+ /// Begin an asynchronous write operation
+ /// </summary>
+ /// <param name="buffer">Buffer to write</param>
+ /// <param name="callback">A callback to call when the operation completes</param>
+ /// <param name="state">State object</param>
+ /// <returns>An <see cref="System.IAsyncResult"/> object</returns>
+ public IAsyncResult BeginWrite(ByteBuffer buffer, AsyncCallback callback, object state)
+ {
+ try
+ {
+ return _topStream.BeginWrite(
+ buffer.Array, buffer.Position, buffer.Limit,
+ callback, state
+ );
+ } catch ( Exception e )
+ {
+ _log.Error("BeginWrite caused exception", e);
+ // not clear if an exception here should be propagated? we still
+ // need to propagate it upwards anyway!
+ _protocolListener.OnException(e);
+ throw;
+ }
+ }
+
+ /// <summary>
+ /// End an asynchronous write operation
+ /// </summary>
+ /// <param name="result">The <see cref="System.IAsyncResult"/> object returned by <see cref="BeginWrite"/></param>
+ public void EndWrite(IAsyncResult result)
+ {
+ try
+ {
+ _topStream.EndWrite(result);
+ } catch ( Exception e )
+ {
+ _log.Error("EndWrite caused exception", e);
+ // not clear if an exception here should be propagated?
+ _protocolListener.OnException(e);
+ //throw;
+ }
+ }
+ #endregion // IByteChannel Implementation
+
+ #region IDisposable Implementation
+ //
+ // IDisposable Implementation
+ //
+
+ public void Dispose()
+ {
+ if ( _topStream != null )
+ {
+ _topStream.Close();
+ }
+ }
+
+ #endregion // IDisposable Implementation
+
+ #region Private and Helper Classes/Methods
+ //
+ // Private and Helper Classes/Methods
+ //
+
+ private byte[] AllocateBuffer()
+ {
+ return new byte[ReadBufferSize];
+ }
+
+ private static ByteBuffer WrapByteArray(byte[] bytes, int size)
+ {
+ ByteBuffer byteBuffer = ByteBuffer.Wrap(bytes);
+ byteBuffer.Limit = size;
+ byteBuffer.Flip();
+
+ return byteBuffer;
+ }
+
+
+ private static void OnAsyncReadDone(IAsyncResult result)
+ {
+ ReadData rd = (ReadData) result.AsyncState;
+ IAsyncResult wrapped = new WrappedAsyncResult(result, rd.Buffer);
+ rd.Callback(wrapped);
+ }
+
+ class ReadData
+ {
+ private object _state;
+ private AsyncCallback _callback;
+ private byte[] _buffer;
+
+ public object State
+ {
+ get { return _state; }
+ }
+
+ public AsyncCallback Callback
+ {
+ get { return _callback; }
+ }
+
+ public byte[] Buffer
+ {
+ get { return _buffer; }
+ }
+
+ public ReadData(AsyncCallback callback, object state, byte[] buffer)
+ {
+ _callback = callback;
+ _state = state;
+ _buffer = buffer;
+ }
+ }
+
+ class WrappedAsyncResult : IAsyncResult
+ {
+ private IAsyncResult _innerResult;
+ private byte[] _buffer;
+
+ #region IAsyncResult Properties
+ //
+ // IAsyncResult Properties
+ //
+ public bool IsCompleted
+ {
+ get { return _innerResult.IsCompleted; }
+ }
+
+ public WaitHandle AsyncWaitHandle
+ {
+ get { return _innerResult.AsyncWaitHandle; }
+ }
+
+ public object AsyncState
+ {
+ get { return _innerResult.AsyncState; }
+ }
+
+ public bool CompletedSynchronously
+ {
+ get { return _innerResult.CompletedSynchronously; }
+ }
+ #endregion // IAsyncResult Properties
+
+ public IAsyncResult InnerResult
+ {
+ get { return _innerResult; }
+ }
+ public byte[] Buffer
+ {
+ get { return _buffer; }
+ }
+
+ public WrappedAsyncResult(IAsyncResult result, byte[] buffer)
+ {
+ if ( result == null )
+ throw new ArgumentNullException("result");
+ if ( buffer == null )
+ throw new ArgumentNullException("buffer");
+
+ _innerResult = result;
+ _buffer = buffer;
+ }
+ }
+
+ #endregion // Private and Helper Classes/Methods
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Transport/ProtocolDecoderOutput.cs b/qpid/dotnet/Qpid.Client/Client/Transport/ProtocolDecoderOutput.cs
index 3841c158e4..9fa313152f 100644
--- a/qpid/dotnet/Qpid.Client/Client/Transport/ProtocolDecoderOutput.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Transport/ProtocolDecoderOutput.cs
@@ -1,60 +1,60 @@
-/*
- *
- * 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 System.Threading;
-using Apache.Qpid.Client.Protocol;
-using Apache.Qpid.Codec;
-using Apache.Qpid.Framing;
-using log4net;
-
-namespace Apache.Qpid.Client.Transport
-{
- /// <summary>
- /// <see cref="IProtocolDecoderOutput"/> implementation that forwards
- /// each <see cref="IDataBlock"/> as it is decoded to the
- /// protocol listener
- /// </summary>
- internal class ProtocolDecoderOutput : IProtocolDecoderOutput
- {
- private IProtocolListener _protocolListener;
- static readonly ILog _protocolTraceLog = LogManager.GetLogger("TRACE.Qpid.Client.ProtocolChannel");
-
- public ProtocolDecoderOutput(IProtocolListener protocolListener)
- {
- if ( protocolListener == null )
- throw new ArgumentNullException("protocolListener");
-
- _protocolListener = protocolListener;
- }
-
- public void Write(object message)
- {
- IDataBlock block = message as IDataBlock;
- if ( block != null )
- {
- _protocolTraceLog.Debug(String.Format("READ {0}", block));
- _protocolListener.OnMessage(block);
- }
- }
- }
-} // namespace Apache.Qpid.Client.Transport
-
-
+/*
+ *
+ * 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 System.Threading;
+using Apache.Qpid.Client.Protocol;
+using Apache.Qpid.Codec;
+using Apache.Qpid.Framing;
+using log4net;
+
+namespace Apache.Qpid.Client.Transport
+{
+ /// <summary>
+ /// <see cref="IProtocolDecoderOutput"/> implementation that forwards
+ /// each <see cref="IDataBlock"/> as it is decoded to the
+ /// protocol listener
+ /// </summary>
+ internal class ProtocolDecoderOutput : IProtocolDecoderOutput
+ {
+ private IProtocolListener _protocolListener;
+ static readonly ILog _protocolTraceLog = LogManager.GetLogger("TRACE.Qpid.Client.ProtocolChannel");
+
+ public ProtocolDecoderOutput(IProtocolListener protocolListener)
+ {
+ if ( protocolListener == null )
+ throw new ArgumentNullException("protocolListener");
+
+ _protocolListener = protocolListener;
+ }
+
+ public void Write(object message)
+ {
+ IDataBlock block = message as IDataBlock;
+ if ( block != null )
+ {
+ _protocolTraceLog.Debug(String.Format("READ {0}", block));
+ _protocolListener.OnMessage(block);
+ }
+ }
+ }
+} // namespace Apache.Qpid.Client.Transport
+
+
diff --git a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/BlockingSocketTransport.cs b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/BlockingSocketTransport.cs
index 8a16f9a675..f336d8a80a 100644
--- a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/BlockingSocketTransport.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/BlockingSocketTransport.cs
@@ -1,150 +1,150 @@
-/*
- *
- * 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 System.Collections;
-using System.IO;
-using System.Threading;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client.Protocol;
-using Apache.Qpid.Codec;
-using Apache.Qpid.Framing;
-
-namespace Apache.Qpid.Client.Transport.Socket.Blocking
-{
- /// <summary>
- /// TCP Socket transport supporting both
- /// SSL and non-SSL connections.
- /// </summary>
- public class BlockingSocketTransport : ITransport
- {
- // Configuration variables.
- IProtocolListener _protocolListener;
-
- // Runtime variables.
- private ISocketConnector _connector;
- private IoHandler _ioHandler;
- private AmqpChannel _amqpChannel;
- private ManualResetEvent _stopEvent;
-
- public IProtocolWriter ProtocolWriter
- {
- get { return _amqpChannel; }
- }
- public string LocalEndpoint
- {
- get { return _connector.LocalEndpoint; }
- }
-
-
- /// <summary>
- /// Connect to the specified broker
- /// </summary>
- /// <param name="broker">The broker to connect to</param>
- /// <param name="connection">The AMQ connection</param>
- public void Connect(IBrokerInfo broker, AMQConnection connection)
- {
- _stopEvent = new ManualResetEvent(false);
- _protocolListener = connection.ProtocolListener;
-
- _ioHandler = MakeBrokerConnection(broker, connection);
- // todo: get default read size from config!
-
- IProtocolDecoderOutput decoderOutput =
- new ProtocolDecoderOutput(_protocolListener);
- _amqpChannel =
- new AmqpChannel(new ByteChannel(_ioHandler), decoderOutput);
-
- // post an initial async read
- _amqpChannel.BeginRead(new AsyncCallback(OnAsyncReadDone), this);
- }
-
- /// <summary>
- /// Close the broker connection
- /// </summary>
- public void Close()
- {
- StopReading();
- CloseBrokerConnection();
- }
-
- private void StopReading()
- {
- _stopEvent.Set();
- }
-
- private void CloseBrokerConnection()
- {
- if ( _ioHandler != null )
- {
- _ioHandler.Dispose();
- _ioHandler = null;
- }
- if ( _connector != null )
- {
- _connector.Dispose();
- _connector = null;
- }
- }
-
- private IoHandler MakeBrokerConnection(IBrokerInfo broker, AMQConnection connection)
- {
- if ( broker.UseSSL )
- {
- _connector = new SslSocketConnector();
- } else
- {
- _connector = new SocketConnector();
- }
-
- Stream stream = _connector.Connect(broker);
- return new IoHandler(stream, connection.ProtocolListener);
- }
-
- private void OnAsyncReadDone(IAsyncResult result)
- {
- try
- {
- _amqpChannel.EndRead(result);
-
- bool stopping = _stopEvent.WaitOne(0, false);
- if ( !stopping )
- _amqpChannel.BeginRead(new AsyncCallback(OnAsyncReadDone), null);
- } catch ( Exception e )
- {
- // ignore any errors during closing
- bool stopping = _stopEvent.WaitOne(0, false);
- if ( !stopping )
- _protocolListener.OnException(e);
- }
- }
-
- #region IProtocolDecoderOutput Members
-
- public void Write(object message)
- {
- _protocolListener.OnMessage((IDataBlock)message);
- }
-
- #endregion
- }
-}
-
-
+/*
+ *
+ * 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 System.Collections;
+using System.IO;
+using System.Threading;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client.Protocol;
+using Apache.Qpid.Codec;
+using Apache.Qpid.Framing;
+
+namespace Apache.Qpid.Client.Transport.Socket.Blocking
+{
+ /// <summary>
+ /// TCP Socket transport supporting both
+ /// SSL and non-SSL connections.
+ /// </summary>
+ public class BlockingSocketTransport : ITransport
+ {
+ // Configuration variables.
+ IProtocolListener _protocolListener;
+
+ // Runtime variables.
+ private ISocketConnector _connector;
+ private IoHandler _ioHandler;
+ private AmqpChannel _amqpChannel;
+ private ManualResetEvent _stopEvent;
+
+ public IProtocolWriter ProtocolWriter
+ {
+ get { return _amqpChannel; }
+ }
+ public string LocalEndpoint
+ {
+ get { return _connector.LocalEndpoint; }
+ }
+
+
+ /// <summary>
+ /// Connect to the specified broker
+ /// </summary>
+ /// <param name="broker">The broker to connect to</param>
+ /// <param name="connection">The AMQ connection</param>
+ public void Connect(IBrokerInfo broker, AMQConnection connection)
+ {
+ _stopEvent = new ManualResetEvent(false);
+ _protocolListener = connection.ProtocolListener;
+
+ _ioHandler = MakeBrokerConnection(broker, connection);
+ // todo: get default read size from config!
+
+ IProtocolDecoderOutput decoderOutput =
+ new ProtocolDecoderOutput(_protocolListener);
+ _amqpChannel =
+ new AmqpChannel(new ByteChannel(_ioHandler), decoderOutput);
+
+ // post an initial async read
+ _amqpChannel.BeginRead(new AsyncCallback(OnAsyncReadDone), this);
+ }
+
+ /// <summary>
+ /// Close the broker connection
+ /// </summary>
+ public void Close()
+ {
+ StopReading();
+ CloseBrokerConnection();
+ }
+
+ private void StopReading()
+ {
+ _stopEvent.Set();
+ }
+
+ private void CloseBrokerConnection()
+ {
+ if ( _ioHandler != null )
+ {
+ _ioHandler.Dispose();
+ _ioHandler = null;
+ }
+ if ( _connector != null )
+ {
+ _connector.Dispose();
+ _connector = null;
+ }
+ }
+
+ private IoHandler MakeBrokerConnection(IBrokerInfo broker, AMQConnection connection)
+ {
+ if ( broker.UseSSL )
+ {
+ _connector = new SslSocketConnector();
+ } else
+ {
+ _connector = new SocketConnector();
+ }
+
+ Stream stream = _connector.Connect(broker);
+ return new IoHandler(stream, connection.ProtocolListener);
+ }
+
+ private void OnAsyncReadDone(IAsyncResult result)
+ {
+ try
+ {
+ _amqpChannel.EndRead(result);
+
+ bool stopping = _stopEvent.WaitOne(0, false);
+ if ( !stopping )
+ _amqpChannel.BeginRead(new AsyncCallback(OnAsyncReadDone), null);
+ } catch ( Exception e )
+ {
+ // ignore any errors during closing
+ bool stopping = _stopEvent.WaitOne(0, false);
+ if ( !stopping )
+ _protocolListener.OnException(e);
+ }
+ }
+
+ #region IProtocolDecoderOutput Members
+
+ public void Write(object message)
+ {
+ _protocolListener.OnMessage((IDataBlock)message);
+ }
+
+ #endregion
+ }
+}
+
+
diff --git a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ByteChannel.cs b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ByteChannel.cs
index 73575c7086..4540f01f4e 100644
--- a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ByteChannel.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ByteChannel.cs
@@ -1,92 +1,92 @@
-/*
- *
- * 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 log4net;
-using Apache.Qpid.Buffer;
-
-namespace Apache.Qpid.Client.Transport.Socket.Blocking
-{
- class ByteChannel : IByteChannel
- {
- // Warning: don't use this log for regular logging.
- private static readonly ILog _ioTraceLog = LogManager.GetLogger("TRACE.Qpid.Client.ByteChannel");
-
- private IByteChannel _lowerChannel;
-
- public ByteChannel(IByteChannel lowerChannel)
- {
- _lowerChannel = lowerChannel;
- }
-
- public ByteBuffer Read()
- {
- ByteBuffer result = _lowerChannel.Read();
-
- // TODO: Move into decorator.
- if (_ioTraceLog.IsDebugEnabled)
- {
- _ioTraceLog.Debug(String.Format("READ {0}", result));
- }
-
- return result;
- }
-
- public IAsyncResult BeginRead(AsyncCallback callback, object state)
- {
- return _lowerChannel.BeginRead(callback, state);
- }
-
- public ByteBuffer EndRead(IAsyncResult result)
- {
- ByteBuffer buffer = _lowerChannel.EndRead(result);
- if ( _ioTraceLog.IsDebugEnabled )
- {
- _ioTraceLog.Debug(String.Format("READ {0}", buffer));
- }
- return buffer;
- }
-
- public void Write(ByteBuffer buffer)
- {
- // TODO: Move into decorator.
- if (_ioTraceLog.IsDebugEnabled)
- {
- _ioTraceLog.Debug(String.Format("WRITE {0}", buffer));
- }
-
- _lowerChannel.Write(buffer);
- }
-
- public IAsyncResult BeginWrite(ByteBuffer buffer, AsyncCallback callback, object state)
- {
- if ( _ioTraceLog.IsDebugEnabled )
- {
- _ioTraceLog.Debug(String.Format("WRITE {0}", buffer));
- }
- return _lowerChannel.BeginWrite(buffer, callback, state);
- }
-
- public void EndWrite(IAsyncResult result)
- {
- _lowerChannel.EndWrite(result);
- }
- }
-}
+/*
+ *
+ * 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 log4net;
+using Apache.Qpid.Buffer;
+
+namespace Apache.Qpid.Client.Transport.Socket.Blocking
+{
+ class ByteChannel : IByteChannel
+ {
+ // Warning: don't use this log for regular logging.
+ private static readonly ILog _ioTraceLog = LogManager.GetLogger("TRACE.Qpid.Client.ByteChannel");
+
+ private IByteChannel _lowerChannel;
+
+ public ByteChannel(IByteChannel lowerChannel)
+ {
+ _lowerChannel = lowerChannel;
+ }
+
+ public ByteBuffer Read()
+ {
+ ByteBuffer result = _lowerChannel.Read();
+
+ // TODO: Move into decorator.
+ if (_ioTraceLog.IsDebugEnabled)
+ {
+ _ioTraceLog.Debug(String.Format("READ {0}", result));
+ }
+
+ return result;
+ }
+
+ public IAsyncResult BeginRead(AsyncCallback callback, object state)
+ {
+ return _lowerChannel.BeginRead(callback, state);
+ }
+
+ public ByteBuffer EndRead(IAsyncResult result)
+ {
+ ByteBuffer buffer = _lowerChannel.EndRead(result);
+ if ( _ioTraceLog.IsDebugEnabled )
+ {
+ _ioTraceLog.Debug(String.Format("READ {0}", buffer));
+ }
+ return buffer;
+ }
+
+ public void Write(ByteBuffer buffer)
+ {
+ // TODO: Move into decorator.
+ if (_ioTraceLog.IsDebugEnabled)
+ {
+ _ioTraceLog.Debug(String.Format("WRITE {0}", buffer));
+ }
+
+ _lowerChannel.Write(buffer);
+ }
+
+ public IAsyncResult BeginWrite(ByteBuffer buffer, AsyncCallback callback, object state)
+ {
+ if ( _ioTraceLog.IsDebugEnabled )
+ {
+ _ioTraceLog.Debug(String.Format("WRITE {0}", buffer));
+ }
+ return _lowerChannel.BeginWrite(buffer, callback, state);
+ }
+
+ public void EndWrite(IAsyncResult result)
+ {
+ _lowerChannel.EndWrite(result);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ISocketConnector.cs b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ISocketConnector.cs
index 3d5d2898cf..137fa19c0d 100644
--- a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ISocketConnector.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/ISocketConnector.cs
@@ -1,34 +1,34 @@
-/*
- *
- * 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 System.IO;
-using Apache.Qpid.Client.Qms;
-
-namespace Apache.Qpid.Client.Transport.Socket.Blocking
-{
- interface ISocketConnector : IDisposable
- {
- string LocalEndpoint { get; }
- Stream Connect(IBrokerInfo broker);
- }
-}
-
-
+/*
+ *
+ * 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 System.IO;
+using Apache.Qpid.Client.Qms;
+
+namespace Apache.Qpid.Client.Transport.Socket.Blocking
+{
+ interface ISocketConnector : IDisposable
+ {
+ string LocalEndpoint { get; }
+ Stream Connect(IBrokerInfo broker);
+ }
+}
+
+
diff --git a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SocketConnector.cs b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SocketConnector.cs
index 83f7287e9b..b6dd8c3be1 100644
--- a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SocketConnector.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SocketConnector.cs
@@ -1,71 +1,71 @@
-/*
- *
- * 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.IO;
-using System.Net;
-using System.Net.Sockets;
-using Apache.Qpid.Client.Qms;
-
-namespace Apache.Qpid.Client.Transport.Socket.Blocking
-{
- /// <summary>
- /// Implements a TCP connection over regular sockets.
- /// </summary>
- class SocketConnector : ISocketConnector
- {
- private MyTcpClient _tcpClient;
-
- public string LocalEndpoint
- {
- get { return _tcpClient.LocalEndpoint.ToString(); }
- }
-
- public Stream Connect(IBrokerInfo broker)
- {
- _tcpClient = new MyTcpClient(broker.Host, broker.Port);
- return _tcpClient.GetStream();
- }
-
- public void Dispose()
- {
- if ( _tcpClient != null )
- {
- _tcpClient.Close();
- _tcpClient = null;
- }
- }
-
- class MyTcpClient : TcpClient
- {
- public MyTcpClient(string host, int port)
- : base(host, port)
- {
- }
-
- public EndPoint LocalEndpoint
- {
- get { return Client.LocalEndPoint; }
- }
- }
-
- }
-}
-
-
+/*
+ *
+ * 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.IO;
+using System.Net;
+using System.Net.Sockets;
+using Apache.Qpid.Client.Qms;
+
+namespace Apache.Qpid.Client.Transport.Socket.Blocking
+{
+ /// <summary>
+ /// Implements a TCP connection over regular sockets.
+ /// </summary>
+ class SocketConnector : ISocketConnector
+ {
+ private MyTcpClient _tcpClient;
+
+ public string LocalEndpoint
+ {
+ get { return _tcpClient.LocalEndpoint.ToString(); }
+ }
+
+ public Stream Connect(IBrokerInfo broker)
+ {
+ _tcpClient = new MyTcpClient(broker.Host, broker.Port);
+ return _tcpClient.GetStream();
+ }
+
+ public void Dispose()
+ {
+ if ( _tcpClient != null )
+ {
+ _tcpClient.Close();
+ _tcpClient = null;
+ }
+ }
+
+ class MyTcpClient : TcpClient
+ {
+ public MyTcpClient(string host, int port)
+ : base(host, port)
+ {
+ }
+
+ public EndPoint LocalEndpoint
+ {
+ get { return Client.LocalEndPoint; }
+ }
+ }
+
+ }
+}
+
+
diff --git a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SslSocketConnector.cs b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SslSocketConnector.cs
index 708edde48c..8436e6fc4f 100644
--- a/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SslSocketConnector.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Transport/Socket/Blocking/SslSocketConnector.cs
@@ -1,107 +1,107 @@
-/*
- *
- * 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.IO;
-using System.Net;
-using log4net;
-using Apache.Qpid.Client.Qms;
-using Org.Mentalis.Security.Ssl;
-using MCertificate = Org.Mentalis.Security.Certificates.Certificate;
-using MCertificateChain = Org.Mentalis.Security.Certificates.CertificateChain;
-
-namespace Apache.Qpid.Client.Transport.Socket.Blocking
-{
- /// <summary>
- /// Implements a TLS v1.0 connection using the Mentalis.org library
- /// </summary>
- /// <remarks>
- /// It would've been easier to implement this at the StreamFilter
- /// level, but unfortunately the Mentalis library doesn't support
- /// a passthrough SSL stream class and is tied directly
- /// to socket-like classes.
- /// </remarks>
- class SslSocketConnector : ISocketConnector
- {
- private static ILog _logger = LogManager.GetLogger(typeof(SslSocketConnector));
- private MyTcpClient _tcpClient;
-
- public string LocalEndpoint
- {
- get { return _tcpClient.LocalEndpoint.ToString(); }
- }
-
- public Stream Connect(IBrokerInfo broker)
- {
- MCertificate cert = GetClientCert(broker);
- SecurityOptions options = new SecurityOptions(
- SecureProtocol.Tls1, cert, ConnectionEnd.Client
- );
- if ( broker.SslOptions != null
- && broker.SslOptions.IgnoreValidationErrors )
- {
- _logger.Warn("Ignoring any certificate validation errors during SSL handshake...");
- options.VerificationType = CredentialVerification.None;
- }
-
- _tcpClient = new MyTcpClient(broker.Host, broker.Port, options);
- return _tcpClient.GetStream();
- }
-
- public void Dispose()
- {
- if ( _tcpClient != null )
- {
- _tcpClient.Close();
- _tcpClient = null;
- }
- }
-
- private static MCertificate GetClientCert(IBrokerInfo broker)
- {
- // if a client certificate is configured,
- // use that to enable mutual authentication
- MCertificate cert = null;
- if ( broker.SslOptions != null
- && broker.SslOptions.ClientCertificate != null )
- {
- cert = MCertificate.CreateFromX509Certificate(
- broker.SslOptions.ClientCertificate
- );
- _logger.DebugFormat("Using Client Certificate for SSL '{0}'", cert.ToString(true));
- }
- return cert;
- }
-
- class MyTcpClient : SecureTcpClient
- {
- public MyTcpClient(string host, int port, SecurityOptions options)
- : base(host, port, options)
- {
- }
-
- public EndPoint LocalEndpoint
- {
- get { return Client.LocalEndPoint; }
- }
-
- }
-
- }
-}
+/*
+ *
+ * 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.IO;
+using System.Net;
+using log4net;
+using Apache.Qpid.Client.Qms;
+using Org.Mentalis.Security.Ssl;
+using MCertificate = Org.Mentalis.Security.Certificates.Certificate;
+using MCertificateChain = Org.Mentalis.Security.Certificates.CertificateChain;
+
+namespace Apache.Qpid.Client.Transport.Socket.Blocking
+{
+ /// <summary>
+ /// Implements a TLS v1.0 connection using the Mentalis.org library
+ /// </summary>
+ /// <remarks>
+ /// It would've been easier to implement this at the StreamFilter
+ /// level, but unfortunately the Mentalis library doesn't support
+ /// a passthrough SSL stream class and is tied directly
+ /// to socket-like classes.
+ /// </remarks>
+ class SslSocketConnector : ISocketConnector
+ {
+ private static ILog _logger = LogManager.GetLogger(typeof(SslSocketConnector));
+ private MyTcpClient _tcpClient;
+
+ public string LocalEndpoint
+ {
+ get { return _tcpClient.LocalEndpoint.ToString(); }
+ }
+
+ public Stream Connect(IBrokerInfo broker)
+ {
+ MCertificate cert = GetClientCert(broker);
+ SecurityOptions options = new SecurityOptions(
+ SecureProtocol.Tls1, cert, ConnectionEnd.Client
+ );
+ if ( broker.SslOptions != null
+ && broker.SslOptions.IgnoreValidationErrors )
+ {
+ _logger.Warn("Ignoring any certificate validation errors during SSL handshake...");
+ options.VerificationType = CredentialVerification.None;
+ }
+
+ _tcpClient = new MyTcpClient(broker.Host, broker.Port, options);
+ return _tcpClient.GetStream();
+ }
+
+ public void Dispose()
+ {
+ if ( _tcpClient != null )
+ {
+ _tcpClient.Close();
+ _tcpClient = null;
+ }
+ }
+
+ private static MCertificate GetClientCert(IBrokerInfo broker)
+ {
+ // if a client certificate is configured,
+ // use that to enable mutual authentication
+ MCertificate cert = null;
+ if ( broker.SslOptions != null
+ && broker.SslOptions.ClientCertificate != null )
+ {
+ cert = MCertificate.CreateFromX509Certificate(
+ broker.SslOptions.ClientCertificate
+ );
+ _logger.DebugFormat("Using Client Certificate for SSL '{0}'", cert.ToString(true));
+ }
+ return cert;
+ }
+
+ class MyTcpClient : SecureTcpClient
+ {
+ public MyTcpClient(string host, int port, SecurityOptions options)
+ : base(host, port, options)
+ {
+ }
+
+ public EndPoint LocalEndpoint
+ {
+ get { return Client.LocalEndPoint; }
+ }
+
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Client/Client/Util/FlowControlQueue.cs b/qpid/dotnet/Qpid.Client/Client/Util/FlowControlQueue.cs
index 87bb2a2859..a06de9eac8 100644
--- a/qpid/dotnet/Qpid.Client/Client/Util/FlowControlQueue.cs
+++ b/qpid/dotnet/Qpid.Client/Client/Util/FlowControlQueue.cs
@@ -1,98 +1,98 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-using System.Threading;
-using Apache.Qpid.Collections;
-using Apache.Qpid.Common;
-
-namespace Apache.Qpid.Client.Util
-{
- internal delegate void ThresholdMethod(int currentCount);
-
- /// <summary>
- /// Basic bounded queue used to implement prefetching.
- /// Notice we do the callbacks here asynchronously to
- /// avoid adding more complexity to the channel impl.
- /// </summary>
- internal class FlowControlQueue
- {
- private BlockingQueue _queue = new LinkedBlockingQueue();
- private int _itemCount;
- private int _lowerBound;
- private int _upperBound;
- private ThresholdMethod _underThreshold;
- private ThresholdMethod _overThreshold;
-
- public FlowControlQueue(
- int lowerBound,
- int upperBound,
- ThresholdMethod underThreshold,
- ThresholdMethod overThreshold
- )
- {
- _lowerBound = lowerBound;
- _upperBound = upperBound;
- _underThreshold = underThreshold;
- _overThreshold = overThreshold;
- }
-
- public void Enqueue(object item)
- {
- _queue.EnqueueBlocking(item);
- int count = Interlocked.Increment(ref _itemCount);
- if ( _overThreshold != null )
- {
- if ( count == _upperBound )
- {
- _overThreshold.BeginInvoke(
- count, new AsyncCallback(OnAsyncCallEnd),
- _overThreshold
- );
- }
- }
- }
-
- public object Dequeue()
- {
- object item = _queue.DequeueBlocking();
- int count = Interlocked.Decrement(ref _itemCount);
- if ( _underThreshold != null )
- {
- if ( count == _lowerBound )
- {
- _underThreshold.BeginInvoke(
- count, new AsyncCallback(OnAsyncCallEnd),
- _underThreshold
- );
- }
- }
- return item;
- }
-
- private void OnAsyncCallEnd(IAsyncResult res)
- {
- ThresholdMethod method = (ThresholdMethod)res.AsyncState;
- method.EndInvoke(res);
- }
- }
-}
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+using System.Threading;
+using Apache.Qpid.Collections;
+using Apache.Qpid.Common;
+
+namespace Apache.Qpid.Client.Util
+{
+ internal delegate void ThresholdMethod(int currentCount);
+
+ /// <summary>
+ /// Basic bounded queue used to implement prefetching.
+ /// Notice we do the callbacks here asynchronously to
+ /// avoid adding more complexity to the channel impl.
+ /// </summary>
+ internal class FlowControlQueue
+ {
+ private BlockingQueue _queue = new LinkedBlockingQueue();
+ private int _itemCount;
+ private int _lowerBound;
+ private int _upperBound;
+ private ThresholdMethod _underThreshold;
+ private ThresholdMethod _overThreshold;
+
+ public FlowControlQueue(
+ int lowerBound,
+ int upperBound,
+ ThresholdMethod underThreshold,
+ ThresholdMethod overThreshold
+ )
+ {
+ _lowerBound = lowerBound;
+ _upperBound = upperBound;
+ _underThreshold = underThreshold;
+ _overThreshold = overThreshold;
+ }
+
+ public void Enqueue(object item)
+ {
+ _queue.EnqueueBlocking(item);
+ int count = Interlocked.Increment(ref _itemCount);
+ if ( _overThreshold != null )
+ {
+ if ( count == _upperBound )
+ {
+ _overThreshold.BeginInvoke(
+ count, new AsyncCallback(OnAsyncCallEnd),
+ _overThreshold
+ );
+ }
+ }
+ }
+
+ public object Dequeue()
+ {
+ object item = _queue.DequeueBlocking();
+ int count = Interlocked.Decrement(ref _itemCount);
+ if ( _underThreshold != null )
+ {
+ if ( count == _lowerBound )
+ {
+ _underThreshold.BeginInvoke(
+ count, new AsyncCallback(OnAsyncCallEnd),
+ _underThreshold
+ );
+ }
+ }
+ return item;
+ }
+
+ private void OnAsyncCallEnd(IAsyncResult res)
+ {
+ ThresholdMethod method = (ThresholdMethod)res.AsyncState;
+ method.EndInvoke(res);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs b/qpid/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs
index 03ed999999..3e19508bac 100644
--- a/qpid/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs
+++ b/qpid/dotnet/Qpid.Common.Tests/Qpid/Collections/TestConsumerProducerQueue.cs
@@ -1,85 +1,85 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-using System.Threading;
-using NUnit.Framework;
-using Apache.Qpid.Collections;
-
-namespace Apache.Qpid.Collections.Tests
-{
- [TestFixture]
- public class TestConsumerProducerQueue
- {
- private ConsumerProducerQueue _queue;
-
- [SetUp]
- public void SetUp()
- {
- _queue = new ConsumerProducerQueue();
- }
-
- [Test]
- public void CanDequeueWithInifiniteWait()
- {
- Thread producer = new Thread(new ThreadStart(ProduceFive));
- producer.Start();
- for ( int i = 0; i < 5; i++ )
- {
- object item = _queue.Dequeue();
- Assert.IsNotNull(item);
- }
- }
-
- [Test]
- public void ReturnsNullOnDequeueTimeout()
- {
- // queue is empty
- Assert.IsNull(_queue.Dequeue(500));
- }
-
- [Test]
- public void DequeueTillEmpty()
- {
- _queue.Enqueue(1);
- _queue.Enqueue(2);
- _queue.Enqueue(3);
- Assert.AreEqual(1, _queue.Dequeue());
- Assert.AreEqual(2, _queue.Dequeue());
- Assert.AreEqual(3, _queue.Dequeue());
- // no messages in queue, will timeout
- Assert.IsNull(_queue.Dequeue(500));
- }
-
-
- private void ProduceFive()
- {
- Thread.Sleep(1000);
- _queue.Enqueue("test item 1");
- _queue.Enqueue("test item 2");
- _queue.Enqueue("test item 3");
- Thread.Sleep(0);
- _queue.Enqueue("test item 4");
- _queue.Enqueue("test item 5");
- }
- }
-}
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+using System.Threading;
+using NUnit.Framework;
+using Apache.Qpid.Collections;
+
+namespace Apache.Qpid.Collections.Tests
+{
+ [TestFixture]
+ public class TestConsumerProducerQueue
+ {
+ private ConsumerProducerQueue _queue;
+
+ [SetUp]
+ public void SetUp()
+ {
+ _queue = new ConsumerProducerQueue();
+ }
+
+ [Test]
+ public void CanDequeueWithInifiniteWait()
+ {
+ Thread producer = new Thread(new ThreadStart(ProduceFive));
+ producer.Start();
+ for ( int i = 0; i < 5; i++ )
+ {
+ object item = _queue.Dequeue();
+ Assert.IsNotNull(item);
+ }
+ }
+
+ [Test]
+ public void ReturnsNullOnDequeueTimeout()
+ {
+ // queue is empty
+ Assert.IsNull(_queue.Dequeue(500));
+ }
+
+ [Test]
+ public void DequeueTillEmpty()
+ {
+ _queue.Enqueue(1);
+ _queue.Enqueue(2);
+ _queue.Enqueue(3);
+ Assert.AreEqual(1, _queue.Dequeue());
+ Assert.AreEqual(2, _queue.Dequeue());
+ Assert.AreEqual(3, _queue.Dequeue());
+ // no messages in queue, will timeout
+ Assert.IsNull(_queue.Dequeue(500));
+ }
+
+
+ private void ProduceFive()
+ {
+ Thread.Sleep(1000);
+ _queue.Enqueue("test item 1");
+ _queue.Enqueue("test item 2");
+ _queue.Enqueue("test item 3");
+ Thread.Sleep(0);
+ _queue.Enqueue("test item 4");
+ _queue.Enqueue("test item 5");
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs b/qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs
index ab4cb4409c..23cb71c9f8 100644
--- a/qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs
+++ b/qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestAMQType.cs
@@ -1,270 +1,270 @@
-/*
- *
- * 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 Apache.Qpid.Buffer;
-using Apache.Qpid.Framing;
-
-namespace Apache.Qpid.Framing.Tests
-{
- [TestFixture]
- public class TestAMQType
- {
-
- #region LONG_STRING tests
- [Test]
- public void LONG_STRING_ReadWrite()
- {
- AMQType type = AMQType.LONG_STRING;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const string VALUE = "simple string 1";
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // LONG_STRING tests
-
- #region UINT32 tests
- [Test]
- public void UINT32_CanGetEncodingSize()
- {
- AMQType type = AMQType.UINT32;
- Assert.AreEqual(4, type.GetEncodingSize(1234443));
- }
-
- [Test]
- public void UINT32_ToNativeValue()
- {
- AMQType type = AMQType.UINT32;
- Assert.AreEqual(1, type.ToNativeValue(1));
- Assert.AreEqual(1, type.ToNativeValue((short)1));
- Assert.AreEqual(1, type.ToNativeValue((byte)1));
- Assert.AreEqual(1, type.ToNativeValue("1"));
-
- try
- {
- Assert.AreEqual(1, type.ToNativeValue("adasdads"));
- Assert.Fail("Invalid format allowed");
- } catch ( FormatException )
- {
- }
- }
-
- [Test]
- public void UINT32_ReadWrite()
- {
- AMQType type = AMQType.UINT32;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const uint VALUE = 0xFFEEDDCC;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // UINT32 Tests
-
- #region VOID Tests
- [Test]
- public void VOID_CanGetEncodingSize()
- {
- AMQType type = AMQType.VOID;
- Assert.AreEqual(0, type.GetEncodingSize(null));
- }
-
- [Test]
- public void VOID_ToNativeValue()
- {
- AMQType type = AMQType.VOID;
- Assert.IsNull(type.ToNativeValue(null));
-
- try
- {
- type.ToNativeValue("asdasd");
- Assert.Fail("converted invalid value");
- } catch (FormatException)
- {
- }
- }
-
- [Test]
- public void VOID_ReadWrite()
- {
- AMQType type = AMQType.VOID;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
-
- type.WriteToBuffer(null, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(null, value.Value);
- }
-
- #endregion // VOID Tests
-
- #region BOOLEAN Tests
- [Test]
- public void BOOLEAN_CanGetEncodingSize()
- {
- AMQType type = AMQType.BOOLEAN;
- Assert.AreEqual(1, type.GetEncodingSize(true));
- }
-
- [Test]
- public void BOOLEAN_ToNativeValue()
- {
- AMQType type = AMQType.BOOLEAN;
- Assert.AreEqual(true, type.ToNativeValue(true));
- Assert.AreEqual(false, type.ToNativeValue("false"));
-
- try
- {
- type.ToNativeValue("asdasd");
- Assert.Fail("converted invalid value");
- } catch ( FormatException )
- {
- }
- }
-
- [Test]
- public void BOOLEAN_ReadWrite()
- {
- AMQType type = AMQType.BOOLEAN;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
-
- type.WriteToBuffer(true, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(true, value.Value);
- }
- #endregion // BOOLEAN Tests
-
- #region INT16 tests
- [Test]
- public void INT16_ReadWrite()
- {
- AMQType type = AMQType.INT16;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const short VALUE = -32765;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- //public void UINT16_ReadWrite()
- //{
- // AMQType type = AMQType.UINT16;
- // ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- // const ushort VALUE = 64321;
-
- // type.WriteToBuffer(VALUE, buffer);
- // buffer.Flip();
- // buffer.Rewind();
- // AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- // Assert.AreEqual(VALUE, value.Value);
- //}
- #endregion // INT16 Tests
-
- #region INT32 tests
- [Test]
- public void INT32_ReadWrite()
- {
- AMQType type = AMQType.INT32;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const int VALUE = -39273563;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // INT32 Tests
-
- #region INT64 tests
- [Test]
- public void INT64_ReadWrite()
- {
- AMQType type = AMQType.INT64;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const long VALUE = -(2^43+1233123);
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- [Test]
- public void UINT64_ReadWrite()
- {
- AMQType type = AMQType.UINT64;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const ulong VALUE = (2 ^ 61 + 1233123);
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // INT64 Tests
-
- #region FLOAT tests
- [Test]
- public void FLOAT_ReadWrite()
- {
- AMQType type = AMQType.FLOAT;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const float VALUE = 1.2345000E-035f;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // FLOAT Tests
-
- #region DOUBLE tests
- [Test]
- public void DOUBLE_ReadWrite()
- {
- AMQType type = AMQType.DOUBLE;
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- const double VALUE = 1.2345000E-045;
-
- type.WriteToBuffer(VALUE, buffer);
- buffer.Flip();
- buffer.Rewind();
- AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
- Assert.AreEqual(VALUE, value.Value);
- }
- #endregion // FLOAT Tests
- }
-}
+/*
+ *
+ * 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 Apache.Qpid.Buffer;
+using Apache.Qpid.Framing;
+
+namespace Apache.Qpid.Framing.Tests
+{
+ [TestFixture]
+ public class TestAMQType
+ {
+
+ #region LONG_STRING tests
+ [Test]
+ public void LONG_STRING_ReadWrite()
+ {
+ AMQType type = AMQType.LONG_STRING;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ const string VALUE = "simple string 1";
+
+ type.WriteToBuffer(VALUE, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(VALUE, value.Value);
+ }
+ #endregion // LONG_STRING tests
+
+ #region UINT32 tests
+ [Test]
+ public void UINT32_CanGetEncodingSize()
+ {
+ AMQType type = AMQType.UINT32;
+ Assert.AreEqual(4, type.GetEncodingSize(1234443));
+ }
+
+ [Test]
+ public void UINT32_ToNativeValue()
+ {
+ AMQType type = AMQType.UINT32;
+ Assert.AreEqual(1, type.ToNativeValue(1));
+ Assert.AreEqual(1, type.ToNativeValue((short)1));
+ Assert.AreEqual(1, type.ToNativeValue((byte)1));
+ Assert.AreEqual(1, type.ToNativeValue("1"));
+
+ try
+ {
+ Assert.AreEqual(1, type.ToNativeValue("adasdads"));
+ Assert.Fail("Invalid format allowed");
+ } catch ( FormatException )
+ {
+ }
+ }
+
+ [Test]
+ public void UINT32_ReadWrite()
+ {
+ AMQType type = AMQType.UINT32;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ const uint VALUE = 0xFFEEDDCC;
+
+ type.WriteToBuffer(VALUE, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(VALUE, value.Value);
+ }
+ #endregion // UINT32 Tests
+
+ #region VOID Tests
+ [Test]
+ public void VOID_CanGetEncodingSize()
+ {
+ AMQType type = AMQType.VOID;
+ Assert.AreEqual(0, type.GetEncodingSize(null));
+ }
+
+ [Test]
+ public void VOID_ToNativeValue()
+ {
+ AMQType type = AMQType.VOID;
+ Assert.IsNull(type.ToNativeValue(null));
+
+ try
+ {
+ type.ToNativeValue("asdasd");
+ Assert.Fail("converted invalid value");
+ } catch (FormatException)
+ {
+ }
+ }
+
+ [Test]
+ public void VOID_ReadWrite()
+ {
+ AMQType type = AMQType.VOID;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+
+ type.WriteToBuffer(null, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(null, value.Value);
+ }
+
+ #endregion // VOID Tests
+
+ #region BOOLEAN Tests
+ [Test]
+ public void BOOLEAN_CanGetEncodingSize()
+ {
+ AMQType type = AMQType.BOOLEAN;
+ Assert.AreEqual(1, type.GetEncodingSize(true));
+ }
+
+ [Test]
+ public void BOOLEAN_ToNativeValue()
+ {
+ AMQType type = AMQType.BOOLEAN;
+ Assert.AreEqual(true, type.ToNativeValue(true));
+ Assert.AreEqual(false, type.ToNativeValue("false"));
+
+ try
+ {
+ type.ToNativeValue("asdasd");
+ Assert.Fail("converted invalid value");
+ } catch ( FormatException )
+ {
+ }
+ }
+
+ [Test]
+ public void BOOLEAN_ReadWrite()
+ {
+ AMQType type = AMQType.BOOLEAN;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+
+ type.WriteToBuffer(true, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(true, value.Value);
+ }
+ #endregion // BOOLEAN Tests
+
+ #region INT16 tests
+ [Test]
+ public void INT16_ReadWrite()
+ {
+ AMQType type = AMQType.INT16;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ const short VALUE = -32765;
+
+ type.WriteToBuffer(VALUE, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(VALUE, value.Value);
+ }
+ //public void UINT16_ReadWrite()
+ //{
+ // AMQType type = AMQType.UINT16;
+ // ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ // const ushort VALUE = 64321;
+
+ // type.WriteToBuffer(VALUE, buffer);
+ // buffer.Flip();
+ // buffer.Rewind();
+ // AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ // Assert.AreEqual(VALUE, value.Value);
+ //}
+ #endregion // INT16 Tests
+
+ #region INT32 tests
+ [Test]
+ public void INT32_ReadWrite()
+ {
+ AMQType type = AMQType.INT32;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ const int VALUE = -39273563;
+
+ type.WriteToBuffer(VALUE, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(VALUE, value.Value);
+ }
+ #endregion // INT32 Tests
+
+ #region INT64 tests
+ [Test]
+ public void INT64_ReadWrite()
+ {
+ AMQType type = AMQType.INT64;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ const long VALUE = -(2^43+1233123);
+
+ type.WriteToBuffer(VALUE, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(VALUE, value.Value);
+ }
+ [Test]
+ public void UINT64_ReadWrite()
+ {
+ AMQType type = AMQType.UINT64;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ const ulong VALUE = (2 ^ 61 + 1233123);
+
+ type.WriteToBuffer(VALUE, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(VALUE, value.Value);
+ }
+ #endregion // INT64 Tests
+
+ #region FLOAT tests
+ [Test]
+ public void FLOAT_ReadWrite()
+ {
+ AMQType type = AMQType.FLOAT;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ const float VALUE = 1.2345000E-035f;
+
+ type.WriteToBuffer(VALUE, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(VALUE, value.Value);
+ }
+ #endregion // FLOAT Tests
+
+ #region DOUBLE tests
+ [Test]
+ public void DOUBLE_ReadWrite()
+ {
+ AMQType type = AMQType.DOUBLE;
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ const double VALUE = 1.2345000E-045;
+
+ type.WriteToBuffer(VALUE, buffer);
+ buffer.Flip();
+ buffer.Rewind();
+ AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer);
+ Assert.AreEqual(VALUE, value.Value);
+ }
+ #endregion // FLOAT Tests
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs b/qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs
index 720d7697d3..a8202dc70d 100644
--- a/qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs
+++ b/qpid/dotnet/Qpid.Common.Tests/Qpid/Framing/TestEncodingUtils.cs
@@ -1,60 +1,60 @@
-/*
- *
- * 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 Apache.Qpid.Buffer;
-using Apache.Qpid.Framing;
-
-namespace Apache.Qpid.Framing.Tests
-{
- [TestFixture]
- public class TestEncodingUtils
- {
- [Test]
- public void CanReadLongAsShortString()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- EncodingUtils.WriteShortStringBytes(buffer, "98878122");
- buffer.Flip();
- long value = EncodingUtils.ReadLongAsShortString(buffer);
- Assert.AreEqual(98878122, value);
- }
- [Test]
- public void CanReadLongAsShortStringNegative()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- EncodingUtils.WriteShortStringBytes(buffer, "-98878122");
- buffer.Flip();
- long value = EncodingUtils.ReadLongAsShortString(buffer);
- Assert.AreEqual(-98878122, value);
- }
- [Test]
- public void CanReadLongAsShortStringEmpty()
- {
- ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
- EncodingUtils.WriteShortStringBytes(buffer, "");
- buffer.Flip();
- long value = EncodingUtils.ReadLongAsShortString(buffer);
- Assert.AreEqual(0, value);
- }
-
- }
-}
+/*
+ *
+ * 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 Apache.Qpid.Buffer;
+using Apache.Qpid.Framing;
+
+namespace Apache.Qpid.Framing.Tests
+{
+ [TestFixture]
+ public class TestEncodingUtils
+ {
+ [Test]
+ public void CanReadLongAsShortString()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ EncodingUtils.WriteShortStringBytes(buffer, "98878122");
+ buffer.Flip();
+ long value = EncodingUtils.ReadLongAsShortString(buffer);
+ Assert.AreEqual(98878122, value);
+ }
+ [Test]
+ public void CanReadLongAsShortStringNegative()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ EncodingUtils.WriteShortStringBytes(buffer, "-98878122");
+ buffer.Flip();
+ long value = EncodingUtils.ReadLongAsShortString(buffer);
+ Assert.AreEqual(-98878122, value);
+ }
+ [Test]
+ public void CanReadLongAsShortStringEmpty()
+ {
+ ByteBuffer buffer = ByteBuffer.Allocate(0x1000);
+ EncodingUtils.WriteShortStringBytes(buffer, "");
+ buffer.Flip();
+ long value = EncodingUtils.ReadLongAsShortString(buffer);
+ Assert.AreEqual(0, value);
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common/AMQInvalidArgumentException.cs b/qpid/dotnet/Qpid.Common/AMQInvalidArgumentException.cs
index 0fb4ddae99..831f7bab0e 100644
--- a/qpid/dotnet/Qpid.Common/AMQInvalidArgumentException.cs
+++ b/qpid/dotnet/Qpid.Common/AMQInvalidArgumentException.cs
@@ -1,46 +1,46 @@
-/*
- *
- * 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 System.Runtime.Serialization;
-
-using Apache.Qpid.Protocol;
-
-namespace Apache.Qpid
-{
- /// <summary>
- /// Thrown when an invalid argument was supplied to the broker
- /// </summary>
- [Serializable]
- public class AMQInvalidArgumentException : AMQException
- {
- public AMQInvalidArgumentException(string message)
- : base(AMQConstant.INVALID_ARGUMENT.Code, message, null)
- {
- }
-
- protected AMQInvalidArgumentException(SerializationInfo info, StreamingContext ctxt)
- : base(info, ctxt)
- {
- }
-
- }
-}
+/*
+ *
+ * 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 System.Runtime.Serialization;
+
+using Apache.Qpid.Protocol;
+
+namespace Apache.Qpid
+{
+ /// <summary>
+ /// Thrown when an invalid argument was supplied to the broker
+ /// </summary>
+ [Serializable]
+ public class AMQInvalidArgumentException : AMQException
+ {
+ public AMQInvalidArgumentException(string message)
+ : base(AMQConstant.INVALID_ARGUMENT.Code, message, null)
+ {
+ }
+
+ protected AMQInvalidArgumentException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common/AMQInvalidRoutingKeyException.cs b/qpid/dotnet/Qpid.Common/AMQInvalidRoutingKeyException.cs
index 3f8dead94d..a3ce813d1b 100644
--- a/qpid/dotnet/Qpid.Common/AMQInvalidRoutingKeyException.cs
+++ b/qpid/dotnet/Qpid.Common/AMQInvalidRoutingKeyException.cs
@@ -1,46 +1,46 @@
-/*
- *
- * 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 System.Runtime.Serialization;
-
-using Apache.Qpid.Protocol;
-
-namespace Apache.Qpid
-{
- /// <summary>
- /// Thrown when an invalid routing key was sent to the broker
- /// </summary>
- [Serializable]
- public class AMQInvalidRoutingKeyException : AMQException
- {
- public AMQInvalidRoutingKeyException(string message)
- : base(AMQConstant.INVALID_ROUTING_KEY.Code, message, null)
- {
- }
-
- protected AMQInvalidRoutingKeyException(SerializationInfo info, StreamingContext ctxt)
- : base(info, ctxt)
- {
- }
-
- }
-}
+/*
+ *
+ * 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 System.Runtime.Serialization;
+
+using Apache.Qpid.Protocol;
+
+namespace Apache.Qpid
+{
+ /// <summary>
+ /// Thrown when an invalid routing key was sent to the broker
+ /// </summary>
+ [Serializable]
+ public class AMQInvalidRoutingKeyException : AMQException
+ {
+ public AMQInvalidRoutingKeyException(string message)
+ : base(AMQConstant.INVALID_ROUTING_KEY.Code, message, null)
+ {
+ }
+
+ protected AMQInvalidRoutingKeyException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common/Collections/ConsumerProducerQueue.cs b/qpid/dotnet/Qpid.Common/Collections/ConsumerProducerQueue.cs
index ea4526faaf..131f316da6 100644
--- a/qpid/dotnet/Qpid.Common/Collections/ConsumerProducerQueue.cs
+++ b/qpid/dotnet/Qpid.Common/Collections/ConsumerProducerQueue.cs
@@ -1,113 +1,113 @@
-/*
- *
- * 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 System.Collections;
-using System.Threading;
-
-
-namespace Apache.Qpid.Collections
-{
- /// <summary>
- /// Simple FIFO queue to support multi-threaded consumer
- /// and producers. It supports timeouts in dequeue operations.
- /// </summary>
- public sealed class ConsumerProducerQueue
- {
- private Queue _queue = new Queue();
- private WaitSemaphore _semaphore = new WaitSemaphore();
-
- /// <summary>
- /// Put an item into the tail of the queue
- /// </summary>
- /// <param name="item"></param>
- public void Enqueue(object item)
- {
- lock ( _queue.SyncRoot )
- {
- _queue.Enqueue(item);
- _semaphore.Increment();
- }
- }
-
- /// <summary>
- /// Wait indefinitely for an item to be available
- /// on the queue.
- /// </summary>
- /// <returns>The object at the head of the queue</returns>
- public object Dequeue()
- {
- return Dequeue(Timeout.Infinite);
- }
-
- /// <summary>
- /// Wait up to the number of milliseconds specified
- /// for an item to be available on the queue
- /// </summary>
- /// <param name="timeout">Number of milliseconds to wait</param>
- /// <returns>The object at the head of the queue, or null
- /// if the timeout expires</returns>
- public object Dequeue(long timeout)
- {
- if ( _semaphore.Decrement(timeout) )
- {
- lock ( _queue.SyncRoot )
- {
- return _queue.Dequeue();
- }
- }
- return null;
- }
-
- #region Simple Semaphore
- //
- // Simple Semaphore
- //
-
- class WaitSemaphore
- {
- private int _count;
- private AutoResetEvent _event = new AutoResetEvent(false);
-
- public void Increment()
- {
- Interlocked.Increment(ref _count);
- _event.Set();
- }
-
- public bool Decrement(long timeout)
- {
- if ( timeout > int.MaxValue )
- throw new ArgumentOutOfRangeException("timeout", timeout, "Must be <= Int32.MaxValue");
-
- int millis = (int) (timeout & 0x7FFFFFFF);
- if ( Interlocked.Decrement(ref _count) > 0 )
- {
- // there are messages in queue, so no need to wait
- return true;
- } else
- {
- return _event.WaitOne(millis, false);
- }
- }
- }
- #endregion // Simple Semaphore
- }
-}
+/*
+ *
+ * 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 System.Collections;
+using System.Threading;
+
+
+namespace Apache.Qpid.Collections
+{
+ /// <summary>
+ /// Simple FIFO queue to support multi-threaded consumer
+ /// and producers. It supports timeouts in dequeue operations.
+ /// </summary>
+ public sealed class ConsumerProducerQueue
+ {
+ private Queue _queue = new Queue();
+ private WaitSemaphore _semaphore = new WaitSemaphore();
+
+ /// <summary>
+ /// Put an item into the tail of the queue
+ /// </summary>
+ /// <param name="item"></param>
+ public void Enqueue(object item)
+ {
+ lock ( _queue.SyncRoot )
+ {
+ _queue.Enqueue(item);
+ _semaphore.Increment();
+ }
+ }
+
+ /// <summary>
+ /// Wait indefinitely for an item to be available
+ /// on the queue.
+ /// </summary>
+ /// <returns>The object at the head of the queue</returns>
+ public object Dequeue()
+ {
+ return Dequeue(Timeout.Infinite);
+ }
+
+ /// <summary>
+ /// Wait up to the number of milliseconds specified
+ /// for an item to be available on the queue
+ /// </summary>
+ /// <param name="timeout">Number of milliseconds to wait</param>
+ /// <returns>The object at the head of the queue, or null
+ /// if the timeout expires</returns>
+ public object Dequeue(long timeout)
+ {
+ if ( _semaphore.Decrement(timeout) )
+ {
+ lock ( _queue.SyncRoot )
+ {
+ return _queue.Dequeue();
+ }
+ }
+ return null;
+ }
+
+ #region Simple Semaphore
+ //
+ // Simple Semaphore
+ //
+
+ class WaitSemaphore
+ {
+ private int _count;
+ private AutoResetEvent _event = new AutoResetEvent(false);
+
+ public void Increment()
+ {
+ Interlocked.Increment(ref _count);
+ _event.Set();
+ }
+
+ public bool Decrement(long timeout)
+ {
+ if ( timeout > int.MaxValue )
+ throw new ArgumentOutOfRangeException("timeout", timeout, "Must be <= Int32.MaxValue");
+
+ int millis = (int) (timeout & 0x7FFFFFFF);
+ if ( Interlocked.Decrement(ref _count) > 0 )
+ {
+ // there are messages in queue, so no need to wait
+ return true;
+ } else
+ {
+ return _event.WaitOne(millis, false);
+ }
+ }
+ }
+ #endregion // Simple Semaphore
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQType.cs b/qpid/dotnet/Qpid.Common/Framing/AMQType.cs
index 618ab31d32..95da72b907 100644
--- a/qpid/dotnet/Qpid.Common/Framing/AMQType.cs
+++ b/qpid/dotnet/Qpid.Common/Framing/AMQType.cs
@@ -1,700 +1,700 @@
-/*
- *
- * 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 System.Text;
-using Apache.Qpid.Buffer;
-
-namespace Apache.Qpid.Framing
-{
- /// <summary>
- /// Base class for the Field Table Type system.
- /// Ported over from the Java AMQType enumeration
- /// </summary>
- public abstract class AMQType
- {
- private byte _identifier;
-
- /// <summary>
- /// Type code identifier for this type
- /// </summary>
- public byte Identifier
- {
- get { return _identifier; }
- }
-
- protected AMQType(char identifier)
- {
- _identifier = (byte)identifier;
- }
-
- /// <summary>
- /// Create a new <see cref="AMQTypedValue"/> instance
- /// </summary>
- /// <param name="value">Value to initialize with</param>
- /// <returns>A new typed value instance</returns>
- public AMQTypedValue AsTypedValue(object value)
- {
- return new AMQTypedValue(this, ToNativeValue(value));
- }
-
- /// <summary>
- /// Write the specified value to the buffer using the encoding
- /// specified for this type
- /// </summary>
- /// <param name="value">Value to write</param>
- /// <param name="buffer">Buffer to write to</param>
- public void WriteToBuffer(object value, ByteBuffer buffer)
- {
- buffer.Put(Identifier);
- WriteValueImpl(value, buffer);
- }
-
- public override string ToString()
- {
- return ((Char) Identifier).ToString();
- }
-
- /// <summary>
- /// Get the encoding size for the specified value in this type format
- /// </summary>
- /// <param name="value">Value to find encoded size for</param>
- /// <returns>The encoded size</returns>
- public abstract uint GetEncodingSize(object value);
- /// <summary>
- /// Convert the specified value to this type
- /// </summary>
- /// <param name="value">Value to convert</param>
- /// <returns>The converted value</returns>
- public abstract object ToNativeValue(object value);
-
- /// <summary>
- /// Read a value from the specified buffer using the encoding for
- /// this type
- /// </summary>
- /// <param name="buffer">Buffer to read from</param>
- /// <returns>The value read</returns>
- public abstract object ReadValueFromBuffer(ByteBuffer buffer);
-
- protected abstract void WriteValueImpl(Object value, ByteBuffer buffer);
-
-
- #region Known Types
- //
- // Known Types
- //
-
- // long string is not defined in the proposed specification,
- // and the 'S' discriminator is left for unsigned short (16-bit) values
- public static readonly AMQType LONG_STRING = new AMQLongStringType();
- public static readonly AMQType UINT32 = new AMQUInt32Type();
- public static readonly AMQType DECIMAL = new AMQDecimalType();
- public static readonly AMQType TIMESTAMP = new AMQTimeStampType();
- public static readonly AMQType FIELD_TABLE = new AMQFieldTableType();
- public static readonly AMQType VOID = new AMQVoidType();
- public static readonly AMQType BINARY = new AMQBinaryType();
- public static readonly AMQType ASCII_STRING = new AMQAsciiStringType();
- public static readonly AMQType WIDE_STRING = new AMQWideStringType();
- public static readonly AMQType BOOLEAN = new AMQBooleanType();
- public static readonly AMQType ASCII_CHARACTER = new AMQAsciiCharType();
- public static readonly AMQType BYTE = new AMQByteType();
- public static readonly AMQType SBYTE = new AMQSByteType();
- public static readonly AMQType INT16 = new AMQInt16Type();
- public static readonly AMQType UINT16 = new AMQUInt16Type();
- public static readonly AMQType INT32 = new AMQInt32Type();
- public static readonly AMQType INT64 = new AMQInt64Type();
- public static readonly AMQType UINT64 = new AMQUInt64Type();
- public static readonly AMQType FLOAT = new AMQFloatType();
- public static readonly AMQType DOUBLE = new AMQDoubleType();
-
- #endregion // Known Types
-
- #region Type Implementation
- //
- // Type Implementation
- //
-
- sealed class AMQLongStringType : AMQType
- {
- public AMQLongStringType() : base('S')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedLongStringLength((string) value);
- }
-
- public override object ToNativeValue(object value)
- {
- if ( value == null )
- throw new ArgumentNullException("value");
- return value.ToString();
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadLongString(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteLongStringBytes(buffer, (string) value);
- }
-
- }
-
- sealed class AMQUInt32Type : AMQType
- {
- public AMQUInt32Type() : base('i')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.UnsignedIntegerLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToUInt32(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadUnsignedInteger(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteUnsignedInteger(buffer, (uint) value);
- }
-
- }
-
- sealed class AMQDecimalType : AMQType
- {
- public AMQDecimalType() : base('D')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- throw new NotImplementedException();
- }
-
- public override object ToNativeValue(object value)
- {
- throw new NotImplementedException();
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- throw new NotImplementedException();
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- throw new NotImplementedException();
- }
- }
-
- sealed class AMQTimeStampType : AMQType
- {
- public AMQTimeStampType() : base('T')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- throw new NotImplementedException();
- }
-
- public override object ToNativeValue(object value)
- {
- throw new NotImplementedException();
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- throw new NotImplementedException();
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- throw new NotImplementedException();
- }
- }
-
- sealed class AMQFieldTableType : AMQType
- {
- public AMQFieldTableType() : base('F')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- throw new NotImplementedException();
- }
-
- public override object ToNativeValue(object value)
- {
- throw new NotImplementedException();
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- throw new NotImplementedException();
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- throw new NotImplementedException();
- }
- }
-
- sealed class AMQVoidType : AMQType
- {
- public AMQVoidType() : base('V')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return 0;
- }
-
- public override object ToNativeValue(object value)
- {
- if ( value != null )
- throw new FormatException(string.Format("Cannot convert {0} to VOID type", value));
- return null;
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return null;
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- }
- }
-
- // Extended Types
-
- sealed class AMQBinaryType : AMQType
- {
- public AMQBinaryType() : base('x')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedLongstrLength((byte[]) value);
- }
-
- public override object ToNativeValue(object value)
- {
- if ( value is byte[] || value == null )
- {
- return value;
- }
- throw new ArgumentException("Value cannot be converted to byte[]");
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadLongstr(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteLongstr(buffer, (byte[])value);
- }
- }
-
- sealed class AMQAsciiStringType : AMQType
- {
- public AMQAsciiStringType() : base('c')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedAsciiStringLength((string)value);
- }
-
- public override object ToNativeValue(object value)
- {
- if ( value == null )
- throw new ArgumentNullException("value");
- return value.ToString();
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadAsciiString(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteAsciiString(buffer, (string)value);
- }
- }
-
- sealed class AMQWideStringType : AMQType
- {
- // todo: Change encoding to UTF16 (java code still uses default
- // ascii encoding for wide strings
- private static readonly Encoding ENCODING = Encoding.ASCII;
-
- public AMQWideStringType()
- : base('C')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedLongStringLength((string)value, ENCODING);
- }
-
- public override object ToNativeValue(object value)
- {
- if ( value == null )
- throw new ArgumentNullException("value");
- return value.ToString();
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadLongString(buffer, ENCODING);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteLongStringBytes(buffer, (string)value, ENCODING);
- }
- }
-
- sealed class AMQBooleanType : AMQType
- {
- public AMQBooleanType() : base('t')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedBooleanLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToBoolean(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadBoolean(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteBoolean(buffer, (bool)value);
- }
- }
-
- sealed class AMQAsciiCharType : AMQType
- {
- public AMQAsciiCharType() : base('k')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedCharLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToChar(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadChar(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteChar(buffer, (char)value);
- }
- }
-
- sealed class AMQByteType : AMQType
- {
- public AMQByteType() : base('B')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedByteLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToByte(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadByte(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteByte(buffer, (byte)value);
- }
- }
-
- sealed class AMQSByteType : AMQType
- {
- public AMQSByteType()
- : base('b')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedSByteLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToSByte(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadSByte(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteSByte(buffer, (sbyte)value);
- }
- }
-
- sealed class AMQInt16Type : AMQType
- {
- public AMQInt16Type() : base('s')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedShortLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToInt16(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadShort(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteShort(buffer, (short)value);
- }
- }
-
- sealed class AMQUInt16Type : AMQType
- {
- public AMQUInt16Type()
- : base('S')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedUnsignedShortLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToUInt16(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadUnsignedShort(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteUnsignedShort(buffer, (ushort)value);
- }
- }
-
- sealed class AMQInt32Type : AMQType
- {
- public AMQInt32Type() : base('I')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedIntegerLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToInt32(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadInteger(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteInteger(buffer, (int)value);
- }
- }
-
- sealed class AMQInt64Type : AMQType
- {
- public AMQInt64Type() : base('l')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedLongLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToInt64(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadLong(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteLong(buffer, (long)value);
- }
- }
-
- sealed class AMQUInt64Type : AMQType
- {
- public AMQUInt64Type()
- : base('L')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedUnsignedLongLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToUInt64(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadUnsignedLong(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteUnsignedLong(buffer, (ulong)value);
- }
- }
-
- sealed class AMQFloatType : AMQType
- {
- public AMQFloatType() : base('f')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedFloatLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToSingle(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadFloat(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteFloat(buffer, (float)value);
- }
- }
-
- sealed class AMQDoubleType : AMQType
- {
- public AMQDoubleType() : base('d')
- {
- }
-
- public override uint GetEncodingSize(object value)
- {
- return EncodingUtils.EncodedDoubleLength();
- }
-
- public override object ToNativeValue(object value)
- {
- return Convert.ToDouble(value);
- }
-
- public override object ReadValueFromBuffer(ByteBuffer buffer)
- {
- return EncodingUtils.ReadDouble(buffer);
- }
-
- protected override void WriteValueImpl(object value, ByteBuffer buffer)
- {
- EncodingUtils.WriteDouble(buffer, (double)value);
- }
- }
-
- #endregion // Type Implementation
-
- } // class AMQType
-}
+/*
+ *
+ * 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 System.Text;
+using Apache.Qpid.Buffer;
+
+namespace Apache.Qpid.Framing
+{
+ /// <summary>
+ /// Base class for the Field Table Type system.
+ /// Ported over from the Java AMQType enumeration
+ /// </summary>
+ public abstract class AMQType
+ {
+ private byte _identifier;
+
+ /// <summary>
+ /// Type code identifier for this type
+ /// </summary>
+ public byte Identifier
+ {
+ get { return _identifier; }
+ }
+
+ protected AMQType(char identifier)
+ {
+ _identifier = (byte)identifier;
+ }
+
+ /// <summary>
+ /// Create a new <see cref="AMQTypedValue"/> instance
+ /// </summary>
+ /// <param name="value">Value to initialize with</param>
+ /// <returns>A new typed value instance</returns>
+ public AMQTypedValue AsTypedValue(object value)
+ {
+ return new AMQTypedValue(this, ToNativeValue(value));
+ }
+
+ /// <summary>
+ /// Write the specified value to the buffer using the encoding
+ /// specified for this type
+ /// </summary>
+ /// <param name="value">Value to write</param>
+ /// <param name="buffer">Buffer to write to</param>
+ public void WriteToBuffer(object value, ByteBuffer buffer)
+ {
+ buffer.Put(Identifier);
+ WriteValueImpl(value, buffer);
+ }
+
+ public override string ToString()
+ {
+ return ((Char) Identifier).ToString();
+ }
+
+ /// <summary>
+ /// Get the encoding size for the specified value in this type format
+ /// </summary>
+ /// <param name="value">Value to find encoded size for</param>
+ /// <returns>The encoded size</returns>
+ public abstract uint GetEncodingSize(object value);
+ /// <summary>
+ /// Convert the specified value to this type
+ /// </summary>
+ /// <param name="value">Value to convert</param>
+ /// <returns>The converted value</returns>
+ public abstract object ToNativeValue(object value);
+
+ /// <summary>
+ /// Read a value from the specified buffer using the encoding for
+ /// this type
+ /// </summary>
+ /// <param name="buffer">Buffer to read from</param>
+ /// <returns>The value read</returns>
+ public abstract object ReadValueFromBuffer(ByteBuffer buffer);
+
+ protected abstract void WriteValueImpl(Object value, ByteBuffer buffer);
+
+
+ #region Known Types
+ //
+ // Known Types
+ //
+
+ // long string is not defined in the proposed specification,
+ // and the 'S' discriminator is left for unsigned short (16-bit) values
+ public static readonly AMQType LONG_STRING = new AMQLongStringType();
+ public static readonly AMQType UINT32 = new AMQUInt32Type();
+ public static readonly AMQType DECIMAL = new AMQDecimalType();
+ public static readonly AMQType TIMESTAMP = new AMQTimeStampType();
+ public static readonly AMQType FIELD_TABLE = new AMQFieldTableType();
+ public static readonly AMQType VOID = new AMQVoidType();
+ public static readonly AMQType BINARY = new AMQBinaryType();
+ public static readonly AMQType ASCII_STRING = new AMQAsciiStringType();
+ public static readonly AMQType WIDE_STRING = new AMQWideStringType();
+ public static readonly AMQType BOOLEAN = new AMQBooleanType();
+ public static readonly AMQType ASCII_CHARACTER = new AMQAsciiCharType();
+ public static readonly AMQType BYTE = new AMQByteType();
+ public static readonly AMQType SBYTE = new AMQSByteType();
+ public static readonly AMQType INT16 = new AMQInt16Type();
+ public static readonly AMQType UINT16 = new AMQUInt16Type();
+ public static readonly AMQType INT32 = new AMQInt32Type();
+ public static readonly AMQType INT64 = new AMQInt64Type();
+ public static readonly AMQType UINT64 = new AMQUInt64Type();
+ public static readonly AMQType FLOAT = new AMQFloatType();
+ public static readonly AMQType DOUBLE = new AMQDoubleType();
+
+ #endregion // Known Types
+
+ #region Type Implementation
+ //
+ // Type Implementation
+ //
+
+ sealed class AMQLongStringType : AMQType
+ {
+ public AMQLongStringType() : base('S')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedLongStringLength((string) value);
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ if ( value == null )
+ throw new ArgumentNullException("value");
+ return value.ToString();
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadLongString(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteLongStringBytes(buffer, (string) value);
+ }
+
+ }
+
+ sealed class AMQUInt32Type : AMQType
+ {
+ public AMQUInt32Type() : base('i')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.UnsignedIntegerLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToUInt32(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadUnsignedInteger(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteUnsignedInteger(buffer, (uint) value);
+ }
+
+ }
+
+ sealed class AMQDecimalType : AMQType
+ {
+ public AMQDecimalType() : base('D')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ sealed class AMQTimeStampType : AMQType
+ {
+ public AMQTimeStampType() : base('T')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ sealed class AMQFieldTableType : AMQType
+ {
+ public AMQFieldTableType() : base('F')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ sealed class AMQVoidType : AMQType
+ {
+ public AMQVoidType() : base('V')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return 0;
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ if ( value != null )
+ throw new FormatException(string.Format("Cannot convert {0} to VOID type", value));
+ return null;
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return null;
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ }
+ }
+
+ // Extended Types
+
+ sealed class AMQBinaryType : AMQType
+ {
+ public AMQBinaryType() : base('x')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedLongstrLength((byte[]) value);
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ if ( value is byte[] || value == null )
+ {
+ return value;
+ }
+ throw new ArgumentException("Value cannot be converted to byte[]");
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadLongstr(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteLongstr(buffer, (byte[])value);
+ }
+ }
+
+ sealed class AMQAsciiStringType : AMQType
+ {
+ public AMQAsciiStringType() : base('c')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedAsciiStringLength((string)value);
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ if ( value == null )
+ throw new ArgumentNullException("value");
+ return value.ToString();
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadAsciiString(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteAsciiString(buffer, (string)value);
+ }
+ }
+
+ sealed class AMQWideStringType : AMQType
+ {
+ // todo: Change encoding to UTF16 (java code still uses default
+ // ascii encoding for wide strings
+ private static readonly Encoding ENCODING = Encoding.ASCII;
+
+ public AMQWideStringType()
+ : base('C')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedLongStringLength((string)value, ENCODING);
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ if ( value == null )
+ throw new ArgumentNullException("value");
+ return value.ToString();
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadLongString(buffer, ENCODING);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteLongStringBytes(buffer, (string)value, ENCODING);
+ }
+ }
+
+ sealed class AMQBooleanType : AMQType
+ {
+ public AMQBooleanType() : base('t')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedBooleanLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToBoolean(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadBoolean(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteBoolean(buffer, (bool)value);
+ }
+ }
+
+ sealed class AMQAsciiCharType : AMQType
+ {
+ public AMQAsciiCharType() : base('k')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedCharLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToChar(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadChar(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteChar(buffer, (char)value);
+ }
+ }
+
+ sealed class AMQByteType : AMQType
+ {
+ public AMQByteType() : base('B')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedByteLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToByte(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadByte(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteByte(buffer, (byte)value);
+ }
+ }
+
+ sealed class AMQSByteType : AMQType
+ {
+ public AMQSByteType()
+ : base('b')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedSByteLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToSByte(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadSByte(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteSByte(buffer, (sbyte)value);
+ }
+ }
+
+ sealed class AMQInt16Type : AMQType
+ {
+ public AMQInt16Type() : base('s')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedShortLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToInt16(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadShort(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteShort(buffer, (short)value);
+ }
+ }
+
+ sealed class AMQUInt16Type : AMQType
+ {
+ public AMQUInt16Type()
+ : base('S')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedUnsignedShortLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToUInt16(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadUnsignedShort(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteUnsignedShort(buffer, (ushort)value);
+ }
+ }
+
+ sealed class AMQInt32Type : AMQType
+ {
+ public AMQInt32Type() : base('I')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedIntegerLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToInt32(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadInteger(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteInteger(buffer, (int)value);
+ }
+ }
+
+ sealed class AMQInt64Type : AMQType
+ {
+ public AMQInt64Type() : base('l')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedLongLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToInt64(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadLong(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteLong(buffer, (long)value);
+ }
+ }
+
+ sealed class AMQUInt64Type : AMQType
+ {
+ public AMQUInt64Type()
+ : base('L')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedUnsignedLongLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToUInt64(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadUnsignedLong(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteUnsignedLong(buffer, (ulong)value);
+ }
+ }
+
+ sealed class AMQFloatType : AMQType
+ {
+ public AMQFloatType() : base('f')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedFloatLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToSingle(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadFloat(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteFloat(buffer, (float)value);
+ }
+ }
+
+ sealed class AMQDoubleType : AMQType
+ {
+ public AMQDoubleType() : base('d')
+ {
+ }
+
+ public override uint GetEncodingSize(object value)
+ {
+ return EncodingUtils.EncodedDoubleLength();
+ }
+
+ public override object ToNativeValue(object value)
+ {
+ return Convert.ToDouble(value);
+ }
+
+ public override object ReadValueFromBuffer(ByteBuffer buffer)
+ {
+ return EncodingUtils.ReadDouble(buffer);
+ }
+
+ protected override void WriteValueImpl(object value, ByteBuffer buffer)
+ {
+ EncodingUtils.WriteDouble(buffer, (double)value);
+ }
+ }
+
+ #endregion // Type Implementation
+
+ } // class AMQType
+}
diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQTypeMap.cs b/qpid/dotnet/Qpid.Common/Framing/AMQTypeMap.cs
index ed38c203a9..8497c283f9 100644
--- a/qpid/dotnet/Qpid.Common/Framing/AMQTypeMap.cs
+++ b/qpid/dotnet/Qpid.Common/Framing/AMQTypeMap.cs
@@ -1,75 +1,75 @@
-/*
- *
- * 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 System.Collections;
-
-namespace Apache.Qpid.Framing
-{
- public sealed class AMQTypeMap
- {
- private static Hashtable _reverseTypeMap;
-
- private AMQTypeMap()
- {
- }
-
- static AMQTypeMap()
- {
- _reverseTypeMap = Hashtable.Synchronized(new Hashtable());
-
- Add(AMQType.LONG_STRING);
- Add(AMQType.BOOLEAN);
- Add(AMQType.BYTE);
- Add(AMQType.SBYTE);
- Add(AMQType.INT16);
- // not supported for now as type code conflicts
- // with LONG_STRING
- //Add(AMQType.UINT16);
- Add(AMQType.INT32);
- Add(AMQType.UINT32);
- Add(AMQType.INT64);
- Add(AMQType.UINT64);
- Add(AMQType.FLOAT);
- Add(AMQType.DOUBLE);
- Add(AMQType.DECIMAL);
- Add(AMQType.BINARY);
- Add(AMQType.ASCII_STRING);
- Add(AMQType.WIDE_STRING);
- Add(AMQType.ASCII_CHARACTER);
- Add(AMQType.TIMESTAMP);
- Add(AMQType.FIELD_TABLE);
- Add(AMQType.VOID);
- }
-
- public static AMQType GetType(byte identifier)
- {
- AMQType type = (AMQType)_reverseTypeMap[identifier];
- if ( type == null )
- throw new ArgumentOutOfRangeException(string.Format("No such type code: {0:x}", identifier));
- return type;
- }
-
- private static void Add(AMQType type)
- {
- _reverseTypeMap.Add(type.Identifier, type);
- }
- }
-}
+/*
+ *
+ * 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 System.Collections;
+
+namespace Apache.Qpid.Framing
+{
+ public sealed class AMQTypeMap
+ {
+ private static Hashtable _reverseTypeMap;
+
+ private AMQTypeMap()
+ {
+ }
+
+ static AMQTypeMap()
+ {
+ _reverseTypeMap = Hashtable.Synchronized(new Hashtable());
+
+ Add(AMQType.LONG_STRING);
+ Add(AMQType.BOOLEAN);
+ Add(AMQType.BYTE);
+ Add(AMQType.SBYTE);
+ Add(AMQType.INT16);
+ // not supported for now as type code conflicts
+ // with LONG_STRING
+ //Add(AMQType.UINT16);
+ Add(AMQType.INT32);
+ Add(AMQType.UINT32);
+ Add(AMQType.INT64);
+ Add(AMQType.UINT64);
+ Add(AMQType.FLOAT);
+ Add(AMQType.DOUBLE);
+ Add(AMQType.DECIMAL);
+ Add(AMQType.BINARY);
+ Add(AMQType.ASCII_STRING);
+ Add(AMQType.WIDE_STRING);
+ Add(AMQType.ASCII_CHARACTER);
+ Add(AMQType.TIMESTAMP);
+ Add(AMQType.FIELD_TABLE);
+ Add(AMQType.VOID);
+ }
+
+ public static AMQType GetType(byte identifier)
+ {
+ AMQType type = (AMQType)_reverseTypeMap[identifier];
+ if ( type == null )
+ throw new ArgumentOutOfRangeException(string.Format("No such type code: {0:x}", identifier));
+ return type;
+ }
+
+ private static void Add(AMQType type)
+ {
+ _reverseTypeMap.Add(type.Identifier, type);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs b/qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs
index 8d21a60831..3d2e313fa6 100644
--- a/qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs
+++ b/qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs
@@ -1,76 +1,76 @@
-/*
- *
- * 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 Apache.Qpid.Buffer;
-
-namespace Apache.Qpid.Framing
-{
- public class AMQTypedValue
- {
- private readonly AMQType _type;
- private readonly object _value;
-
- public AMQType Type
- {
- get { return _type; }
- }
-
- public object Value
- {
- get { return _value; }
- }
-
- public uint EncodingLength
- {
- get { return _type.GetEncodingSize(_value); }
- }
-
- public AMQTypedValue(AMQType type, object value)
- {
- if ( type == null )
- throw new ArgumentNullException("type");
- _type = type;
- _value = type.ToNativeValue(value);
- }
-
- public AMQTypedValue(AMQType type, ByteBuffer buffer)
- {
- _type = type;
- _value = type.ReadValueFromBuffer(buffer);
- }
-
- public void WriteToBuffer(ByteBuffer buffer)
- {
- _type.WriteToBuffer(_value, buffer);
- }
-
- public static AMQTypedValue ReadFromBuffer(ByteBuffer buffer)
- {
- AMQType type = AMQTypeMap.GetType(buffer.GetByte());
- return new AMQTypedValue(type, buffer);
- }
-
- public override string ToString()
- {
- return string.Format("{0}: {1}", Type, Value);
- }
- }
-}
+/*
+ *
+ * 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 Apache.Qpid.Buffer;
+
+namespace Apache.Qpid.Framing
+{
+ public class AMQTypedValue
+ {
+ private readonly AMQType _type;
+ private readonly object _value;
+
+ public AMQType Type
+ {
+ get { return _type; }
+ }
+
+ public object Value
+ {
+ get { return _value; }
+ }
+
+ public uint EncodingLength
+ {
+ get { return _type.GetEncodingSize(_value); }
+ }
+
+ public AMQTypedValue(AMQType type, object value)
+ {
+ if ( type == null )
+ throw new ArgumentNullException("type");
+ _type = type;
+ _value = type.ToNativeValue(value);
+ }
+
+ public AMQTypedValue(AMQType type, ByteBuffer buffer)
+ {
+ _type = type;
+ _value = type.ReadValueFromBuffer(buffer);
+ }
+
+ public void WriteToBuffer(ByteBuffer buffer)
+ {
+ _type.WriteToBuffer(_value, buffer);
+ }
+
+ public static AMQTypedValue ReadFromBuffer(ByteBuffer buffer)
+ {
+ AMQType type = AMQTypeMap.GetType(buffer.GetByte());
+ return new AMQTypedValue(type, buffer);
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{0}: {1}", Type, Value);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Common/Protocol/AMQConstant.cs b/qpid/dotnet/Qpid.Common/Protocol/AMQConstant.cs
index fcf94c29f4..9400b1bd80 100644
--- a/qpid/dotnet/Qpid.Common/Protocol/AMQConstant.cs
+++ b/qpid/dotnet/Qpid.Common/Protocol/AMQConstant.cs
@@ -1,100 +1,100 @@
-/*
- *
- * 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 System.Collections;
-
-namespace Apache.Qpid.Protocol
-{
- public sealed class AMQConstant
- {
- private int _code;
- private string _name;
- private static Hashtable _codeMap = new Hashtable();
-
- public int Code
- {
- get { return _code; }
- }
-
- public string Name
- {
- get { return _name; }
- }
-
- private AMQConstant(int code, string name, bool map)
- {
- _code = code;
- _name = name;
-
- if ( map )
- {
- _codeMap.Add(code, this);
- }
- }
-
- public override string ToString()
- {
- return string.Format("{0}: {1}", Code, Name);
- }
-
- public static AMQConstant GetConstant(int code)
- {
- AMQConstant c = (AMQConstant)_codeMap[code];
- if ( c == null )
- {
- c = new AMQConstant(code, "unknown code", false);
- }
- return c;
- }
-
- #region Constants
- //
- // Constants
- //
- public static readonly AMQConstant FRAME_MIN_SIZE = new AMQConstant(4096, "frame min size", true);
- public static readonly AMQConstant FRAME_END = new AMQConstant(206, "frame end", true);
- public static readonly AMQConstant REPLY_SUCCESS = new AMQConstant(200, "reply success", true);
- public static readonly AMQConstant NOT_DELIVERED = new AMQConstant(310, "not delivered", true);
- public static readonly AMQConstant MESSAGE_TOO_LARGE = new AMQConstant(311, "message too large", true);
- public static readonly AMQConstant NO_ROUTE = new AMQConstant(312, "no route", true);
- public static readonly AMQConstant NO_CONSUMERS = new AMQConstant(313, "no consumers", true);
- public static readonly AMQConstant CONTEXT_IN_USE = new AMQConstant(320, "context in use", true);
- public static readonly AMQConstant INVALID_PATH = new AMQConstant(402, "invalid path", true);
- public static readonly AMQConstant ACCESS_REFUSED = new AMQConstant(403, "access refused", true);
- public static readonly AMQConstant NOT_FOUND = new AMQConstant(404, "not found", true);
- public static readonly AMQConstant ALREADY_EXISTS = new AMQConstant(405, "already exists", true);
- public static readonly AMQConstant IN_USE = new AMQConstant(406, "in use", true);
- public static readonly AMQConstant INVALID_ROUTING_KEY = new AMQConstant(407, "routing key invalid", true);
- public static readonly AMQConstant REQUEST_TIMEOUT = new AMQConstant(408, "request timeout", true);
- public static readonly AMQConstant INVALID_ARGUMENT = new AMQConstant(409, "argument invalid", true);
- public static readonly AMQConstant FRAME_ERROR = new AMQConstant(501, "frame error", true);
- public static readonly AMQConstant SYNTAX_ERROR = new AMQConstant(502, "syntax error", true);
- public static readonly AMQConstant COMMAND_INVALID = new AMQConstant(503, "command invalid", true);
- public static readonly AMQConstant CHANNEL_ERROR = new AMQConstant(504, "channel error", true);
- public static readonly AMQConstant RESOURCE_ERROR = new AMQConstant(506, "resource error", true);
- public static readonly AMQConstant NOT_ALLOWED = new AMQConstant(530, "not allowed", true);
- public static readonly AMQConstant NOT_IMPLEMENTED = new AMQConstant(540, "not implemented", true);
- public static readonly AMQConstant INTERNAL_ERROR = new AMQConstant(541, "internal error", true);
-
- #endregion // Constants
-
- }
-}
+/*
+ *
+ * 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 System.Collections;
+
+namespace Apache.Qpid.Protocol
+{
+ public sealed class AMQConstant
+ {
+ private int _code;
+ private string _name;
+ private static Hashtable _codeMap = new Hashtable();
+
+ public int Code
+ {
+ get { return _code; }
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ private AMQConstant(int code, string name, bool map)
+ {
+ _code = code;
+ _name = name;
+
+ if ( map )
+ {
+ _codeMap.Add(code, this);
+ }
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{0}: {1}", Code, Name);
+ }
+
+ public static AMQConstant GetConstant(int code)
+ {
+ AMQConstant c = (AMQConstant)_codeMap[code];
+ if ( c == null )
+ {
+ c = new AMQConstant(code, "unknown code", false);
+ }
+ return c;
+ }
+
+ #region Constants
+ //
+ // Constants
+ //
+ public static readonly AMQConstant FRAME_MIN_SIZE = new AMQConstant(4096, "frame min size", true);
+ public static readonly AMQConstant FRAME_END = new AMQConstant(206, "frame end", true);
+ public static readonly AMQConstant REPLY_SUCCESS = new AMQConstant(200, "reply success", true);
+ public static readonly AMQConstant NOT_DELIVERED = new AMQConstant(310, "not delivered", true);
+ public static readonly AMQConstant MESSAGE_TOO_LARGE = new AMQConstant(311, "message too large", true);
+ public static readonly AMQConstant NO_ROUTE = new AMQConstant(312, "no route", true);
+ public static readonly AMQConstant NO_CONSUMERS = new AMQConstant(313, "no consumers", true);
+ public static readonly AMQConstant CONTEXT_IN_USE = new AMQConstant(320, "context in use", true);
+ public static readonly AMQConstant INVALID_PATH = new AMQConstant(402, "invalid path", true);
+ public static readonly AMQConstant ACCESS_REFUSED = new AMQConstant(403, "access refused", true);
+ public static readonly AMQConstant NOT_FOUND = new AMQConstant(404, "not found", true);
+ public static readonly AMQConstant ALREADY_EXISTS = new AMQConstant(405, "already exists", true);
+ public static readonly AMQConstant IN_USE = new AMQConstant(406, "in use", true);
+ public static readonly AMQConstant INVALID_ROUTING_KEY = new AMQConstant(407, "routing key invalid", true);
+ public static readonly AMQConstant REQUEST_TIMEOUT = new AMQConstant(408, "request timeout", true);
+ public static readonly AMQConstant INVALID_ARGUMENT = new AMQConstant(409, "argument invalid", true);
+ public static readonly AMQConstant FRAME_ERROR = new AMQConstant(501, "frame error", true);
+ public static readonly AMQConstant SYNTAX_ERROR = new AMQConstant(502, "syntax error", true);
+ public static readonly AMQConstant COMMAND_INVALID = new AMQConstant(503, "command invalid", true);
+ public static readonly AMQConstant CHANNEL_ERROR = new AMQConstant(504, "channel error", true);
+ public static readonly AMQConstant RESOURCE_ERROR = new AMQConstant(506, "resource error", true);
+ public static readonly AMQConstant NOT_ALLOWED = new AMQConstant(530, "not allowed", true);
+ public static readonly AMQConstant NOT_IMPLEMENTED = new AMQConstant(540, "not implemented", true);
+ public static readonly AMQConstant INTERNAL_ERROR = new AMQConstant(541, "internal error", true);
+
+ #endregion // Constants
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/Properties/AssemblyInfo.cs b/qpid/dotnet/Qpid.Integration.Tests/Properties/AssemblyInfo.cs
index 895688e29e..e19650559f 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/Properties/AssemblyInfo.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/Properties/AssemblyInfo.cs
@@ -1,53 +1,53 @@
-/*
- *
- * 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.Reflection;
-using System.Runtime.InteropServices;
-using log4net.Config;
-[assembly: XmlConfigurator(ConfigFile="log4net.config")]
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Apache.Qpid.Integration.Tests")]
-[assembly: AssemblyDescription("Built from svn revision number: ")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache.Qpid.Integration.Tests")]
-[assembly: AssemblyCopyright("Apache Software Foundation")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("7ebdea21-1352-4673-b66e-fdc0beff461f")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("0.5.0.0")]
+/*
+ *
+ * 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.Reflection;
+using System.Runtime.InteropServices;
+using log4net.Config;
+[assembly: XmlConfigurator(ConfigFile="log4net.config")]
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Apache.Qpid.Integration.Tests")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache.Qpid.Integration.Tests")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("7ebdea21-1352-4673-b66e-fdc0beff461f")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.5.0.0")]
diff --git a/qpid/dotnet/Qpid.Integration.Tests/framework/Assertion.cs b/qpid/dotnet/Qpid.Integration.Tests/framework/Assertion.cs
index fba8253251..de12de6522 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/framework/Assertion.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/framework/Assertion.cs
@@ -1,39 +1,39 @@
-/*
- *
- * 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.
- *
- */
-namespace Apache.Qpid.Integration.Tests.framework
-{
- /// <summary>
- /// Assertion models an assertion on a test <see cref="Circuit"/>.
- ///
- /// <p/><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities
- /// <tr><td> Indicate whether or not the assertion passes when applied.
- /// </table>
- /// </summary>
- public interface Assertion
- {
- /// <summary>
- /// Applies the assertion.
- /// </summary>
- /// <return> <tt>true</tt> if the assertion passes, <tt>false</tt> if it fails. </return>
- bool apply();
- }
+/*
+ *
+ * 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.
+ *
+ */
+namespace Apache.Qpid.Integration.Tests.framework
+{
+ /// <summary>
+ /// Assertion models an assertion on a test <see cref="Circuit"/>.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities
+ /// <tr><td> Indicate whether or not the assertion passes when applied.
+ /// </table>
+ /// </summary>
+ public interface Assertion
+ {
+ /// <summary>
+ /// Applies the assertion.
+ /// </summary>
+ /// <return> <tt>true</tt> if the assertion passes, <tt>false</tt> if it fails. </return>
+ bool apply();
+ }
} \ No newline at end of file
diff --git a/qpid/dotnet/Qpid.Integration.Tests/framework/Circuit.cs b/qpid/dotnet/Qpid.Integration.Tests/framework/Circuit.cs
index d5f0ed15e2..aae9ca0496 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/framework/Circuit.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/framework/Circuit.cs
@@ -1,102 +1,102 @@
-/*
- *
- * 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.Collections.Generic;//.IList;
-
-namespace Apache.Qpid.Integration.Tests.framework
-{
- /// <summary>
- /// A Circuit is the basic test unit against which test cases are to be written. A circuit consists of two 'ends', an
- /// instigating 'publisher' end and a more passive 'receivers' end.
- ///
- /// <p/>Once created, the life-cycle of a circuit may be controlled by <see cref="#start()"/>ing it, or <see cref="#close()"/>ing it.
- /// Once started, the circuit is ready to send messages over. Once closed the circuit can no longer be used.
- ///
- /// <p/>The state of the circuit may be taken with the <see cref="#check()"/> method, and asserted against by the
- /// <see cref="#applyAssertions(System.Collections.Generic.IList)"/> method.
- ///
- /// <p/>There is a default test procedure which may be performed against the circuit. The outline of this procedure is:
- ///
- /// <p/><pre>
- /// Start the circuit.
- /// Send test messages.
- /// Request a status report.
- /// Assert conditions on the publishing end of the circuit.
- /// Assert conditions on the receiving end of the circuit.
- /// Close the circuit.
- /// Pass with no failed assertions or fail with a list of failed assertions.
- /// </pre>
- ///
- /// <p/><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities
- /// <tr><td> Supply the publishing and receiving ends of a test messaging circuit.
- /// <tr><td> Start the circuit running.
- /// <tr><td> Close the circuit down.
- /// <tr><td> Take a reading of the circuits state.
- /// <tr><td> Apply assertions against the circuits state.
- /// <tr><td> Send test messages over the circuit.
- /// <tr><td> Perform the default test procedue on the circuit.
- /// </table>
- /// </summary>
- public interface Circuit
- {
- /// <summary> Gets the interface on the publishing end of the circuit. </summary>
- ///
- /// <return> The publishing end of the circuit. </return>
- Publisher GetPublisher();
-
- /// <summary> Gets the interface on the receiving end of the circuit. </summary>
- ///
- /// <return> The receiving end of the circuit. </return>
- Receiver GetReceiver();
-
- /// <summary> Connects and starts the circuit. After this method is called the circuit is ready to send messages. </summary>
- void Start();
-
- /// <summary>
- /// Checks the test circuit. The effect of this is to gather the circuits state, for both ends of the circuit,
- /// into a report, against which assertions may be checked.
- /// </summary>
- void Check();
-
- /// <summary> Closes the circuit. All associated resources are closed. </summary>
- void Close();
-
- /// <summary>
- /// Applied a list of assertions against the test circuit. The <see cref="#check()"/> method should be called before doing
- /// this, to ensure that the circuit has gathered its state into a report to assert against.
- /// </summary>
- ///
- /// <param name="assertions"> The list of assertions to apply to the circuit. </param>
- ///
- /// <return> Any assertions that failed. </return>
- IList<Assertion> ApplyAssertions(IList<Assertion> assertions);
-
- /// <summary>
- /// Runs the default test procedure against the circuit, and checks that all of the specified assertions hold.
- /// </summary>
- ///
- /// <param name="numMessages"> The number of messages to send using the default test procedure. </param>
- /// <param name="assertions"> The list of assertions to apply. </param>
- ///
- /// <return> Any assertions that failed. </return>
- IList<Assertion> Test(int numMessages, IList<Assertion> assertions);
- }
+/*
+ *
+ * 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.Collections.Generic;//.IList;
+
+namespace Apache.Qpid.Integration.Tests.framework
+{
+ /// <summary>
+ /// A Circuit is the basic test unit against which test cases are to be written. A circuit consists of two 'ends', an
+ /// instigating 'publisher' end and a more passive 'receivers' end.
+ ///
+ /// <p/>Once created, the life-cycle of a circuit may be controlled by <see cref="#start()"/>ing it, or <see cref="#close()"/>ing it.
+ /// Once started, the circuit is ready to send messages over. Once closed the circuit can no longer be used.
+ ///
+ /// <p/>The state of the circuit may be taken with the <see cref="#check()"/> method, and asserted against by the
+ /// <see cref="#applyAssertions(System.Collections.Generic.IList)"/> method.
+ ///
+ /// <p/>There is a default test procedure which may be performed against the circuit. The outline of this procedure is:
+ ///
+ /// <p/><pre>
+ /// Start the circuit.
+ /// Send test messages.
+ /// Request a status report.
+ /// Assert conditions on the publishing end of the circuit.
+ /// Assert conditions on the receiving end of the circuit.
+ /// Close the circuit.
+ /// Pass with no failed assertions or fail with a list of failed assertions.
+ /// </pre>
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities
+ /// <tr><td> Supply the publishing and receiving ends of a test messaging circuit.
+ /// <tr><td> Start the circuit running.
+ /// <tr><td> Close the circuit down.
+ /// <tr><td> Take a reading of the circuits state.
+ /// <tr><td> Apply assertions against the circuits state.
+ /// <tr><td> Send test messages over the circuit.
+ /// <tr><td> Perform the default test procedue on the circuit.
+ /// </table>
+ /// </summary>
+ public interface Circuit
+ {
+ /// <summary> Gets the interface on the publishing end of the circuit. </summary>
+ ///
+ /// <return> The publishing end of the circuit. </return>
+ Publisher GetPublisher();
+
+ /// <summary> Gets the interface on the receiving end of the circuit. </summary>
+ ///
+ /// <return> The receiving end of the circuit. </return>
+ Receiver GetReceiver();
+
+ /// <summary> Connects and starts the circuit. After this method is called the circuit is ready to send messages. </summary>
+ void Start();
+
+ /// <summary>
+ /// Checks the test circuit. The effect of this is to gather the circuits state, for both ends of the circuit,
+ /// into a report, against which assertions may be checked.
+ /// </summary>
+ void Check();
+
+ /// <summary> Closes the circuit. All associated resources are closed. </summary>
+ void Close();
+
+ /// <summary>
+ /// Applied a list of assertions against the test circuit. The <see cref="#check()"/> method should be called before doing
+ /// this, to ensure that the circuit has gathered its state into a report to assert against.
+ /// </summary>
+ ///
+ /// <param name="assertions"> The list of assertions to apply to the circuit. </param>
+ ///
+ /// <return> Any assertions that failed. </return>
+ IList<Assertion> ApplyAssertions(IList<Assertion> assertions);
+
+ /// <summary>
+ /// Runs the default test procedure against the circuit, and checks that all of the specified assertions hold.
+ /// </summary>
+ ///
+ /// <param name="numMessages"> The number of messages to send using the default test procedure. </param>
+ /// <param name="assertions"> The list of assertions to apply. </param>
+ ///
+ /// <return> Any assertions that failed. </return>
+ IList<Assertion> Test(int numMessages, IList<Assertion> assertions);
+ }
} \ No newline at end of file
diff --git a/qpid/dotnet/Qpid.Integration.Tests/framework/FrameworkBaseCase.cs b/qpid/dotnet/Qpid.Integration.Tests/framework/FrameworkBaseCase.cs
index a7a663e531..77c1cae0ad 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/framework/FrameworkBaseCase.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/framework/FrameworkBaseCase.cs
@@ -1,282 +1,282 @@
-/*
- *
- * 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 log4net;
-using NUnit.Framework;
-//using org.apache.log4j.NDC;
-
-using Apache.Qpid.Integration.Tests.framework.sequencers;//.CircuitFactory;
-
-//using uk.co.thebadgerset.junit.extensions.AsymptoticTestCase;
-//using uk.co.thebadgerset.junit.extensions.SetupTaskAware;
-//using uk.co.thebadgerset.junit.extensions.SetupTaskHandler;
-//using uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
-//using uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
-
-//using java.util.ArrayList;
-using System.Collections.Generic;//.IList;
-
-namespace Apache.Qpid.Integration.Tests.framework
-{
- /// <summary>
- /// FrameworkBaseCase provides a starting point for writing test cases against the test framework. Its main purpose is
- /// to provide some convenience methods for testing.
- ///
- /// <p/><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Create and clean up in-vm brokers on every test case.
- /// <tr><td> Produce lists of assertions from assertion creation calls.
- /// <tr><td> Produce JUnit failures from assertion failures.
- /// <tr><td> Convert failed assertions to error messages.
- /// </table>
- /// </summary>
- public class FrameworkBaseCase //extends AsymptoticTestCase : FrameworkTestContext, SetupTaskAware, BrokerLifecycleAware
- {
- /// <summary> Used for debugging purposes. </summary>
- private static ILog log = LogManager.GetLogger(typeof(FrameworkBaseCase));
-
- /// <summary> Holds the test sequencer to create and run test circuits with. </summary>
- protected CircuitFactory circuitFactory;// = new LocalCircuitFactory();
-
- /// <summary> Used to read the tests configurable properties through. </summary>
- protected TestModel testProps;
-
- /// <summary> A default setup task processor to delegate setup tasks to. </summary>
- //protected SetupTaskHandler taskHandler = new SetupTaskHandler();
-
- /// <summary> Flag used to track whether the test is in-vm or not. </summary>
- //protected bool isUsingInVM;
-
- /// <summary> Holds the failure mechanism. </summary>
- //protected CauseFailure failureMechanism = new CauseFailureUserPrompt();
-
- /*
- /// <summary>
- /// Creates a new test case with the specified name.
- /// </summary>
- /// <param name="name"> The test case name. </param>
- public FrameworkBaseCase(string name) : base(name)
- {
- }
- */
-
- /// <summary>
- /// Returns the test case sequencer that provides test circuit, and test sequence implementations. The sequencer
- /// that this base case returns by default is suitable for running a test circuit with both circuit ends colocated
- /// on the same JVM.
- /// </summary>
- /// <return> The test case sequencer. </return>
- protected CircuitFactory GetCircuitFactory()
- {
- return circuitFactory;
- }
-
- /// <summary>
- /// Overrides the default test circuit factory. Test decorators can use this to supply distributed test sequencers or
- /// other test circuit factory specializations.
- /// </summary>
- /// <param name="circuitFactory"> The new test circuit factory. </param>
- public void SetCircuitFactory(CircuitFactory circuitFactory)
- {
- this.circuitFactory = circuitFactory;
- }
-
- /*
- /// <summary>
- /// Reports the current test case name.
- /// </summary>
- /// <return> The current test case name. </return>
- public TestCaseVector GetTestCaseVector()
- {
- return new TestCaseVector(this.getName(), 0);
- }
- */
-
- /// <summary>
- /// Reports the current test case parameters.
- /// </summary>
- /// <return> The current test case parameters. </return>
- public TestModel getTestParameters()
- {
- return testProps;
- }
-
- /// <summary>
- /// Creates a list of assertions.
- /// </summary>
- /// <param name="asserts"> The assertions to compile in a list. </param>
- ///
- /// <return> A list of assertions. </return>
- protected IList<Assertion> AssertionList(params Assertion[] asserts)
- {
- IList<Assertion> result = new List<Assertion>();
-
- foreach (Assertion assertion in asserts)
- {
- result.Add(assertion);
- }
-
- return result;
- }
-
- /// <summary>
- /// Generates a JUnit assertion exception (failure) if any assertions are passed into this method, also concatenating
- /// all of the error messages in the assertions together to form an error message to diagnose the test failure with.
- /// </summary>
- /// <param name="asserts"> The list of failed assertions. </param>
- protected static void AssertNoFailures(List<Assertion> asserts)
- {
- log.Debug("protected void assertNoFailures(List<Assertion> asserts = " + asserts + "): called");
-
- // Check if there are no assertion failures, and return without doing anything if so.
- if ((asserts == null) || (asserts.Count == 0))
- {
- return;
- }
-
- // Compile all of the assertion failure messages together.
- string errorMessage = AssertionsToString(asserts);
-
- // Fail with the error message from all of the assertions.
- Assert.Fail(errorMessage);
- }
-
- /// <summary>
- /// Converts a list of failed assertions into an error message.
- /// </summary>
- /// <param name="asserts"> The failed assertions. </param>
- ///
- /// <return> The error message. </return>
- protected static string AssertionsToString(List<Assertion> asserts)
- {
- string errorMessage = "";
-
- foreach (Assertion assertion in asserts)
- {
- errorMessage += assertion.ToString() + "\n";
- }
-
- return errorMessage;
- }
-
- /// <summary>
- /// Ensures that the in-vm broker is created and initialized.
- /// </summary>
- ///
- /// <exception cref="Exception"> Any exceptions allowed to fall through and fail the test. </exception>
- [SetUp]
- protected void SetUp()
- {
- //NDC.Push(Name);
-
- //testProps = TestContextProperties.getInstance(TestModel.defaults);
-
- // Process all optional setup tasks. This may include in-vm broker creation, if a decorator has added it.
- //taskHandler.runSetupTasks();
- }
-
- /// <summary> Ensures that the in-vm broker is cleaned up after each test run. </summary>
- [TearDown]
- protected void TearDown()
- {
- //NDC.Pop();
-
- // Process all optional tear down tasks. This may include in-vm broker clean up, if a decorator has added it.
- //taskHandler.runTearDownTasks();
- }
-
- /*
- /// <summary>
- /// Adds the specified task to the tests setup.
- /// </summary>
- /// <param name="task"> The task to add to the tests setup. </param>
- public void chainSetupTask(Runnable task)
- {
- taskHandler.chainSetupTask(task);
- }
- */
-
- /*
- /// <summary>
- /// Adds the specified task to the tests tear down.
- /// </summary>
- /// <param name="task"> The task to add to the tests tear down. </param>
- public void chainTearDownTask(Runnable task)
- {
- taskHandler.chainTearDownTask(task);
- }
- */
-
- /*
- /// <summary>
- /// Should provide a translation from the junit method name of a test to its test case name as known to the test
- /// clients that will run the test. The purpose of this is to convert the JUnit method name into the correct test
- /// case name to place into the test invite. For example the method "testP2P" might map onto the interop test case
- /// name "TC2_BasicP2P".
- /// </summary>
- /// <param name="methodName"> The name of the JUnit test method. </param>
- ///
- /// <return> The name of the corresponding interop test case. </return>
- public string getTestCaseNameForTestMethod(string methodName)
- {
- return methodName;
- }
-
- public void setInVmBrokers()
- {
- isUsingInVM = true;
- }
-
- /// <summary>
- /// Indicates whether or not a test case is using in-vm brokers.
- /// </summary>
- /// <return> <tt>true</tt> if the test is using in-vm brokers, <tt>false</tt> otherwise. </return>
- public bool usingInVmBroker()
- {
- return isUsingInVM;
- }
-
- /// <summary>
- /// Sets the currently live in-vm broker.
- /// </summary>
- /// <param name="i"> The currently live in-vm broker. </param>
- public void setLiveBroker(int i)
- { }
-
- /// <summary>
- /// Reports the currently live in-vm broker.
- /// </summary>
- /// <return> The currently live in-vm broker. </return>
- public int getLiveBroker()
- {
- return 0;
- }
-
- /// <summary>
- /// Accepts a failure mechanism.
- /// </summary>
- /// <param name="failureMechanism"> The failure mechanism. </param>
- public void setFailureMechanism(CauseFailure failureMechanism)
- {
- this.failureMechanism = failureMechanism;
- }
- */
- }
+/*
+ *
+ * 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 log4net;
+using NUnit.Framework;
+//using org.apache.log4j.NDC;
+
+using Apache.Qpid.Integration.Tests.framework.sequencers;//.CircuitFactory;
+
+//using uk.co.thebadgerset.junit.extensions.AsymptoticTestCase;
+//using uk.co.thebadgerset.junit.extensions.SetupTaskAware;
+//using uk.co.thebadgerset.junit.extensions.SetupTaskHandler;
+//using uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+//using uk.co.thebadgerset.junit.extensions.util.TestContextProperties;
+
+//using java.util.ArrayList;
+using System.Collections.Generic;//.IList;
+
+namespace Apache.Qpid.Integration.Tests.framework
+{
+ /// <summary>
+ /// FrameworkBaseCase provides a starting point for writing test cases against the test framework. Its main purpose is
+ /// to provide some convenience methods for testing.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Create and clean up in-vm brokers on every test case.
+ /// <tr><td> Produce lists of assertions from assertion creation calls.
+ /// <tr><td> Produce JUnit failures from assertion failures.
+ /// <tr><td> Convert failed assertions to error messages.
+ /// </table>
+ /// </summary>
+ public class FrameworkBaseCase //extends AsymptoticTestCase : FrameworkTestContext, SetupTaskAware, BrokerLifecycleAware
+ {
+ /// <summary> Used for debugging purposes. </summary>
+ private static ILog log = LogManager.GetLogger(typeof(FrameworkBaseCase));
+
+ /// <summary> Holds the test sequencer to create and run test circuits with. </summary>
+ protected CircuitFactory circuitFactory;// = new LocalCircuitFactory();
+
+ /// <summary> Used to read the tests configurable properties through. </summary>
+ protected TestModel testProps;
+
+ /// <summary> A default setup task processor to delegate setup tasks to. </summary>
+ //protected SetupTaskHandler taskHandler = new SetupTaskHandler();
+
+ /// <summary> Flag used to track whether the test is in-vm or not. </summary>
+ //protected bool isUsingInVM;
+
+ /// <summary> Holds the failure mechanism. </summary>
+ //protected CauseFailure failureMechanism = new CauseFailureUserPrompt();
+
+ /*
+ /// <summary>
+ /// Creates a new test case with the specified name.
+ /// </summary>
+ /// <param name="name"> The test case name. </param>
+ public FrameworkBaseCase(string name) : base(name)
+ {
+ }
+ */
+
+ /// <summary>
+ /// Returns the test case sequencer that provides test circuit, and test sequence implementations. The sequencer
+ /// that this base case returns by default is suitable for running a test circuit with both circuit ends colocated
+ /// on the same JVM.
+ /// </summary>
+ /// <return> The test case sequencer. </return>
+ protected CircuitFactory GetCircuitFactory()
+ {
+ return circuitFactory;
+ }
+
+ /// <summary>
+ /// Overrides the default test circuit factory. Test decorators can use this to supply distributed test sequencers or
+ /// other test circuit factory specializations.
+ /// </summary>
+ /// <param name="circuitFactory"> The new test circuit factory. </param>
+ public void SetCircuitFactory(CircuitFactory circuitFactory)
+ {
+ this.circuitFactory = circuitFactory;
+ }
+
+ /*
+ /// <summary>
+ /// Reports the current test case name.
+ /// </summary>
+ /// <return> The current test case name. </return>
+ public TestCaseVector GetTestCaseVector()
+ {
+ return new TestCaseVector(this.getName(), 0);
+ }
+ */
+
+ /// <summary>
+ /// Reports the current test case parameters.
+ /// </summary>
+ /// <return> The current test case parameters. </return>
+ public TestModel getTestParameters()
+ {
+ return testProps;
+ }
+
+ /// <summary>
+ /// Creates a list of assertions.
+ /// </summary>
+ /// <param name="asserts"> The assertions to compile in a list. </param>
+ ///
+ /// <return> A list of assertions. </return>
+ protected IList<Assertion> AssertionList(params Assertion[] asserts)
+ {
+ IList<Assertion> result = new List<Assertion>();
+
+ foreach (Assertion assertion in asserts)
+ {
+ result.Add(assertion);
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Generates a JUnit assertion exception (failure) if any assertions are passed into this method, also concatenating
+ /// all of the error messages in the assertions together to form an error message to diagnose the test failure with.
+ /// </summary>
+ /// <param name="asserts"> The list of failed assertions. </param>
+ protected static void AssertNoFailures(List<Assertion> asserts)
+ {
+ log.Debug("protected void assertNoFailures(List<Assertion> asserts = " + asserts + "): called");
+
+ // Check if there are no assertion failures, and return without doing anything if so.
+ if ((asserts == null) || (asserts.Count == 0))
+ {
+ return;
+ }
+
+ // Compile all of the assertion failure messages together.
+ string errorMessage = AssertionsToString(asserts);
+
+ // Fail with the error message from all of the assertions.
+ Assert.Fail(errorMessage);
+ }
+
+ /// <summary>
+ /// Converts a list of failed assertions into an error message.
+ /// </summary>
+ /// <param name="asserts"> The failed assertions. </param>
+ ///
+ /// <return> The error message. </return>
+ protected static string AssertionsToString(List<Assertion> asserts)
+ {
+ string errorMessage = "";
+
+ foreach (Assertion assertion in asserts)
+ {
+ errorMessage += assertion.ToString() + "\n";
+ }
+
+ return errorMessage;
+ }
+
+ /// <summary>
+ /// Ensures that the in-vm broker is created and initialized.
+ /// </summary>
+ ///
+ /// <exception cref="Exception"> Any exceptions allowed to fall through and fail the test. </exception>
+ [SetUp]
+ protected void SetUp()
+ {
+ //NDC.Push(Name);
+
+ //testProps = TestContextProperties.getInstance(TestModel.defaults);
+
+ // Process all optional setup tasks. This may include in-vm broker creation, if a decorator has added it.
+ //taskHandler.runSetupTasks();
+ }
+
+ /// <summary> Ensures that the in-vm broker is cleaned up after each test run. </summary>
+ [TearDown]
+ protected void TearDown()
+ {
+ //NDC.Pop();
+
+ // Process all optional tear down tasks. This may include in-vm broker clean up, if a decorator has added it.
+ //taskHandler.runTearDownTasks();
+ }
+
+ /*
+ /// <summary>
+ /// Adds the specified task to the tests setup.
+ /// </summary>
+ /// <param name="task"> The task to add to the tests setup. </param>
+ public void chainSetupTask(Runnable task)
+ {
+ taskHandler.chainSetupTask(task);
+ }
+ */
+
+ /*
+ /// <summary>
+ /// Adds the specified task to the tests tear down.
+ /// </summary>
+ /// <param name="task"> The task to add to the tests tear down. </param>
+ public void chainTearDownTask(Runnable task)
+ {
+ taskHandler.chainTearDownTask(task);
+ }
+ */
+
+ /*
+ /// <summary>
+ /// Should provide a translation from the junit method name of a test to its test case name as known to the test
+ /// clients that will run the test. The purpose of this is to convert the JUnit method name into the correct test
+ /// case name to place into the test invite. For example the method "testP2P" might map onto the interop test case
+ /// name "TC2_BasicP2P".
+ /// </summary>
+ /// <param name="methodName"> The name of the JUnit test method. </param>
+ ///
+ /// <return> The name of the corresponding interop test case. </return>
+ public string getTestCaseNameForTestMethod(string methodName)
+ {
+ return methodName;
+ }
+
+ public void setInVmBrokers()
+ {
+ isUsingInVM = true;
+ }
+
+ /// <summary>
+ /// Indicates whether or not a test case is using in-vm brokers.
+ /// </summary>
+ /// <return> <tt>true</tt> if the test is using in-vm brokers, <tt>false</tt> otherwise. </return>
+ public bool usingInVmBroker()
+ {
+ return isUsingInVM;
+ }
+
+ /// <summary>
+ /// Sets the currently live in-vm broker.
+ /// </summary>
+ /// <param name="i"> The currently live in-vm broker. </param>
+ public void setLiveBroker(int i)
+ { }
+
+ /// <summary>
+ /// Reports the currently live in-vm broker.
+ /// </summary>
+ /// <return> The currently live in-vm broker. </return>
+ public int getLiveBroker()
+ {
+ return 0;
+ }
+
+ /// <summary>
+ /// Accepts a failure mechanism.
+ /// </summary>
+ /// <param name="failureMechanism"> The failure mechanism. </param>
+ public void setFailureMechanism(CauseFailure failureMechanism)
+ {
+ this.failureMechanism = failureMechanism;
+ }
+ */
+ }
} \ No newline at end of file
diff --git a/qpid/dotnet/Qpid.Integration.Tests/framework/Publisher.cs b/qpid/dotnet/Qpid.Integration.Tests/framework/Publisher.cs
index 72bd079277..5fbdc7a907 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/framework/Publisher.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/framework/Publisher.cs
@@ -1,65 +1,65 @@
-/*
- *
- * 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 uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
-using System;
-
-namespace Apache.Qpid.Integration.Tests.framework
-{
- /// <summary>
- /// A Publisher represents the status of the publishing side of a test circuit. Its main purpose is to provide assertions
- /// that can be applied to test the behaviour of the publishers.
- ///
- /// <p/><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities
- /// <tr><td> Provide assertion that the publishers received no exceptions.
- /// </table>
- /// </summary>
- public interface Publisher
- {
- /// <summary>
- /// Provides an assertion that the publisher encountered no exceptions.
- /// </summary>
- ///
- /// <param name="testProps"> The test configuration properties. </param>
- ///
- /// <return> An assertion that the publisher encountered no exceptions. </return>
- Assertion NoExceptionsAssertion(TestModel testProps);
-
- /// <summary>
- /// Provides an assertion that the AMQP channel was forcibly closed by an error condition.
- /// </summary>
- ///
- /// <param name="testProps"> The test configuration properties. </param>
- ///
- /// <return> An assertion that the AMQP channel was forcibly closed by an error condition. </return>
- Assertion ChannelClosedAssertion(TestModel testProps);
-
- /// <summary>
- /// Provides an assertion that the publisher got a given exception during the test.
- /// </summary>
- ///
- /// <param name="testProps"> The test configuration properties. </param>
- /// <param name="exceptionClass"> The exception class to check for. </param>
- ///
- /// <return> An assertion that the publisher got a given exception during the test. </return>
- Assertion ExceptionAssertion(TestModel testProps, Type exceptionClass);
- }
+/*
+ *
+ * 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 uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+using System;
+
+namespace Apache.Qpid.Integration.Tests.framework
+{
+ /// <summary>
+ /// A Publisher represents the status of the publishing side of a test circuit. Its main purpose is to provide assertions
+ /// that can be applied to test the behaviour of the publishers.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities
+ /// <tr><td> Provide assertion that the publishers received no exceptions.
+ /// </table>
+ /// </summary>
+ public interface Publisher
+ {
+ /// <summary>
+ /// Provides an assertion that the publisher encountered no exceptions.
+ /// </summary>
+ ///
+ /// <param name="testProps"> The test configuration properties. </param>
+ ///
+ /// <return> An assertion that the publisher encountered no exceptions. </return>
+ Assertion NoExceptionsAssertion(TestModel testProps);
+
+ /// <summary>
+ /// Provides an assertion that the AMQP channel was forcibly closed by an error condition.
+ /// </summary>
+ ///
+ /// <param name="testProps"> The test configuration properties. </param>
+ ///
+ /// <return> An assertion that the AMQP channel was forcibly closed by an error condition. </return>
+ Assertion ChannelClosedAssertion(TestModel testProps);
+
+ /// <summary>
+ /// Provides an assertion that the publisher got a given exception during the test.
+ /// </summary>
+ ///
+ /// <param name="testProps"> The test configuration properties. </param>
+ /// <param name="exceptionClass"> The exception class to check for. </param>
+ ///
+ /// <return> An assertion that the publisher got a given exception during the test. </return>
+ Assertion ExceptionAssertion(TestModel testProps, Type exceptionClass);
+ }
} \ No newline at end of file
diff --git a/qpid/dotnet/Qpid.Integration.Tests/framework/Receiver.cs b/qpid/dotnet/Qpid.Integration.Tests/framework/Receiver.cs
index 80320c68b6..96820b5980 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/framework/Receiver.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/framework/Receiver.cs
@@ -1,80 +1,80 @@
-/*
- *
- * 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 uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
-using System;
-
-namespace Apache.Qpid.Integration.Tests.framework
-{
- /// <summary>
- /// A Receiver is a <see cref="CircuitEnd"/> that represents the status of the receiving side of a test circuit. Its main
- /// purpose is to provide assertions that can be applied to check the behaviour of the receivers.
- ///
- /// <p/><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities
- /// <tr><td> Provide assertion that the receivers received no exceptions.
- /// <tr><td> Provide assertion that the receivers received all test messages sent to it.
- /// </table>
- /// </summary>
- public interface Receiver
- {
- /// <summary>
- /// Provides an assertion that the receivers encountered no exceptions.
- /// </summary>
- ///
- /// <param name="testProps"> The test configuration properties. </param>
- ///
- /// <return> An assertion that the receivers encountered no exceptions. </return>
- Assertion NoExceptionsAssertion(TestModel testProps);
-
- /// <summary>
- /// Provides an assertion that the receivers got all messages that were sent to it.
- /// </summary>
- /// <param name="testProps"> The test configuration properties. </param>
- ///
- /// <return> An assertion that the receivers got all messages that were sent to it. </return>
- Assertion AllMessagesReceivedAssertion(TestModel testProps);
-
- /// <summary>
- /// Provides an assertion that the receivers got none of the messages that were sent to it.
- /// </summary>
- /// <param name="testProps"> The test configuration properties. </param>
- ///
- /// <return> An assertion that the receivers got none of the messages that were sent to it. </return>
- Assertion NoMessagesReceivedAssertion(TestModel testProps);
-
- /// <summary>
- /// Provides an assertion that the AMQP channel was forcibly closed by an error condition.
- /// </summary>
- /// <param name="testProps"> The test configuration properties. </param>
- ///
- /// <return> An assertion that the AMQP channel was forcibly closed by an error condition. </return>
- Assertion ChannelClosedAssertion(TestModel testProps);
-
- /// <summary>
- /// Provides an assertion that the receiver got a given exception during the test.
- /// </summary>
- /// <param name="testProps"> The test configuration properties. </param>
- /// <param name="exceptionClass"> The exception class to check for. </param>
- ///
- /// <return> An assertion that the receiver got a given exception during the test. </return>
- Assertion ExceptionAssertion(TestModel testProps, Type exceptionClass);
- }
+/*
+ *
+ * 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 uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+using System;
+
+namespace Apache.Qpid.Integration.Tests.framework
+{
+ /// <summary>
+ /// A Receiver is a <see cref="CircuitEnd"/> that represents the status of the receiving side of a test circuit. Its main
+ /// purpose is to provide assertions that can be applied to check the behaviour of the receivers.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities
+ /// <tr><td> Provide assertion that the receivers received no exceptions.
+ /// <tr><td> Provide assertion that the receivers received all test messages sent to it.
+ /// </table>
+ /// </summary>
+ public interface Receiver
+ {
+ /// <summary>
+ /// Provides an assertion that the receivers encountered no exceptions.
+ /// </summary>
+ ///
+ /// <param name="testProps"> The test configuration properties. </param>
+ ///
+ /// <return> An assertion that the receivers encountered no exceptions. </return>
+ Assertion NoExceptionsAssertion(TestModel testProps);
+
+ /// <summary>
+ /// Provides an assertion that the receivers got all messages that were sent to it.
+ /// </summary>
+ /// <param name="testProps"> The test configuration properties. </param>
+ ///
+ /// <return> An assertion that the receivers got all messages that were sent to it. </return>
+ Assertion AllMessagesReceivedAssertion(TestModel testProps);
+
+ /// <summary>
+ /// Provides an assertion that the receivers got none of the messages that were sent to it.
+ /// </summary>
+ /// <param name="testProps"> The test configuration properties. </param>
+ ///
+ /// <return> An assertion that the receivers got none of the messages that were sent to it. </return>
+ Assertion NoMessagesReceivedAssertion(TestModel testProps);
+
+ /// <summary>
+ /// Provides an assertion that the AMQP channel was forcibly closed by an error condition.
+ /// </summary>
+ /// <param name="testProps"> The test configuration properties. </param>
+ ///
+ /// <return> An assertion that the AMQP channel was forcibly closed by an error condition. </return>
+ Assertion ChannelClosedAssertion(TestModel testProps);
+
+ /// <summary>
+ /// Provides an assertion that the receiver got a given exception during the test.
+ /// </summary>
+ /// <param name="testProps"> The test configuration properties. </param>
+ /// <param name="exceptionClass"> The exception class to check for. </param>
+ ///
+ /// <return> An assertion that the receiver got a given exception during the test. </return>
+ Assertion ExceptionAssertion(TestModel testProps, Type exceptionClass);
+ }
} \ No newline at end of file
diff --git a/qpid/dotnet/Qpid.Integration.Tests/framework/TestClientDetails.cs b/qpid/dotnet/Qpid.Integration.Tests/framework/TestClientDetails.cs
index 401e183fd0..8be8de3d96 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/framework/TestClientDetails.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/framework/TestClientDetails.cs
@@ -1,84 +1,84 @@
-/*
- *
- * 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;
-
-namespace Apache.Qpid.Integration.Tests.framework
-{
- /// <summary>
- /// TestClientDetails is used to encapsulate information about an interop test client. It pairs together the unique
- /// name of the client, and the route on which it listens to its control messages.
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Record test clients control addresses together with their names.
- /// </table>
- /// </summary>
- public class TestClientDetails
- {
- /// <summary> The test clients name. </summary>
- public string clientName;
-
- /// <summary> The routing key of the test clients control topic. </summary>
- public string privateControlKey;
-
- /// <summary>
- /// Two TestClientDetails are considered to be equal, iff they have the same client name.
- /// </summary>
- /// <param name="o"> The object to compare to. </param>
- ///
- /// <return> <tt>If the object to compare to is a TestClientDetails equal to this one, <tt>false</tt> otherwise. </return>
- public override bool Equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
-
- if (!(o is TestClientDetails))
- {
- return false;
- }
-
- TestClientDetails testClientDetails = (TestClientDetails) o;
-
- return !((clientName != null) ? (!clientName.Equals(testClientDetails.clientName))
- : (testClientDetails.clientName != null));
- }
-
- /// <summary>
- /// Computes a hash code compatible with the equals method; based on the client name alone.
- /// </summary>
- /// <return> A hash code for this. </return>
- public override int GetHashCode()
- {
- return ((clientName != null) ? clientName.GetHashCode() : 0);
- }
-
- /// <summary>
- /// Outputs the client name and address details. Mostly used for debugging purposes.
- /// </summary>
- /// <return> The client name and address. </return>
- public override string ToString()
- {
- return "TestClientDetails: [ clientName = " + clientName + ", privateControlKey = " + privateControlKey + " ]";
- }
- }
-}
+/*
+ *
+ * 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;
+
+namespace Apache.Qpid.Integration.Tests.framework
+{
+ /// <summary>
+ /// TestClientDetails is used to encapsulate information about an interop test client. It pairs together the unique
+ /// name of the client, and the route on which it listens to its control messages.
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Record test clients control addresses together with their names.
+ /// </table>
+ /// </summary>
+ public class TestClientDetails
+ {
+ /// <summary> The test clients name. </summary>
+ public string clientName;
+
+ /// <summary> The routing key of the test clients control topic. </summary>
+ public string privateControlKey;
+
+ /// <summary>
+ /// Two TestClientDetails are considered to be equal, iff they have the same client name.
+ /// </summary>
+ /// <param name="o"> The object to compare to. </param>
+ ///
+ /// <return> <tt>If the object to compare to is a TestClientDetails equal to this one, <tt>false</tt> otherwise. </return>
+ public override bool Equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+
+ if (!(o is TestClientDetails))
+ {
+ return false;
+ }
+
+ TestClientDetails testClientDetails = (TestClientDetails) o;
+
+ return !((clientName != null) ? (!clientName.Equals(testClientDetails.clientName))
+ : (testClientDetails.clientName != null));
+ }
+
+ /// <summary>
+ /// Computes a hash code compatible with the equals method; based on the client name alone.
+ /// </summary>
+ /// <return> A hash code for this. </return>
+ public override int GetHashCode()
+ {
+ return ((clientName != null) ? clientName.GetHashCode() : 0);
+ }
+
+ /// <summary>
+ /// Outputs the client name and address details. Mostly used for debugging purposes.
+ /// </summary>
+ /// <return> The client name and address. </return>
+ public override string ToString()
+ {
+ return "TestClientDetails: [ clientName = " + clientName + ", privateControlKey = " + privateControlKey + " ]";
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/framework/TestModel.cs b/qpid/dotnet/Qpid.Integration.Tests/framework/TestModel.cs
index a4a1d7db9b..88bea1e5ad 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/framework/TestModel.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/framework/TestModel.cs
@@ -1,657 +1,657 @@
-/*
- *
- * 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 uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
-
-//using javax.jms.Session;
-
-//using java.util.Properties;
-
-namespace Apache.Qpid.Integration.Tests.framework
-{
- public class TestModel //extends ParsedProperties
- {}
-
- /*
- /// <summary>
- /// MessagingTestConfigProperties defines a set of property names and default values for specifying a messaging topology,
- /// and test parameters for running a messaging test over that topology. A Properties object holding some of these
- /// properties, superimposed onto the defaults, is used to establish test topologies and control test behaviour.
- ///
- /// <p/>A complete list of the parameters, default values and comments on their usage is provided here:
- ///
- /// <p/><table><caption>Parameters</caption>
- /// <tr><th> Parameter <th> Default <th> Comments
- /// <tr><td> messageSize <td> 0 <td> Message size in bytes. Not including any headers.
- /// <tr><td> destinationName <td> ping <td> The root name to use to generate destination names to ping.
- /// <tr><td> persistent <td> false <td> Determines whether peristent delivery is used.
- /// <tr><td> transacted <td> false <td> Determines whether messages are sent/received in transactions.
- /// <tr><td> broker <td> tcp://localhost:5672 <td> Determines the broker to connect to.
- /// <tr><td> virtualHost <td> test <td> Determines the virtual host to send all ping over.
- /// <tr><td> rate <td> 0 <td> The maximum rate (in hertz) to send messages at. 0 means no limit.
- /// <tr><td> verbose <td> false <td> The verbose flag for debugging. Prints to console on every message.
- /// <tr><td> pubsub <td> false <td> Whether to ping topics or queues. Uses p2p by default.
- /// <tr><td> username <td> guest <td> The username to access the broker with.
- /// <tr><td> password <td> guest <td> The password to access the broker with.
- /// <tr><td> selector <td> null <td> Not used. Defines a message selector to filter pings with.
- /// <tr><td> destinationCount <td> 1 <td> The number of receivers listening to the pings.
- /// <tr><td> timeout <td> 30000 <td> In milliseconds. The timeout to stop waiting for replies.
- /// <tr><td> commitBatchSize <td> 1 <td> The number of messages per transaction in transactional mode.
- /// <tr><td> uniqueDests <td> true <td> Whether each receivers only listens to one ping destination or all.
- /// <tr><td> durableDests <td> false <td> Whether or not durable destinations are used.
- /// <tr><td> ackMode <td> AUTO_ACK <td> The message acknowledgement mode. Possible values are:
- /// 0 - SESSION_TRANSACTED
- /// 1 - AUTO_ACKNOWLEDGE
- /// 2 - CLIENT_ACKNOWLEDGE
- /// 3 - DUPS_OK_ACKNOWLEDGE
- /// 257 - NO_ACKNOWLEDGE
- /// 258 - PRE_ACKNOWLEDGE
- /// <tr><td> maxPending <td> 0 <td> The maximum size in bytes, of messages sent but not yet received.
- /// Limits the volume of messages currently buffered on the client
- /// or broker. Can help scale test clients by limiting amount of buffered
- /// data to avoid out of memory errors.
- /// </table>
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Provide the names and defaults of all test parameters.
- /// </table>
- /// </summary>
- ///
- /// <remarks> Put a type-safe wrapper around these properties, but continue to store the parameters as properties. This is
- /// simply to ensure that it is a simple matter to serialize/deserialize string/string pairs onto messages.</remarks>
- public class MessagingTestConfigProperties extends ParsedProperties
- {
- // ====================== Connection Properties ==================================
-
- /// <summary> Holds the name of the default connection configuration. </summary>
- public static final string CONNECTION_NAME = "broker";
-
- /// <summary> Holds the name of the property to get the initial context factory name from. </summary>
- public static final string INITIAL_CONTEXT_FACTORY_PROPNAME = "java.naming.factory.initial";
-
- /// <summary> Defines the class to use as the initial context factory by default. </summary>
- public static final string INITIAL_CONTEXT_FACTORY_DEFAULT = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
-
- /// <summary> Holds the name of the property to get the test broker url from. </summary>
- public static final string BROKER_PROPNAME = "qpid.test.broker";
-
- /// <summary> Holds the default broker url for the test. </summary>
- public static final string BROKER_DEFAULT = "vm://:1";
-
- /// <summary> Holds the name of the property to get the test broker virtual path. </summary>
- public static final string VIRTUAL_HOST_PROPNAME = "virtualHost";
-
- /// <summary> Holds the default virtual path for the test. </summary>
- public static final string VIRTUAL_HOST_DEFAULT = "";
-
- /// <summary> Holds the name of the property to get the broker access username from. </summary>
- public static final string USERNAME_PROPNAME = "username";
-
- /// <summary> Holds the default broker log on username. </summary>
- public static final string USERNAME_DEFAULT = "guest";
-
- /// <summary> Holds the name of the property to get the broker access password from. </summary>
- public static final string PASSWORD_PROPNAME = "password";
-
- /// <summary> Holds the default broker log on password. </summary>
- public static final string PASSWORD_DEFAULT = "guest";
-
- // ====================== Messaging Topology Properties ==========================
-
- /// <summary> Holds the name of the property to get the bind publisher procuder flag from. </summary>
- public static final string PUBLISHER_PRODUCER_BIND_PROPNAME = "publisherProducerBind";
-
- /// <summary> Holds the default value of the publisher producer flag. </summary>
- public static final bool PUBLISHER_PRODUCER_BIND_DEFAULT = true;
-
- /// <summary> Holds the name of the property to get the bind publisher procuder flag from. </summary>
- public static final string PUBLISHER_CONSUMER_BIND_PROPNAME = "publisherConsumerBind";
-
- /// <summary> Holds the default value of the publisher consumer flag. </summary>
- public static final bool PUBLISHER_CONSUMER_BIND_DEFAULT = false;
-
- /// <summary> Holds the name of the property to get the bind receivers procuder flag from. </summary>
- public static final string RECEIVER_PRODUCER_BIND_PROPNAME = "receiverProducerBind";
-
- /// <summary> Holds the default value of the receivers producer flag. </summary>
- public static final bool RECEIVER_PRODUCER_BIND_DEFAULT = false;
-
- /// <summary> Holds the name of the property to get the bind receivers procuder flag from. </summary>
- public static final string RECEIVER_CONSUMER_BIND_PROPNAME = "receiverConsumerBind";
-
- /// <summary> Holds the default value of the receivers consumer flag. </summary>
- public static final bool RECEIVER_CONSUMER_BIND_DEFAULT = true;
-
- /// <summary> Holds the name of the property to get the publishers consumer active flag from. </summary>
- public static final string PUBLISHER_CONSUMER_ACTIVE_PROPNAME = "publisherConsumerActive";
-
- /// <summary> Holds the default value of the publishers consumer active flag. </summary>
- public static final bool PUBLISHER_CONSUMER_ACTIVE_DEFAULT = true;
-
- /// <summary> Holds the name of the property to get the receivers consumer active flag from. </summary>
- public static final string RECEIVER_CONSUMER_ACTIVE_PROPNAME = "receiverConsumerActive";
-
- /// <summary> Holds the default value of the receivers consumer active flag. </summary>
- public static final bool RECEIVER_CONSUMER_ACTIVE_DEFAULT = true;
-
- /// <summary> Holds the name of the property to get the destination name root from. </summary>
- public static final string SEND_DESTINATION_NAME_ROOT_PROPNAME = "sendDestinationRoot";
-
- /// <summary> Holds the root of the name of the default destination to send to. </summary>
- public static final string SEND_DESTINATION_NAME_ROOT_DEFAULT = "sendTo";
-
- /// <summary> Holds the name of the property to get the destination name root from. </summary>
- public static final string RECEIVE_DESTINATION_NAME_ROOT_PROPNAME = "receiveDestinationRoot";
-
- /// <summary> Holds the root of the name of the default destination to send to. </summary>
- public static final string RECEIVE_DESTINATION_NAME_ROOT_DEFAULT = "receiveFrom";
-
- /// <summary> Holds the name of the proeprty to get the destination count from. </summary>
- public static final string DESTINATION_COUNT_PROPNAME = "destinationCount";
-
- /// <summary> Defines the default number of destinations to ping. </summary>
- public static final int DESTINATION_COUNT_DEFAULT = 1;
-
- /// <summary> Holds the name of the property to get the p2p or pub/sub messaging mode from. </summary>
- public static final string PUBSUB_PROPNAME = "pubsub";
-
- /// <summary> Holds the pub/sub mode default, true means ping a topic, false means ping a queue. </summary>
- public static final bool PUBSUB_DEFAULT = false;
-
- // ====================== JMS Options and Flags =================================
-
- /// <summary> Holds the name of the property to get the test delivery mode from. </summary>
- public static final string PERSISTENT_MODE_PROPNAME = "persistent";
-
- /// <summary> Holds the message delivery mode to use for the test. </summary>
- public static final bool PERSISTENT_MODE_DEFAULT = false;
-
- /// <summary> Holds the name of the property to get the test transactional mode from. </summary>
- public static final string TRANSACTED_PUBLISHER_PROPNAME = "transactedPublisher";
-
- /// <summary> Holds the transactional mode to use for the test. </summary>
- public static final bool TRANSACTED_PUBLISHER_DEFAULT = false;
-
- /// <summary> Holds the name of the property to get the test transactional mode from. </summary>
- public static final string TRANSACTED_RECEIVER_PROPNAME = "transactedReceiver";
-
- /// <summary> Holds the transactional mode to use for the test. </summary>
- public static final bool TRANSACTED_RECEIVER_DEFAULT = false;
-
- /// <summary> Holds the name of the property to set the no local flag from. </summary>
- public static final string NO_LOCAL_PROPNAME = "noLocal";
-
- /// <summary> Defines the default value of the no local flag to use when consuming messages. </summary>
- public static final bool NO_LOCAL_DEFAULT = false;
-
- /// <summary> Holds the name of the property to get the message acknowledgement mode from. </summary>
- public static final string ACK_MODE_PROPNAME = "ackMode";
-
- /// <summary> Defines the default message acknowledgement mode. </summary>
- public static final int ACK_MODE_DEFAULT = Session.AUTO_ACKNOWLEDGE;
-
- /// <summary> Holds the name of the property to get the durable subscriptions flag from, when doing pub/sub messaging. </summary>
- public static final string DURABLE_SUBSCRIPTION_PROPNAME = "durableSubscription";
-
- /// <summary> Defines the default value of the durable subscriptions flag. </summary>
- public static final bool DURABLE_SUBSCRIPTION_DEFAULT = false;
-
- // ====================== Qpid/AMQP Options and Flags ================================
-
- /// <summary> Holds the name of the property to set the exclusive flag from. </summary>
- public static final string EXCLUSIVE_PROPNAME = "exclusive";
-
- /// <summary> Defines the default value of the exclusive flag to use when consuming messages. </summary>
- public static final bool EXCLUSIVE_DEFAULT = false;
-
- /// <summary> Holds the name of the property to set the immediate flag from. </summary>
- public static final string IMMEDIATE_PROPNAME = "immediate";
-
- /// <summary> Defines the default value of the immediate flag to use when sending messages. </summary>
- public static final bool IMMEDIATE_DEFAULT = false;
-
- /// <summary> Holds the name of the property to set the mandatory flag from. </summary>
- public static final string MANDATORY_PROPNAME = "mandatory";
-
- /// <summary> Defines the default value of the mandatory flag to use when sending messages. </summary>
- public static final bool MANDATORY_DEFAULT = false;
-
- /// <summary> Holds the name of the property to get the durable destinations flag from. </summary>
- public static final string DURABLE_DESTS_PROPNAME = "durableDests";
-
- /// <summary> Default value for the durable destinations flag. </summary>
- public static final bool DURABLE_DESTS_DEFAULT = false;
-
- /// <summary> Holds the name of the property to set the prefetch size from. </summary>
- public static final string PREFETCH_PROPNAME = "prefetch";
-
- /// <summary> Defines the default prefetch size to use when consuming messages. </summary>
- public static final int PREFETCH_DEFAULT = 100;
-
- // ====================== Common Test Parameters ================================
-
- /// <summary> Holds the name of the property to get the test message size from. </summary>
- public static final string MESSAGE_SIZE_PROPNAME = "messageSize";
-
- /// <summary> Used to set up a default message size. </summary>
- public static final int MESSAGE_SIZE_DEAFULT = 0;
-
- /// <summary> Holds the name of the property to get the message rate from. </summary>
- public static final string RATE_PROPNAME = "rate";
-
- /// <summary> Defines the default rate (in pings per second) to send pings at. 0 means as fast as possible, no restriction. </summary>
- public static final int RATE_DEFAULT = 0;
-
- /// <summary> Holds the name of the proeprty to get the. </summary>
- public static final string SELECTOR_PROPNAME = "selector";
-
- /// <summary> Holds the default message selector. </summary>
- public static final string SELECTOR_DEFAULT = "";
-
- /// <summary> Holds the name of the property to get the waiting timeout for response messages. </summary>
- public static final string TIMEOUT_PROPNAME = "timeout";
-
- /// <summary> Default time to wait before assuming that a ping has timed out. </summary>
- public static final long TIMEOUT_DEFAULT = 30000;
-
- /// <summary> Holds the name of the property to get the commit batch size from. </summary>
- public static final string TX_BATCH_SIZE_PROPNAME = "commitBatchSize";
-
- /// <summary> Defines the default number of pings to send in each transaction when running transactionally. </summary>
- public static final int TX_BATCH_SIZE_DEFAULT = 1;
-
- /// <summary> Holds the name of the property to set the maximum amount of pending message data for a producer to hold. </summary>
- public static final string MAX_PENDING_PROPNAME = "maxPending";
-
- /// <summary> Defines the default maximum quantity of pending message data to allow producers to hold. </summary>
- public static final int MAX_PENDING_DEFAULT = 0;
-
- /// <summary> Holds the name of the property to get the publisher rollback flag from. </summary>
- public static final string ROLLBACK_PUBLISHER_PROPNAME = "rollbackPublisher";
-
- /// <summary> Holds the default publisher roll back setting. </summary>
- public static final bool ROLLBACK_PUBLISHER_DEFAULT = false;
-
- /// <summary> Holds the name of the property to get the publisher rollback flag from. </summary>
- public static final string ROLLBACK_RECEIVER_PROPNAME = "rollbackReceiver";
-
- /// <summary> Holds the default publisher roll back setting. </summary>
- public static final bool ROLLBACK_RECEIVER_DEFAULT = false;
-
- // ====================== Options that control the bahviour of the test framework. =========================
-
- /// <summary> Holds the name of the property to get the behavioural mode of not applicable assertions. </summary>
- public static final string NOT_APPLICABLE_ASSERTION_PROPNAME = "notApplicableAssertion";
-
- /// <summary> Holds the default behavioral mode of not applicable assertions, which is logging them as a warning. </summary>
- public static final string NOT_APPLICABLE_ASSERTION_DEFAULT = "warn";
-
- /// <summary> Holds the name of the property to get the verbose mode proeprty from. </summary>
- public static final string VERBOSE_PROPNAME = "verbose";
-
- /// <summary> Holds the default verbose mode. </summary>
- public static final bool VERBOSE_DEFAULT = false;
-
- /// <summary> Holds the default configuration properties. </summary>
- public static ParsedProperties defaults = new ParsedProperties();
-
- static
- {
- defaults.setPropertyIfNull(INITIAL_CONTEXT_FACTORY_PROPNAME, INITIAL_CONTEXT_FACTORY_DEFAULT);
- defaults.setPropertyIfNull(BROKER_PROPNAME, BROKER_DEFAULT);
- defaults.setPropertyIfNull(VIRTUAL_HOST_PROPNAME, VIRTUAL_HOST_DEFAULT);
- defaults.setPropertyIfNull(USERNAME_PROPNAME, USERNAME_DEFAULT);
- defaults.setPropertyIfNull(PASSWORD_PROPNAME, PASSWORD_DEFAULT);
-
- defaults.setPropertyIfNull(PUBLISHER_PRODUCER_BIND_PROPNAME, PUBLISHER_PRODUCER_BIND_DEFAULT);
- defaults.setPropertyIfNull(PUBLISHER_CONSUMER_BIND_PROPNAME, PUBLISHER_CONSUMER_BIND_DEFAULT);
- defaults.setPropertyIfNull(RECEIVER_PRODUCER_BIND_PROPNAME, RECEIVER_PRODUCER_BIND_DEFAULT);
- defaults.setPropertyIfNull(RECEIVER_CONSUMER_BIND_PROPNAME, RECEIVER_CONSUMER_BIND_DEFAULT);
- defaults.setPropertyIfNull(PUBLISHER_CONSUMER_ACTIVE_PROPNAME, PUBLISHER_CONSUMER_ACTIVE_DEFAULT);
- defaults.setPropertyIfNull(RECEIVER_CONSUMER_ACTIVE_PROPNAME, RECEIVER_CONSUMER_ACTIVE_DEFAULT);
- defaults.setPropertyIfNull(SEND_DESTINATION_NAME_ROOT_PROPNAME, SEND_DESTINATION_NAME_ROOT_DEFAULT);
- defaults.setPropertyIfNull(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME, RECEIVE_DESTINATION_NAME_ROOT_DEFAULT);
- defaults.setPropertyIfNull(DESTINATION_COUNT_PROPNAME, DESTINATION_COUNT_DEFAULT);
- defaults.setPropertyIfNull(PUBSUB_PROPNAME, PUBSUB_DEFAULT);
-
- defaults.setPropertyIfNull(PERSISTENT_MODE_PROPNAME, PERSISTENT_MODE_DEFAULT);
- defaults.setPropertyIfNull(TRANSACTED_PUBLISHER_PROPNAME, TRANSACTED_PUBLISHER_DEFAULT);
- defaults.setPropertyIfNull(TRANSACTED_RECEIVER_PROPNAME, TRANSACTED_RECEIVER_DEFAULT);
- defaults.setPropertyIfNull(NO_LOCAL_PROPNAME, NO_LOCAL_DEFAULT);
- defaults.setPropertyIfNull(ACK_MODE_PROPNAME, ACK_MODE_DEFAULT);
- defaults.setPropertyIfNull(DURABLE_SUBSCRIPTION_PROPNAME, DURABLE_SUBSCRIPTION_DEFAULT);
-
- defaults.setPropertyIfNull(EXCLUSIVE_PROPNAME, EXCLUSIVE_DEFAULT);
- defaults.setPropertyIfNull(IMMEDIATE_PROPNAME, IMMEDIATE_DEFAULT);
- defaults.setPropertyIfNull(MANDATORY_PROPNAME, MANDATORY_DEFAULT);
- defaults.setPropertyIfNull(DURABLE_DESTS_PROPNAME, DURABLE_DESTS_DEFAULT);
- defaults.setPropertyIfNull(PREFETCH_PROPNAME, PREFETCH_DEFAULT);
-
- defaults.setPropertyIfNull(MESSAGE_SIZE_PROPNAME, MESSAGE_SIZE_DEAFULT);
- defaults.setPropertyIfNull(RATE_PROPNAME, RATE_DEFAULT);
- defaults.setPropertyIfNull(SELECTOR_PROPNAME, SELECTOR_DEFAULT);
- defaults.setPropertyIfNull(TIMEOUT_PROPNAME, TIMEOUT_DEFAULT);
- defaults.setPropertyIfNull(TX_BATCH_SIZE_PROPNAME, TX_BATCH_SIZE_DEFAULT);
- defaults.setPropertyIfNull(MAX_PENDING_PROPNAME, MAX_PENDING_DEFAULT);
- defaults.setPropertyIfNull(ROLLBACK_PUBLISHER_PROPNAME, ROLLBACK_PUBLISHER_DEFAULT);
- defaults.setPropertyIfNull(ROLLBACK_RECEIVER_PROPNAME, ROLLBACK_RECEIVER_DEFAULT);
-
- defaults.setPropertyIfNull(NOT_APPLICABLE_ASSERTION_PROPNAME, NOT_APPLICABLE_ASSERTION_DEFAULT);
- defaults.setPropertyIfNull(VERBOSE_PROPNAME, VERBOSE_DEFAULT);
- }
-
- /// <summary> Creates a test configuration based on the defaults. </summary>
- public MessagingTestConfigProperties()
- {
- super(defaults);
- }
-
- /// <summary>
- /// Creates a test configuration based on the supplied properties.
- /// </summary>
- /// <param name="properties"> The test configuration. </param>
- public MessagingTestConfigProperties(Properties properties)
- {
- super(properties);
- }
-
- /// <summary>
- /// The size of test messages to send.
- /// </summary>
- /// <return> The size of test messages to send. </return>
- public int getMessageSize()
- {
- return getPropertyAsInteger(MESSAGE_SIZE_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that the publishing producer should be set up to publish to a destination.
- /// </summary>
- /// <return> Flag to indicate that the publishing producer should be set up to publish to a destination. </return>
- public bool getPublisherProducerBind()
- {
- return getPropertyAsBoolean(PUBLISHER_PRODUCER_BIND_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that the publishing consumer should be set up to receive from a destination.
- /// </summary>
- /// <return> Flag to indicate that the publishing consumer should be set up to receive from a destination. </return>
- public bool getPublisherConsumerBind()
- {
- return getPropertyAsBoolean(PUBLISHER_CONSUMER_BIND_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that the receiving producer should be set up to publish to a destination.
- /// </summary>
- /// <return> Flag to indicate that the receiving producer should be set up to publish to a destination. </return>
- public bool getReceiverProducerBind()
- {
- return getPropertyAsBoolean(RECEIVER_PRODUCER_BIND_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that the receiving consumer should be set up to receive from a destination.
- /// </summary>
- /// <return> Flag to indicate that the receiving consumer should be set up to receive from a destination. </return>
- public bool getReceiverConsumerBind()
- {
- return getPropertyAsBoolean(RECEIVER_CONSUMER_BIND_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that the publishing consumer should be created and actively listening.
- /// </summary>
- /// <return> Flag to indicate that the publishing consumer should be created. </return>
- public bool getPublisherConsumerActive()
- {
- return getPropertyAsBoolean(PUBLISHER_CONSUMER_ACTIVE_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that the receiving consumers should be created and actively listening.
- /// </summary>
- /// <return> Flag to indicate that the receiving consumers should be created and actively listening. </return>
- public bool getReceiverConsumerActive()
- {
- return getPropertyAsBoolean(RECEIVER_CONSUMER_ACTIVE_PROPNAME);
- }
-
- /// <summary>
- /// A root to create all test destination names from.
- /// </summary>
- /// <return> A root to create all test destination names from. </return>
- public string getSendDestinationNameRoot()
- {
- return getProperty(SEND_DESTINATION_NAME_ROOT_PROPNAME);
- }
-
- /// <summary>
- /// A root to create all receiving destination names from.
- /// </summary>
- /// <return> A root to create all receiving destination names from. </return>
- public string getReceiveDestinationNameRoot()
- {
- return getProperty(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that persistent messages should be used.
- /// </summary>
- /// <return> Flag to indicate that persistent messages should be used. </return>
- public bool getPersistentMode()
- {
- return getPropertyAsBoolean(PERSISTENT_MODE_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that transactional messages should be sent by the publisher.
- /// </summary>
- /// <return> Flag to indicate that transactional messages should be sent by the publisher. </return>
- public bool getPublisherTransacted()
- {
- return getPropertyAsBoolean(TRANSACTED_PUBLISHER_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that transactional receives should be used by the receiver.
- /// </summary>
- /// <return> Flag to indicate that transactional receives should be used by the receiver. </return>
- public bool getReceiverTransacted()
- {
- return getPropertyAsBoolean(TRANSACTED_PUBLISHER_PROPNAME);
- }
-
- /// <summary>
- /// The name of the virtual host to run all tests over.
- /// </summary>
- /// <return> The name of the virtual host to run all tests over. </return>
- public string getVirtualHost()
- {
- return getProperty(VIRTUAL_HOST_PROPNAME);
- }
-
- /// <summary>
- /// Limiting rate for each sender in messages per second, or zero for unlimited.
- /// </summary>
- /// <return> Limiting rate for each sender in messages per second, or zero for unlimited. </return>
- public string getRate()
- {
- return getProperty(RATE_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that test messages should be received publish/subscribe style by all receivers.
- /// </summary>
- /// <return> Flag to indicate that test messages should be received publish/subscribe style by all receivers. </return>
- public bool getPubsub()
- {
- return getPropertyAsBoolean(PUBSUB_PROPNAME);
- }
-
- /// <summary>
- /// The username credentials to run tests with.
- /// </summary>
- /// <return> The username credentials to run tests with. </return>
- public string getUsername()
- {
- return getProperty(USERNAME_PROPNAME);
- }
-
- /// <summary>
- /// The password credentials to run tests with.
- /// </summary>
- /// <return> The password credentials to run tests with. </return>
- public string getPassword()
- {
- return getProperty(PASSWORD_PROPNAME);
- }
-
- /// <summary>
- /// The timeout duration to fail tests on, should they receive no messages within it.
- /// </summary>
- /// <return> The timeout duration to fail tests on, should they receive no messages within it. </return>
- public long getTimeout()
- {
- return getPropertyAsLong(TIMEOUT_PROPNAME);
- }
-
- /// <summary>
- /// The number of messages to batch into each transaction in transational tests.
- /// </summary>
- /// <return> The number of messages to batch into each transaction in transational tests. </return>
- public int getTxBatchSize()
- {
- return getPropertyAsInteger(TX_BATCH_SIZE_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that tests should use durable destinations.
- /// </summary>
- /// <return> Flag to indicate that tests should use durable destinations. </return>
- public bool getDurableDests()
- {
- return getPropertyAsBoolean(DURABLE_DESTS_PROPNAME);
- }
-
- /// <summary>
- /// The ack mode for message receivers to use.
- /// </summary>
- /// <return> The ack mode for message receivers to use. </return>
- public int getAckMode()
- {
- return getPropertyAsInteger(ACK_MODE_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that tests should use durable subscriptions.
- /// </summary>
- /// <return> Flag to indicate that tests should use durable subscriptions. </return>
- public bool getDurableSubscription()
- {
- return getPropertyAsBoolean(DURABLE_SUBSCRIPTION_PROPNAME);
- }
-
- /// <summary>
- /// The maximum amount of in-flight data, in bytes, that tests should send at any time.
- /// </summary>
- /// <return> The maximum amount of in-flight data, in bytes, that tests should send at any time. </return>
- public int getMaxPending()
- {
- return getPropertyAsInteger(MAX_PENDING_PROPNAME);
- }
-
- /// <summary>
- /// The size of the prefetch queue to use.
- /// </summary>
- /// <return> The size of the prefetch queue to use. </return>
- public int getPrefetch()
- {
- return getPropertyAsInteger(PREFETCH_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that subscriptions should be no-local.
- /// </summary>
- /// <return> Flag to indicate that subscriptions should be no-local. </return>
- public bool getNoLocal()
- {
- return getPropertyAsBoolean(NO_LOCAL_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that subscriptions should be exclusive.
- /// </summary>
- /// <return> Flag to indicate that subscriptions should be exclusive. </return>
- public bool getExclusive()
- {
- return getPropertyAsBoolean(EXCLUSIVE_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that messages must be delivered immediately.
- /// </summary>
- /// <return> Flag to indicate that messages must be delivered immediately. </return>
- public bool getImmediate()
- {
- return getPropertyAsBoolean(IMMEDIATE_PROPNAME);
- }
-
- /// <summary>
- /// Flag to indicate that messages must be routable.
- /// </summary>
- /// <return> Flag to indicate that messages must be routable. </return>
- public bool getMandatory()
- {
- return getPropertyAsBoolean(MANDATORY_PROPNAME);
- }
-
- /// <summary>
- /// Gets the value of a flag to indicate that the publisher should rollback all messages sent.
- /// </summary>
- /// <return> A flag to indicate that the publisher should rollback all messages sent. </return>
- public bool getRollbackPublisher()
- {
- return getPropertyAsBoolean(ROLLBACK_PUBLISHER_PROPNAME);
- }
-
- /// <summary>
- /// Gets the value of a flag to indicate that the receiver should rollback all messages received, then receive them
- /// again.
- /// </summary>
- /// <return> A flag to indicate that the publisher should rollback all messages received. </return>
- public bool getRollbackReceiver()
- {
- return getPropertyAsBoolean(ROLLBACK_RECEIVER_PROPNAME);
- }
-
- /// <summary>
- /// Gets the behavioural mode of not applicable assertions. Should be one of 'quiet', 'warn' or 'fail'.
- /// </summary>
- /// <return> The behavioural mode of not applicable assertions. </return>
- public string getNotApplicableAssertionMode()
- {
- return getProperty(NOT_APPLICABLE_ASSERTION_PROPNAME);
- }
- }
- */
+/*
+ *
+ * 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 uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+
+//using javax.jms.Session;
+
+//using java.util.Properties;
+
+namespace Apache.Qpid.Integration.Tests.framework
+{
+ public class TestModel //extends ParsedProperties
+ {}
+
+ /*
+ /// <summary>
+ /// MessagingTestConfigProperties defines a set of property names and default values for specifying a messaging topology,
+ /// and test parameters for running a messaging test over that topology. A Properties object holding some of these
+ /// properties, superimposed onto the defaults, is used to establish test topologies and control test behaviour.
+ ///
+ /// <p/>A complete list of the parameters, default values and comments on their usage is provided here:
+ ///
+ /// <p/><table><caption>Parameters</caption>
+ /// <tr><th> Parameter <th> Default <th> Comments
+ /// <tr><td> messageSize <td> 0 <td> Message size in bytes. Not including any headers.
+ /// <tr><td> destinationName <td> ping <td> The root name to use to generate destination names to ping.
+ /// <tr><td> persistent <td> false <td> Determines whether peristent delivery is used.
+ /// <tr><td> transacted <td> false <td> Determines whether messages are sent/received in transactions.
+ /// <tr><td> broker <td> tcp://localhost:5672 <td> Determines the broker to connect to.
+ /// <tr><td> virtualHost <td> test <td> Determines the virtual host to send all ping over.
+ /// <tr><td> rate <td> 0 <td> The maximum rate (in hertz) to send messages at. 0 means no limit.
+ /// <tr><td> verbose <td> false <td> The verbose flag for debugging. Prints to console on every message.
+ /// <tr><td> pubsub <td> false <td> Whether to ping topics or queues. Uses p2p by default.
+ /// <tr><td> username <td> guest <td> The username to access the broker with.
+ /// <tr><td> password <td> guest <td> The password to access the broker with.
+ /// <tr><td> selector <td> null <td> Not used. Defines a message selector to filter pings with.
+ /// <tr><td> destinationCount <td> 1 <td> The number of receivers listening to the pings.
+ /// <tr><td> timeout <td> 30000 <td> In milliseconds. The timeout to stop waiting for replies.
+ /// <tr><td> commitBatchSize <td> 1 <td> The number of messages per transaction in transactional mode.
+ /// <tr><td> uniqueDests <td> true <td> Whether each receivers only listens to one ping destination or all.
+ /// <tr><td> durableDests <td> false <td> Whether or not durable destinations are used.
+ /// <tr><td> ackMode <td> AUTO_ACK <td> The message acknowledgement mode. Possible values are:
+ /// 0 - SESSION_TRANSACTED
+ /// 1 - AUTO_ACKNOWLEDGE
+ /// 2 - CLIENT_ACKNOWLEDGE
+ /// 3 - DUPS_OK_ACKNOWLEDGE
+ /// 257 - NO_ACKNOWLEDGE
+ /// 258 - PRE_ACKNOWLEDGE
+ /// <tr><td> maxPending <td> 0 <td> The maximum size in bytes, of messages sent but not yet received.
+ /// Limits the volume of messages currently buffered on the client
+ /// or broker. Can help scale test clients by limiting amount of buffered
+ /// data to avoid out of memory errors.
+ /// </table>
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Provide the names and defaults of all test parameters.
+ /// </table>
+ /// </summary>
+ ///
+ /// <remarks> Put a type-safe wrapper around these properties, but continue to store the parameters as properties. This is
+ /// simply to ensure that it is a simple matter to serialize/deserialize string/string pairs onto messages.</remarks>
+ public class MessagingTestConfigProperties extends ParsedProperties
+ {
+ // ====================== Connection Properties ==================================
+
+ /// <summary> Holds the name of the default connection configuration. </summary>
+ public static final string CONNECTION_NAME = "broker";
+
+ /// <summary> Holds the name of the property to get the initial context factory name from. </summary>
+ public static final string INITIAL_CONTEXT_FACTORY_PROPNAME = "java.naming.factory.initial";
+
+ /// <summary> Defines the class to use as the initial context factory by default. </summary>
+ public static final string INITIAL_CONTEXT_FACTORY_DEFAULT = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
+
+ /// <summary> Holds the name of the property to get the test broker url from. </summary>
+ public static final string BROKER_PROPNAME = "qpid.test.broker";
+
+ /// <summary> Holds the default broker url for the test. </summary>
+ public static final string BROKER_DEFAULT = "vm://:1";
+
+ /// <summary> Holds the name of the property to get the test broker virtual path. </summary>
+ public static final string VIRTUAL_HOST_PROPNAME = "virtualHost";
+
+ /// <summary> Holds the default virtual path for the test. </summary>
+ public static final string VIRTUAL_HOST_DEFAULT = "";
+
+ /// <summary> Holds the name of the property to get the broker access username from. </summary>
+ public static final string USERNAME_PROPNAME = "username";
+
+ /// <summary> Holds the default broker log on username. </summary>
+ public static final string USERNAME_DEFAULT = "guest";
+
+ /// <summary> Holds the name of the property to get the broker access password from. </summary>
+ public static final string PASSWORD_PROPNAME = "password";
+
+ /// <summary> Holds the default broker log on password. </summary>
+ public static final string PASSWORD_DEFAULT = "guest";
+
+ // ====================== Messaging Topology Properties ==========================
+
+ /// <summary> Holds the name of the property to get the bind publisher procuder flag from. </summary>
+ public static final string PUBLISHER_PRODUCER_BIND_PROPNAME = "publisherProducerBind";
+
+ /// <summary> Holds the default value of the publisher producer flag. </summary>
+ public static final bool PUBLISHER_PRODUCER_BIND_DEFAULT = true;
+
+ /// <summary> Holds the name of the property to get the bind publisher procuder flag from. </summary>
+ public static final string PUBLISHER_CONSUMER_BIND_PROPNAME = "publisherConsumerBind";
+
+ /// <summary> Holds the default value of the publisher consumer flag. </summary>
+ public static final bool PUBLISHER_CONSUMER_BIND_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to get the bind receivers procuder flag from. </summary>
+ public static final string RECEIVER_PRODUCER_BIND_PROPNAME = "receiverProducerBind";
+
+ /// <summary> Holds the default value of the receivers producer flag. </summary>
+ public static final bool RECEIVER_PRODUCER_BIND_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to get the bind receivers procuder flag from. </summary>
+ public static final string RECEIVER_CONSUMER_BIND_PROPNAME = "receiverConsumerBind";
+
+ /// <summary> Holds the default value of the receivers consumer flag. </summary>
+ public static final bool RECEIVER_CONSUMER_BIND_DEFAULT = true;
+
+ /// <summary> Holds the name of the property to get the publishers consumer active flag from. </summary>
+ public static final string PUBLISHER_CONSUMER_ACTIVE_PROPNAME = "publisherConsumerActive";
+
+ /// <summary> Holds the default value of the publishers consumer active flag. </summary>
+ public static final bool PUBLISHER_CONSUMER_ACTIVE_DEFAULT = true;
+
+ /// <summary> Holds the name of the property to get the receivers consumer active flag from. </summary>
+ public static final string RECEIVER_CONSUMER_ACTIVE_PROPNAME = "receiverConsumerActive";
+
+ /// <summary> Holds the default value of the receivers consumer active flag. </summary>
+ public static final bool RECEIVER_CONSUMER_ACTIVE_DEFAULT = true;
+
+ /// <summary> Holds the name of the property to get the destination name root from. </summary>
+ public static final string SEND_DESTINATION_NAME_ROOT_PROPNAME = "sendDestinationRoot";
+
+ /// <summary> Holds the root of the name of the default destination to send to. </summary>
+ public static final string SEND_DESTINATION_NAME_ROOT_DEFAULT = "sendTo";
+
+ /// <summary> Holds the name of the property to get the destination name root from. </summary>
+ public static final string RECEIVE_DESTINATION_NAME_ROOT_PROPNAME = "receiveDestinationRoot";
+
+ /// <summary> Holds the root of the name of the default destination to send to. </summary>
+ public static final string RECEIVE_DESTINATION_NAME_ROOT_DEFAULT = "receiveFrom";
+
+ /// <summary> Holds the name of the proeprty to get the destination count from. </summary>
+ public static final string DESTINATION_COUNT_PROPNAME = "destinationCount";
+
+ /// <summary> Defines the default number of destinations to ping. </summary>
+ public static final int DESTINATION_COUNT_DEFAULT = 1;
+
+ /// <summary> Holds the name of the property to get the p2p or pub/sub messaging mode from. </summary>
+ public static final string PUBSUB_PROPNAME = "pubsub";
+
+ /// <summary> Holds the pub/sub mode default, true means ping a topic, false means ping a queue. </summary>
+ public static final bool PUBSUB_DEFAULT = false;
+
+ // ====================== JMS Options and Flags =================================
+
+ /// <summary> Holds the name of the property to get the test delivery mode from. </summary>
+ public static final string PERSISTENT_MODE_PROPNAME = "persistent";
+
+ /// <summary> Holds the message delivery mode to use for the test. </summary>
+ public static final bool PERSISTENT_MODE_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to get the test transactional mode from. </summary>
+ public static final string TRANSACTED_PUBLISHER_PROPNAME = "transactedPublisher";
+
+ /// <summary> Holds the transactional mode to use for the test. </summary>
+ public static final bool TRANSACTED_PUBLISHER_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to get the test transactional mode from. </summary>
+ public static final string TRANSACTED_RECEIVER_PROPNAME = "transactedReceiver";
+
+ /// <summary> Holds the transactional mode to use for the test. </summary>
+ public static final bool TRANSACTED_RECEIVER_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to set the no local flag from. </summary>
+ public static final string NO_LOCAL_PROPNAME = "noLocal";
+
+ /// <summary> Defines the default value of the no local flag to use when consuming messages. </summary>
+ public static final bool NO_LOCAL_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to get the message acknowledgement mode from. </summary>
+ public static final string ACK_MODE_PROPNAME = "ackMode";
+
+ /// <summary> Defines the default message acknowledgement mode. </summary>
+ public static final int ACK_MODE_DEFAULT = Session.AUTO_ACKNOWLEDGE;
+
+ /// <summary> Holds the name of the property to get the durable subscriptions flag from, when doing pub/sub messaging. </summary>
+ public static final string DURABLE_SUBSCRIPTION_PROPNAME = "durableSubscription";
+
+ /// <summary> Defines the default value of the durable subscriptions flag. </summary>
+ public static final bool DURABLE_SUBSCRIPTION_DEFAULT = false;
+
+ // ====================== Qpid/AMQP Options and Flags ================================
+
+ /// <summary> Holds the name of the property to set the exclusive flag from. </summary>
+ public static final string EXCLUSIVE_PROPNAME = "exclusive";
+
+ /// <summary> Defines the default value of the exclusive flag to use when consuming messages. </summary>
+ public static final bool EXCLUSIVE_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to set the immediate flag from. </summary>
+ public static final string IMMEDIATE_PROPNAME = "immediate";
+
+ /// <summary> Defines the default value of the immediate flag to use when sending messages. </summary>
+ public static final bool IMMEDIATE_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to set the mandatory flag from. </summary>
+ public static final string MANDATORY_PROPNAME = "mandatory";
+
+ /// <summary> Defines the default value of the mandatory flag to use when sending messages. </summary>
+ public static final bool MANDATORY_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to get the durable destinations flag from. </summary>
+ public static final string DURABLE_DESTS_PROPNAME = "durableDests";
+
+ /// <summary> Default value for the durable destinations flag. </summary>
+ public static final bool DURABLE_DESTS_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to set the prefetch size from. </summary>
+ public static final string PREFETCH_PROPNAME = "prefetch";
+
+ /// <summary> Defines the default prefetch size to use when consuming messages. </summary>
+ public static final int PREFETCH_DEFAULT = 100;
+
+ // ====================== Common Test Parameters ================================
+
+ /// <summary> Holds the name of the property to get the test message size from. </summary>
+ public static final string MESSAGE_SIZE_PROPNAME = "messageSize";
+
+ /// <summary> Used to set up a default message size. </summary>
+ public static final int MESSAGE_SIZE_DEAFULT = 0;
+
+ /// <summary> Holds the name of the property to get the message rate from. </summary>
+ public static final string RATE_PROPNAME = "rate";
+
+ /// <summary> Defines the default rate (in pings per second) to send pings at. 0 means as fast as possible, no restriction. </summary>
+ public static final int RATE_DEFAULT = 0;
+
+ /// <summary> Holds the name of the proeprty to get the. </summary>
+ public static final string SELECTOR_PROPNAME = "selector";
+
+ /// <summary> Holds the default message selector. </summary>
+ public static final string SELECTOR_DEFAULT = "";
+
+ /// <summary> Holds the name of the property to get the waiting timeout for response messages. </summary>
+ public static final string TIMEOUT_PROPNAME = "timeout";
+
+ /// <summary> Default time to wait before assuming that a ping has timed out. </summary>
+ public static final long TIMEOUT_DEFAULT = 30000;
+
+ /// <summary> Holds the name of the property to get the commit batch size from. </summary>
+ public static final string TX_BATCH_SIZE_PROPNAME = "commitBatchSize";
+
+ /// <summary> Defines the default number of pings to send in each transaction when running transactionally. </summary>
+ public static final int TX_BATCH_SIZE_DEFAULT = 1;
+
+ /// <summary> Holds the name of the property to set the maximum amount of pending message data for a producer to hold. </summary>
+ public static final string MAX_PENDING_PROPNAME = "maxPending";
+
+ /// <summary> Defines the default maximum quantity of pending message data to allow producers to hold. </summary>
+ public static final int MAX_PENDING_DEFAULT = 0;
+
+ /// <summary> Holds the name of the property to get the publisher rollback flag from. </summary>
+ public static final string ROLLBACK_PUBLISHER_PROPNAME = "rollbackPublisher";
+
+ /// <summary> Holds the default publisher roll back setting. </summary>
+ public static final bool ROLLBACK_PUBLISHER_DEFAULT = false;
+
+ /// <summary> Holds the name of the property to get the publisher rollback flag from. </summary>
+ public static final string ROLLBACK_RECEIVER_PROPNAME = "rollbackReceiver";
+
+ /// <summary> Holds the default publisher roll back setting. </summary>
+ public static final bool ROLLBACK_RECEIVER_DEFAULT = false;
+
+ // ====================== Options that control the bahviour of the test framework. =========================
+
+ /// <summary> Holds the name of the property to get the behavioural mode of not applicable assertions. </summary>
+ public static final string NOT_APPLICABLE_ASSERTION_PROPNAME = "notApplicableAssertion";
+
+ /// <summary> Holds the default behavioral mode of not applicable assertions, which is logging them as a warning. </summary>
+ public static final string NOT_APPLICABLE_ASSERTION_DEFAULT = "warn";
+
+ /// <summary> Holds the name of the property to get the verbose mode proeprty from. </summary>
+ public static final string VERBOSE_PROPNAME = "verbose";
+
+ /// <summary> Holds the default verbose mode. </summary>
+ public static final bool VERBOSE_DEFAULT = false;
+
+ /// <summary> Holds the default configuration properties. </summary>
+ public static ParsedProperties defaults = new ParsedProperties();
+
+ static
+ {
+ defaults.setPropertyIfNull(INITIAL_CONTEXT_FACTORY_PROPNAME, INITIAL_CONTEXT_FACTORY_DEFAULT);
+ defaults.setPropertyIfNull(BROKER_PROPNAME, BROKER_DEFAULT);
+ defaults.setPropertyIfNull(VIRTUAL_HOST_PROPNAME, VIRTUAL_HOST_DEFAULT);
+ defaults.setPropertyIfNull(USERNAME_PROPNAME, USERNAME_DEFAULT);
+ defaults.setPropertyIfNull(PASSWORD_PROPNAME, PASSWORD_DEFAULT);
+
+ defaults.setPropertyIfNull(PUBLISHER_PRODUCER_BIND_PROPNAME, PUBLISHER_PRODUCER_BIND_DEFAULT);
+ defaults.setPropertyIfNull(PUBLISHER_CONSUMER_BIND_PROPNAME, PUBLISHER_CONSUMER_BIND_DEFAULT);
+ defaults.setPropertyIfNull(RECEIVER_PRODUCER_BIND_PROPNAME, RECEIVER_PRODUCER_BIND_DEFAULT);
+ defaults.setPropertyIfNull(RECEIVER_CONSUMER_BIND_PROPNAME, RECEIVER_CONSUMER_BIND_DEFAULT);
+ defaults.setPropertyIfNull(PUBLISHER_CONSUMER_ACTIVE_PROPNAME, PUBLISHER_CONSUMER_ACTIVE_DEFAULT);
+ defaults.setPropertyIfNull(RECEIVER_CONSUMER_ACTIVE_PROPNAME, RECEIVER_CONSUMER_ACTIVE_DEFAULT);
+ defaults.setPropertyIfNull(SEND_DESTINATION_NAME_ROOT_PROPNAME, SEND_DESTINATION_NAME_ROOT_DEFAULT);
+ defaults.setPropertyIfNull(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME, RECEIVE_DESTINATION_NAME_ROOT_DEFAULT);
+ defaults.setPropertyIfNull(DESTINATION_COUNT_PROPNAME, DESTINATION_COUNT_DEFAULT);
+ defaults.setPropertyIfNull(PUBSUB_PROPNAME, PUBSUB_DEFAULT);
+
+ defaults.setPropertyIfNull(PERSISTENT_MODE_PROPNAME, PERSISTENT_MODE_DEFAULT);
+ defaults.setPropertyIfNull(TRANSACTED_PUBLISHER_PROPNAME, TRANSACTED_PUBLISHER_DEFAULT);
+ defaults.setPropertyIfNull(TRANSACTED_RECEIVER_PROPNAME, TRANSACTED_RECEIVER_DEFAULT);
+ defaults.setPropertyIfNull(NO_LOCAL_PROPNAME, NO_LOCAL_DEFAULT);
+ defaults.setPropertyIfNull(ACK_MODE_PROPNAME, ACK_MODE_DEFAULT);
+ defaults.setPropertyIfNull(DURABLE_SUBSCRIPTION_PROPNAME, DURABLE_SUBSCRIPTION_DEFAULT);
+
+ defaults.setPropertyIfNull(EXCLUSIVE_PROPNAME, EXCLUSIVE_DEFAULT);
+ defaults.setPropertyIfNull(IMMEDIATE_PROPNAME, IMMEDIATE_DEFAULT);
+ defaults.setPropertyIfNull(MANDATORY_PROPNAME, MANDATORY_DEFAULT);
+ defaults.setPropertyIfNull(DURABLE_DESTS_PROPNAME, DURABLE_DESTS_DEFAULT);
+ defaults.setPropertyIfNull(PREFETCH_PROPNAME, PREFETCH_DEFAULT);
+
+ defaults.setPropertyIfNull(MESSAGE_SIZE_PROPNAME, MESSAGE_SIZE_DEAFULT);
+ defaults.setPropertyIfNull(RATE_PROPNAME, RATE_DEFAULT);
+ defaults.setPropertyIfNull(SELECTOR_PROPNAME, SELECTOR_DEFAULT);
+ defaults.setPropertyIfNull(TIMEOUT_PROPNAME, TIMEOUT_DEFAULT);
+ defaults.setPropertyIfNull(TX_BATCH_SIZE_PROPNAME, TX_BATCH_SIZE_DEFAULT);
+ defaults.setPropertyIfNull(MAX_PENDING_PROPNAME, MAX_PENDING_DEFAULT);
+ defaults.setPropertyIfNull(ROLLBACK_PUBLISHER_PROPNAME, ROLLBACK_PUBLISHER_DEFAULT);
+ defaults.setPropertyIfNull(ROLLBACK_RECEIVER_PROPNAME, ROLLBACK_RECEIVER_DEFAULT);
+
+ defaults.setPropertyIfNull(NOT_APPLICABLE_ASSERTION_PROPNAME, NOT_APPLICABLE_ASSERTION_DEFAULT);
+ defaults.setPropertyIfNull(VERBOSE_PROPNAME, VERBOSE_DEFAULT);
+ }
+
+ /// <summary> Creates a test configuration based on the defaults. </summary>
+ public MessagingTestConfigProperties()
+ {
+ super(defaults);
+ }
+
+ /// <summary>
+ /// Creates a test configuration based on the supplied properties.
+ /// </summary>
+ /// <param name="properties"> The test configuration. </param>
+ public MessagingTestConfigProperties(Properties properties)
+ {
+ super(properties);
+ }
+
+ /// <summary>
+ /// The size of test messages to send.
+ /// </summary>
+ /// <return> The size of test messages to send. </return>
+ public int getMessageSize()
+ {
+ return getPropertyAsInteger(MESSAGE_SIZE_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that the publishing producer should be set up to publish to a destination.
+ /// </summary>
+ /// <return> Flag to indicate that the publishing producer should be set up to publish to a destination. </return>
+ public bool getPublisherProducerBind()
+ {
+ return getPropertyAsBoolean(PUBLISHER_PRODUCER_BIND_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that the publishing consumer should be set up to receive from a destination.
+ /// </summary>
+ /// <return> Flag to indicate that the publishing consumer should be set up to receive from a destination. </return>
+ public bool getPublisherConsumerBind()
+ {
+ return getPropertyAsBoolean(PUBLISHER_CONSUMER_BIND_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that the receiving producer should be set up to publish to a destination.
+ /// </summary>
+ /// <return> Flag to indicate that the receiving producer should be set up to publish to a destination. </return>
+ public bool getReceiverProducerBind()
+ {
+ return getPropertyAsBoolean(RECEIVER_PRODUCER_BIND_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that the receiving consumer should be set up to receive from a destination.
+ /// </summary>
+ /// <return> Flag to indicate that the receiving consumer should be set up to receive from a destination. </return>
+ public bool getReceiverConsumerBind()
+ {
+ return getPropertyAsBoolean(RECEIVER_CONSUMER_BIND_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that the publishing consumer should be created and actively listening.
+ /// </summary>
+ /// <return> Flag to indicate that the publishing consumer should be created. </return>
+ public bool getPublisherConsumerActive()
+ {
+ return getPropertyAsBoolean(PUBLISHER_CONSUMER_ACTIVE_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that the receiving consumers should be created and actively listening.
+ /// </summary>
+ /// <return> Flag to indicate that the receiving consumers should be created and actively listening. </return>
+ public bool getReceiverConsumerActive()
+ {
+ return getPropertyAsBoolean(RECEIVER_CONSUMER_ACTIVE_PROPNAME);
+ }
+
+ /// <summary>
+ /// A root to create all test destination names from.
+ /// </summary>
+ /// <return> A root to create all test destination names from. </return>
+ public string getSendDestinationNameRoot()
+ {
+ return getProperty(SEND_DESTINATION_NAME_ROOT_PROPNAME);
+ }
+
+ /// <summary>
+ /// A root to create all receiving destination names from.
+ /// </summary>
+ /// <return> A root to create all receiving destination names from. </return>
+ public string getReceiveDestinationNameRoot()
+ {
+ return getProperty(RECEIVE_DESTINATION_NAME_ROOT_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that persistent messages should be used.
+ /// </summary>
+ /// <return> Flag to indicate that persistent messages should be used. </return>
+ public bool getPersistentMode()
+ {
+ return getPropertyAsBoolean(PERSISTENT_MODE_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that transactional messages should be sent by the publisher.
+ /// </summary>
+ /// <return> Flag to indicate that transactional messages should be sent by the publisher. </return>
+ public bool getPublisherTransacted()
+ {
+ return getPropertyAsBoolean(TRANSACTED_PUBLISHER_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that transactional receives should be used by the receiver.
+ /// </summary>
+ /// <return> Flag to indicate that transactional receives should be used by the receiver. </return>
+ public bool getReceiverTransacted()
+ {
+ return getPropertyAsBoolean(TRANSACTED_PUBLISHER_PROPNAME);
+ }
+
+ /// <summary>
+ /// The name of the virtual host to run all tests over.
+ /// </summary>
+ /// <return> The name of the virtual host to run all tests over. </return>
+ public string getVirtualHost()
+ {
+ return getProperty(VIRTUAL_HOST_PROPNAME);
+ }
+
+ /// <summary>
+ /// Limiting rate for each sender in messages per second, or zero for unlimited.
+ /// </summary>
+ /// <return> Limiting rate for each sender in messages per second, or zero for unlimited. </return>
+ public string getRate()
+ {
+ return getProperty(RATE_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that test messages should be received publish/subscribe style by all receivers.
+ /// </summary>
+ /// <return> Flag to indicate that test messages should be received publish/subscribe style by all receivers. </return>
+ public bool getPubsub()
+ {
+ return getPropertyAsBoolean(PUBSUB_PROPNAME);
+ }
+
+ /// <summary>
+ /// The username credentials to run tests with.
+ /// </summary>
+ /// <return> The username credentials to run tests with. </return>
+ public string getUsername()
+ {
+ return getProperty(USERNAME_PROPNAME);
+ }
+
+ /// <summary>
+ /// The password credentials to run tests with.
+ /// </summary>
+ /// <return> The password credentials to run tests with. </return>
+ public string getPassword()
+ {
+ return getProperty(PASSWORD_PROPNAME);
+ }
+
+ /// <summary>
+ /// The timeout duration to fail tests on, should they receive no messages within it.
+ /// </summary>
+ /// <return> The timeout duration to fail tests on, should they receive no messages within it. </return>
+ public long getTimeout()
+ {
+ return getPropertyAsLong(TIMEOUT_PROPNAME);
+ }
+
+ /// <summary>
+ /// The number of messages to batch into each transaction in transational tests.
+ /// </summary>
+ /// <return> The number of messages to batch into each transaction in transational tests. </return>
+ public int getTxBatchSize()
+ {
+ return getPropertyAsInteger(TX_BATCH_SIZE_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that tests should use durable destinations.
+ /// </summary>
+ /// <return> Flag to indicate that tests should use durable destinations. </return>
+ public bool getDurableDests()
+ {
+ return getPropertyAsBoolean(DURABLE_DESTS_PROPNAME);
+ }
+
+ /// <summary>
+ /// The ack mode for message receivers to use.
+ /// </summary>
+ /// <return> The ack mode for message receivers to use. </return>
+ public int getAckMode()
+ {
+ return getPropertyAsInteger(ACK_MODE_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that tests should use durable subscriptions.
+ /// </summary>
+ /// <return> Flag to indicate that tests should use durable subscriptions. </return>
+ public bool getDurableSubscription()
+ {
+ return getPropertyAsBoolean(DURABLE_SUBSCRIPTION_PROPNAME);
+ }
+
+ /// <summary>
+ /// The maximum amount of in-flight data, in bytes, that tests should send at any time.
+ /// </summary>
+ /// <return> The maximum amount of in-flight data, in bytes, that tests should send at any time. </return>
+ public int getMaxPending()
+ {
+ return getPropertyAsInteger(MAX_PENDING_PROPNAME);
+ }
+
+ /// <summary>
+ /// The size of the prefetch queue to use.
+ /// </summary>
+ /// <return> The size of the prefetch queue to use. </return>
+ public int getPrefetch()
+ {
+ return getPropertyAsInteger(PREFETCH_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that subscriptions should be no-local.
+ /// </summary>
+ /// <return> Flag to indicate that subscriptions should be no-local. </return>
+ public bool getNoLocal()
+ {
+ return getPropertyAsBoolean(NO_LOCAL_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that subscriptions should be exclusive.
+ /// </summary>
+ /// <return> Flag to indicate that subscriptions should be exclusive. </return>
+ public bool getExclusive()
+ {
+ return getPropertyAsBoolean(EXCLUSIVE_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that messages must be delivered immediately.
+ /// </summary>
+ /// <return> Flag to indicate that messages must be delivered immediately. </return>
+ public bool getImmediate()
+ {
+ return getPropertyAsBoolean(IMMEDIATE_PROPNAME);
+ }
+
+ /// <summary>
+ /// Flag to indicate that messages must be routable.
+ /// </summary>
+ /// <return> Flag to indicate that messages must be routable. </return>
+ public bool getMandatory()
+ {
+ return getPropertyAsBoolean(MANDATORY_PROPNAME);
+ }
+
+ /// <summary>
+ /// Gets the value of a flag to indicate that the publisher should rollback all messages sent.
+ /// </summary>
+ /// <return> A flag to indicate that the publisher should rollback all messages sent. </return>
+ public bool getRollbackPublisher()
+ {
+ return getPropertyAsBoolean(ROLLBACK_PUBLISHER_PROPNAME);
+ }
+
+ /// <summary>
+ /// Gets the value of a flag to indicate that the receiver should rollback all messages received, then receive them
+ /// again.
+ /// </summary>
+ /// <return> A flag to indicate that the publisher should rollback all messages received. </return>
+ public bool getRollbackReceiver()
+ {
+ return getPropertyAsBoolean(ROLLBACK_RECEIVER_PROPNAME);
+ }
+
+ /// <summary>
+ /// Gets the behavioural mode of not applicable assertions. Should be one of 'quiet', 'warn' or 'fail'.
+ /// </summary>
+ /// <return> The behavioural mode of not applicable assertions. </return>
+ public string getNotApplicableAssertionMode()
+ {
+ return getProperty(NOT_APPLICABLE_ASSERTION_PROPNAME);
+ }
+ }
+ */
} \ No newline at end of file
diff --git a/qpid/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.cs b/qpid/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.cs
index 463cf06dfb..4be08c3f38 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/framework/sequencers/CircuitFactory.cs
@@ -1,85 +1,85 @@
-/*
- *
- * 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 Apache.Qpid.Integration.Tests.framework;
-//using org.apache.qpid.util.ConversationFactory;
-
-//using uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
-
-//using javax.jms.JMSException;
-//using javax.jms.Message;
-
-using System.Collections.Generic;//.IList;
-//using System.Collections.Generic.IDictionary;
-//using java.util.Properties;
-
-namespace Apache.Qpid.Integration.Tests.framework.sequencers
-{
- /// <summary>
- /// A CircuitFactory is responsibile for creating test circuits appropriate to the context that a test case is
- /// running in, and providing an implementation of a standard test procedure over a test circuit.
- ///
- /// <p/><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities
- /// <tr><td> Provide a standard test procedure over a test circuit.
- /// <tr><td> Construct test circuits appropriate to a tests context.
- /// </table>
- /// </summary>
- public interface CircuitFactory
- {
- /// <summary>
- /// Creates a test circuit for the test, configered by the test parameters specified.
- /// </summary>
- /// <param name="testProperties"> The test parameters. </param>
- ///
- /// <return> A test circuit. </return>
- Circuit CreateCircuit(TestModel testProperties);
-
- /// <summary>
- /// Sets the sender test client to coordinate the test with.
- /// </summary>
- /// <param name="sender"> The contact details of the sending client in the test. </param>
- void SetSender(TestClientDetails sender);
-
- /// <summary>
- /// Sets the receiving test client to coordinate the test with.
- /// </summary>
- /// <param name="receiver"> The contact details of the sending client in the test. </param>
- void SetReceiver(TestClientDetails receiver);
-
- /// <summary>
- /// Supplies the sending test client.
- /// </summary>
- /// <return> The sending test client. </return>
- TestClientDetails GetSender();
-
- /// <summary>
- /// Supplies the receiving test client.
- /// </summary>
- /// <return> The receiving test client. </return>
- IList<TestClientDetails> GetReceivers();
-
- /// <summary>
- /// Accepts the conversation factory over which to hold the test coordinating conversation.
- /// </summary>
- /// <param name="conversationFactory"> The conversation factory to coordinate the test over. </param>
- //void setConversationFactory(ConversationFactory conversationFactory);
- }
+/*
+ *
+ * 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 Apache.Qpid.Integration.Tests.framework;
+//using org.apache.qpid.util.ConversationFactory;
+
+//using uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
+
+//using javax.jms.JMSException;
+//using javax.jms.Message;
+
+using System.Collections.Generic;//.IList;
+//using System.Collections.Generic.IDictionary;
+//using java.util.Properties;
+
+namespace Apache.Qpid.Integration.Tests.framework.sequencers
+{
+ /// <summary>
+ /// A CircuitFactory is responsibile for creating test circuits appropriate to the context that a test case is
+ /// running in, and providing an implementation of a standard test procedure over a test circuit.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities
+ /// <tr><td> Provide a standard test procedure over a test circuit.
+ /// <tr><td> Construct test circuits appropriate to a tests context.
+ /// </table>
+ /// </summary>
+ public interface CircuitFactory
+ {
+ /// <summary>
+ /// Creates a test circuit for the test, configered by the test parameters specified.
+ /// </summary>
+ /// <param name="testProperties"> The test parameters. </param>
+ ///
+ /// <return> A test circuit. </return>
+ Circuit CreateCircuit(TestModel testProperties);
+
+ /// <summary>
+ /// Sets the sender test client to coordinate the test with.
+ /// </summary>
+ /// <param name="sender"> The contact details of the sending client in the test. </param>
+ void SetSender(TestClientDetails sender);
+
+ /// <summary>
+ /// Sets the receiving test client to coordinate the test with.
+ /// </summary>
+ /// <param name="receiver"> The contact details of the sending client in the test. </param>
+ void SetReceiver(TestClientDetails receiver);
+
+ /// <summary>
+ /// Supplies the sending test client.
+ /// </summary>
+ /// <return> The sending test client. </return>
+ TestClientDetails GetSender();
+
+ /// <summary>
+ /// Supplies the receiving test client.
+ /// </summary>
+ /// <return> The receiving test client. </return>
+ IList<TestClientDetails> GetReceivers();
+
+ /// <summary>
+ /// Accepts the conversation factory over which to hold the test coordinating conversation.
+ /// </summary>
+ /// <param name="conversationFactory"> The conversation factory to coordinate the test over. </param>
+ //void setConversationFactory(ConversationFactory conversationFactory);
+ }
} \ No newline at end of file
diff --git a/qpid/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs b/qpid/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs
index 547266a7a5..142ac40b27 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/interactive/FailoverTest.cs
@@ -73,12 +73,12 @@ namespace Apache.Qpid.Integration.Tests.interactive
/// <summary>Used to wait for test completion on. </summary>
private static object testComplete = new Object();
- /// <summary>Used to wait for failover completion on. </summary>
+ /// <summary>Used to wait for failover completion on. </summary>
private static object failoverComplete = new Object();
bool failedOver=false;
- /// <summary>Used to record the extra message count (1) if the message sent right after failover actually made it to the new broker.</summary>
+ /// <summary>Used to record the extra message count (1) if the message sent right after failover actually made it to the new broker.</summary>
int _extraMessage = 0;
/// <summary>
diff --git a/qpid/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs b/qpid/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs
index ebc9307c2e..68d7a2ae68 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/interactive/SendReceiveTest.cs
@@ -1,181 +1,181 @@
-/*
- *
- * 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 System.Threading;
-using log4net;
-using NUnit.Framework;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-using Apache.Qpid.Integration.Tests.testcases;
-
-namespace Apache.Qpid.Integration.Tests.interactive
-{
- /// <summary>
- /// SendReceiveTest provides a quick interactive send-receive test, where the user is prompted to trigger each send or receive.
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Run an interactive send-receive loop prompting user to trigger each event.
- /// </table>
- /// </summary>
- [TestFixture, Category("Interactive")]
- public class SendReceiveTest : BaseMessagingTestFixture
- {
- /// <summary>Used for debugging purposes.</summary>
- private static ILog log = LogManager.GetLogger(typeof(SendReceiveTest));
-
- /// <summary>Defines the name of the test topic to use with the tests.</summary>
- public const string TEST_ROUTING_KEY = "quicktestkey";
-
- /// <summary>The number of consumers to test.</summary>
- private const int CONSUMER_COUNT = 5;
-
- /// <summary>The number of test messages to send.</summary>
- private const int MESSAGE_COUNT = 10;
-
- /// <summary>Monitor used to signal succesfull receipt of all test messages.</summary>
- AutoResetEvent _finishedEvent;
-
- /// <summary>Used to count test messages received so far.</summary>
- private int _messageReceivedCount;
-
- /// <summary>Used to hold the expected number of messages to receive.</summary>
- private int expectedMessageCount;
-
- /// <summary>Flag used to indicate that all messages really were received, and that the test did not just time out. </summary>
- private bool allReceived;
-
- /// <summary> Creates one producing end-point and many consuming end-points connected on a topic. </summary>
- [SetUp]
- public override void Init()
- {
- base.Init();
-
- // Reset all test counts and flags.
- _messageReceivedCount = 0;
- allReceived = false;
- _finishedEvent = new AutoResetEvent(false);
- }
-
- /// <summary> Cleans up all test end-points. </summary>
- [TearDown]
- public override void Shutdown()
- {
- try
- {
- // Close all end points for producer and consumers.
- // Producer is on 0, and consumers on 1 .. n, so loop is from 0 to n inclusive.
- for (int i = 0; i <= CONSUMER_COUNT; i++)
- {
- CloseEndPoint(i);
- }
- }
- finally
- {
- base.Shutdown();
- }
- }
-
- /// <summary> Check that all consumers on a topic each receive all message on it. </summary>
- [Test]
- public void AllConsumerReceiveAllMessagesOnTopic()
- {
- // Create end-points for all the consumers in the test.
- for (int i = 1; i <= CONSUMER_COUNT; i++)
- {
- SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC,
- true, false, null);
- testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage);
- }
-
- // Create an end-point to publish to the test topic.
- SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC,
- true, false, null);
-
- expectedMessageCount = (MESSAGE_COUNT * CONSUMER_COUNT);
-
- PromptAndWait("Press to send...");
-
- for (int i = 0; i < MESSAGE_COUNT; i++)
- {
- testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
- }
-
- _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 10), false);
-
- PromptAndWait("Press to complete test...");
-
- // Check that all messages really were received.
- Assert.IsTrue(allReceived, "All messages were not received, only got " + _messageReceivedCount + " but wanted " + expectedMessageCount);
- }
-
- /// <summary> Check that consumers on the same queue receive each message once accross all consumers. </summary>
- //[Test]
- public void AllConsumerReceiveAllMessagesOnDirect()
- {
- // Create end-points for all the consumers in the test.
- for (int i = 1; i <= CONSUMER_COUNT; i++)
- {
- SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT,
- true, false, null);
- testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage);
- }
-
- // Create an end-point to publish to the test topic.
- SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT,
- true, false, null);
-
- expectedMessageCount = MESSAGE_COUNT;
-
- for (int i = 0; i < MESSAGE_COUNT; i++)
- {
- testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
- }
-
- _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 10), false);
-
- // Check that all messages really were received.
- Assert.IsTrue(allReceived, "All messages were not received, only got: " + _messageReceivedCount + " but wanted " + expectedMessageCount);
- }
-
- /// <summary> Atomically increments the message count on every message, and signals once all messages in the test are received. </summary>
- public void OnMessage(IMessage m)
- {
- int newCount = Interlocked.Increment(ref _messageReceivedCount);
-
- if (newCount >= expectedMessageCount)
- {
- allReceived = true;
- _finishedEvent.Set();
- }
- }
-
- /// <summary>Prompts the user on stdout and waits for a reply on stdin, using the specified prompt message.</summary>
- ///
- /// <param name="message">The message to prompt the user with.</param>
- private void PromptAndWait(string message)
- {
- Console.WriteLine("\n" + message);
- Console.ReadLine();
- }
- }
+/*
+ *
+ * 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 System.Threading;
+using log4net;
+using NUnit.Framework;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+using Apache.Qpid.Integration.Tests.testcases;
+
+namespace Apache.Qpid.Integration.Tests.interactive
+{
+ /// <summary>
+ /// SendReceiveTest provides a quick interactive send-receive test, where the user is prompted to trigger each send or receive.
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Run an interactive send-receive loop prompting user to trigger each event.
+ /// </table>
+ /// </summary>
+ [TestFixture, Category("Interactive")]
+ public class SendReceiveTest : BaseMessagingTestFixture
+ {
+ /// <summary>Used for debugging purposes.</summary>
+ private static ILog log = LogManager.GetLogger(typeof(SendReceiveTest));
+
+ /// <summary>Defines the name of the test topic to use with the tests.</summary>
+ public const string TEST_ROUTING_KEY = "quicktestkey";
+
+ /// <summary>The number of consumers to test.</summary>
+ private const int CONSUMER_COUNT = 5;
+
+ /// <summary>The number of test messages to send.</summary>
+ private const int MESSAGE_COUNT = 10;
+
+ /// <summary>Monitor used to signal succesfull receipt of all test messages.</summary>
+ AutoResetEvent _finishedEvent;
+
+ /// <summary>Used to count test messages received so far.</summary>
+ private int _messageReceivedCount;
+
+ /// <summary>Used to hold the expected number of messages to receive.</summary>
+ private int expectedMessageCount;
+
+ /// <summary>Flag used to indicate that all messages really were received, and that the test did not just time out. </summary>
+ private bool allReceived;
+
+ /// <summary> Creates one producing end-point and many consuming end-points connected on a topic. </summary>
+ [SetUp]
+ public override void Init()
+ {
+ base.Init();
+
+ // Reset all test counts and flags.
+ _messageReceivedCount = 0;
+ allReceived = false;
+ _finishedEvent = new AutoResetEvent(false);
+ }
+
+ /// <summary> Cleans up all test end-points. </summary>
+ [TearDown]
+ public override void Shutdown()
+ {
+ try
+ {
+ // Close all end points for producer and consumers.
+ // Producer is on 0, and consumers on 1 .. n, so loop is from 0 to n inclusive.
+ for (int i = 0; i <= CONSUMER_COUNT; i++)
+ {
+ CloseEndPoint(i);
+ }
+ }
+ finally
+ {
+ base.Shutdown();
+ }
+ }
+
+ /// <summary> Check that all consumers on a topic each receive all message on it. </summary>
+ [Test]
+ public void AllConsumerReceiveAllMessagesOnTopic()
+ {
+ // Create end-points for all the consumers in the test.
+ for (int i = 1; i <= CONSUMER_COUNT; i++)
+ {
+ SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC,
+ true, false, null);
+ testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage);
+ }
+
+ // Create an end-point to publish to the test topic.
+ SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC,
+ true, false, null);
+
+ expectedMessageCount = (MESSAGE_COUNT * CONSUMER_COUNT);
+
+ PromptAndWait("Press to send...");
+
+ for (int i = 0; i < MESSAGE_COUNT; i++)
+ {
+ testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
+ }
+
+ _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 10), false);
+
+ PromptAndWait("Press to complete test...");
+
+ // Check that all messages really were received.
+ Assert.IsTrue(allReceived, "All messages were not received, only got " + _messageReceivedCount + " but wanted " + expectedMessageCount);
+ }
+
+ /// <summary> Check that consumers on the same queue receive each message once accross all consumers. </summary>
+ //[Test]
+ public void AllConsumerReceiveAllMessagesOnDirect()
+ {
+ // Create end-points for all the consumers in the test.
+ for (int i = 1; i <= CONSUMER_COUNT; i++)
+ {
+ SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT,
+ true, false, null);
+ testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage);
+ }
+
+ // Create an end-point to publish to the test topic.
+ SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT,
+ true, false, null);
+
+ expectedMessageCount = MESSAGE_COUNT;
+
+ for (int i = 0; i < MESSAGE_COUNT; i++)
+ {
+ testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
+ }
+
+ _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 10), false);
+
+ // Check that all messages really were received.
+ Assert.IsTrue(allReceived, "All messages were not received, only got: " + _messageReceivedCount + " but wanted " + expectedMessageCount);
+ }
+
+ /// <summary> Atomically increments the message count on every message, and signals once all messages in the test are received. </summary>
+ public void OnMessage(IMessage m)
+ {
+ int newCount = Interlocked.Increment(ref _messageReceivedCount);
+
+ if (newCount >= expectedMessageCount)
+ {
+ allReceived = true;
+ _finishedEvent.Set();
+ }
+ }
+
+ /// <summary>Prompts the user on stdout and waits for a reply on stdin, using the specified prompt message.</summary>
+ ///
+ /// <param name="message">The message to prompt the user with.</param>
+ private void PromptAndWait(string message)
+ {
+ Console.WriteLine("\n" + message);
+ Console.ReadLine();
+ }
+ }
} \ No newline at end of file
diff --git a/qpid/dotnet/Qpid.Integration.Tests/interop/InteropClientTestCase.cs b/qpid/dotnet/Qpid.Integration.Tests/interop/InteropClientTestCase.cs
index c1283454c5..09361b33e8 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/interop/InteropClientTestCase.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/interop/InteropClientTestCase.cs
@@ -1,87 +1,87 @@
-/*
- *
- * 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 System.Text;
-using Apache.Qpid.Messaging;
-
-namespace Apache.Qpid.Integration.Tests.interop
-{
- /// <summary> Defines the possible test case roles that an interop test case can take on. </summary>
- public enum Roles { SENDER, RECEIVER };
-
- /// <summary>
- /// InteropClientTestCase provides an interface that classes implementing test cases from the interop testing spec
- /// (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification) should implement.
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities
- /// <tr><td> Supply the name of the test case that this implements.
- /// <tr><td> Accept/Reject invites based on test parameters.
- /// <tr><td> Adapt to assigned roles.
- /// <tr><td> Perform test case actions.
- /// <tr><td> Generate test reports.
- /// </table>
- /// </summary>
- interface InteropClientTestCase
- {
- /// <summary>
- /// Should provide the name of the test case that this class implements. The exact names are defined in the
- /// interop testing spec.
- /// </summary>
- ///
- /// <returns> The name of the test case that this implements. </returns>
- string GetName();
-
- /// <summary>
- /// Determines whether the test invite that matched this test case is acceptable.
- /// </summary>
- ///
- /// <param name="inviteMessage"> The invitation to accept or reject. </param>
- ///
- /// <returns> <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it. </returns>
- ///
- /// @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
- bool AcceptInvite(IMessage inviteMessage);
-
- /// <summary>
- /// Assigns the role to be played by this test case. The test parameters are fully specified in the
- /// assignment message. When this method return the test case will be ready to execute.
- /// </summary>
- ///
- /// <param name="role"> The role to be played; sender or receiver. </param>
- /// <param name="assignRoleMessage"> The role assingment message, contains the full test parameters. </param>
- void AssignRole(Roles role, IMessage assignRoleMessage);
-
- /// <summary>
- /// Performs the test case actions.
- /// </summary>
- void Start();
-
- /// <summary>
- /// Gets a report on the actions performed by the test case in its assigned role.
- /// </summary>
- ///
- /// <param name="session"> The session to create the report message in. </param>
- ///
- /// <returns> The report message. </returns>
- IMessage GetReport(IChannel channel);
- }
-}
+/*
+ *
+ * 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 System.Text;
+using Apache.Qpid.Messaging;
+
+namespace Apache.Qpid.Integration.Tests.interop
+{
+ /// <summary> Defines the possible test case roles that an interop test case can take on. </summary>
+ public enum Roles { SENDER, RECEIVER };
+
+ /// <summary>
+ /// InteropClientTestCase provides an interface that classes implementing test cases from the interop testing spec
+ /// (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification) should implement.
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities
+ /// <tr><td> Supply the name of the test case that this implements.
+ /// <tr><td> Accept/Reject invites based on test parameters.
+ /// <tr><td> Adapt to assigned roles.
+ /// <tr><td> Perform test case actions.
+ /// <tr><td> Generate test reports.
+ /// </table>
+ /// </summary>
+ interface InteropClientTestCase
+ {
+ /// <summary>
+ /// Should provide the name of the test case that this class implements. The exact names are defined in the
+ /// interop testing spec.
+ /// </summary>
+ ///
+ /// <returns> The name of the test case that this implements. </returns>
+ string GetName();
+
+ /// <summary>
+ /// Determines whether the test invite that matched this test case is acceptable.
+ /// </summary>
+ ///
+ /// <param name="inviteMessage"> The invitation to accept or reject. </param>
+ ///
+ /// <returns> <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it. </returns>
+ ///
+ /// @throws JMSException Any JMSException resulting from reading the message are allowed to fall through.
+ bool AcceptInvite(IMessage inviteMessage);
+
+ /// <summary>
+ /// Assigns the role to be played by this test case. The test parameters are fully specified in the
+ /// assignment message. When this method return the test case will be ready to execute.
+ /// </summary>
+ ///
+ /// <param name="role"> The role to be played; sender or receiver. </param>
+ /// <param name="assignRoleMessage"> The role assingment message, contains the full test parameters. </param>
+ void AssignRole(Roles role, IMessage assignRoleMessage);
+
+ /// <summary>
+ /// Performs the test case actions.
+ /// </summary>
+ void Start();
+
+ /// <summary>
+ /// Gets a report on the actions performed by the test case in its assigned role.
+ /// </summary>
+ ///
+ /// <param name="session"> The session to create the report message in. </param>
+ ///
+ /// <returns> The report message. </returns>
+ IMessage GetReport(IChannel channel);
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase1DummyRun.cs b/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase1DummyRun.cs
index a63bb84517..d908b7af0b 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase1DummyRun.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase1DummyRun.cs
@@ -1,89 +1,89 @@
-/*
- *
- * 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 System.Text;
-using log4net;
-using Apache.Qpid.Messaging;
-
-namespace Apache.Qpid.Integration.Tests.interop.TestCases
-{
- /// <summary>
- /// Implements tet case 1, dummy run. This test case sends no test messages, it exists to confirm that the test harness
- /// is interacting with the coordinator correctly.
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Supply the name of the test case that this implements.
- /// <tr><td> Accept/Reject invites based on test parameters.
- /// <tr><td> Adapt to assigned roles.
- /// <tr><td> Perform test case actions.
- /// <tr><td> Generate test reports.
- /// </table>
- /// </summary>
- public class TestCase1DummyRun : InteropClientTestCase
- {
- private static ILog log = LogManager.GetLogger(typeof(TestCase1DummyRun));
-
- public String GetName()
- {
- log.Debug("public String getName(): called");
-
- return "TC1_DummyRun";
- }
-
- public bool AcceptInvite(IMessage inviteMessage)
- {
- log.Debug("public boolean acceptInvite(Message inviteMessage): called");
-
- // Test parameters don't matter, accept all invites.
- return true;
- }
-
- public void AssignRole(Roles role, IMessage assignRoleMessage)
- {
- log.Debug("public void assignRole(Roles role, Message assignRoleMessage): called");
-
- // Do nothing, both roles are the same.
- }
-
- public void Start()
- {
- log.Debug("public void start(): called");
-
- // Do nothing.
- }
-
- public IMessage GetReport(IChannel channel)
- {
- log.Debug("public Message getReport(Session session): called");
-
- // Generate a dummy report, the coordinator expects a report but doesn't care what it is.
- return channel.CreateTextMessage("Dummy Run, Ok.");
- }
-
- public void OnMessage(IMessage message)
- {
- log.Debug("public void onMessage(Message message = " + message + "): called");
-
- // Ignore any messages.
- }
- }
-}
+/*
+ *
+ * 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 System.Text;
+using log4net;
+using Apache.Qpid.Messaging;
+
+namespace Apache.Qpid.Integration.Tests.interop.TestCases
+{
+ /// <summary>
+ /// Implements tet case 1, dummy run. This test case sends no test messages, it exists to confirm that the test harness
+ /// is interacting with the coordinator correctly.
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Supply the name of the test case that this implements.
+ /// <tr><td> Accept/Reject invites based on test parameters.
+ /// <tr><td> Adapt to assigned roles.
+ /// <tr><td> Perform test case actions.
+ /// <tr><td> Generate test reports.
+ /// </table>
+ /// </summary>
+ public class TestCase1DummyRun : InteropClientTestCase
+ {
+ private static ILog log = LogManager.GetLogger(typeof(TestCase1DummyRun));
+
+ public String GetName()
+ {
+ log.Debug("public String getName(): called");
+
+ return "TC1_DummyRun";
+ }
+
+ public bool AcceptInvite(IMessage inviteMessage)
+ {
+ log.Debug("public boolean acceptInvite(Message inviteMessage): called");
+
+ // Test parameters don't matter, accept all invites.
+ return true;
+ }
+
+ public void AssignRole(Roles role, IMessage assignRoleMessage)
+ {
+ log.Debug("public void assignRole(Roles role, Message assignRoleMessage): called");
+
+ // Do nothing, both roles are the same.
+ }
+
+ public void Start()
+ {
+ log.Debug("public void start(): called");
+
+ // Do nothing.
+ }
+
+ public IMessage GetReport(IChannel channel)
+ {
+ log.Debug("public Message getReport(Session session): called");
+
+ // Generate a dummy report, the coordinator expects a report but doesn't care what it is.
+ return channel.CreateTextMessage("Dummy Run, Ok.");
+ }
+
+ public void OnMessage(IMessage message)
+ {
+ log.Debug("public void onMessage(Message message = " + message + "): called");
+
+ // Ignore any messages.
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase2BasicP2P.cs b/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase2BasicP2P.cs
index 3460d9091f..8993da832e 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase2BasicP2P.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase2BasicP2P.cs
@@ -1,205 +1,205 @@
-/*
- *
- * 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 System.Text;
-using log4net;
-using Apache.Qpid.Messaging;
-
-namespace Apache.Qpid.Integration.Tests.interop.TestCases
-{
- /// <summary>
- /// Implements test case 2, basic P2P. Sends/receives a specified number of messages to a specified route on the
- /// default direct exchange. Produces reports on the actual number of messages sent/received.
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Supply the name of the test case that this implements.
- /// <tr><td> Accept/Reject invites based on test parameters.
- /// <tr><td> Adapt to assigned roles.
- /// <tr><td> Send required number of test messages.
- /// <tr><td> Generate test reports.
- /// </table>
- /// </summary>
- public class TestCase2BasicP2P : InteropClientTestCase
- {
- /// <summary> Used for debugging. </summary>
- private static ILog log = LogManager.GetLogger(typeof(TestCase2BasicP2P));
-
- /// <summary> Holds the count of test messages received. </summary>
- private int messageCount;
-
- /// <summary> The role to be played by the test. </summary>
- private Roles role;
-
- /// <summary> The number of test messages to send. </summary>
- private int numMessages;
-
- /// <summary> The routing key to send them to on the default direct exchange. </summary>
- private string sendDestination;
-
- /// <summary> The connection to send the test messages on. </summary>
- private IConnection connection;
-
- /// <summary> The session to send the test messages on. </summary>
- private IChannel channel;
-
- /// <summary> The producer to send the test messages with. </summary>
- private IMessagePublisher publisher;
-
- /// <summary>
- /// Should provide the name of the test case that this class implements. The exact names are defined in the
- /// interop testing spec.
- /// </summary>
- ///
- /// <returns> The name of the test case that this implements. </returns>
- public String GetName()
- {
- log.Debug("public String GetName(): called");
-
- return "TC2_BasicP2P";
- }
-
- /// <summary>
- /// Determines whether the test invite that matched this test case is acceptable.
- /// </summary>
- ///
- /// <param name="inviteMessage"> The invitation to accept or reject. </param>
- ///
- /// <returns> <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it. </returns>
- public bool AcceptInvite(IMessage inviteMessage)
- {
- log.Debug("public boolean AcceptInvite(Message inviteMessage = " + inviteMessage + "): called");
-
- // All invites are acceptable.
- return true;
- }
-
- /// <summary>
- /// Assigns the role to be played by this test case. The test parameters are fully specified in the
- /// assignment message. When this method return the test case will be ready to execute.
- /// </summary>
- ///
- /// <param name="role"> The role to be played; sender or receiver. </param>
- /// <param name="assignRoleMessage"> The role assingment message, contains the full test parameters. </param>
- public void AssignRole(Roles role, IMessage assignRoleMessage)
- {
- log.Debug("public void AssignRole(Roles role = " + role + ", Message assignRoleMessage = " + assignRoleMessage
- + "): called");
-
- // Reset the message count for a new test.
- messageCount = 0;
-
- // Take note of the role to be played.
- this.role = role;
-
- // Create a new connection to pass the test messages on.
- connection =
- TestClient.CreateConnection(TestClient.brokerUrl, TestClient.virtualHost);
- channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
-
- // Extract and retain the test parameters.
- numMessages = assignRoleMessage.Headers.GetInt("P2P_NUM_MESSAGES");
- string queueAndKeyName = assignRoleMessage.Headers.GetString("P2P_QUEUE_AND_KEY_NAME");
- channel.DeclareQueue(queueAndKeyName, false, true, true);
- channel.Bind(queueAndKeyName, ExchangeNameDefaults.DIRECT, queueAndKeyName);
- sendDestination = queueAndKeyName;
-
- log.Debug("numMessages = " + numMessages);
- log.Debug("sendDestination = " + sendDestination);
- log.Debug("role = " + role);
-
- switch (role)
- {
- // Check if the sender role is being assigned, and set up a message producer if so.
- case Roles.SENDER:
- publisher = channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.DIRECT)
- .WithRoutingKey(sendDestination)
- .Create();
- break;
-
- // Otherwise the receiver role is being assigned, so set this up to listen for messages.
- case Roles.RECEIVER:
- IMessageConsumer consumer = channel.CreateConsumerBuilder(sendDestination).Create();
- consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
-
- break;
- }
-
- connection.Start();
- }
-
- /// <summary> Performs the test case actions. </summary>
- public void Start()
- {
- log.Debug("public void start(): called");
-
- // Check that the sender role is being performed.
- if (role == Roles.SENDER)
- {
- IMessage testMessage = channel.CreateTextMessage("test");
-
- for (int i = 0; i < numMessages; i++)
- {
- publisher.Send(testMessage);
-
- // Increment the message count.
- messageCount++;
- }
- }
- }
-
- /// <summary>
- /// Gets a report on the actions performed by the test case in its assigned role.
- /// </summary>
- ///
- /// <param name="session"> The session to create the report message in. </param>
- ///
- /// <returns> The report message. </returns>
- public IMessage GetReport(IChannel channel)
- {
- log.Debug("public Message GetReport(IChannel channel): called");
-
- // Close the test connection.
- //connection.Stop();
-
- // Generate a report message containing the count of the number of messages passed.
- IMessage report = channel.CreateMessage();
- //report.Headers.SetString("CONTROL_TYPE", "REPORT");
- report.Headers.SetInt("MESSAGE_COUNT", messageCount);
-
- return report;
- }
-
- /// <summary>
- /// Counts incoming test messages.
- /// </summary>
- ///
- /// <param name="message"> The incoming test message. </param>
- public void OnMessage(IMessage message)
- {
- log.Debug("public void OnMessage(IMessage message = " + message + "): called");
-
- // Increment the message count.
- messageCount++;
- }
- }
-}
+/*
+ *
+ * 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 System.Text;
+using log4net;
+using Apache.Qpid.Messaging;
+
+namespace Apache.Qpid.Integration.Tests.interop.TestCases
+{
+ /// <summary>
+ /// Implements test case 2, basic P2P. Sends/receives a specified number of messages to a specified route on the
+ /// default direct exchange. Produces reports on the actual number of messages sent/received.
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Supply the name of the test case that this implements.
+ /// <tr><td> Accept/Reject invites based on test parameters.
+ /// <tr><td> Adapt to assigned roles.
+ /// <tr><td> Send required number of test messages.
+ /// <tr><td> Generate test reports.
+ /// </table>
+ /// </summary>
+ public class TestCase2BasicP2P : InteropClientTestCase
+ {
+ /// <summary> Used for debugging. </summary>
+ private static ILog log = LogManager.GetLogger(typeof(TestCase2BasicP2P));
+
+ /// <summary> Holds the count of test messages received. </summary>
+ private int messageCount;
+
+ /// <summary> The role to be played by the test. </summary>
+ private Roles role;
+
+ /// <summary> The number of test messages to send. </summary>
+ private int numMessages;
+
+ /// <summary> The routing key to send them to on the default direct exchange. </summary>
+ private string sendDestination;
+
+ /// <summary> The connection to send the test messages on. </summary>
+ private IConnection connection;
+
+ /// <summary> The session to send the test messages on. </summary>
+ private IChannel channel;
+
+ /// <summary> The producer to send the test messages with. </summary>
+ private IMessagePublisher publisher;
+
+ /// <summary>
+ /// Should provide the name of the test case that this class implements. The exact names are defined in the
+ /// interop testing spec.
+ /// </summary>
+ ///
+ /// <returns> The name of the test case that this implements. </returns>
+ public String GetName()
+ {
+ log.Debug("public String GetName(): called");
+
+ return "TC2_BasicP2P";
+ }
+
+ /// <summary>
+ /// Determines whether the test invite that matched this test case is acceptable.
+ /// </summary>
+ ///
+ /// <param name="inviteMessage"> The invitation to accept or reject. </param>
+ ///
+ /// <returns> <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it. </returns>
+ public bool AcceptInvite(IMessage inviteMessage)
+ {
+ log.Debug("public boolean AcceptInvite(Message inviteMessage = " + inviteMessage + "): called");
+
+ // All invites are acceptable.
+ return true;
+ }
+
+ /// <summary>
+ /// Assigns the role to be played by this test case. The test parameters are fully specified in the
+ /// assignment message. When this method return the test case will be ready to execute.
+ /// </summary>
+ ///
+ /// <param name="role"> The role to be played; sender or receiver. </param>
+ /// <param name="assignRoleMessage"> The role assingment message, contains the full test parameters. </param>
+ public void AssignRole(Roles role, IMessage assignRoleMessage)
+ {
+ log.Debug("public void AssignRole(Roles role = " + role + ", Message assignRoleMessage = " + assignRoleMessage
+ + "): called");
+
+ // Reset the message count for a new test.
+ messageCount = 0;
+
+ // Take note of the role to be played.
+ this.role = role;
+
+ // Create a new connection to pass the test messages on.
+ connection =
+ TestClient.CreateConnection(TestClient.brokerUrl, TestClient.virtualHost);
+ channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
+
+ // Extract and retain the test parameters.
+ numMessages = assignRoleMessage.Headers.GetInt("P2P_NUM_MESSAGES");
+ string queueAndKeyName = assignRoleMessage.Headers.GetString("P2P_QUEUE_AND_KEY_NAME");
+ channel.DeclareQueue(queueAndKeyName, false, true, true);
+ channel.Bind(queueAndKeyName, ExchangeNameDefaults.DIRECT, queueAndKeyName);
+ sendDestination = queueAndKeyName;
+
+ log.Debug("numMessages = " + numMessages);
+ log.Debug("sendDestination = " + sendDestination);
+ log.Debug("role = " + role);
+
+ switch (role)
+ {
+ // Check if the sender role is being assigned, and set up a message producer if so.
+ case Roles.SENDER:
+ publisher = channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.DIRECT)
+ .WithRoutingKey(sendDestination)
+ .Create();
+ break;
+
+ // Otherwise the receiver role is being assigned, so set this up to listen for messages.
+ case Roles.RECEIVER:
+ IMessageConsumer consumer = channel.CreateConsumerBuilder(sendDestination).Create();
+ consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
+
+ break;
+ }
+
+ connection.Start();
+ }
+
+ /// <summary> Performs the test case actions. </summary>
+ public void Start()
+ {
+ log.Debug("public void start(): called");
+
+ // Check that the sender role is being performed.
+ if (role == Roles.SENDER)
+ {
+ IMessage testMessage = channel.CreateTextMessage("test");
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ publisher.Send(testMessage);
+
+ // Increment the message count.
+ messageCount++;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets a report on the actions performed by the test case in its assigned role.
+ /// </summary>
+ ///
+ /// <param name="session"> The session to create the report message in. </param>
+ ///
+ /// <returns> The report message. </returns>
+ public IMessage GetReport(IChannel channel)
+ {
+ log.Debug("public Message GetReport(IChannel channel): called");
+
+ // Close the test connection.
+ //connection.Stop();
+
+ // Generate a report message containing the count of the number of messages passed.
+ IMessage report = channel.CreateMessage();
+ //report.Headers.SetString("CONTROL_TYPE", "REPORT");
+ report.Headers.SetInt("MESSAGE_COUNT", messageCount);
+
+ return report;
+ }
+
+ /// <summary>
+ /// Counts incoming test messages.
+ /// </summary>
+ ///
+ /// <param name="message"> The incoming test message. </param>
+ public void OnMessage(IMessage message)
+ {
+ log.Debug("public void OnMessage(IMessage message = " + message + "): called");
+
+ // Increment the message count.
+ messageCount++;
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase3BasicPubSub.cs b/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase3BasicPubSub.cs
index fd0db10fa5..79c0322bcd 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase3BasicPubSub.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/interop/TestCases/TestCase3BasicPubSub.cs
@@ -1,244 +1,244 @@
-/*
- *
- * 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 System.Text;
-using log4net;
-using Apache.Qpid.Messaging;
-
-namespace Apache.Qpid.Integration.Tests.interop.TestCases
-{
- /// <summary>
- /// Implements test case 3, basic pub/sub. Sends/received a specified number of messages to a specified route on the
- /// default topic exchange, using the specified number of receiver connections. Produces reports on the actual number of
- /// messages sent/received.
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Supply the name of the test case that this implements.
- /// <tr><td> Accept/Reject invites based on test parameters.
- /// <tr><td> Adapt to assigned roles.
- /// <tr><td> Send required number of test messages using pub/sub.
- /// <tr><td> Generate test reports.
- /// </table>
- /// </summary>
- public class TestCase3BasicPubSub : InteropClientTestCase
- {
- /// <summary> Used for debugging. </summary>
- private static ILog log = LogManager.GetLogger(typeof(TestCase3BasicPubSub));
-
- /// <summary> Holds the count of test messages received. </summary>
- private int messageCount;
-
- /// <summary> The role to be played by the test. </summary>
- private Roles role;
-
- /// <summary> The number of test messages to send. </summary>
- private int numMessages;
-
- /// <summary> The number of receiver connection to use. </summary>
- private int numReceivers;
-
- /// <summary> The routing key to send them to on the default direct exchange. </summary>
- private string sendDestination;
-
- /// <summary> The connections to send/receive the test messages on. </summary>
- private IConnection[] connection;
-
- /// <summary> The sessions to send/receive the test messages on. </summary>
- private IChannel[] channel;
-
- /// <summary> The producer to send the test messages with. </summary>
- IMessagePublisher publisher;
-
- /// <summary>
- /// Should provide the name of the test case that this class implements. The exact names are defined in the
- /// interop testing spec.
- /// </summary>
- ///
- /// <returns> The name of the test case that this implements. </returns>
- public String GetName()
- {
- log.Debug("public String GetName(): called");
-
- return "TC3_BasicPubSub";
- }
-
- /// <summary>
- /// Determines whether the test invite that matched this test case is acceptable.
- /// </summary>
- ///
- /// <param name="inviteMessage"> The invitation to accept or reject. </param>
- ///
- /// <returns> <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it. </returns>
- public bool AcceptInvite(IMessage inviteMessage)
- {
- log.Debug("public boolean AcceptInvite(IMessage inviteMessage = " + inviteMessage + "): called");
-
- // All invites are acceptable.
- return true;
- }
-
- /// <summary>
- /// Assigns the role to be played by this test case. The test parameters are fully specified in the
- /// assignment message. When this method return the test case will be ready to execute.
- /// </summary>
- ///
- /// <param name="role"> The role to be played; sender or receiver. </param>
- /// <param name="assignRoleMessage"> The role assingment message, contains the full test parameters. </param>
- public void AssignRole(Roles role, IMessage assignRoleMessage)
- {
- log.Debug("public void assignRole(Roles role = " + role + ", IMessage assignRoleMessage = " + assignRoleMessage
- + "): called");
-
- // Reset the message count for a new test.
- messageCount = 0;
-
- // Take note of the role to be played.
- this.role = role;
-
- // Extract and retain the test parameters.
- numMessages = assignRoleMessage.Headers.GetInt("PUBSUB_NUM_MESSAGES");
- numReceivers = assignRoleMessage.Headers.GetInt("PUBSUB_NUM_RECEIVERS");
- string sendKey = assignRoleMessage.Headers.GetString("PUBSUB_KEY");
- sendDestination = sendKey;
-
- log.Debug("numMessages = " + numMessages);
- log.Debug("numReceivers = " + numReceivers);
- log.Debug("sendKey = " + sendKey);
- log.Debug("role = " + role);
-
- switch (role)
- {
- // Check if the sender role is being assigned, and set up a single message producer if so.
- case Roles.SENDER:
- // Create a new connection to pass the test messages on.
- connection = new IConnection[1];
- channel = new IChannel[1];
-
- connection[0] =
- TestClient.CreateConnection(TestClient.brokerUrl, TestClient.virtualHost);
- channel[0] = connection[0].CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
-
- // Extract and retain the test parameters.
- publisher = channel[0].CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.TOPIC)
- .WithRoutingKey(sendDestination)
- .WithMandatory(false)
- .WithImmediate(false)
- .Create();
- break;
-
- // Otherwise the receiver role is being assigned, so set this up to listen for messages on the required number
- // of receiver connections.
- case Roles.RECEIVER:
- // Create the required number of receiver connections.
- connection = new IConnection[numReceivers];
- channel = new IChannel[numReceivers];
-
- for (int i = 0; i < numReceivers; i++)
- {
- connection[i] =
- TestClient.CreateConnection(TestClient.brokerUrl, TestClient.virtualHost);
- channel[i] = connection[i].CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
-
- IMessageConsumer consumer = channel[i].CreateConsumerBuilder(sendDestination).Create();
- consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
- }
-
- break;
- }
-
- // Start all the connection dispatcher threads running.
- foreach (IConnection con in connection)
- {
- con.Start();
- }
- }
-
- /// <summary>
- /// Performs the test case actions.
- /// </summary>
- public void Start()
- {
- log.Debug("public void Start(): called");
-
- // Check that the sender role is being performed.
- if (role == Roles.SENDER)
- {
- IMessage testMessage = channel[0].CreateTextMessage("test");
-
- for (int i = 0; i < numMessages; i++)
- {
- publisher.Send(testMessage);
-
- // Increment the message count.
- messageCount++;
- }
- }
- }
-
- /// <summary>
- /// Gets a report on the actions performed by the test case in its assigned role.
- /// </summary>
- ///
- /// <param name="session"> The session to create the report message in. </param>
- ///
- /// <returns> The report message. </returns>
- public IMessage GetReport(IChannel channel)
- {
- log.Debug("public IMessage getReport(IChannel channel): called");
-
- // Close the test connections.
- /*foreach (IConnection con in connection)
- {
- try
- {
- con.Stop();
- }
- catch (AMQConnectionClosedException e)
- {
- // The connection has already died due to an error. Log this as a warning.
- log.Warn("Connection already closed.");
- }
- }*/
-
- // Generate a report message containing the count of the number of messages passed.
- IMessage report = channel.CreateMessage();
- //report.Headers.SetString("CONTROL_TYPE", "REPORT");
- report.Headers.SetInt("MESSAGE_COUNT", messageCount);
-
- return report;
- }
-
- /// <summary>
- /// Counts incoming test messages.
- /// </summary>
- ///
- /// <param name="message"> The incoming test message. </param>
- public void OnMessage(IMessage message)
- {
- log.Debug("public void onMessage(IMessage message = " + message + "): called");
-
- // Increment the message count.
- messageCount++;
- }
- }
-}
+/*
+ *
+ * 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 System.Text;
+using log4net;
+using Apache.Qpid.Messaging;
+
+namespace Apache.Qpid.Integration.Tests.interop.TestCases
+{
+ /// <summary>
+ /// Implements test case 3, basic pub/sub. Sends/received a specified number of messages to a specified route on the
+ /// default topic exchange, using the specified number of receiver connections. Produces reports on the actual number of
+ /// messages sent/received.
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Supply the name of the test case that this implements.
+ /// <tr><td> Accept/Reject invites based on test parameters.
+ /// <tr><td> Adapt to assigned roles.
+ /// <tr><td> Send required number of test messages using pub/sub.
+ /// <tr><td> Generate test reports.
+ /// </table>
+ /// </summary>
+ public class TestCase3BasicPubSub : InteropClientTestCase
+ {
+ /// <summary> Used for debugging. </summary>
+ private static ILog log = LogManager.GetLogger(typeof(TestCase3BasicPubSub));
+
+ /// <summary> Holds the count of test messages received. </summary>
+ private int messageCount;
+
+ /// <summary> The role to be played by the test. </summary>
+ private Roles role;
+
+ /// <summary> The number of test messages to send. </summary>
+ private int numMessages;
+
+ /// <summary> The number of receiver connection to use. </summary>
+ private int numReceivers;
+
+ /// <summary> The routing key to send them to on the default direct exchange. </summary>
+ private string sendDestination;
+
+ /// <summary> The connections to send/receive the test messages on. </summary>
+ private IConnection[] connection;
+
+ /// <summary> The sessions to send/receive the test messages on. </summary>
+ private IChannel[] channel;
+
+ /// <summary> The producer to send the test messages with. </summary>
+ IMessagePublisher publisher;
+
+ /// <summary>
+ /// Should provide the name of the test case that this class implements. The exact names are defined in the
+ /// interop testing spec.
+ /// </summary>
+ ///
+ /// <returns> The name of the test case that this implements. </returns>
+ public String GetName()
+ {
+ log.Debug("public String GetName(): called");
+
+ return "TC3_BasicPubSub";
+ }
+
+ /// <summary>
+ /// Determines whether the test invite that matched this test case is acceptable.
+ /// </summary>
+ ///
+ /// <param name="inviteMessage"> The invitation to accept or reject. </param>
+ ///
+ /// <returns> <tt>true</tt> to accept the invitation, <tt>false</tt> to reject it. </returns>
+ public bool AcceptInvite(IMessage inviteMessage)
+ {
+ log.Debug("public boolean AcceptInvite(IMessage inviteMessage = " + inviteMessage + "): called");
+
+ // All invites are acceptable.
+ return true;
+ }
+
+ /// <summary>
+ /// Assigns the role to be played by this test case. The test parameters are fully specified in the
+ /// assignment message. When this method return the test case will be ready to execute.
+ /// </summary>
+ ///
+ /// <param name="role"> The role to be played; sender or receiver. </param>
+ /// <param name="assignRoleMessage"> The role assingment message, contains the full test parameters. </param>
+ public void AssignRole(Roles role, IMessage assignRoleMessage)
+ {
+ log.Debug("public void assignRole(Roles role = " + role + ", IMessage assignRoleMessage = " + assignRoleMessage
+ + "): called");
+
+ // Reset the message count for a new test.
+ messageCount = 0;
+
+ // Take note of the role to be played.
+ this.role = role;
+
+ // Extract and retain the test parameters.
+ numMessages = assignRoleMessage.Headers.GetInt("PUBSUB_NUM_MESSAGES");
+ numReceivers = assignRoleMessage.Headers.GetInt("PUBSUB_NUM_RECEIVERS");
+ string sendKey = assignRoleMessage.Headers.GetString("PUBSUB_KEY");
+ sendDestination = sendKey;
+
+ log.Debug("numMessages = " + numMessages);
+ log.Debug("numReceivers = " + numReceivers);
+ log.Debug("sendKey = " + sendKey);
+ log.Debug("role = " + role);
+
+ switch (role)
+ {
+ // Check if the sender role is being assigned, and set up a single message producer if so.
+ case Roles.SENDER:
+ // Create a new connection to pass the test messages on.
+ connection = new IConnection[1];
+ channel = new IChannel[1];
+
+ connection[0] =
+ TestClient.CreateConnection(TestClient.brokerUrl, TestClient.virtualHost);
+ channel[0] = connection[0].CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
+
+ // Extract and retain the test parameters.
+ publisher = channel[0].CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.TOPIC)
+ .WithRoutingKey(sendDestination)
+ .WithMandatory(false)
+ .WithImmediate(false)
+ .Create();
+ break;
+
+ // Otherwise the receiver role is being assigned, so set this up to listen for messages on the required number
+ // of receiver connections.
+ case Roles.RECEIVER:
+ // Create the required number of receiver connections.
+ connection = new IConnection[numReceivers];
+ channel = new IChannel[numReceivers];
+
+ for (int i = 0; i < numReceivers; i++)
+ {
+ connection[i] =
+ TestClient.CreateConnection(TestClient.brokerUrl, TestClient.virtualHost);
+ channel[i] = connection[i].CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
+
+ IMessageConsumer consumer = channel[i].CreateConsumerBuilder(sendDestination).Create();
+ consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
+ }
+
+ break;
+ }
+
+ // Start all the connection dispatcher threads running.
+ foreach (IConnection con in connection)
+ {
+ con.Start();
+ }
+ }
+
+ /// <summary>
+ /// Performs the test case actions.
+ /// </summary>
+ public void Start()
+ {
+ log.Debug("public void Start(): called");
+
+ // Check that the sender role is being performed.
+ if (role == Roles.SENDER)
+ {
+ IMessage testMessage = channel[0].CreateTextMessage("test");
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ publisher.Send(testMessage);
+
+ // Increment the message count.
+ messageCount++;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets a report on the actions performed by the test case in its assigned role.
+ /// </summary>
+ ///
+ /// <param name="session"> The session to create the report message in. </param>
+ ///
+ /// <returns> The report message. </returns>
+ public IMessage GetReport(IChannel channel)
+ {
+ log.Debug("public IMessage getReport(IChannel channel): called");
+
+ // Close the test connections.
+ /*foreach (IConnection con in connection)
+ {
+ try
+ {
+ con.Stop();
+ }
+ catch (AMQConnectionClosedException e)
+ {
+ // The connection has already died due to an error. Log this as a warning.
+ log.Warn("Connection already closed.");
+ }
+ }*/
+
+ // Generate a report message containing the count of the number of messages passed.
+ IMessage report = channel.CreateMessage();
+ //report.Headers.SetString("CONTROL_TYPE", "REPORT");
+ report.Headers.SetInt("MESSAGE_COUNT", messageCount);
+
+ return report;
+ }
+
+ /// <summary>
+ /// Counts incoming test messages.
+ /// </summary>
+ ///
+ /// <param name="message"> The incoming test message. </param>
+ public void OnMessage(IMessage message)
+ {
+ log.Debug("public void onMessage(IMessage message = " + message + "): called");
+
+ // Increment the message count.
+ messageCount++;
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs b/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs
index 82a9de742a..e2fac9e1a4 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/interop/TestClient.cs
@@ -1,379 +1,379 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-using System.Threading;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-using log4net;
-using Apache.Qpid.Integration.Tests.interop.TestCases;
-
-namespace Apache.Qpid.Integration.Tests.interop
-{
- /// <summary>
- /// Implements a test client as described in the interop testing spec
- /// (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). A test client is an agent that
- /// reacts to control message sequences send by the test coordinator.
- ///
- /// <p/><table><caption>Messages Handled by TestClient</caption>
- /// <tr><th> Message <th> Action
- /// <tr><td> Invite(compulsory) <td> Reply with Enlist.
- /// <tr><td> Invite(test case) <td> Reply with Enlist if test case available.
- /// <tr><td> AssignRole(test case) <td> Reply with Accept Role if matches an enlisted test. Keep test parameters.
- /// <tr><td> Start <td> Send test messages defined by test parameters. Send report on messages sent.
- /// <tr><td> Status Request <td> Send report on messages received.
- /// </table>
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Handle all incoming control messages. <td> {@link InteropClientTestCase}
- /// <tr><td> Configure and look up test cases by name. <td> {@link InteropClientTestCase}
- /// </table>
- /// </summary>
- public class TestClient
- {
- private static ILog log = LogManager.GetLogger(typeof(TestClient));
-
- /// <summary> Defines the default broker for the tests, localhost, default port. </summary>
- public static string DEFAULT_BROKER_URL = "amqp://guest:guest@clientid/?brokerlist='tcp://localhost:5672'";
-
- /// <summary> Defines the default virtual host to use for the tests, none. </summary>
- public static string DEFAULT_VIRTUAL_HOST = "";
-
- /// <summary> Defines the default identifying name of this test client. </summary>
- public static string DEFAULT_CLIENT_NAME = "dotnet";
-
- /// <summary> Holds the URL of the broker to run the tests on. </summary>
- public static string brokerUrl;
-
- /// <summary> Holds the virtual host to run the tests on. If <tt>null</tt>, then the default virtual host is used. </summary>
- public static string virtualHost;
-
- /// <summary> The clients identifying name to print in test results and to distinguish from other clients. </summary>
- private string clientName;
-
- /// <summary> Holds all the test cases. </summary>
- private IDictionary testCases = new Hashtable();
-
- InteropClientTestCase currentTestCase;
-
- private MessagePublisherBuilder publisherBuilder;
-
- private IChannel channel;
-
- /// <summary> Monitor to wait for termination events on. </summary>
- private static object terminationMonitor = new Object();
-
- /// <summary>
- /// Creates a new interop test client, listenting to the specified broker and virtual host, with the specified
- /// client identifying name.
- /// </summary>
- ///
- /// <param name="brokerUrl"> The url of the broker to connect to. </param>
- /// <param name="virtualHost"> The virtual host to conect to. </param>
- /// <param name="clientName"> The client name to use. </param>
- public TestClient(string brokerUrl, string virtualHost, string clientName)
- {
- log.Info("public TestClient(string brokerUrl = " + brokerUrl + ", string virtualHost = " + virtualHost
- + ", string clientName = " + clientName + "): called");
-
- // Retain the connection parameters.
- TestClient.brokerUrl = brokerUrl;
- TestClient.virtualHost = virtualHost;
- this.clientName = clientName;
- }
-
-
- /// <summary>
- /// The entry point for the interop test coordinator. This client accepts the following command line arguments:
- /// </summary>
- ///
- /// <p/><table>
- /// <tr><td> -b <td> The broker URL. <td> Optional.
- /// <tr><td> -h <td> The virtual host. <td> Optional.
- /// <tr><td> -n <td> The test client name. <td> Optional.
- /// <tr><td> name=value <td> Trailing argument define name/value pairs. Added to system properties. <td> Optional.
- /// </table>
- ///
- /// <param name="args"> The command line arguments. </param>
- public static void Main(string[] args)
- {
- // Extract the command line options (Not exactly Posix but it will do for now...).
- string brokerUrl = DEFAULT_BROKER_URL;
- string virtualHost = DEFAULT_VIRTUAL_HOST;
- string clientName = DEFAULT_CLIENT_NAME;
-
- foreach (string nextArg in args)
- {
- if (nextArg.StartsWith("-b"))
- {
- brokerUrl = nextArg.Substring(2);
- }
- else if (nextArg.StartsWith("-h"))
- {
- virtualHost = nextArg.Substring(2);
- }
- else if (nextArg.StartsWith("-n"))
- {
- clientName = nextArg.Substring(2);
- }
- }
-
- NDC.Push(clientName);
-
- // Create a test client and start it running.
- TestClient client = new TestClient(brokerUrl, virtualHost, clientName);
-
- try
- {
- client.Start();
- }
- catch (Exception e)
- {
- log.Error("The test client was unable to start.", e);
- System.Environment.Exit(1);
- }
-
- // Wait for a signal on the termination monitor before quitting.
- lock (terminationMonitor)
- {
- Monitor.Wait(terminationMonitor);
- }
-
- NDC.Pop();
- }
-
- /// <summary>
- /// Starts the interop test client running. This causes it to start listening for incoming test invites.
- /// </summary>
- private void Start()
- {
- log.Info("private void Start(): called");
-
- // Use a class path scanner to find all the interop test case implementations.
- ArrayList testCaseClasses = new ArrayList();
-
- // ClasspathScanner.getMatches(InteropClientTestCase.class, "^TestCase.*", true);
- // Hard code the test classes till the classpath scanner is fixed.
- testCaseClasses.Add(typeof(TestCase1DummyRun));
- testCaseClasses.Add(typeof(TestCase2BasicP2P));
- testCaseClasses.Add(typeof(TestCase3BasicPubSub));
-
- // Create all the test case implementations and index them by the test names.
- foreach (Type testClass in testCaseClasses)
- {
- InteropClientTestCase testCase = (InteropClientTestCase)Activator.CreateInstance(testClass);
- testCases.Add(testCase.GetName(), testCase);
-
- log.Info("Found test case: " + testClass);
- }
-
- // Open a connection to communicate with the coordinator on.
- log.Info("brokerUrl = " + brokerUrl);
- IConnection connection = CreateConnection(brokerUrl, virtualHost);
-
- channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
-
- // Set this up to listen for control messages.
- string responseQueueName = channel.GenerateUniqueName();
- channel.DeclareQueue(responseQueueName, false, true, true);
-
- channel.Bind(responseQueueName, ExchangeNameDefaults.TOPIC, "iop.control." + clientName);
- channel.Bind(responseQueueName, ExchangeNameDefaults.TOPIC, "iop.control");
-
- IMessageConsumer consumer = channel.CreateConsumerBuilder(responseQueueName)
- .Create();
- consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
-
- // Create a publisher to send replies with.
- publisherBuilder = channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.DIRECT);
-
-
- // Start listening for incoming control messages.
- connection.Start();
- Console.WriteLine("Test client " + clientName + " ready to receive test control messages...");
- }
-
- /// <summary>
- /// Establishes an AMQ connection. This is a simple convenience method for code that does not anticipate handling connection failures.
- /// All exceptions that indicate that the connection has failed, are allowed to fall through.
- /// </summary>
- ///
- /// <param name="brokerUrl"> The broker url to connect to, <tt>null</tt> to use the default from the properties. </param>
- /// <param name="virtualHost"> The virtual host to connectio to, <tt>null</tt> to use the default. </param>
- ///
- /// <returns> A JMS conneciton. </returns>
- public static IConnection CreateConnection(string brokerUrl, string virtualHost)
- {
- log.Info("public static Connection createConnection(string brokerUrl = " + brokerUrl + ", string virtualHost = "
- + virtualHost + "): called");
-
- // Create a connection to the broker.
- IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(brokerUrl);
- connectionInfo.VirtualHost = virtualHost;
- IConnection connection = new AMQConnection(connectionInfo);
-
- return connection;
- }
-
- /// <summary>
- /// Handles all incoming control messages.
- /// </summary>
- ///
- /// <param name="message"> The incoming message. </param>
- public void OnMessage(IMessage message)
- {
- log.Info("public void OnMessage(IMessage message = " + message + "): called");
-
- try
- {
- string controlType = message.Headers.GetString("CONTROL_TYPE");
- string testName = message.Headers.GetString("TEST_NAME");
-
- // Check if the message is a test invite.
- if ("INVITE" == controlType)
- {
- string testCaseName = message.Headers.GetString("TEST_NAME");
-
- // Flag used to indicate that an enlist should be sent. Only enlist to compulsory invites or invites
- // for which test cases exist.
- bool enlist = false;
-
- if (testCaseName != null)
- {
- log.Info("Got an invite to test: " + testCaseName);
-
- // Check if the requested test case is available.
- InteropClientTestCase testCase = (InteropClientTestCase)testCases[testCaseName];
-
- if (testCase != null)
- {
- // Make the requested test case the current test case.
- currentTestCase = testCase;
- enlist = true;
- }
- }
- else
- {
- log.Info("Got a compulsory invite.");
-
- enlist = true;
- }
-
- log.Info("enlist = " + enlist);
-
- if (enlist)
- {
- // Reply with the client name in an Enlist message.
- IMessage enlistMessage = channel.CreateMessage();
- enlistMessage.Headers.SetString("CONTROL_TYPE", "ENLIST");
- enlistMessage.Headers.SetString("CLIENT_NAME", clientName);
- enlistMessage.Headers.SetString("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
- enlistMessage.CorrelationId = message.CorrelationId;
-
- Send(enlistMessage, message.ReplyToRoutingKey);
- }
- }
- else if ("ASSIGN_ROLE" == controlType)
- {
- // Assign the role to the current test case.
- string roleName = message.Headers.GetString("ROLE");
-
- log.Info("Got a role assignment to role: " + roleName);
-
- Roles role;
-
- if (roleName == "SENDER")
- {
- role = Roles.SENDER;
- }
- else
- {
- role = Roles.RECEIVER;
- }
-
- currentTestCase.AssignRole(role, message);
-
- // Reply by accepting the role in an Accept Role message.
- IMessage acceptRoleMessage = channel.CreateMessage();
- acceptRoleMessage.Headers.SetString("CONTROL_TYPE", "ACCEPT_ROLE");
- acceptRoleMessage.CorrelationId = message.CorrelationId;
-
- Send(acceptRoleMessage, message.ReplyToRoutingKey);
- }
- else if ("START" == controlType || "STATUS_REQUEST" == controlType)
- {
- if ("START" == controlType)
- {
- log.Info("Got a start notification.");
-
- // Start the current test case.
- currentTestCase.Start();
- }
- else
- {
- log.Info("Got a status request.");
- }
-
- // Generate the report from the test case and reply with it as a Report message.
- IMessage reportMessage = currentTestCase.GetReport(channel);
- reportMessage.Headers.SetString("CONTROL_TYPE", "REPORT");
- reportMessage.CorrelationId = message.CorrelationId;
-
- Send(reportMessage, message.ReplyToRoutingKey);
- }
- else if ("TERMINATE" == controlType)
- {
- Console.WriteLine("Received termination instruction from coordinator.");
-
- // Is a cleaner shutdown needed?
- System.Environment.Exit(1);
- }
- else
- {
- // Log a warning about this but otherwise ignore it.
- log.Warn("Got an unknown control message, controlType = " + controlType + ", message = " + message);
- }
- }
- catch (QpidException e)
- {
- // Log a warning about this, but otherwise ignore it.
- log.Warn("A QpidException occurred whilst handling a message.");
- log.Info("Got QpidException whilst handling message: " + message, e);
- }
- }
-
- /// <summary>
- /// Send the specified message using the specified routing key on the direct exchange.
- /// </summary>
- ///
- /// <param name="message"> The message to send.</param>
- /// <param name="routingKey"> The routing key to send the message with.</param>
- public void Send(IMessage message, string routingKey)
- {
- IMessagePublisher publisher = publisherBuilder.WithRoutingKey(routingKey).Create();
- publisher.Send(message);
- }
- }
-}
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+using System.Threading;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+using log4net;
+using Apache.Qpid.Integration.Tests.interop.TestCases;
+
+namespace Apache.Qpid.Integration.Tests.interop
+{
+ /// <summary>
+ /// Implements a test client as described in the interop testing spec
+ /// (http://cwiki.apache.org/confluence/display/qpid/Interop+Testing+Specification). A test client is an agent that
+ /// reacts to control message sequences send by the test coordinator.
+ ///
+ /// <p/><table><caption>Messages Handled by TestClient</caption>
+ /// <tr><th> Message <th> Action
+ /// <tr><td> Invite(compulsory) <td> Reply with Enlist.
+ /// <tr><td> Invite(test case) <td> Reply with Enlist if test case available.
+ /// <tr><td> AssignRole(test case) <td> Reply with Accept Role if matches an enlisted test. Keep test parameters.
+ /// <tr><td> Start <td> Send test messages defined by test parameters. Send report on messages sent.
+ /// <tr><td> Status Request <td> Send report on messages received.
+ /// </table>
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Handle all incoming control messages. <td> {@link InteropClientTestCase}
+ /// <tr><td> Configure and look up test cases by name. <td> {@link InteropClientTestCase}
+ /// </table>
+ /// </summary>
+ public class TestClient
+ {
+ private static ILog log = LogManager.GetLogger(typeof(TestClient));
+
+ /// <summary> Defines the default broker for the tests, localhost, default port. </summary>
+ public static string DEFAULT_BROKER_URL = "amqp://guest:guest@clientid/?brokerlist='tcp://localhost:5672'";
+
+ /// <summary> Defines the default virtual host to use for the tests, none. </summary>
+ public static string DEFAULT_VIRTUAL_HOST = "";
+
+ /// <summary> Defines the default identifying name of this test client. </summary>
+ public static string DEFAULT_CLIENT_NAME = "dotnet";
+
+ /// <summary> Holds the URL of the broker to run the tests on. </summary>
+ public static string brokerUrl;
+
+ /// <summary> Holds the virtual host to run the tests on. If <tt>null</tt>, then the default virtual host is used. </summary>
+ public static string virtualHost;
+
+ /// <summary> The clients identifying name to print in test results and to distinguish from other clients. </summary>
+ private string clientName;
+
+ /// <summary> Holds all the test cases. </summary>
+ private IDictionary testCases = new Hashtable();
+
+ InteropClientTestCase currentTestCase;
+
+ private MessagePublisherBuilder publisherBuilder;
+
+ private IChannel channel;
+
+ /// <summary> Monitor to wait for termination events on. </summary>
+ private static object terminationMonitor = new Object();
+
+ /// <summary>
+ /// Creates a new interop test client, listenting to the specified broker and virtual host, with the specified
+ /// client identifying name.
+ /// </summary>
+ ///
+ /// <param name="brokerUrl"> The url of the broker to connect to. </param>
+ /// <param name="virtualHost"> The virtual host to conect to. </param>
+ /// <param name="clientName"> The client name to use. </param>
+ public TestClient(string brokerUrl, string virtualHost, string clientName)
+ {
+ log.Info("public TestClient(string brokerUrl = " + brokerUrl + ", string virtualHost = " + virtualHost
+ + ", string clientName = " + clientName + "): called");
+
+ // Retain the connection parameters.
+ TestClient.brokerUrl = brokerUrl;
+ TestClient.virtualHost = virtualHost;
+ this.clientName = clientName;
+ }
+
+
+ /// <summary>
+ /// The entry point for the interop test coordinator. This client accepts the following command line arguments:
+ /// </summary>
+ ///
+ /// <p/><table>
+ /// <tr><td> -b <td> The broker URL. <td> Optional.
+ /// <tr><td> -h <td> The virtual host. <td> Optional.
+ /// <tr><td> -n <td> The test client name. <td> Optional.
+ /// <tr><td> name=value <td> Trailing argument define name/value pairs. Added to system properties. <td> Optional.
+ /// </table>
+ ///
+ /// <param name="args"> The command line arguments. </param>
+ public static void Main(string[] args)
+ {
+ // Extract the command line options (Not exactly Posix but it will do for now...).
+ string brokerUrl = DEFAULT_BROKER_URL;
+ string virtualHost = DEFAULT_VIRTUAL_HOST;
+ string clientName = DEFAULT_CLIENT_NAME;
+
+ foreach (string nextArg in args)
+ {
+ if (nextArg.StartsWith("-b"))
+ {
+ brokerUrl = nextArg.Substring(2);
+ }
+ else if (nextArg.StartsWith("-h"))
+ {
+ virtualHost = nextArg.Substring(2);
+ }
+ else if (nextArg.StartsWith("-n"))
+ {
+ clientName = nextArg.Substring(2);
+ }
+ }
+
+ NDC.Push(clientName);
+
+ // Create a test client and start it running.
+ TestClient client = new TestClient(brokerUrl, virtualHost, clientName);
+
+ try
+ {
+ client.Start();
+ }
+ catch (Exception e)
+ {
+ log.Error("The test client was unable to start.", e);
+ System.Environment.Exit(1);
+ }
+
+ // Wait for a signal on the termination monitor before quitting.
+ lock (terminationMonitor)
+ {
+ Monitor.Wait(terminationMonitor);
+ }
+
+ NDC.Pop();
+ }
+
+ /// <summary>
+ /// Starts the interop test client running. This causes it to start listening for incoming test invites.
+ /// </summary>
+ private void Start()
+ {
+ log.Info("private void Start(): called");
+
+ // Use a class path scanner to find all the interop test case implementations.
+ ArrayList testCaseClasses = new ArrayList();
+
+ // ClasspathScanner.getMatches(InteropClientTestCase.class, "^TestCase.*", true);
+ // Hard code the test classes till the classpath scanner is fixed.
+ testCaseClasses.Add(typeof(TestCase1DummyRun));
+ testCaseClasses.Add(typeof(TestCase2BasicP2P));
+ testCaseClasses.Add(typeof(TestCase3BasicPubSub));
+
+ // Create all the test case implementations and index them by the test names.
+ foreach (Type testClass in testCaseClasses)
+ {
+ InteropClientTestCase testCase = (InteropClientTestCase)Activator.CreateInstance(testClass);
+ testCases.Add(testCase.GetName(), testCase);
+
+ log.Info("Found test case: " + testClass);
+ }
+
+ // Open a connection to communicate with the coordinator on.
+ log.Info("brokerUrl = " + brokerUrl);
+ IConnection connection = CreateConnection(brokerUrl, virtualHost);
+
+ channel = connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
+
+ // Set this up to listen for control messages.
+ string responseQueueName = channel.GenerateUniqueName();
+ channel.DeclareQueue(responseQueueName, false, true, true);
+
+ channel.Bind(responseQueueName, ExchangeNameDefaults.TOPIC, "iop.control." + clientName);
+ channel.Bind(responseQueueName, ExchangeNameDefaults.TOPIC, "iop.control");
+
+ IMessageConsumer consumer = channel.CreateConsumerBuilder(responseQueueName)
+ .Create();
+ consumer.OnMessage += new MessageReceivedDelegate(OnMessage);
+
+ // Create a publisher to send replies with.
+ publisherBuilder = channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.DIRECT);
+
+
+ // Start listening for incoming control messages.
+ connection.Start();
+ Console.WriteLine("Test client " + clientName + " ready to receive test control messages...");
+ }
+
+ /// <summary>
+ /// Establishes an AMQ connection. This is a simple convenience method for code that does not anticipate handling connection failures.
+ /// All exceptions that indicate that the connection has failed, are allowed to fall through.
+ /// </summary>
+ ///
+ /// <param name="brokerUrl"> The broker url to connect to, <tt>null</tt> to use the default from the properties. </param>
+ /// <param name="virtualHost"> The virtual host to connectio to, <tt>null</tt> to use the default. </param>
+ ///
+ /// <returns> A JMS conneciton. </returns>
+ public static IConnection CreateConnection(string brokerUrl, string virtualHost)
+ {
+ log.Info("public static Connection createConnection(string brokerUrl = " + brokerUrl + ", string virtualHost = "
+ + virtualHost + "): called");
+
+ // Create a connection to the broker.
+ IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(brokerUrl);
+ connectionInfo.VirtualHost = virtualHost;
+ IConnection connection = new AMQConnection(connectionInfo);
+
+ return connection;
+ }
+
+ /// <summary>
+ /// Handles all incoming control messages.
+ /// </summary>
+ ///
+ /// <param name="message"> The incoming message. </param>
+ public void OnMessage(IMessage message)
+ {
+ log.Info("public void OnMessage(IMessage message = " + message + "): called");
+
+ try
+ {
+ string controlType = message.Headers.GetString("CONTROL_TYPE");
+ string testName = message.Headers.GetString("TEST_NAME");
+
+ // Check if the message is a test invite.
+ if ("INVITE" == controlType)
+ {
+ string testCaseName = message.Headers.GetString("TEST_NAME");
+
+ // Flag used to indicate that an enlist should be sent. Only enlist to compulsory invites or invites
+ // for which test cases exist.
+ bool enlist = false;
+
+ if (testCaseName != null)
+ {
+ log.Info("Got an invite to test: " + testCaseName);
+
+ // Check if the requested test case is available.
+ InteropClientTestCase testCase = (InteropClientTestCase)testCases[testCaseName];
+
+ if (testCase != null)
+ {
+ // Make the requested test case the current test case.
+ currentTestCase = testCase;
+ enlist = true;
+ }
+ }
+ else
+ {
+ log.Info("Got a compulsory invite.");
+
+ enlist = true;
+ }
+
+ log.Info("enlist = " + enlist);
+
+ if (enlist)
+ {
+ // Reply with the client name in an Enlist message.
+ IMessage enlistMessage = channel.CreateMessage();
+ enlistMessage.Headers.SetString("CONTROL_TYPE", "ENLIST");
+ enlistMessage.Headers.SetString("CLIENT_NAME", clientName);
+ enlistMessage.Headers.SetString("CLIENT_PRIVATE_CONTROL_KEY", "iop.control." + clientName);
+ enlistMessage.CorrelationId = message.CorrelationId;
+
+ Send(enlistMessage, message.ReplyToRoutingKey);
+ }
+ }
+ else if ("ASSIGN_ROLE" == controlType)
+ {
+ // Assign the role to the current test case.
+ string roleName = message.Headers.GetString("ROLE");
+
+ log.Info("Got a role assignment to role: " + roleName);
+
+ Roles role;
+
+ if (roleName == "SENDER")
+ {
+ role = Roles.SENDER;
+ }
+ else
+ {
+ role = Roles.RECEIVER;
+ }
+
+ currentTestCase.AssignRole(role, message);
+
+ // Reply by accepting the role in an Accept Role message.
+ IMessage acceptRoleMessage = channel.CreateMessage();
+ acceptRoleMessage.Headers.SetString("CONTROL_TYPE", "ACCEPT_ROLE");
+ acceptRoleMessage.CorrelationId = message.CorrelationId;
+
+ Send(acceptRoleMessage, message.ReplyToRoutingKey);
+ }
+ else if ("START" == controlType || "STATUS_REQUEST" == controlType)
+ {
+ if ("START" == controlType)
+ {
+ log.Info("Got a start notification.");
+
+ // Start the current test case.
+ currentTestCase.Start();
+ }
+ else
+ {
+ log.Info("Got a status request.");
+ }
+
+ // Generate the report from the test case and reply with it as a Report message.
+ IMessage reportMessage = currentTestCase.GetReport(channel);
+ reportMessage.Headers.SetString("CONTROL_TYPE", "REPORT");
+ reportMessage.CorrelationId = message.CorrelationId;
+
+ Send(reportMessage, message.ReplyToRoutingKey);
+ }
+ else if ("TERMINATE" == controlType)
+ {
+ Console.WriteLine("Received termination instruction from coordinator.");
+
+ // Is a cleaner shutdown needed?
+ System.Environment.Exit(1);
+ }
+ else
+ {
+ // Log a warning about this but otherwise ignore it.
+ log.Warn("Got an unknown control message, controlType = " + controlType + ", message = " + message);
+ }
+ }
+ catch (QpidException e)
+ {
+ // Log a warning about this, but otherwise ignore it.
+ log.Warn("A QpidException occurred whilst handling a message.");
+ log.Info("Got QpidException whilst handling message: " + message, e);
+ }
+ }
+
+ /// <summary>
+ /// Send the specified message using the specified routing key on the direct exchange.
+ /// </summary>
+ ///
+ /// <param name="message"> The message to send.</param>
+ /// <param name="routingKey"> The routing key to send the message with.</param>
+ public void Send(IMessage message, string routingKey)
+ {
+ IMessagePublisher publisher = publisherBuilder.WithRoutingKey(routingKey).Create();
+ publisher.Send(message);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs
index d4b61a2788..4c82dbe08c 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/BaseMessagingTestFixture.cs
@@ -1,261 +1,261 @@
-/*
- *
- * 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 System.Text;
-using log4net;
-using NUnit.Framework;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// <summary>
- /// Provides a basis for writing Unit tests that communicate with an AMQ protocol broker. By default it creates a connection
- /// to a message broker running on localhost on the standard AMQ port, 5672, using guest:guest login credentials. It also
- /// creates a standard auto-ack channel on this connection.
- /// </summary>
- public class BaseMessagingTestFixture
- {
- private static ILog log = LogManager.GetLogger(typeof(BaseMessagingTestFixture));
-
- /// <summary> Used to build dummy data to fill test messages with. </summary>
- private const string MESSAGE_DATA_BYTES = "-- Test Message -- Test Message -- Test Message -- Test Message -- Test Message ";
-
- /// <summary> The default timeout in milliseconds to use on receives. </summary>
- private const long RECEIVE_WAIT = 2000;
-
- /// <summary> The default AMQ connection URL to use for tests. </summary>
- public const string connectionUri = "amqp://guest:guest@test/test?brokerlist='tcp://localhost:5672'";
-
- /// <summary> The default AMQ connection URL parsed as a connection info. </summary>
- protected IConnectionInfo connectionInfo;
-
- /// <summary> Holds an array of connections for building mutiple test end-points. </summary>
- protected IConnection[] testConnection = new IConnection[10];
-
- /// <summary> Holds an array of channels for building mutiple test end-points. </summary>
- protected IChannel[] testChannel = new IChannel[10];
-
- /// <summary> Holds an array of queues for building mutiple test end-points. </summary>
- protected String[] testQueue = new String[10];
-
- /// <summary> Holds an array of producers for building mutiple test end-points. </summary>
- protected IMessagePublisher[] testProducer = new IMessagePublisher[10];
-
- /// <summary> Holds an array of consumers for building mutiple test end-points. </summary>
- protected IMessageConsumer[] testConsumer = new IMessageConsumer[10];
-
- /// <summary> A counter used to supply unique ids. </summary>
- private static int uniqueId = 0;
-
- /// <summary> Used to hold unique ids per test. </summary>
- protected Guid testId;
-
- /// <summary> Creates the test connection and channel. </summary>
- [SetUp]
- public virtual void Init()
- {
- log.Debug("public virtual void Init(): called");
-
- // Set up a unique id for this test.
- testId = System.Guid.NewGuid();
- }
-
- /// <summary>
- /// Disposes of the test connection. This is called manually because the connection is a field so dispose will not be automatically
- /// called on it.
- /// </summary>
- [TearDown]
- public virtual void Shutdown()
- {
- log.Debug("public virtual void Shutdown(): called");
- }
-
- /// <summary> Sets up the nth test end-point. </summary>
- ///
- /// <param name="n">The index of the test end-point to set up.</param>
- /// <param name="producer"><tt>true</tt> to set up a producer on the end-point.</param>
- /// <param name="consumer"><tt>true</tt> to set up a consumer on the end-point.</param>
- /// <param name="routingKey">The routing key for the producer to send on.</param>
- /// <param name="ackMode">The ack mode for the end-points channel.</param>
- /// <param name="transacted"><tt>true</tt> to use transactions on the end-points channel.</param>
- /// <param name="exchangeName">The exchange to produce or consume on.</param>
- /// <param name="declareBind"><tt>true</tt> if the consumers queue should be declared and bound, <tt>false</tt> if it has already been.</param>
- /// <param name="durable"><tt>true</tt> to declare the consumers queue as durable.</param>
- /// <param name="subscriptionName">If durable is true, the fixed unique queue name to use.</param>
- public void SetUpEndPoint(int n, bool producer, bool consumer, string routingKey, AcknowledgeMode ackMode, bool transacted,
- string exchangeName, bool declareBind, bool durable, string subscriptionName)
- {
- // Allow client id to be fixed, or undefined.
- {
- // Use unique id for end point.
- connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
-
- connectionInfo.ClientName = "test" + n;
- }
-
- testConnection[n] = new AMQConnection(connectionInfo);
- testConnection[n].Start();
- testChannel[n] = testConnection[n].CreateChannel(transacted, ackMode);
-
- if (producer)
- {
- testProducer[n] = testChannel[n].CreatePublisherBuilder()
- .WithExchangeName(exchangeName)
- .WithRoutingKey(routingKey)
- .Create();
- }
-
- if (consumer)
- {
- string queueName;
-
- // Use the subscription name as the queue name if the subscription is durable, otherwise use a generated name.
- if (durable)
- {
- // The durable queue is declared without auto-delete, and passively, in case it has already been declared.
- queueName = subscriptionName;
-
- if (declareBind)
- {
- testChannel[n].DeclareQueue(queueName, durable, true, false);
- testChannel[n].Bind(queueName, exchangeName, routingKey);
- }
- }
- else
- {
- queueName = testChannel[n].GenerateUniqueName();
-
- if (declareBind)
- {
- if (durable)
- {
- testQueue[n] = queueName;
- }
- testChannel[n].DeclareQueue(queueName, durable, true, true);
- testChannel[n].Bind(queueName, exchangeName, routingKey);
- }
- }
-
- testConsumer[n] = testChannel[n].CreateConsumerBuilder(queueName).Create();
- }
- }
-
- /// <summary> Closes down the nth test end-point. </summary>
- public void CloseEndPoint(int n)
- {
- log.Debug("public void CloseEndPoint(int n): called");
-
- if (testProducer[n] != null)
- {
- testProducer[n].Close();
- testProducer[n].Dispose();
- testProducer[n] = null;
- }
-
- if (testConsumer[n] != null)
- {
- if (testQueue[n] != null)
- {
- testChannel[n].DeleteQueue(testQueue[n], false, false, true);
- }
- testConsumer[n].Close();
- testConsumer[n].Dispose();
- testConsumer[n] = null;
- }
-
- if (testConnection[n] != null)
- {
- testConnection[n].Stop();
- testConnection[n].Close();
- testConnection[n].Dispose();
- testConnection[n] = null;
- }
- }
-
- /// <summary>
- /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages
- /// are text messages with contents equal to the specified message body.
- /// </summary>
- ///
- /// <param name="n">The number of messages to consume.</param>
- /// <param name="body">The body text to match against all messages.</param>
- /// <param name="consumer">The message consumer to recieve the messages on.</param>
- public static void ConsumeNMessagesOnly(int n, string body, IMessageConsumer consumer)
- {
- ConsumeNMessages(n, body, consumer);
-
- // Check that one more than n cannot be received.
- IMessage msg = consumer.Receive(RECEIVE_WAIT);
- Assert.IsNull(msg, "Consumer got more messages than the number requested (" + n + ").");
- }
-
- /// <summary>
- /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages
- /// are text messages with contents equal to the specified message body.
- /// </summary>
- ///
- /// <param name="n">The number of messages to consume.</param>
- /// <param name="body">The body text to match against all messages.</param>
- /// <param name="consumer">The message consumer to recieve the messages on.</param>
- public static void ConsumeNMessages(int n, string body, IMessageConsumer consumer)
- {
- IMessage msg;
-
- // Try to receive n messages.
- for (int i = 0; i < n; i++)
- {
- msg = consumer.Receive(RECEIVE_WAIT);
- Assert.IsNotNull(msg, "Consumer did not receive message number: " + i);
- Assert.AreEqual(body, ((ITextMessage)msg).Text, "Incorrect Message recevied on consumer1.");
- }
- }
-
- /// <summary>Creates the requested number of bytes of dummy text. Usually used for filling test messages. </summary>
- ///
- /// <param name="size">The number of bytes of dummy text to generate.</param>
- ///
- /// <return>The requested number of bytes of dummy text.</return>
- public static String GetData(int size)
- {
- StringBuilder buf = new StringBuilder(size);
-
- if (size > 0)
- {
- int div = MESSAGE_DATA_BYTES.Length / size;
- int mod = MESSAGE_DATA_BYTES.Length % size;
-
- for (int i = 0; i < div; i++)
- {
- buf.Append(MESSAGE_DATA_BYTES);
- }
-
- if (mod != 0)
- {
- buf.Append(MESSAGE_DATA_BYTES, 0, mod);
- }
- }
-
- return buf.ToString();
- }
- }
-}
+/*
+ *
+ * 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 System.Text;
+using log4net;
+using NUnit.Framework;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// <summary>
+ /// Provides a basis for writing Unit tests that communicate with an AMQ protocol broker. By default it creates a connection
+ /// to a message broker running on localhost on the standard AMQ port, 5672, using guest:guest login credentials. It also
+ /// creates a standard auto-ack channel on this connection.
+ /// </summary>
+ public class BaseMessagingTestFixture
+ {
+ private static ILog log = LogManager.GetLogger(typeof(BaseMessagingTestFixture));
+
+ /// <summary> Used to build dummy data to fill test messages with. </summary>
+ private const string MESSAGE_DATA_BYTES = "-- Test Message -- Test Message -- Test Message -- Test Message -- Test Message ";
+
+ /// <summary> The default timeout in milliseconds to use on receives. </summary>
+ private const long RECEIVE_WAIT = 2000;
+
+ /// <summary> The default AMQ connection URL to use for tests. </summary>
+ public const string connectionUri = "amqp://guest:guest@test/test?brokerlist='tcp://localhost:5672'";
+
+ /// <summary> The default AMQ connection URL parsed as a connection info. </summary>
+ protected IConnectionInfo connectionInfo;
+
+ /// <summary> Holds an array of connections for building mutiple test end-points. </summary>
+ protected IConnection[] testConnection = new IConnection[10];
+
+ /// <summary> Holds an array of channels for building mutiple test end-points. </summary>
+ protected IChannel[] testChannel = new IChannel[10];
+
+ /// <summary> Holds an array of queues for building mutiple test end-points. </summary>
+ protected String[] testQueue = new String[10];
+
+ /// <summary> Holds an array of producers for building mutiple test end-points. </summary>
+ protected IMessagePublisher[] testProducer = new IMessagePublisher[10];
+
+ /// <summary> Holds an array of consumers for building mutiple test end-points. </summary>
+ protected IMessageConsumer[] testConsumer = new IMessageConsumer[10];
+
+ /// <summary> A counter used to supply unique ids. </summary>
+ private static int uniqueId = 0;
+
+ /// <summary> Used to hold unique ids per test. </summary>
+ protected Guid testId;
+
+ /// <summary> Creates the test connection and channel. </summary>
+ [SetUp]
+ public virtual void Init()
+ {
+ log.Debug("public virtual void Init(): called");
+
+ // Set up a unique id for this test.
+ testId = System.Guid.NewGuid();
+ }
+
+ /// <summary>
+ /// Disposes of the test connection. This is called manually because the connection is a field so dispose will not be automatically
+ /// called on it.
+ /// </summary>
+ [TearDown]
+ public virtual void Shutdown()
+ {
+ log.Debug("public virtual void Shutdown(): called");
+ }
+
+ /// <summary> Sets up the nth test end-point. </summary>
+ ///
+ /// <param name="n">The index of the test end-point to set up.</param>
+ /// <param name="producer"><tt>true</tt> to set up a producer on the end-point.</param>
+ /// <param name="consumer"><tt>true</tt> to set up a consumer on the end-point.</param>
+ /// <param name="routingKey">The routing key for the producer to send on.</param>
+ /// <param name="ackMode">The ack mode for the end-points channel.</param>
+ /// <param name="transacted"><tt>true</tt> to use transactions on the end-points channel.</param>
+ /// <param name="exchangeName">The exchange to produce or consume on.</param>
+ /// <param name="declareBind"><tt>true</tt> if the consumers queue should be declared and bound, <tt>false</tt> if it has already been.</param>
+ /// <param name="durable"><tt>true</tt> to declare the consumers queue as durable.</param>
+ /// <param name="subscriptionName">If durable is true, the fixed unique queue name to use.</param>
+ public void SetUpEndPoint(int n, bool producer, bool consumer, string routingKey, AcknowledgeMode ackMode, bool transacted,
+ string exchangeName, bool declareBind, bool durable, string subscriptionName)
+ {
+ // Allow client id to be fixed, or undefined.
+ {
+ // Use unique id for end point.
+ connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
+
+ connectionInfo.ClientName = "test" + n;
+ }
+
+ testConnection[n] = new AMQConnection(connectionInfo);
+ testConnection[n].Start();
+ testChannel[n] = testConnection[n].CreateChannel(transacted, ackMode);
+
+ if (producer)
+ {
+ testProducer[n] = testChannel[n].CreatePublisherBuilder()
+ .WithExchangeName(exchangeName)
+ .WithRoutingKey(routingKey)
+ .Create();
+ }
+
+ if (consumer)
+ {
+ string queueName;
+
+ // Use the subscription name as the queue name if the subscription is durable, otherwise use a generated name.
+ if (durable)
+ {
+ // The durable queue is declared without auto-delete, and passively, in case it has already been declared.
+ queueName = subscriptionName;
+
+ if (declareBind)
+ {
+ testChannel[n].DeclareQueue(queueName, durable, true, false);
+ testChannel[n].Bind(queueName, exchangeName, routingKey);
+ }
+ }
+ else
+ {
+ queueName = testChannel[n].GenerateUniqueName();
+
+ if (declareBind)
+ {
+ if (durable)
+ {
+ testQueue[n] = queueName;
+ }
+ testChannel[n].DeclareQueue(queueName, durable, true, true);
+ testChannel[n].Bind(queueName, exchangeName, routingKey);
+ }
+ }
+
+ testConsumer[n] = testChannel[n].CreateConsumerBuilder(queueName).Create();
+ }
+ }
+
+ /// <summary> Closes down the nth test end-point. </summary>
+ public void CloseEndPoint(int n)
+ {
+ log.Debug("public void CloseEndPoint(int n): called");
+
+ if (testProducer[n] != null)
+ {
+ testProducer[n].Close();
+ testProducer[n].Dispose();
+ testProducer[n] = null;
+ }
+
+ if (testConsumer[n] != null)
+ {
+ if (testQueue[n] != null)
+ {
+ testChannel[n].DeleteQueue(testQueue[n], false, false, true);
+ }
+ testConsumer[n].Close();
+ testConsumer[n].Dispose();
+ testConsumer[n] = null;
+ }
+
+ if (testConnection[n] != null)
+ {
+ testConnection[n].Stop();
+ testConnection[n].Close();
+ testConnection[n].Dispose();
+ testConnection[n] = null;
+ }
+ }
+
+ /// <summary>
+ /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages
+ /// are text messages with contents equal to the specified message body.
+ /// </summary>
+ ///
+ /// <param name="n">The number of messages to consume.</param>
+ /// <param name="body">The body text to match against all messages.</param>
+ /// <param name="consumer">The message consumer to recieve the messages on.</param>
+ public static void ConsumeNMessagesOnly(int n, string body, IMessageConsumer consumer)
+ {
+ ConsumeNMessages(n, body, consumer);
+
+ // Check that one more than n cannot be received.
+ IMessage msg = consumer.Receive(RECEIVE_WAIT);
+ Assert.IsNull(msg, "Consumer got more messages than the number requested (" + n + ").");
+ }
+
+ /// <summary>
+ /// Consumes n messages, checking that the n+1th is not available within a timeout, and that the consumed messages
+ /// are text messages with contents equal to the specified message body.
+ /// </summary>
+ ///
+ /// <param name="n">The number of messages to consume.</param>
+ /// <param name="body">The body text to match against all messages.</param>
+ /// <param name="consumer">The message consumer to recieve the messages on.</param>
+ public static void ConsumeNMessages(int n, string body, IMessageConsumer consumer)
+ {
+ IMessage msg;
+
+ // Try to receive n messages.
+ for (int i = 0; i < n; i++)
+ {
+ msg = consumer.Receive(RECEIVE_WAIT);
+ Assert.IsNotNull(msg, "Consumer did not receive message number: " + i);
+ Assert.AreEqual(body, ((ITextMessage)msg).Text, "Incorrect Message recevied on consumer1.");
+ }
+ }
+
+ /// <summary>Creates the requested number of bytes of dummy text. Usually used for filling test messages. </summary>
+ ///
+ /// <param name="size">The number of bytes of dummy text to generate.</param>
+ ///
+ /// <return>The requested number of bytes of dummy text.</return>
+ public static String GetData(int size)
+ {
+ StringBuilder buf = new StringBuilder(size);
+
+ if (size > 0)
+ {
+ int div = MESSAGE_DATA_BYTES.Length / size;
+ int mod = MESSAGE_DATA_BYTES.Length % size;
+
+ for (int i = 0; i < div; i++)
+ {
+ buf.Append(MESSAGE_DATA_BYTES);
+ }
+
+ if (mod != 0)
+ {
+ buf.Append(MESSAGE_DATA_BYTES, 0, mod);
+ }
+ }
+
+ return buf.ToString();
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs
index e34864aefd..4692e7ecb1 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/ChannelQueueTest.cs
@@ -1,237 +1,237 @@
-/*
- *
- * 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 System.Net;
-using System.Threading;
-using log4net;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-using Apache.Qpid.Messaging;
-using NUnit.Framework;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// <summary>
- /// Test the queue methods
- /// </summary>
- [TestFixture, Category("Integration")]
- public class ChannelQueueTest
- {
- private static ILog _logger = LogManager.GetLogger(typeof(ChannelQueueTest));
-
- /// <summary> The default AMQ connection URL to use for tests. </summary>
- const string DEFAULT_URI = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'";
- const string _routingKey = "ServiceQ1";
-
- private ExceptionListenerDelegate _exceptionDelegate;
- private AutoResetEvent _evt = new AutoResetEvent(false);
- private Exception _lastException = null;
-
- private IMessageConsumer _consumer;
- private IMessagePublisher _publisher;
- private IChannel _channel;
- private IConnection _connection;
-
- private string _queueName;
-
- [SetUp]
- public virtual void Init()
- {
- _logger.Info("public virtual void Init(): called");
-
- // Create a connection to the broker.
- IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(DEFAULT_URI);
- _connection = new AMQConnection(connectionInfo);
- _logger.Info("Starting...");
-
- // Register this to listen for exceptions on the test connection.
- _exceptionDelegate = new ExceptionListenerDelegate(OnException);
- _connection.ExceptionListener += _exceptionDelegate;
-
- // Establish a session on the broker.
- _channel = _connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1);
-
- // Create a durable, non-temporary, non-exclusive queue.
- _queueName = _channel.GenerateUniqueName();
- _channel.DeclareQueue(_queueName, true, false, false);
-
- _channel.Bind(_queueName, ExchangeNameDefaults.TOPIC, _routingKey);
-
- // Clear the most recent message and exception.
- _lastException = null;
- }
-
- [TearDown]
- public virtual void ShutDown()
- {
- _logger.Info("public virtual void Shutdown(): called");
-
- if (_connection != null)
- {
- _logger.Info("Disposing connection.");
- _connection.Dispose();
- _logger.Info("Connection disposed.");
- }
- }
-
- [Test]
- public void DeleteUsedQueue()
- {
- // Create the consumer
- _consumer = _channel.CreateConsumerBuilder(_queueName)
- .WithPrefetchLow(100)
- .Create();
- _logger.Info("Consumer was created...");
-
- // delete the queue
- _channel.DeleteQueue(_queueName, false, true, true);
- _logger.InfoFormat("Queue {0} was delete", _queueName);
-
- Assert.IsNull(_lastException);
- }
-
- [Test]
- public void DeleteUnusedQueue()
- {
- // delete the queue
- _channel.DeleteQueue(_queueName, true, true, true);
- _logger.InfoFormat("Queue {0} was delete", _queueName);
-
- Assert.IsNull(_lastException);
- }
-
- [Test]
- public void DeleteNonEmptyQueue()
- {
- // Create the publisher
- _publisher = _channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.TOPIC)
- .WithRoutingKey(_routingKey)
- .Create();
- _logger.Info("Publisher created...");
- SendTestMessage("DeleteNonEmptyQueue Message 1");
-
- try
- {
- _channel.DeleteQueue(_queueName, true, false, true);
- }
- catch (AMQException)
- {
- Assert.Fail("The test fails");
- }
- }
-
- [Test]
- public void DeleteEmptyQueue()
- {
- // Create the publisher
- _publisher = _channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.TOPIC)
- .WithRoutingKey(_routingKey)
- .Create();
- _logger.Info("Publisher created...");
-
- // delete an empty queue with ifEmpty = true
- _channel.DeleteQueue(_queueName, false, true, true);
-
- Assert.IsNull(_lastException);
- }
-
- [Test]
- public void DeleteQueueWithResponse()
- {
- // Create the publisher
- _publisher = _channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.TOPIC)
- .WithRoutingKey(_routingKey)
- .Create();
- _logger.Info("Publisher created...");
-
- SendTestMessage("DeleteQueueWithResponse Message 1");
- SendTestMessage("DeleteQueueWithResponse Message 2");
-
- // delete the queue, the server must respond
- _channel.DeleteQueue(_queueName, false, false, false);
- }
-
- [Test]
- public void PurgeQueueWithResponse()
- {
- _publisher = _channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.TOPIC)
- .WithRoutingKey(_routingKey)
- .Create();
- _logger.Info("Pubisher created");
-
- SendTestMessage("Message 1");
- SendTestMessage("Message 2");
-
- _channel.PurgeQueue(_queueName, false);
- }
-
- [Test]
- public void PurgeQueueWithOutResponse()
- {
- _publisher = _channel.CreatePublisherBuilder()
- .WithExchangeName(ExchangeNameDefaults.TOPIC)
- .WithRoutingKey(_routingKey)
- .Create();
- _logger.Info("Pubisher created");
-
- SendTestMessage("Message 1");
- SendTestMessage("Message 2");
-
- _channel.PurgeQueue(_queueName, true);
- }
-
-
- /// <summary>
- /// Callback method to handle any exceptions raised by the test connection.</summary> ///
- /// <param name="e">The connection exception.</param>
- public void OnException(Exception e)
- {
- // Preserve the most recent exception in case test cases need to examine it.
- _lastException = e;
-
- // Notify any waiting threads that an exception event has occurred.
- _evt.Set();
- }
-
- /// <summary>
- /// Sends the specified message to the test publisher, and confirms that it was received by the test consumer or not
- /// depending on whether or not the message should be received by the consumer.
- ///
- /// Any exceptions raised by the connection will cause an Assert failure exception to be raised.
- /// </summary>
- ///
- /// <param name="msgSend">The message to send.</param>
- private void SendTestMessage(string msg)
- {
- // create the IMessage object
- IMessage msgSend = _channel.CreateTextMessage(msg);
-
- // send the message
- _publisher.Send(msgSend);
- _logger.InfoFormat("The messages \"{0}\" was sent", msg);
- }
-
- }
-}
+/*
+ *
+ * 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 System.Net;
+using System.Threading;
+using log4net;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+using Apache.Qpid.Messaging;
+using NUnit.Framework;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// <summary>
+ /// Test the queue methods
+ /// </summary>
+ [TestFixture, Category("Integration")]
+ public class ChannelQueueTest
+ {
+ private static ILog _logger = LogManager.GetLogger(typeof(ChannelQueueTest));
+
+ /// <summary> The default AMQ connection URL to use for tests. </summary>
+ const string DEFAULT_URI = "amqp://guest:guest@default/test?brokerlist='tcp://localhost:5672'";
+ const string _routingKey = "ServiceQ1";
+
+ private ExceptionListenerDelegate _exceptionDelegate;
+ private AutoResetEvent _evt = new AutoResetEvent(false);
+ private Exception _lastException = null;
+
+ private IMessageConsumer _consumer;
+ private IMessagePublisher _publisher;
+ private IChannel _channel;
+ private IConnection _connection;
+
+ private string _queueName;
+
+ [SetUp]
+ public virtual void Init()
+ {
+ _logger.Info("public virtual void Init(): called");
+
+ // Create a connection to the broker.
+ IConnectionInfo connectionInfo = QpidConnectionInfo.FromUrl(DEFAULT_URI);
+ _connection = new AMQConnection(connectionInfo);
+ _logger.Info("Starting...");
+
+ // Register this to listen for exceptions on the test connection.
+ _exceptionDelegate = new ExceptionListenerDelegate(OnException);
+ _connection.ExceptionListener += _exceptionDelegate;
+
+ // Establish a session on the broker.
+ _channel = _connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 1);
+
+ // Create a durable, non-temporary, non-exclusive queue.
+ _queueName = _channel.GenerateUniqueName();
+ _channel.DeclareQueue(_queueName, true, false, false);
+
+ _channel.Bind(_queueName, ExchangeNameDefaults.TOPIC, _routingKey);
+
+ // Clear the most recent message and exception.
+ _lastException = null;
+ }
+
+ [TearDown]
+ public virtual void ShutDown()
+ {
+ _logger.Info("public virtual void Shutdown(): called");
+
+ if (_connection != null)
+ {
+ _logger.Info("Disposing connection.");
+ _connection.Dispose();
+ _logger.Info("Connection disposed.");
+ }
+ }
+
+ [Test]
+ public void DeleteUsedQueue()
+ {
+ // Create the consumer
+ _consumer = _channel.CreateConsumerBuilder(_queueName)
+ .WithPrefetchLow(100)
+ .Create();
+ _logger.Info("Consumer was created...");
+
+ // delete the queue
+ _channel.DeleteQueue(_queueName, false, true, true);
+ _logger.InfoFormat("Queue {0} was delete", _queueName);
+
+ Assert.IsNull(_lastException);
+ }
+
+ [Test]
+ public void DeleteUnusedQueue()
+ {
+ // delete the queue
+ _channel.DeleteQueue(_queueName, true, true, true);
+ _logger.InfoFormat("Queue {0} was delete", _queueName);
+
+ Assert.IsNull(_lastException);
+ }
+
+ [Test]
+ public void DeleteNonEmptyQueue()
+ {
+ // Create the publisher
+ _publisher = _channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.TOPIC)
+ .WithRoutingKey(_routingKey)
+ .Create();
+ _logger.Info("Publisher created...");
+ SendTestMessage("DeleteNonEmptyQueue Message 1");
+
+ try
+ {
+ _channel.DeleteQueue(_queueName, true, false, true);
+ }
+ catch (AMQException)
+ {
+ Assert.Fail("The test fails");
+ }
+ }
+
+ [Test]
+ public void DeleteEmptyQueue()
+ {
+ // Create the publisher
+ _publisher = _channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.TOPIC)
+ .WithRoutingKey(_routingKey)
+ .Create();
+ _logger.Info("Publisher created...");
+
+ // delete an empty queue with ifEmpty = true
+ _channel.DeleteQueue(_queueName, false, true, true);
+
+ Assert.IsNull(_lastException);
+ }
+
+ [Test]
+ public void DeleteQueueWithResponse()
+ {
+ // Create the publisher
+ _publisher = _channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.TOPIC)
+ .WithRoutingKey(_routingKey)
+ .Create();
+ _logger.Info("Publisher created...");
+
+ SendTestMessage("DeleteQueueWithResponse Message 1");
+ SendTestMessage("DeleteQueueWithResponse Message 2");
+
+ // delete the queue, the server must respond
+ _channel.DeleteQueue(_queueName, false, false, false);
+ }
+
+ [Test]
+ public void PurgeQueueWithResponse()
+ {
+ _publisher = _channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.TOPIC)
+ .WithRoutingKey(_routingKey)
+ .Create();
+ _logger.Info("Pubisher created");
+
+ SendTestMessage("Message 1");
+ SendTestMessage("Message 2");
+
+ _channel.PurgeQueue(_queueName, false);
+ }
+
+ [Test]
+ public void PurgeQueueWithOutResponse()
+ {
+ _publisher = _channel.CreatePublisherBuilder()
+ .WithExchangeName(ExchangeNameDefaults.TOPIC)
+ .WithRoutingKey(_routingKey)
+ .Create();
+ _logger.Info("Pubisher created");
+
+ SendTestMessage("Message 1");
+ SendTestMessage("Message 2");
+
+ _channel.PurgeQueue(_queueName, true);
+ }
+
+
+ /// <summary>
+ /// Callback method to handle any exceptions raised by the test connection.</summary> ///
+ /// <param name="e">The connection exception.</param>
+ public void OnException(Exception e)
+ {
+ // Preserve the most recent exception in case test cases need to examine it.
+ _lastException = e;
+
+ // Notify any waiting threads that an exception event has occurred.
+ _evt.Set();
+ }
+
+ /// <summary>
+ /// Sends the specified message to the test publisher, and confirms that it was received by the test consumer or not
+ /// depending on whether or not the message should be received by the consumer.
+ ///
+ /// Any exceptions raised by the connection will cause an Assert failure exception to be raised.
+ /// </summary>
+ ///
+ /// <param name="msgSend">The message to send.</param>
+ private void SendTestMessage(string msg)
+ {
+ // create the IMessage object
+ IMessage msgSend = _channel.CreateTextMessage(msg);
+
+ // send the message
+ _publisher.Send(msgSend);
+ _logger.InfoFormat("The messages \"{0}\" was sent", msg);
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/CommitRollbackTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/CommitRollbackTest.cs
index 72074da809..dbb3f70aec 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/CommitRollbackTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/CommitRollbackTest.cs
@@ -1,261 +1,261 @@
-/*
- *
- * 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 System.Threading;
-using log4net;
-using NUnit.Framework;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// <summary>
- /// CommitRollbackTest
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Check that an uncommitted send cannot be received.
- /// <tr><td> Check that a committed send can be received.
- /// <tr><td> Check that a rolled back send cannot be received.
- /// <tr><td> Check that an uncommitted receive can be re-received.
- /// <tr><td> Check that a committed receive cannot be re-received.
- /// <tr><td> Check that a rolled back receive can be re-received.
- /// </table>
- /// </summary>
- [TestFixture, Category("Integration")]
- public class CommitRollbackTest : BaseMessagingTestFixture
- {
- /// <summary>Used for debugging purposes.</summary>
- private static ILog log = LogManager.GetLogger(typeof(CommitRollbackTest));
-
- /// <summary>Defines the name of the test topic to use with the tests.</summary>
- public const string TEST_ROUTING_KEY = "commitrollbacktestkey";
-
- /// <summary>Used to count test messages received so far.</summary>
- private int messageReceivedCount;
-
- /// <summary>Used to hold the expected number of messages to receive.</summary>
- private int expectedMessageCount;
-
- /// <summary>Monitor used to signal succesfull receipt of all test messages.</summary>
- AutoResetEvent finishedEvent;
-
- /// <summary>Flag used to indicate that all messages really were received, and that the test did not just time out. </summary>
- private bool allReceived;
-
- [SetUp]
- public override void Init()
- {
- base.Init();
-
- // Create one producer and one consumer, p2p, tx, consumer with queue bound to producers routing key.
- SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.DIRECT,
- true, false, null);
- SetUpEndPoint(1, true, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.DIRECT,
- true, false, null);
-
- // Clear counts
- messageReceivedCount = 0;
- expectedMessageCount = 0;
- finishedEvent = new AutoResetEvent(false);
- allReceived = false;
- }
-
- [TearDown]
- public override void Shutdown()
- {
- try
- {
- // Clean up after the test.
- CloseEndPoint(0);
- CloseEndPoint(1);
- }
- finally
- {
- base.Shutdown();
- }
- }
-
- /// <summary> Check that an uncommitted send cannot be received. </summary>
- [Test]
- public void TestUncommittedSendNotReceived()
- {
- // Send messages.
- testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
-
- // Try to receive messages.
- ConsumeNMessagesOnly(0, "A", testConsumer[1]);
- testChannel[1].Commit();
- }
-
- /// <summary> Check that a committed send can be received. </summary>
- [Test]
- public void TestCommittedSendReceived()
- {
- // Send messages.
- testProducer[0].Send(testChannel[0].CreateTextMessage("B"));
- testChannel[0].Commit();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(1, "B", testConsumer[1]);
- testChannel[1].Commit();
- }
-
- /// <summary> Check that a rolled back send cannot be received. </summary>
- [Test]
- public void TestRolledBackSendNotReceived()
- {
- // Send messages.
- testProducer[0].Send(testChannel[0].CreateTextMessage("B"));
- testChannel[0].Rollback();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(0, "B", testConsumer[1]);
- testChannel[1].Commit();
- }
-
- /// <summary> Check that an uncommitted receive can be re-received. </summary>
- [Test]
- public void TestUncommittedReceiveCanBeRereceived()
- {
- // Create a third end-point as an alternative delivery route for the message.
- SetUpEndPoint(2, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.DIRECT,
- true, false, null);
-
- // Send messages.
- testProducer[0].Send(testChannel[0].CreateTextMessage("C"));
- testChannel[0].Commit();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(1, "C", testConsumer[1]);
-
- // Close end-point 1 without committing the message, then re-open to consume again.
- CloseEndPoint(1);
-
- // Check that the message was released from the rolled back end-point an can be received on the alternative one instead.
- ConsumeNMessagesOnly(1, "C", testConsumer[2]);
-
- CloseEndPoint(2);
- }
-
- /// <summary> Check that a committed receive cannot be re-received. </summary>
- [Test]
- public void TestCommittedReceiveNotRereceived()
- {
- // Send messages.
- testProducer[0].Send(testChannel[0].CreateTextMessage("D"));
- testChannel[0].Commit();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(1, "D", testConsumer[1]);
- testChannel[1].Commit();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(0, "D", testConsumer[1]);
- }
-
- /// <summary> Check that a rolled back receive can be re-received. </summary>
- [Test]
- public void TestRolledBackReceiveCanBeRereceived()
- {
- // Send messages.
- testProducer[0].Send(testChannel[0].CreateTextMessage("E"));
- testChannel[0].Commit();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(1, "E", testConsumer[1]);
-
- testChannel[1].Rollback();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(1, "E", testConsumer[1]);
-
- }
-
- [Test]
- public void TestReceiveAndSendRollback()
- {
- // Send messages
- testProducer[0].Send(testChannel[0].CreateTextMessage("F"));
- testChannel[0].Commit();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(1, "F", testConsumer[1]);
- testProducer[1].Send(testChannel[1].CreateTextMessage("G"));
- testChannel[1].Rollback();
-
- // Try to receive messages.
- ConsumeNMessagesOnly(1, "F", testConsumer[1]);
-
- }
-
- [Test]
- public void TestReceivePrePublished()
- {
- // Send messages
- for (int i = 0; i < 10; ++i)
- {
- testProducer[0].Send(testChannel[0].CreateTextMessage("G"+i));
- testChannel[0].Commit();
- }
-
- for (int i = 0; i < 10; ++i)
- {
- ConsumeNMessages(1, "G"+i, testConsumer[1]);
- }
- testChannel[1].Commit();
- }
-
- [Test]
- public void TestReceivePrePublishedOnMessageHandler()
- {
- testConsumer[1].OnMessage += new MessageReceivedDelegate(OnMessage);
- // Send messages
- for (int i = 0; i < 10; ++i)
- {
- testProducer[0].Send(testChannel[0].CreateTextMessage("G"+i));
- testChannel[0].Commit();
- }
- expectedMessageCount = 10;
-
- finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 30), false);
-
- // Check that all messages really were received.
- Assert.IsTrue(allReceived, "All messages were not received, only got: " + messageReceivedCount + " but wanted " + expectedMessageCount);
-
- testChannel[1].Commit();
- }
-
- /// <summary> Atomically increments the message count on every message, and signals once all messages in the test are received. </summary>
- public void OnMessage(IMessage m)
- {
- int newCount = Interlocked.Increment(ref messageReceivedCount);
-
- if (newCount >= expectedMessageCount)
- {
- allReceived = true;
- finishedEvent.Set();
- }
- }
-
- }
-}
+/*
+ *
+ * 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 System.Threading;
+using log4net;
+using NUnit.Framework;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// <summary>
+ /// CommitRollbackTest
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Check that an uncommitted send cannot be received.
+ /// <tr><td> Check that a committed send can be received.
+ /// <tr><td> Check that a rolled back send cannot be received.
+ /// <tr><td> Check that an uncommitted receive can be re-received.
+ /// <tr><td> Check that a committed receive cannot be re-received.
+ /// <tr><td> Check that a rolled back receive can be re-received.
+ /// </table>
+ /// </summary>
+ [TestFixture, Category("Integration")]
+ public class CommitRollbackTest : BaseMessagingTestFixture
+ {
+ /// <summary>Used for debugging purposes.</summary>
+ private static ILog log = LogManager.GetLogger(typeof(CommitRollbackTest));
+
+ /// <summary>Defines the name of the test topic to use with the tests.</summary>
+ public const string TEST_ROUTING_KEY = "commitrollbacktestkey";
+
+ /// <summary>Used to count test messages received so far.</summary>
+ private int messageReceivedCount;
+
+ /// <summary>Used to hold the expected number of messages to receive.</summary>
+ private int expectedMessageCount;
+
+ /// <summary>Monitor used to signal succesfull receipt of all test messages.</summary>
+ AutoResetEvent finishedEvent;
+
+ /// <summary>Flag used to indicate that all messages really were received, and that the test did not just time out. </summary>
+ private bool allReceived;
+
+ [SetUp]
+ public override void Init()
+ {
+ base.Init();
+
+ // Create one producer and one consumer, p2p, tx, consumer with queue bound to producers routing key.
+ SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.DIRECT,
+ true, false, null);
+ SetUpEndPoint(1, true, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.DIRECT,
+ true, false, null);
+
+ // Clear counts
+ messageReceivedCount = 0;
+ expectedMessageCount = 0;
+ finishedEvent = new AutoResetEvent(false);
+ allReceived = false;
+ }
+
+ [TearDown]
+ public override void Shutdown()
+ {
+ try
+ {
+ // Clean up after the test.
+ CloseEndPoint(0);
+ CloseEndPoint(1);
+ }
+ finally
+ {
+ base.Shutdown();
+ }
+ }
+
+ /// <summary> Check that an uncommitted send cannot be received. </summary>
+ [Test]
+ public void TestUncommittedSendNotReceived()
+ {
+ // Send messages.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(0, "A", testConsumer[1]);
+ testChannel[1].Commit();
+ }
+
+ /// <summary> Check that a committed send can be received. </summary>
+ [Test]
+ public void TestCommittedSendReceived()
+ {
+ // Send messages.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("B"));
+ testChannel[0].Commit();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(1, "B", testConsumer[1]);
+ testChannel[1].Commit();
+ }
+
+ /// <summary> Check that a rolled back send cannot be received. </summary>
+ [Test]
+ public void TestRolledBackSendNotReceived()
+ {
+ // Send messages.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("B"));
+ testChannel[0].Rollback();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(0, "B", testConsumer[1]);
+ testChannel[1].Commit();
+ }
+
+ /// <summary> Check that an uncommitted receive can be re-received. </summary>
+ [Test]
+ public void TestUncommittedReceiveCanBeRereceived()
+ {
+ // Create a third end-point as an alternative delivery route for the message.
+ SetUpEndPoint(2, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.DIRECT,
+ true, false, null);
+
+ // Send messages.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("C"));
+ testChannel[0].Commit();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(1, "C", testConsumer[1]);
+
+ // Close end-point 1 without committing the message, then re-open to consume again.
+ CloseEndPoint(1);
+
+ // Check that the message was released from the rolled back end-point an can be received on the alternative one instead.
+ ConsumeNMessagesOnly(1, "C", testConsumer[2]);
+
+ CloseEndPoint(2);
+ }
+
+ /// <summary> Check that a committed receive cannot be re-received. </summary>
+ [Test]
+ public void TestCommittedReceiveNotRereceived()
+ {
+ // Send messages.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("D"));
+ testChannel[0].Commit();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(1, "D", testConsumer[1]);
+ testChannel[1].Commit();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(0, "D", testConsumer[1]);
+ }
+
+ /// <summary> Check that a rolled back receive can be re-received. </summary>
+ [Test]
+ public void TestRolledBackReceiveCanBeRereceived()
+ {
+ // Send messages.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("E"));
+ testChannel[0].Commit();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(1, "E", testConsumer[1]);
+
+ testChannel[1].Rollback();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(1, "E", testConsumer[1]);
+
+ }
+
+ [Test]
+ public void TestReceiveAndSendRollback()
+ {
+ // Send messages
+ testProducer[0].Send(testChannel[0].CreateTextMessage("F"));
+ testChannel[0].Commit();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(1, "F", testConsumer[1]);
+ testProducer[1].Send(testChannel[1].CreateTextMessage("G"));
+ testChannel[1].Rollback();
+
+ // Try to receive messages.
+ ConsumeNMessagesOnly(1, "F", testConsumer[1]);
+
+ }
+
+ [Test]
+ public void TestReceivePrePublished()
+ {
+ // Send messages
+ for (int i = 0; i < 10; ++i)
+ {
+ testProducer[0].Send(testChannel[0].CreateTextMessage("G"+i));
+ testChannel[0].Commit();
+ }
+
+ for (int i = 0; i < 10; ++i)
+ {
+ ConsumeNMessages(1, "G"+i, testConsumer[1]);
+ }
+ testChannel[1].Commit();
+ }
+
+ [Test]
+ public void TestReceivePrePublishedOnMessageHandler()
+ {
+ testConsumer[1].OnMessage += new MessageReceivedDelegate(OnMessage);
+ // Send messages
+ for (int i = 0; i < 10; ++i)
+ {
+ testProducer[0].Send(testChannel[0].CreateTextMessage("G"+i));
+ testChannel[0].Commit();
+ }
+ expectedMessageCount = 10;
+
+ finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 30), false);
+
+ // Check that all messages really were received.
+ Assert.IsTrue(allReceived, "All messages were not received, only got: " + messageReceivedCount + " but wanted " + expectedMessageCount);
+
+ testChannel[1].Commit();
+ }
+
+ /// <summary> Atomically increments the message count on every message, and signals once all messages in the test are received. </summary>
+ public void OnMessage(IMessage m)
+ {
+ int newCount = Interlocked.Increment(ref messageReceivedCount);
+
+ if (newCount >= expectedMessageCount)
+ {
+ allReceived = true;
+ finishedEvent.Set();
+ }
+ }
+
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/ConnectionTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/ConnectionTest.cs
index 357f164346..d7b4a4ddd2 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/ConnectionTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/ConnectionTest.cs
@@ -1,73 +1,73 @@
-/*
- *
- * 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 Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-using Apache.Qpid.Messaging;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- [TestFixture, Category("Integration")]
- public class ConnectionTest
- {
- private AmqBrokerInfo _broker =
- new AmqBrokerInfo("amqp", "localhost", 5672, false);
-
- [Test]
- public void SimpleConnection()
- {
- IConnectionInfo connectionInfo = new QpidConnectionInfo();
- connectionInfo.VirtualHost = "test";
- connectionInfo.AddBrokerInfo(_broker);
- using (IConnection connection = new AMQConnection(connectionInfo))
- {
- Console.WriteLine("connection = " + connection);
- }
- }
-
- [Test]
- [ExpectedException(typeof(AMQAuthenticationException))]
- public void PasswordFailureConnection()
- {
- IConnectionInfo connectionInfo = new QpidConnectionInfo();
- connectionInfo.VirtualHost = "test";
- connectionInfo.Password = "rubbish";
- connectionInfo.AddBrokerInfo(_broker);
-
- using (IConnection connection = new AMQConnection(connectionInfo))
- {
- Console.WriteLine("connection = " + connection);
- // wrong
- Assert.Fail("Authentication succeeded but should've failed");
- }
- }
-
- [Test]
- [ExpectedException(typeof(AMQConnectionException))]
- public void ConnectionFailure()
- {
- string url = "amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5673?retries='0''";
- new AMQConnection(QpidConnectionInfo.FromUrl(url));
- Assert.Fail("Connection should not be established");
- }
- }
-}
+/*
+ *
+ * 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 Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+using Apache.Qpid.Messaging;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ [TestFixture, Category("Integration")]
+ public class ConnectionTest
+ {
+ private AmqBrokerInfo _broker =
+ new AmqBrokerInfo("amqp", "localhost", 5672, false);
+
+ [Test]
+ public void SimpleConnection()
+ {
+ IConnectionInfo connectionInfo = new QpidConnectionInfo();
+ connectionInfo.VirtualHost = "test";
+ connectionInfo.AddBrokerInfo(_broker);
+ using (IConnection connection = new AMQConnection(connectionInfo))
+ {
+ Console.WriteLine("connection = " + connection);
+ }
+ }
+
+ [Test]
+ [ExpectedException(typeof(AMQAuthenticationException))]
+ public void PasswordFailureConnection()
+ {
+ IConnectionInfo connectionInfo = new QpidConnectionInfo();
+ connectionInfo.VirtualHost = "test";
+ connectionInfo.Password = "rubbish";
+ connectionInfo.AddBrokerInfo(_broker);
+
+ using (IConnection connection = new AMQConnection(connectionInfo))
+ {
+ Console.WriteLine("connection = " + connection);
+ // wrong
+ Assert.Fail("Authentication succeeded but should've failed");
+ }
+ }
+
+ [Test]
+ [ExpectedException(typeof(AMQConnectionException))]
+ public void ConnectionFailure()
+ {
+ string url = "amqp://guest:guest@clientid/testpath?brokerlist='tcp://localhost:5673?retries='0''";
+ new AMQConnection(QpidConnectionInfo.FromUrl(url));
+ Assert.Fail("Connection should not be established");
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs
index ac975100b1..b7973ae3f5 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/DurableSubscriptionTest.cs
@@ -1,166 +1,166 @@
-/*
- *
- * 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 System.Threading;
-using log4net;
-using NUnit.Framework;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// <summary>
- /// DurableSubscriptionTest checks that durable subscriptions work, by sending messages that can be picked up by
- /// a subscription that is currently off-line, and checking that the subscriber gets all of its messages when it
- /// does come on-line.
- ///
- /// <p/><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td>
- /// </table>
- /// </summary>
- [TestFixture, Category("Integration")]
- public class DurableSubscriptionTest : BaseMessagingTestFixture
- {
- /// <summary>Used for debugging purposes.</summary>
- private static ILog log = LogManager.GetLogger(typeof(DurableSubscriptionTest));
-
- /// <summary>Defines the name of the test topic to use with the tests.</summary>
- public const string TEST_ROUTING_KEY = "durablesubtestkey";
-
- [SetUp]
- public override void Init()
- {
- base.Init();
- }
-
- [TearDown]
- public override void Shutdown()
- {
- base.Shutdown();
- }
-
- [Test]
- public void TestDurableSubscriptionNoAck()
- {
- TestDurableSubscription(AcknowledgeMode.NoAcknowledge);
- }
-
- [Test]
- public void TestDurableSubscriptionAutoAck()
- {
- TestDurableSubscription(AcknowledgeMode.AutoAcknowledge);
- }
-
- private void TestDurableSubscription(AcknowledgeMode ackMode)
- {
- // Create a topic with one producer and two consumers.
- SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, ackMode, false, ExchangeNameDefaults.TOPIC, true, false, null);
- SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, ackMode, false, ExchangeNameDefaults.TOPIC, true, false, null);
- SetUpEndPoint(2, false, true, TEST_ROUTING_KEY + testId, ackMode, false, ExchangeNameDefaults.TOPIC, true,
- true, "TestSubscription" + testId);
-
- Thread.Sleep(500);
-
- // Send messages and receive on both consumers.
- testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
-
- ConsumeNMessagesOnly(1, "A", testConsumer[1]);
- ConsumeNMessagesOnly(1, "A", testConsumer[2]);
-
- // Detach one consumer.
- CloseEndPoint(2);
-
- // Send message and receive on one consumer.
- testProducer[0].Send(testChannel[0].CreateTextMessage("B"));
-
- ConsumeNMessagesOnly(1, "B", testConsumer[1]);
-
- // Re-attach consumer, check that it gets the messages that it missed.
- SetUpEndPoint(2, false, true, TEST_ROUTING_KEY + testId, ackMode, false, ExchangeNameDefaults.TOPIC, true,
- true, "TestSubscription" + testId);
-
- ConsumeNMessagesOnly(1, "B", testConsumer[2]);
-
- // Clean up any open consumers at the end of the test.
- CloseEndPoint(2);
- CloseEndPoint(1);
- CloseEndPoint(0);
- }
-
- /// <summary> Check that an uncommitted receive can be re-received, on re-consume from the same durable subscription. </summary>
- [Test]
- public void TestUncommittedReceiveCanBeRereceivedNewConnection()
- {
- SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
- true, false, null);
- SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
- true, true, "foo"+testId);
-
- // Send messages.
- testProducer[0].Send(testChannel[0].CreateTextMessage("C"));
- testChannel[0].Commit();
-
- // Try to receive messages, but don't commit them.
- ConsumeNMessagesOnly(1, "C", testConsumer[1]);
-
- // Close end-point 1 without committing the message, then re-open the subscription to consume again.
- CloseEndPoint(1);
- SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
- true, true, "foo"+testId);
-
- // Check that the message was released from the rolled back end-point an can be received on the alternative one instead.
- ConsumeNMessagesOnly(1, "C", testConsumer[1]);
- testChannel[1].Commit();
- CloseEndPoint(1);
- CloseEndPoint(0);
- }
-
- /// <summary> Check that a rolled back receive can be re-received, on re-consume from the same durable subscription. </summary>
- [Test]
- public void TestRolledBackReceiveCanBeRereceivedNewConnection()
- {
- SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
- true, false, null);
- SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
- true, true, "foo"+testId);
-
- // Send messages.
- testProducer[0].Send(testChannel[0].CreateTextMessage("D"));
- testChannel[0].Commit();
-
- // Try to receive messages, but roll them back.
- ConsumeNMessagesOnly(1, "D", testConsumer[1]);
- testChannel[1].Rollback();
-
- // Close end-point 1 without committing the message, then re-open the subscription to consume again.
- CloseEndPoint(1);
- SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
- true, true, "foo"+testId);
-
- // Check that the message was released from the rolled back end-point an can be received on the alternative one instead.
- ConsumeNMessagesOnly(1, "D", testConsumer[1]);
- testChannel[1].Commit();
- CloseEndPoint(1);
- CloseEndPoint(0);
- }
- }
-}
+/*
+ *
+ * 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 System.Threading;
+using log4net;
+using NUnit.Framework;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// <summary>
+ /// DurableSubscriptionTest checks that durable subscriptions work, by sending messages that can be picked up by
+ /// a subscription that is currently off-line, and checking that the subscriber gets all of its messages when it
+ /// does come on-line.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td>
+ /// </table>
+ /// </summary>
+ [TestFixture, Category("Integration")]
+ public class DurableSubscriptionTest : BaseMessagingTestFixture
+ {
+ /// <summary>Used for debugging purposes.</summary>
+ private static ILog log = LogManager.GetLogger(typeof(DurableSubscriptionTest));
+
+ /// <summary>Defines the name of the test topic to use with the tests.</summary>
+ public const string TEST_ROUTING_KEY = "durablesubtestkey";
+
+ [SetUp]
+ public override void Init()
+ {
+ base.Init();
+ }
+
+ [TearDown]
+ public override void Shutdown()
+ {
+ base.Shutdown();
+ }
+
+ [Test]
+ public void TestDurableSubscriptionNoAck()
+ {
+ TestDurableSubscription(AcknowledgeMode.NoAcknowledge);
+ }
+
+ [Test]
+ public void TestDurableSubscriptionAutoAck()
+ {
+ TestDurableSubscription(AcknowledgeMode.AutoAcknowledge);
+ }
+
+ private void TestDurableSubscription(AcknowledgeMode ackMode)
+ {
+ // Create a topic with one producer and two consumers.
+ SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, ackMode, false, ExchangeNameDefaults.TOPIC, true, false, null);
+ SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, ackMode, false, ExchangeNameDefaults.TOPIC, true, false, null);
+ SetUpEndPoint(2, false, true, TEST_ROUTING_KEY + testId, ackMode, false, ExchangeNameDefaults.TOPIC, true,
+ true, "TestSubscription" + testId);
+
+ Thread.Sleep(500);
+
+ // Send messages and receive on both consumers.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
+
+ ConsumeNMessagesOnly(1, "A", testConsumer[1]);
+ ConsumeNMessagesOnly(1, "A", testConsumer[2]);
+
+ // Detach one consumer.
+ CloseEndPoint(2);
+
+ // Send message and receive on one consumer.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("B"));
+
+ ConsumeNMessagesOnly(1, "B", testConsumer[1]);
+
+ // Re-attach consumer, check that it gets the messages that it missed.
+ SetUpEndPoint(2, false, true, TEST_ROUTING_KEY + testId, ackMode, false, ExchangeNameDefaults.TOPIC, true,
+ true, "TestSubscription" + testId);
+
+ ConsumeNMessagesOnly(1, "B", testConsumer[2]);
+
+ // Clean up any open consumers at the end of the test.
+ CloseEndPoint(2);
+ CloseEndPoint(1);
+ CloseEndPoint(0);
+ }
+
+ /// <summary> Check that an uncommitted receive can be re-received, on re-consume from the same durable subscription. </summary>
+ [Test]
+ public void TestUncommittedReceiveCanBeRereceivedNewConnection()
+ {
+ SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
+ true, false, null);
+ SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
+ true, true, "foo"+testId);
+
+ // Send messages.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("C"));
+ testChannel[0].Commit();
+
+ // Try to receive messages, but don't commit them.
+ ConsumeNMessagesOnly(1, "C", testConsumer[1]);
+
+ // Close end-point 1 without committing the message, then re-open the subscription to consume again.
+ CloseEndPoint(1);
+ SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
+ true, true, "foo"+testId);
+
+ // Check that the message was released from the rolled back end-point an can be received on the alternative one instead.
+ ConsumeNMessagesOnly(1, "C", testConsumer[1]);
+ testChannel[1].Commit();
+ CloseEndPoint(1);
+ CloseEndPoint(0);
+ }
+
+ /// <summary> Check that a rolled back receive can be re-received, on re-consume from the same durable subscription. </summary>
+ [Test]
+ public void TestRolledBackReceiveCanBeRereceivedNewConnection()
+ {
+ SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
+ true, false, null);
+ SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
+ true, true, "foo"+testId);
+
+ // Send messages.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("D"));
+ testChannel[0].Commit();
+
+ // Try to receive messages, but roll them back.
+ ConsumeNMessagesOnly(1, "D", testConsumer[1]);
+ testChannel[1].Rollback();
+
+ // Close end-point 1 without committing the message, then re-open the subscription to consume again.
+ CloseEndPoint(1);
+ SetUpEndPoint(1, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, true, ExchangeNameDefaults.TOPIC,
+ true, true, "foo"+testId);
+
+ // Check that the message was released from the rolled back end-point an can be received on the alternative one instead.
+ ConsumeNMessagesOnly(1, "D", testConsumer[1]);
+ testChannel[1].Commit();
+ CloseEndPoint(1);
+ CloseEndPoint(0);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/HeadersExchangeTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/HeadersExchangeTest.cs
index 5e17cf1d2d..2094aa3b1b 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/HeadersExchangeTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/HeadersExchangeTest.cs
@@ -1,282 +1,282 @@
-/*
- *
- * 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 System.Threading;
-using log4net;
-using NUnit.Framework;
-using Apache.Qpid.Framing;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// <summary>
- /// Sets up a producer/consumer pair to send test messages through a header exchange. The header exchange matching pattern is tested to
- /// verify that it correctly matches or filters out messages based on their headers.
- ///
- /// Check that a message matching all fields of a headers exchange is passed by the exchange.
- /// Check that a message containing values for empty fields of a headers exchange is passed by the exchange.
- /// Check that a message matching only some fields of a headers exhcnage is not passed by the exchange.
- /// Check that a message with additional fields to the correct matching fields of a headers exchange is passed by the exchange.
- /// </summary>
- ///
- /// <todo>Remove the HeadersMatchingProducer class and rename this to HeaderExchangeTest. The producer and consumer are implemented
- /// in a single test class to make running this as part of an automated test suite possible.</todo>
- ///
- /// <todo>Consider not using a delegate to callback the OnMessage method. Easier to just call receive on the consumer but using the
- /// callback does demonstrate how to do so.</todo>
- [TestFixture, Category("Integration")]
- public class HeadersExchangeTest : BaseMessagingTestFixture
- {
- private static ILog _logger = LogManager.GetLogger(typeof(HeadersExchangeTest));
-
- /// <summary> Holds the default test timeout for broker communications before tests give up. </summary>
- private static readonly int TIMEOUT = 2000;
-
- /// <summary> Holds the name of the headers exchange to create to send test messages on. </summary>
- private string _exchangeName = "ServiceQ1";
-
- /// <summary> Used to preserve the most recent exception in case test cases need to examine it. </summary>
- private Exception _lastException = null;
-
- /// <summary> Used to preserve the most recent message from the test consumer. </summary>
- private IMessage _lastMessage = null;
-
- /// <summary> The test consumer to get messages from the broker with. </summary>
- private IMessageConsumer _consumer;
-
- private IMessagePublisher _publisher;
-
- private AutoResetEvent _evt = new AutoResetEvent(false);
-
- private MessageReceivedDelegate _msgRecDelegate;
- private ExceptionListenerDelegate _exceptionDelegate;
-
- /// <summary> Holds the test connection. </summary>
- protected IConnection _connection;
-
- /// <summary> Holds the test channel. </summary>
- protected IChannel _channel;
-
- [SetUp]
- public override void Init()
- {
- // Ensure that the base init method is called. It establishes a connection with the broker.
- base.Init();
-
- connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
- _connection = new AMQConnection(connectionInfo);
- _channel = _connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 500, 300);
-
- _logger.Info("Starting...");
- _logger.Info("Exchange name is '" + _exchangeName + "'...");
-
- // Register this to listen for exceptions on the test connection.
- _exceptionDelegate = new ExceptionListenerDelegate(OnException);
- _connection.ExceptionListener += _exceptionDelegate;
-
- // Declare a new headers exchange with the name of the test service.
- _channel.DeclareExchange(_exchangeName, ExchangeClassConstants.HEADERS);
-
- // Create a non-durable, temporary (aka auto-delete), exclusive queue.
- string queueName = _channel.GenerateUniqueName();
- _channel.DeclareQueue(queueName, false, true, true);
-
- // Bind the queue to the new headers exchange, setting up some header patterns for the exchange to match.
- _channel.Bind(queueName, _exchangeName, null, CreatePatternAsFieldTable());
-
- // Create a test consumer to consume messages from the test exchange.
- _consumer = _channel.CreateConsumerBuilder(queueName)
- .WithPrefetchLow(100)
- .WithPrefetchHigh(500)
- .WithNoLocal(false) // make sure we get our own messages
- .Create();
-
- // Register this to listen for messages on the consumer.
- _msgRecDelegate = new MessageReceivedDelegate(OnMessage);
- _consumer.OnMessage += _msgRecDelegate;
-
- // Clear the most recent message and exception.
- _lastException = null;
- _lastMessage = null;
-
- _publisher = _channel.CreatePublisherBuilder()
- .WithExchangeName(_exchangeName)
- .WithMandatory(true)
- .Create();
-
- _publisher.DeliveryMode = DeliveryMode.NonPersistent;
-
- // Start all channel
- _connection.Start();
- }
-
- /// <summary>
- /// Deregisters the on message delegate before closing the connection.
- /// </summary>
- [TearDown]
- public override void Shutdown()
- {
- _logger.Info("public void Shutdown(): called");
-
- //_consumer.OnMessage -= _msgRecDelegate;
- //_connection.ExceptionListener -= _exceptionDelegate;
-
- _connection.Stop();
- _connection.Close();
- _connection.Dispose();
-
- base.Shutdown();
- }
-
- /// <summary>
- /// Callback method that is passed any messages received on the test channel.
- /// </summary>
- ///
- /// <param name="message">The received message.</param>
- public void OnMessage(IMessage message)
- {
- _logger.Debug(string.Format("message.Type = {0}", message.GetType()));
- _logger.Debug("Got message '" + message + "'");
-
- // Preserve the most recent exception so that test cases can examine it.
- _lastMessage = message;
-
- // Notify any waiting threads that a message has been received.
- _evt.Set();
- }
-
- /// <summary>Callback method to handle any exceptions raised by the test connection.</summary>
- ///
- /// <param name="e">The connection exception.</param>
- public void OnException(Exception e)
- {
- // Preserve the most recent exception in case test cases need to examine it.
- _lastException = e;
-
- // Notify any waiting threads that an exception event has occurred.
- _evt.Set();
- }
-
- /// <summary>Check that a message matching all fields of a headers exchange is passed by the exchange.</summary>
- [Test]
- public void TestMatchAll()
- {
- IMessage msg = _channel.CreateTextMessage("matches match2=''");
- msg.Headers["match1"] = "foo";
- msg.Headers["match2"] = "";
-
- // Use the SendTestMessage helper method to verify that the message was sent and received.
- SendTestMessage(msg, true);
- }
-
- /// <summary>Check that a message containing values for empty fields of a headers exchange is passed by the exchange.</summary>
- [Test]
- public void TestMatchEmptyMatchesAnything()
- {
- // Send a test message that matches the headers exchange.
- IMessage msg = _channel.CreateTextMessage("matches match1='foo' and match2='bar'");
- msg.Headers["match1"] = "foo";
- msg.Headers["match2"] = "bar";
-
- // Use the SendTestMessage helper method to verify that the message was sent and received.
- SendTestMessage(msg, true);
- }
-
- /// <summary>Check that a message matching only some fields of a headers exchange is not passed by the exchange.</summary>
- [Test]
- public void TestMatchOneFails()
- {
- IMessage msg = _channel.CreateTextMessage("not match - only match1");
- msg.Headers["match1"] = "foo";
-
- // Use the SendTestMessage helper method to verify that the message was sent and not received.
- SendTestMessage(msg, false);
- }
-
- /// <summary>
- /// Check that a message with additional fields to the correct matching fields of a headers exchange is passed by
- /// the exchange.
- /// </summary>
- [Test]
- public void TestMatchExtraFields()
- {
- IMessage msg = _channel.CreateTextMessage("matches - extra headers");
- msg.Headers["match1"] = "foo";
- msg.Headers["match2"] = "bar";
- msg.Headers["match3"] = "not required";
-
- // Use the SendTestMessage helper method to verify that the message was sent and received.
- SendTestMessage(msg, true);
- }
-
- /// <summary>
- /// Sends the specified message to the test publisher, and confirms that it was received by the test consumer or not
- /// depending on whether or not the message should be received by the consumer.
- ///
- /// Any exceptions raised by the connection will cause an Assert failure exception to be raised.
- /// </summary>
- ///
- /// <param name="msgSend">The message to send.</param>
- /// <param name="shouldPass">A flag to indicate whether or not the message should be received by the consumer.</param>
- private void SendTestMessage(IMessage msgSend, bool shouldPass)
- {
- _publisher.Send(msgSend);
- _evt.WaitOne(TIMEOUT, true);
-
- // Check that an exception other than not routable was raised in which case re-raise it as a test error.
- if (_lastException != null && !(_lastException.InnerException is AMQUndeliveredException))
- {
- Assert.Fail("Exception {0} was raised by the broker connection.", _lastException);
- }
- // Check that a message was returned if the test is expecting the message to pass.
- else if (shouldPass)
- {
- Assert.IsNotNull(_lastMessage, "Did not get a matching message from the headers exchange.");
- }
- // Check that a not routable exception was raised if the test is expecting the message to fail.
- else if (_lastException != null && _lastException.InnerException is AMQUndeliveredException)
- {
- Assert.IsNull(_lastMessage, "Message could not be routed so consumer should not have received it.");
- }
- // The broker did not respond within the test timeout so fail the test.
- else
- {
- Assert.Fail("The test timed out without a response from the broker.");
- }
- }
-
- /// <summary> Returns a field table containing patterns to match the test header exchange against. </summary>
- ///
- /// <returns> A field table containing test patterns. </returns>
- private FieldTable CreatePatternAsFieldTable()
- {
- FieldTable matchTable = new FieldTable();
-
- matchTable["match1"] = "foo";
- matchTable["match2"] = "";
- matchTable["x-match"] = "all";
-
- return matchTable;
- }
- }
-}
+/*
+ *
+ * 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 System.Threading;
+using log4net;
+using NUnit.Framework;
+using Apache.Qpid.Framing;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// <summary>
+ /// Sets up a producer/consumer pair to send test messages through a header exchange. The header exchange matching pattern is tested to
+ /// verify that it correctly matches or filters out messages based on their headers.
+ ///
+ /// Check that a message matching all fields of a headers exchange is passed by the exchange.
+ /// Check that a message containing values for empty fields of a headers exchange is passed by the exchange.
+ /// Check that a message matching only some fields of a headers exhcnage is not passed by the exchange.
+ /// Check that a message with additional fields to the correct matching fields of a headers exchange is passed by the exchange.
+ /// </summary>
+ ///
+ /// <todo>Remove the HeadersMatchingProducer class and rename this to HeaderExchangeTest. The producer and consumer are implemented
+ /// in a single test class to make running this as part of an automated test suite possible.</todo>
+ ///
+ /// <todo>Consider not using a delegate to callback the OnMessage method. Easier to just call receive on the consumer but using the
+ /// callback does demonstrate how to do so.</todo>
+ [TestFixture, Category("Integration")]
+ public class HeadersExchangeTest : BaseMessagingTestFixture
+ {
+ private static ILog _logger = LogManager.GetLogger(typeof(HeadersExchangeTest));
+
+ /// <summary> Holds the default test timeout for broker communications before tests give up. </summary>
+ private static readonly int TIMEOUT = 2000;
+
+ /// <summary> Holds the name of the headers exchange to create to send test messages on. </summary>
+ private string _exchangeName = "ServiceQ1";
+
+ /// <summary> Used to preserve the most recent exception in case test cases need to examine it. </summary>
+ private Exception _lastException = null;
+
+ /// <summary> Used to preserve the most recent message from the test consumer. </summary>
+ private IMessage _lastMessage = null;
+
+ /// <summary> The test consumer to get messages from the broker with. </summary>
+ private IMessageConsumer _consumer;
+
+ private IMessagePublisher _publisher;
+
+ private AutoResetEvent _evt = new AutoResetEvent(false);
+
+ private MessageReceivedDelegate _msgRecDelegate;
+ private ExceptionListenerDelegate _exceptionDelegate;
+
+ /// <summary> Holds the test connection. </summary>
+ protected IConnection _connection;
+
+ /// <summary> Holds the test channel. </summary>
+ protected IChannel _channel;
+
+ [SetUp]
+ public override void Init()
+ {
+ // Ensure that the base init method is called. It establishes a connection with the broker.
+ base.Init();
+
+ connectionInfo = QpidConnectionInfo.FromUrl(connectionUri);
+ _connection = new AMQConnection(connectionInfo);
+ _channel = _connection.CreateChannel(false, AcknowledgeMode.AutoAcknowledge, 500, 300);
+
+ _logger.Info("Starting...");
+ _logger.Info("Exchange name is '" + _exchangeName + "'...");
+
+ // Register this to listen for exceptions on the test connection.
+ _exceptionDelegate = new ExceptionListenerDelegate(OnException);
+ _connection.ExceptionListener += _exceptionDelegate;
+
+ // Declare a new headers exchange with the name of the test service.
+ _channel.DeclareExchange(_exchangeName, ExchangeClassConstants.HEADERS);
+
+ // Create a non-durable, temporary (aka auto-delete), exclusive queue.
+ string queueName = _channel.GenerateUniqueName();
+ _channel.DeclareQueue(queueName, false, true, true);
+
+ // Bind the queue to the new headers exchange, setting up some header patterns for the exchange to match.
+ _channel.Bind(queueName, _exchangeName, null, CreatePatternAsFieldTable());
+
+ // Create a test consumer to consume messages from the test exchange.
+ _consumer = _channel.CreateConsumerBuilder(queueName)
+ .WithPrefetchLow(100)
+ .WithPrefetchHigh(500)
+ .WithNoLocal(false) // make sure we get our own messages
+ .Create();
+
+ // Register this to listen for messages on the consumer.
+ _msgRecDelegate = new MessageReceivedDelegate(OnMessage);
+ _consumer.OnMessage += _msgRecDelegate;
+
+ // Clear the most recent message and exception.
+ _lastException = null;
+ _lastMessage = null;
+
+ _publisher = _channel.CreatePublisherBuilder()
+ .WithExchangeName(_exchangeName)
+ .WithMandatory(true)
+ .Create();
+
+ _publisher.DeliveryMode = DeliveryMode.NonPersistent;
+
+ // Start all channel
+ _connection.Start();
+ }
+
+ /// <summary>
+ /// Deregisters the on message delegate before closing the connection.
+ /// </summary>
+ [TearDown]
+ public override void Shutdown()
+ {
+ _logger.Info("public void Shutdown(): called");
+
+ //_consumer.OnMessage -= _msgRecDelegate;
+ //_connection.ExceptionListener -= _exceptionDelegate;
+
+ _connection.Stop();
+ _connection.Close();
+ _connection.Dispose();
+
+ base.Shutdown();
+ }
+
+ /// <summary>
+ /// Callback method that is passed any messages received on the test channel.
+ /// </summary>
+ ///
+ /// <param name="message">The received message.</param>
+ public void OnMessage(IMessage message)
+ {
+ _logger.Debug(string.Format("message.Type = {0}", message.GetType()));
+ _logger.Debug("Got message '" + message + "'");
+
+ // Preserve the most recent exception so that test cases can examine it.
+ _lastMessage = message;
+
+ // Notify any waiting threads that a message has been received.
+ _evt.Set();
+ }
+
+ /// <summary>Callback method to handle any exceptions raised by the test connection.</summary>
+ ///
+ /// <param name="e">The connection exception.</param>
+ public void OnException(Exception e)
+ {
+ // Preserve the most recent exception in case test cases need to examine it.
+ _lastException = e;
+
+ // Notify any waiting threads that an exception event has occurred.
+ _evt.Set();
+ }
+
+ /// <summary>Check that a message matching all fields of a headers exchange is passed by the exchange.</summary>
+ [Test]
+ public void TestMatchAll()
+ {
+ IMessage msg = _channel.CreateTextMessage("matches match2=''");
+ msg.Headers["match1"] = "foo";
+ msg.Headers["match2"] = "";
+
+ // Use the SendTestMessage helper method to verify that the message was sent and received.
+ SendTestMessage(msg, true);
+ }
+
+ /// <summary>Check that a message containing values for empty fields of a headers exchange is passed by the exchange.</summary>
+ [Test]
+ public void TestMatchEmptyMatchesAnything()
+ {
+ // Send a test message that matches the headers exchange.
+ IMessage msg = _channel.CreateTextMessage("matches match1='foo' and match2='bar'");
+ msg.Headers["match1"] = "foo";
+ msg.Headers["match2"] = "bar";
+
+ // Use the SendTestMessage helper method to verify that the message was sent and received.
+ SendTestMessage(msg, true);
+ }
+
+ /// <summary>Check that a message matching only some fields of a headers exchange is not passed by the exchange.</summary>
+ [Test]
+ public void TestMatchOneFails()
+ {
+ IMessage msg = _channel.CreateTextMessage("not match - only match1");
+ msg.Headers["match1"] = "foo";
+
+ // Use the SendTestMessage helper method to verify that the message was sent and not received.
+ SendTestMessage(msg, false);
+ }
+
+ /// <summary>
+ /// Check that a message with additional fields to the correct matching fields of a headers exchange is passed by
+ /// the exchange.
+ /// </summary>
+ [Test]
+ public void TestMatchExtraFields()
+ {
+ IMessage msg = _channel.CreateTextMessage("matches - extra headers");
+ msg.Headers["match1"] = "foo";
+ msg.Headers["match2"] = "bar";
+ msg.Headers["match3"] = "not required";
+
+ // Use the SendTestMessage helper method to verify that the message was sent and received.
+ SendTestMessage(msg, true);
+ }
+
+ /// <summary>
+ /// Sends the specified message to the test publisher, and confirms that it was received by the test consumer or not
+ /// depending on whether or not the message should be received by the consumer.
+ ///
+ /// Any exceptions raised by the connection will cause an Assert failure exception to be raised.
+ /// </summary>
+ ///
+ /// <param name="msgSend">The message to send.</param>
+ /// <param name="shouldPass">A flag to indicate whether or not the message should be received by the consumer.</param>
+ private void SendTestMessage(IMessage msgSend, bool shouldPass)
+ {
+ _publisher.Send(msgSend);
+ _evt.WaitOne(TIMEOUT, true);
+
+ // Check that an exception other than not routable was raised in which case re-raise it as a test error.
+ if (_lastException != null && !(_lastException.InnerException is AMQUndeliveredException))
+ {
+ Assert.Fail("Exception {0} was raised by the broker connection.", _lastException);
+ }
+ // Check that a message was returned if the test is expecting the message to pass.
+ else if (shouldPass)
+ {
+ Assert.IsNotNull(_lastMessage, "Did not get a matching message from the headers exchange.");
+ }
+ // Check that a not routable exception was raised if the test is expecting the message to fail.
+ else if (_lastException != null && _lastException.InnerException is AMQUndeliveredException)
+ {
+ Assert.IsNull(_lastMessage, "Message could not be routed so consumer should not have received it.");
+ }
+ // The broker did not respond within the test timeout so fail the test.
+ else
+ {
+ Assert.Fail("The test timed out without a response from the broker.");
+ }
+ }
+
+ /// <summary> Returns a field table containing patterns to match the test header exchange against. </summary>
+ ///
+ /// <returns> A field table containing test patterns. </returns>
+ private FieldTable CreatePatternAsFieldTable()
+ {
+ FieldTable matchTable = new FieldTable();
+
+ matchTable["match1"] = "foo";
+ matchTable["match2"] = "";
+ matchTable["x-match"] = "all";
+
+ return matchTable;
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/MandatoryMessageTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/MandatoryMessageTest.cs
index 6cfdad1f94..4abc56905f 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/MandatoryMessageTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/MandatoryMessageTest.cs
@@ -1,149 +1,149 @@
-/*
- *
- * 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 System.Threading;
-using log4net;
-using NUnit.Framework;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// <summary>
- /// MandatoryMessageTest checks that messages sent with the 'mandatory' flag, must either be routed to a valid
- /// queue or returned to the sender when no route is available.
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Check default exchange returns unroutable mandatory messages.
- /// <tr><td> Check direct exchange returns unroutable mandatory messages.
- /// <tr><td> Check headers exchange returns unroutable mandatory messages.
- /// <tr><td> Check topic exchange returns unroutable mandatory messages.
- /// </table>
- /// </summary>
- [TestFixture, Category("Integration")]
- public class MandatoryMessageTest : BaseMessagingTestFixture
- {
- /// <summary>Used for debugging purposes.</summary>
- private static ILog log = LogManager.GetLogger(typeof(MandatoryMessageTest));
-
- /// <summary>Defines the maximum time in milliseconds, to wait for redelivery to occurr.</summary>
- public const int TIMEOUT = 1000;
-
- /// <summary>Defines the name of the routing key to use with the tests.</summary>
- public const string TEST_ROUTING_KEY = "unboundkey";
-
- /// <summary>Condition used to coordinate receipt of redelivery exception to the sending thread.</summary>
- private ManualResetEvent errorEvent;
-
- /// <summary>Holds the last received error condition, for examination by the tests sending thread.</summary>
- private Exception lastErrorException;
-
- /// <summary> Holds the test connection. </summary>
- protected IConnection _connection;
-
- /// <summary> Holds the test channel. </summary>
- protected IChannel _channel;
-
- [SetUp]
- public override void Init()
- {
- base.Init();
-
- errorEvent = new ManualResetEvent(false);
- lastErrorException = null;
- }
-
- [TearDown]
- public override void Shutdown()
- {
- base.Shutdown();
- }
-
- /// <summary>
- /// Handles all exception conditions on the connection. The error event is notified and the exception recorded as the last seen.
- /// </summary>
- ///
- /// <param name="e">The asynchronous exception on the connection.</param>
- public void OnException(Exception e)
- {
- lastErrorException = e;
- errorEvent.Set();
- }
-
- [Test]
- public void SendUndeliverableMessageOnDirectExchange()
- {
- SendOne(ExchangeNameDefaults.DIRECT);
- }
-
- [Test]
- public void SendUndeliverableMessageOnTopicExchange()
- {
- SendOne(ExchangeNameDefaults.TOPIC);
- }
-
- [Test]
- public void SendUndeliverableMessageOnHeadersExchange()
- {
- SendOne(ExchangeNameDefaults.HEADERS);
- }
-
- /// <summary>
- /// Sends a single message to the specified exchange with the routing key 'unboundkey', marked as mandatory.
- /// A check is performed to assert that a redelivery error is returned from the broker for the message.
- /// </summary>
- ///
- /// <param name="exchangeName">The name of the exchange to send to.</param>
- private void SendOne(string exchangeName)
- {
- log.Debug("private void SendOne(string exchangeName = " + exchangeName + "): called");
-
- // Send a test message to a unbound key on the specified exchange.
- SetUpEndPoint(0, false, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, exchangeName,
- true, false, null);
- testProducer[0] = testChannel[0].CreatePublisherBuilder()
- .WithRoutingKey(TEST_ROUTING_KEY + testId)
- .WithMandatory(true)
- .WithExchangeName(exchangeName)
- .Create();
-
- // Set up the exception listener on the connection.
- testConnection[0].ExceptionListener = new ExceptionListenerDelegate(OnException);
-
- // Send message that should fail.
- testProducer[0].Send(testChannel[0].CreateTextMessage("Test Message"));
-
- // Wait for up to the timeout for a redelivery exception to be returned.
- errorEvent.WaitOne(TIMEOUT, true);
-
- // Asserts that a redelivery exception was returned, and is of the correct type.
- Type expectedException = typeof(AMQUndeliveredException);
- Exception ex = lastErrorException;
-
- Assert.IsNotNull(ex, "No exception was thrown by the test. Expected " + expectedException);
- Assert.IsInstanceOfType(expectedException, ex.InnerException);
-
- CloseEndPoint(0);
- }
- }
-}
+/*
+ *
+ * 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 System.Threading;
+using log4net;
+using NUnit.Framework;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// <summary>
+ /// MandatoryMessageTest checks that messages sent with the 'mandatory' flag, must either be routed to a valid
+ /// queue or returned to the sender when no route is available.
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Check default exchange returns unroutable mandatory messages.
+ /// <tr><td> Check direct exchange returns unroutable mandatory messages.
+ /// <tr><td> Check headers exchange returns unroutable mandatory messages.
+ /// <tr><td> Check topic exchange returns unroutable mandatory messages.
+ /// </table>
+ /// </summary>
+ [TestFixture, Category("Integration")]
+ public class MandatoryMessageTest : BaseMessagingTestFixture
+ {
+ /// <summary>Used for debugging purposes.</summary>
+ private static ILog log = LogManager.GetLogger(typeof(MandatoryMessageTest));
+
+ /// <summary>Defines the maximum time in milliseconds, to wait for redelivery to occurr.</summary>
+ public const int TIMEOUT = 1000;
+
+ /// <summary>Defines the name of the routing key to use with the tests.</summary>
+ public const string TEST_ROUTING_KEY = "unboundkey";
+
+ /// <summary>Condition used to coordinate receipt of redelivery exception to the sending thread.</summary>
+ private ManualResetEvent errorEvent;
+
+ /// <summary>Holds the last received error condition, for examination by the tests sending thread.</summary>
+ private Exception lastErrorException;
+
+ /// <summary> Holds the test connection. </summary>
+ protected IConnection _connection;
+
+ /// <summary> Holds the test channel. </summary>
+ protected IChannel _channel;
+
+ [SetUp]
+ public override void Init()
+ {
+ base.Init();
+
+ errorEvent = new ManualResetEvent(false);
+ lastErrorException = null;
+ }
+
+ [TearDown]
+ public override void Shutdown()
+ {
+ base.Shutdown();
+ }
+
+ /// <summary>
+ /// Handles all exception conditions on the connection. The error event is notified and the exception recorded as the last seen.
+ /// </summary>
+ ///
+ /// <param name="e">The asynchronous exception on the connection.</param>
+ public void OnException(Exception e)
+ {
+ lastErrorException = e;
+ errorEvent.Set();
+ }
+
+ [Test]
+ public void SendUndeliverableMessageOnDirectExchange()
+ {
+ SendOne(ExchangeNameDefaults.DIRECT);
+ }
+
+ [Test]
+ public void SendUndeliverableMessageOnTopicExchange()
+ {
+ SendOne(ExchangeNameDefaults.TOPIC);
+ }
+
+ [Test]
+ public void SendUndeliverableMessageOnHeadersExchange()
+ {
+ SendOne(ExchangeNameDefaults.HEADERS);
+ }
+
+ /// <summary>
+ /// Sends a single message to the specified exchange with the routing key 'unboundkey', marked as mandatory.
+ /// A check is performed to assert that a redelivery error is returned from the broker for the message.
+ /// </summary>
+ ///
+ /// <param name="exchangeName">The name of the exchange to send to.</param>
+ private void SendOne(string exchangeName)
+ {
+ log.Debug("private void SendOne(string exchangeName = " + exchangeName + "): called");
+
+ // Send a test message to a unbound key on the specified exchange.
+ SetUpEndPoint(0, false, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, exchangeName,
+ true, false, null);
+ testProducer[0] = testChannel[0].CreatePublisherBuilder()
+ .WithRoutingKey(TEST_ROUTING_KEY + testId)
+ .WithMandatory(true)
+ .WithExchangeName(exchangeName)
+ .Create();
+
+ // Set up the exception listener on the connection.
+ testConnection[0].ExceptionListener = new ExceptionListenerDelegate(OnException);
+
+ // Send message that should fail.
+ testProducer[0].Send(testChannel[0].CreateTextMessage("Test Message"));
+
+ // Wait for up to the timeout for a redelivery exception to be returned.
+ errorEvent.WaitOne(TIMEOUT, true);
+
+ // Asserts that a redelivery exception was returned, and is of the correct type.
+ Type expectedException = typeof(AMQUndeliveredException);
+ Exception ex = lastErrorException;
+
+ Assert.IsNotNull(ex, "No exception was thrown by the test. Expected " + expectedException);
+ Assert.IsInstanceOfType(expectedException, ex.InnerException);
+
+ CloseEndPoint(0);
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/ProducerMultiConsumerTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/ProducerMultiConsumerTest.cs
index 876e7c7bf7..bae6c76818 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/ProducerMultiConsumerTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/ProducerMultiConsumerTest.cs
@@ -1,167 +1,167 @@
-/*
- *
- * 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 System.Text;
-using System.Threading;
-using log4net;
-using NUnit.Framework;
-using Apache.Qpid.Messaging;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// ProducerMultiConsumerTest provides some tests for one producer and multiple consumers.
- ///
- /// <p><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Check that all consumers on a topic each receive all message on it.
- /// <tr><td> Check that consumers on the same queue receive each message once accross all consumers.
- /// </table>
- /// </summary>
- [TestFixture, Category("Integration")]
- public class ProducerMultiConsumerTest : BaseMessagingTestFixture
- {
- private static readonly ILog _logger = LogManager.GetLogger(typeof(ProducerMultiConsumerTest));
-
- /// <summary>Base name for the routing key used for this test (made unique by adding in test id).</summary>
- private const string TEST_ROUTING_KEY = "ProducerMultiConsumerTest";
-
- /// <summary>The number of consumers to test.</summary>
- private const int CONSUMER_COUNT = 5;
-
- /// <summary>The number of test messages to send.</summary>
- private const int MESSAGE_COUNT = 10;
-
- /// <summary>Monitor used to signal succesfull receipt of all test messages.</summary>
- AutoResetEvent _finishedEvent;
-
- /// <summary>Used to count test messages received so far.</summary>
- private int _messageReceivedCount;
-
- /// <summary>Used to hold the expected number of messages to receive.</summary>
- private int expectedMessageCount;
-
- /// <summary>Flag used to indicate that all messages really were received, and that the test did not just time out. </summary>
- private bool allReceived;
-
- /// <summary> Creates one producing end-point and many consuming end-points connected on a topic. </summary>
- [SetUp]
- public override void Init()
- {
- base.Init();
-
- // Reset all test counts and flags.
- _messageReceivedCount = 0;
- allReceived = false;
- _finishedEvent = new AutoResetEvent(false);
- }
-
- /// <summary> Cleans up all test end-points. </summary>
- [TearDown]
- public override void Shutdown()
- {
- try
- {
- // Close all end points for producer and consumers.
- // Producer is on 0, and consumers on 1 .. n, so loop is from 0 to n inclusive.
- for (int i = 0; i <= CONSUMER_COUNT; i++)
- {
- CloseEndPoint(i);
- }
- }
- finally
- {
- base.Shutdown();
- }
- }
-
- /// <summary> Check that all consumers on a topic each receive all message on it. </summary>
- [Test]
- public void AllConsumerReceiveAllMessagesOnTopic()
- {
- // Create end-points for all the consumers in the test.
- for (int i = 1; i <= CONSUMER_COUNT; i++)
- {
- SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC,
- true, false, null);
- testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage);
- }
-
- // Create an end-point to publish to the test topic.
- SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC,
- true, false, null);
-
- expectedMessageCount = (MESSAGE_COUNT * CONSUMER_COUNT);
-
- for (int i = 0; i < MESSAGE_COUNT; i++)
- {
- testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
- }
-
- _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 30), false);
-
- // Check that all messages really were received.
- Assert.IsTrue(allReceived, "All messages were not received, only got " + _messageReceivedCount + " but wanted " + expectedMessageCount);
- }
-
- /// <summary> Check that consumers on the same queue receive each message once accross all consumers. </summary>
- [Test]
- public void AllConsumerReceiveAllMessagesOnDirect()
- {
- // Create end-points for all the consumers in the test.
- for (int i = 1; i <= CONSUMER_COUNT; i++)
- {
- SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT,
- true, false, null);
- testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage);
- }
-
- // Create an end-point to publish to the test topic.
- SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT,
- true, false, null);
-
- expectedMessageCount = (MESSAGE_COUNT * CONSUMER_COUNT);
-
- for (int i = 0; i < MESSAGE_COUNT; i++)
- {
- testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
- }
-
- _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 30), false);
-
- // Check that all messages really were received.
- Assert.IsTrue(allReceived, "All messages were not received, only got: " + _messageReceivedCount + " but wanted " + expectedMessageCount);
- }
-
- /// <summary> Atomically increments the message count on every message, and signals once all messages in the test are received. </summary>
- public void OnMessage(IMessage m)
- {
- int newCount = Interlocked.Increment(ref _messageReceivedCount);
-
- if (newCount >= expectedMessageCount)
- {
- allReceived = true;
- _finishedEvent.Set();
- }
- }
- }
-}
+/*
+ *
+ * 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 System.Text;
+using System.Threading;
+using log4net;
+using NUnit.Framework;
+using Apache.Qpid.Messaging;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// ProducerMultiConsumerTest provides some tests for one producer and multiple consumers.
+ ///
+ /// <p><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Check that all consumers on a topic each receive all message on it.
+ /// <tr><td> Check that consumers on the same queue receive each message once accross all consumers.
+ /// </table>
+ /// </summary>
+ [TestFixture, Category("Integration")]
+ public class ProducerMultiConsumerTest : BaseMessagingTestFixture
+ {
+ private static readonly ILog _logger = LogManager.GetLogger(typeof(ProducerMultiConsumerTest));
+
+ /// <summary>Base name for the routing key used for this test (made unique by adding in test id).</summary>
+ private const string TEST_ROUTING_KEY = "ProducerMultiConsumerTest";
+
+ /// <summary>The number of consumers to test.</summary>
+ private const int CONSUMER_COUNT = 5;
+
+ /// <summary>The number of test messages to send.</summary>
+ private const int MESSAGE_COUNT = 10;
+
+ /// <summary>Monitor used to signal succesfull receipt of all test messages.</summary>
+ AutoResetEvent _finishedEvent;
+
+ /// <summary>Used to count test messages received so far.</summary>
+ private int _messageReceivedCount;
+
+ /// <summary>Used to hold the expected number of messages to receive.</summary>
+ private int expectedMessageCount;
+
+ /// <summary>Flag used to indicate that all messages really were received, and that the test did not just time out. </summary>
+ private bool allReceived;
+
+ /// <summary> Creates one producing end-point and many consuming end-points connected on a topic. </summary>
+ [SetUp]
+ public override void Init()
+ {
+ base.Init();
+
+ // Reset all test counts and flags.
+ _messageReceivedCount = 0;
+ allReceived = false;
+ _finishedEvent = new AutoResetEvent(false);
+ }
+
+ /// <summary> Cleans up all test end-points. </summary>
+ [TearDown]
+ public override void Shutdown()
+ {
+ try
+ {
+ // Close all end points for producer and consumers.
+ // Producer is on 0, and consumers on 1 .. n, so loop is from 0 to n inclusive.
+ for (int i = 0; i <= CONSUMER_COUNT; i++)
+ {
+ CloseEndPoint(i);
+ }
+ }
+ finally
+ {
+ base.Shutdown();
+ }
+ }
+
+ /// <summary> Check that all consumers on a topic each receive all message on it. </summary>
+ [Test]
+ public void AllConsumerReceiveAllMessagesOnTopic()
+ {
+ // Create end-points for all the consumers in the test.
+ for (int i = 1; i <= CONSUMER_COUNT; i++)
+ {
+ SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC,
+ true, false, null);
+ testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage);
+ }
+
+ // Create an end-point to publish to the test topic.
+ SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.TOPIC,
+ true, false, null);
+
+ expectedMessageCount = (MESSAGE_COUNT * CONSUMER_COUNT);
+
+ for (int i = 0; i < MESSAGE_COUNT; i++)
+ {
+ testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
+ }
+
+ _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 30), false);
+
+ // Check that all messages really were received.
+ Assert.IsTrue(allReceived, "All messages were not received, only got " + _messageReceivedCount + " but wanted " + expectedMessageCount);
+ }
+
+ /// <summary> Check that consumers on the same queue receive each message once accross all consumers. </summary>
+ [Test]
+ public void AllConsumerReceiveAllMessagesOnDirect()
+ {
+ // Create end-points for all the consumers in the test.
+ for (int i = 1; i <= CONSUMER_COUNT; i++)
+ {
+ SetUpEndPoint(i, false, true, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT,
+ true, false, null);
+ testConsumer[i].OnMessage += new MessageReceivedDelegate(OnMessage);
+ }
+
+ // Create an end-point to publish to the test topic.
+ SetUpEndPoint(0, true, false, TEST_ROUTING_KEY + testId, AcknowledgeMode.AutoAcknowledge, false, ExchangeNameDefaults.DIRECT,
+ true, false, null);
+
+ expectedMessageCount = (MESSAGE_COUNT * CONSUMER_COUNT);
+
+ for (int i = 0; i < MESSAGE_COUNT; i++)
+ {
+ testProducer[0].Send(testChannel[0].CreateTextMessage("A"));
+ }
+
+ _finishedEvent.WaitOne(new TimeSpan(0, 0, 0, 30), false);
+
+ // Check that all messages really were received.
+ Assert.IsTrue(allReceived, "All messages were not received, only got: " + _messageReceivedCount + " but wanted " + expectedMessageCount);
+ }
+
+ /// <summary> Atomically increments the message count on every message, and signals once all messages in the test are received. </summary>
+ public void OnMessage(IMessage m)
+ {
+ int newCount = Interlocked.Increment(ref _messageReceivedCount);
+
+ if (newCount >= expectedMessageCount)
+ {
+ allReceived = true;
+ _finishedEvent.Set();
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/SslConnectionTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/SslConnectionTest.cs
index 1c104d1451..5f953e1470 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/SslConnectionTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/SslConnectionTest.cs
@@ -1,64 +1,64 @@
-/*
- *
- * 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 System.IO;
-using System.Reflection;
-using System.Security.Cryptography.X509Certificates;
-using NUnit.Framework;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-using Apache.Qpid.Messaging;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// <summary>
- /// Test SSL/TLS connections to the broker
- /// </summary>
- [TestFixture, Category("Integration")]
- public class SslConnectionTest
- {
- /// <summary>
- /// Make a test TLS connection to the broker
- /// without using client-certificates
- /// </summary>
- //[Test]
- public void DoSslConnection()
- {
- // because for tests we don't usually trust the server certificate
- // we need here to tell the client to ignore certificate validation errors
- SslOptions sslConfig = new SslOptions(null, true);
-
- MakeBrokerConnection(sslConfig);
- }
-
- private static void MakeBrokerConnection(SslOptions options)
- {
- IConnectionInfo connectionInfo = new QpidConnectionInfo();
- connectionInfo.VirtualHost = "test";
- connectionInfo.AddBrokerInfo(new AmqBrokerInfo("amqp", "localhost", 8672, options));
-
- using ( IConnection connection = new AMQConnection(connectionInfo) )
- {
- Console.WriteLine("connection = " + connection);
- }
- }
- }
-}
+/*
+ *
+ * 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 System.IO;
+using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
+using NUnit.Framework;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+using Apache.Qpid.Messaging;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// <summary>
+ /// Test SSL/TLS connections to the broker
+ /// </summary>
+ [TestFixture, Category("Integration")]
+ public class SslConnectionTest
+ {
+ /// <summary>
+ /// Make a test TLS connection to the broker
+ /// without using client-certificates
+ /// </summary>
+ //[Test]
+ public void DoSslConnection()
+ {
+ // because for tests we don't usually trust the server certificate
+ // we need here to tell the client to ignore certificate validation errors
+ SslOptions sslConfig = new SslOptions(null, true);
+
+ MakeBrokerConnection(sslConfig);
+ }
+
+ private static void MakeBrokerConnection(SslOptions options)
+ {
+ IConnectionInfo connectionInfo = new QpidConnectionInfo();
+ connectionInfo.VirtualHost = "test";
+ connectionInfo.AddBrokerInfo(new AmqBrokerInfo("amqp", "localhost", 8672, options));
+
+ using ( IConnection connection = new AMQConnection(connectionInfo) )
+ {
+ Console.WriteLine("connection = " + connection);
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Integration.Tests/testcases/SustainedTest.cs b/qpid/dotnet/Qpid.Integration.Tests/testcases/SustainedTest.cs
index aca3f396d6..4074055eba 100644
--- a/qpid/dotnet/Qpid.Integration.Tests/testcases/SustainedTest.cs
+++ b/qpid/dotnet/Qpid.Integration.Tests/testcases/SustainedTest.cs
@@ -1,109 +1,109 @@
-/*
- *
- * 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 System.IO;
-using System.Reflection;
-using System.Threading;
-using NUnit.Framework;
-using Apache.Qpid.Client.Qms;
-using Apache.Qpid.Client;
-using Apache.Qpid.Messaging;
-using log4net;
-
-namespace Apache.Qpid.Integration.Tests.testcases
-{
- /// <summary>
- /// Runs through the range of ack modes for each test case, sending and recieving a large number of messages
- /// </summary>
- [TestFixture, Category("Integration")]
- public class SustainedTest : BaseMessagingTestFixture
- {
- /// <summary>The number of test messages to send.</summary>
- private const int MESSAGE_COUNT = 50;//00;
-
- /// <summary>Base name for the routing key used for this test (made unique by adding in test id).</summary>
- private const string TEST_ROUTING_KEY = "MessageOrderTest";
-
- /// <summary>
- /// The logger
- /// </summary>
- private static ILog _logger = LogManager.GetLogger(typeof(SustainedTest));
-
- [Test]
- public void MessageOrderTestAutoAck()
- {
- MessageOrderTest(AcknowledgeMode.AutoAcknowledge);
- }
-
- [Test]
- public void MessageOrderTestNoAck()
- {
- MessageOrderTest(AcknowledgeMode.NoAcknowledge);
- }
-
- public void MessageOrderTest(AcknowledgeMode consumerMode)
- {
-
- // Consumer
- SetUpEndPoint(1, false, true, TEST_ROUTING_KEY, consumerMode, false, ExchangeNameDefaults.DIRECT,
- true, false, null);
-
-
- Console.WriteLine("Starting producer thread");
- Thread prodThread = new Thread(new ThreadStart(SendMessages));
- prodThread.Start();
-
- Thread.Sleep(2000);
- Console.WriteLine("Starting consuming");
- for (int i = 0; i < MESSAGE_COUNT; i++)
- {
- if ((i % 10) == 0)
- {
- Console.WriteLine("Consuming message "+i);
- }
- ConsumeNMessages(1, "Msg"+i, testConsumer[1]);
- }
- prodThread.Join();
- CloseEndPoint(0);
- CloseEndPoint(1);
- }
-
- private static void SendMessages()
- {
- AMQConnection conn = new AMQConnection(QpidConnectionInfo.FromUrl(BaseMessagingTestFixture.connectionUri));
- conn.Start();
- IChannel channel = conn.CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
- IMessagePublisher producer = channel.CreatePublisherBuilder().
- WithExchangeName(ExchangeNameDefaults.DIRECT).
- WithRoutingKey(TEST_ROUTING_KEY).
- Create();
-
- for (int i = 0; i < MESSAGE_COUNT ; i++)
- {
- if ((i % 10) == 0)
- {
- Console.WriteLine("Sending message "+i);
- }
- producer.Send(channel.CreateTextMessage("Msg" + i));
- }
- }
- }
-}
+/*
+ *
+ * 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 System.IO;
+using System.Reflection;
+using System.Threading;
+using NUnit.Framework;
+using Apache.Qpid.Client.Qms;
+using Apache.Qpid.Client;
+using Apache.Qpid.Messaging;
+using log4net;
+
+namespace Apache.Qpid.Integration.Tests.testcases
+{
+ /// <summary>
+ /// Runs through the range of ack modes for each test case, sending and recieving a large number of messages
+ /// </summary>
+ [TestFixture, Category("Integration")]
+ public class SustainedTest : BaseMessagingTestFixture
+ {
+ /// <summary>The number of test messages to send.</summary>
+ private const int MESSAGE_COUNT = 50;//00;
+
+ /// <summary>Base name for the routing key used for this test (made unique by adding in test id).</summary>
+ private const string TEST_ROUTING_KEY = "MessageOrderTest";
+
+ /// <summary>
+ /// The logger
+ /// </summary>
+ private static ILog _logger = LogManager.GetLogger(typeof(SustainedTest));
+
+ [Test]
+ public void MessageOrderTestAutoAck()
+ {
+ MessageOrderTest(AcknowledgeMode.AutoAcknowledge);
+ }
+
+ [Test]
+ public void MessageOrderTestNoAck()
+ {
+ MessageOrderTest(AcknowledgeMode.NoAcknowledge);
+ }
+
+ public void MessageOrderTest(AcknowledgeMode consumerMode)
+ {
+
+ // Consumer
+ SetUpEndPoint(1, false, true, TEST_ROUTING_KEY, consumerMode, false, ExchangeNameDefaults.DIRECT,
+ true, false, null);
+
+
+ Console.WriteLine("Starting producer thread");
+ Thread prodThread = new Thread(new ThreadStart(SendMessages));
+ prodThread.Start();
+
+ Thread.Sleep(2000);
+ Console.WriteLine("Starting consuming");
+ for (int i = 0; i < MESSAGE_COUNT; i++)
+ {
+ if ((i % 10) == 0)
+ {
+ Console.WriteLine("Consuming message "+i);
+ }
+ ConsumeNMessages(1, "Msg"+i, testConsumer[1]);
+ }
+ prodThread.Join();
+ CloseEndPoint(0);
+ CloseEndPoint(1);
+ }
+
+ private static void SendMessages()
+ {
+ AMQConnection conn = new AMQConnection(QpidConnectionInfo.FromUrl(BaseMessagingTestFixture.connectionUri));
+ conn.Start();
+ IChannel channel = conn.CreateChannel(false, AcknowledgeMode.AutoAcknowledge);
+ IMessagePublisher producer = channel.CreatePublisherBuilder().
+ WithExchangeName(ExchangeNameDefaults.DIRECT).
+ WithRoutingKey(TEST_ROUTING_KEY).
+ Create();
+
+ for (int i = 0; i < MESSAGE_COUNT ; i++)
+ {
+ if ((i % 10) == 0)
+ {
+ Console.WriteLine("Sending message "+i);
+ }
+ producer.Send(channel.CreateTextMessage("Msg" + i));
+ }
+ }
+ }
+}
diff --git a/qpid/dotnet/Qpid.Messaging/ICloseable.cs b/qpid/dotnet/Qpid.Messaging/ICloseable.cs
index 3c9d66047d..658a5ed5a4 100644
--- a/qpid/dotnet/Qpid.Messaging/ICloseable.cs
+++ b/qpid/dotnet/Qpid.Messaging/ICloseable.cs
@@ -1,38 +1,38 @@
-/*
- *
- * 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;
-
-namespace Apache.Qpid.Messaging
-{
- /// <summary>An ICloseable is a resource that can be explicitly closed. Generally speaking a closed resource can no longer be used, and the
- /// act of closing a resource is usually interpreted as a signal that the closed item can have its resource cleaned up and de-allocated.
- ///
- /// <p/><table id="crc"><caption>CRC Card</caption>
- /// <tr><th> Responsibilities <th> Collaborations
- /// <tr><td> Close (and clean-up) a resource.
- /// </table>
- /// </summary>
- public interface ICloseable
- {
- /// <summary> Close the resource. </summary>
- void Close();
- }
-}
+/*
+ *
+ * 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;
+
+namespace Apache.Qpid.Messaging
+{
+ /// <summary>An ICloseable is a resource that can be explicitly closed. Generally speaking a closed resource can no longer be used, and the
+ /// act of closing a resource is usually interpreted as a signal that the closed item can have its resource cleaned up and de-allocated.
+ ///
+ /// <p/><table id="crc"><caption>CRC Card</caption>
+ /// <tr><th> Responsibilities <th> Collaborations
+ /// <tr><td> Close (and clean-up) a resource.
+ /// </table>
+ /// </summary>
+ public interface ICloseable
+ {
+ /// <summary> Close the resource. </summary>
+ void Close();
+ }
+}
diff --git a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/AnonymousSaslClientTests.cs b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/AnonymousSaslClientTests.cs
index 09260736f0..5839f310e1 100644
--- a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/AnonymousSaslClientTests.cs
+++ b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/AnonymousSaslClientTests.cs
@@ -1,72 +1,72 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-using NUnit.Framework;
-using Apache.Qpid.Sasl;
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Sasl.Tests.Mechanisms
-{
- [TestFixture]
- public class AnonymousSaslClientTests : ISaslCallbackHandler
- {
- private const string AUTHID = "nobody@nowhere.com";
-
- [Test]
- public void ReturnsRightMechanismName()
- {
- ISaslClient client = new AnonymousSaslClient(AUTHID, new Hashtable(), this);
-
- Assert.AreEqual("ANONYMOUS", client.MechanismName);
- }
-
- [Test]
- public void HasInitialResponseReturnsTrue()
- {
- ISaslClient client = new AnonymousSaslClient(AUTHID, new Hashtable(), this);
-
- Assert.IsTrue(client.HasInitialResponse);
- }
-
- [Test]
- public void CanEvaluateChallenge()
- {
- Hashtable props = new Hashtable();
- ISaslClient client = new AnonymousSaslClient(AUTHID, props, this);
-
- Assert.IsFalse(client.IsComplete);
- byte[] response = client.EvaluateChallenge(new byte[0]);
- Assert.AreEqual(AUTHID, Encoding.UTF8.GetString(response));
-
- Assert.IsTrue(client.IsComplete);
- }
-
- void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
- {
- }
-
- } // class AnonymousSaslClientTests
-
-} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+using NUnit.Framework;
+using Apache.Qpid.Sasl;
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Sasl.Tests.Mechanisms
+{
+ [TestFixture]
+ public class AnonymousSaslClientTests : ISaslCallbackHandler
+ {
+ private const string AUTHID = "nobody@nowhere.com";
+
+ [Test]
+ public void ReturnsRightMechanismName()
+ {
+ ISaslClient client = new AnonymousSaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.AreEqual("ANONYMOUS", client.MechanismName);
+ }
+
+ [Test]
+ public void HasInitialResponseReturnsTrue()
+ {
+ ISaslClient client = new AnonymousSaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.IsTrue(client.HasInitialResponse);
+ }
+
+ [Test]
+ public void CanEvaluateChallenge()
+ {
+ Hashtable props = new Hashtable();
+ ISaslClient client = new AnonymousSaslClient(AUTHID, props, this);
+
+ Assert.IsFalse(client.IsComplete);
+ byte[] response = client.EvaluateChallenge(new byte[0]);
+ Assert.AreEqual(AUTHID, Encoding.UTF8.GetString(response));
+
+ Assert.IsTrue(client.IsComplete);
+ }
+
+ void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
+ {
+ }
+
+ } // class AnonymousSaslClientTests
+
+} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/CramMD5SaslClientTests.cs b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/CramMD5SaslClientTests.cs
index e8b0ae5468..baeeafb2d2 100644
--- a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/CramMD5SaslClientTests.cs
+++ b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/CramMD5SaslClientTests.cs
@@ -1,90 +1,90 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-using NUnit.Framework;
-using Apache.Qpid.Sasl;
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Sasl.Tests.Mechanisms
-{
- [TestFixture]
- public class CramMD5SaslClientTests : ISaslCallbackHandler
- {
- private const string USERNAME = "testuser";
- private const string PASSWORD = "tanstaaftanstaaf";
- private const string AUTHID = "test";
-
- [Test]
- public void ReturnsRightMechanismName()
- {
- ISaslClient client = new CramMD5SaslClient(AUTHID, new Hashtable(), this);
-
- Assert.AreEqual("CRAM-MD5", client.MechanismName);
- }
-
- [Test]
- public void HasInitialResponseReturnsFalse()
- {
- ISaslClient client = new CramMD5SaslClient(AUTHID, new Hashtable(), this);
-
- Assert.IsFalse(client.HasInitialResponse);
- }
-
- [Test]
- public void CanEvaluateChallenge()
- {
- Hashtable props = new Hashtable();
-
- ISaslClient client = new CramMD5SaslClient(AUTHID, props, this);
-
- Assert.IsFalse(client.IsComplete);
-
- byte[] challenge =
- Encoding.UTF8.GetBytes("<1896.697170952@postoffice.reston.mci.net>");
- byte[] response = client.EvaluateChallenge(challenge);
- string[] parts = Encoding.UTF8.GetString(response).Split(' ');
-
- Assert.AreEqual(2, parts.Length);
- Assert.AreEqual(USERNAME, parts[0]);
- Assert.AreEqual("b913a602c7eda7a495b4e6e7334d3890", parts[1]);
- Assert.IsTrue(client.IsComplete);
- }
-
- void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
- {
- foreach ( ISaslCallback cb in callbacks )
- {
- if ( cb is NameCallback )
- {
- ((NameCallback)cb).Text = USERNAME;
- } else if ( cb is PasswordCallback )
- {
- ((PasswordCallback)cb).Text = PASSWORD;
- }
- }
- }
- } // class CramMD5SaslClientTests
-
-} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+using NUnit.Framework;
+using Apache.Qpid.Sasl;
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Sasl.Tests.Mechanisms
+{
+ [TestFixture]
+ public class CramMD5SaslClientTests : ISaslCallbackHandler
+ {
+ private const string USERNAME = "testuser";
+ private const string PASSWORD = "tanstaaftanstaaf";
+ private const string AUTHID = "test";
+
+ [Test]
+ public void ReturnsRightMechanismName()
+ {
+ ISaslClient client = new CramMD5SaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.AreEqual("CRAM-MD5", client.MechanismName);
+ }
+
+ [Test]
+ public void HasInitialResponseReturnsFalse()
+ {
+ ISaslClient client = new CramMD5SaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.IsFalse(client.HasInitialResponse);
+ }
+
+ [Test]
+ public void CanEvaluateChallenge()
+ {
+ Hashtable props = new Hashtable();
+
+ ISaslClient client = new CramMD5SaslClient(AUTHID, props, this);
+
+ Assert.IsFalse(client.IsComplete);
+
+ byte[] challenge =
+ Encoding.UTF8.GetBytes("<1896.697170952@postoffice.reston.mci.net>");
+ byte[] response = client.EvaluateChallenge(challenge);
+ string[] parts = Encoding.UTF8.GetString(response).Split(' ');
+
+ Assert.AreEqual(2, parts.Length);
+ Assert.AreEqual(USERNAME, parts[0]);
+ Assert.AreEqual("b913a602c7eda7a495b4e6e7334d3890", parts[1]);
+ Assert.IsTrue(client.IsComplete);
+ }
+
+ void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
+ {
+ foreach ( ISaslCallback cb in callbacks )
+ {
+ if ( cb is NameCallback )
+ {
+ ((NameCallback)cb).Text = USERNAME;
+ } else if ( cb is PasswordCallback )
+ {
+ ((PasswordCallback)cb).Text = PASSWORD;
+ }
+ }
+ }
+ } // class CramMD5SaslClientTests
+
+} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/DigestSaslClientTests.cs b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/DigestSaslClientTests.cs
index eb7e7ebbd5..5a18ebaefd 100644
--- a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/DigestSaslClientTests.cs
+++ b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/DigestSaslClientTests.cs
@@ -1,249 +1,249 @@
-/*
- *
- * 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 System.Collections;
-using System.Collections.Specialized;
-using System.Text;
-
-using NUnit.Framework;
-using Apache.Qpid.Sasl;
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Sasl.Tests.Mechanisms
-{
- [TestFixture]
- public class DigestSaslClientTests : ISaslCallbackHandler
- {
- private const string USERNAME = "chris";
- private const string PASSWORD = "secret";
- private const string AUTHID = null;
- private const string PROTOCOL = "IMAP";
- private const string SERVERNAME = "elwood.innosoft.com";
-
- #region Digest Challenge Parsing Tests
- //
- // Digest Challenge Parsing Tests
- //
-
- [Test]
- public void CanParseSimpleString()
- {
- string challenge = "realm=\"elwood.innosoft.com\", algorithm=md5-sess";
- StringDictionary values = DigestChallenge.ParseParameters(challenge);
- Assert.AreEqual(2, values.Count);
- Assert.AreEqual("elwood.innosoft.com", values["realm"]);
- Assert.AreEqual("md5-sess", values["algorithm"]);
- }
-
- [Test]
- public void CanParseEscapedQuotes()
- {
- string challenge = "realm=\"elwood\\\".innosoft.com\", algorithm=md5-sess";
- StringDictionary values = DigestChallenge.ParseParameters(challenge);
- Assert.AreEqual(2, values.Count);
- Assert.AreEqual("elwood\\\".innosoft.com", values["realm"]);
- Assert.AreEqual("md5-sess", values["algorithm"]);
- }
-
- [Test]
- public void CanParseEmbeddedDelimiter()
- {
- string challenge = "realm=\"elwood,innosoft.com\", algorithm=md5-sess";
- StringDictionary values = DigestChallenge.ParseParameters(challenge);
- Assert.AreEqual(2, values.Count);
- Assert.AreEqual("elwood,innosoft.com", values["realm"]);
- Assert.AreEqual("md5-sess", values["algorithm"]);
- }
-
- [Test]
- public void CanParse1()
- {
- string challenge = "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8";
- DigestChallenge parsed = DigestChallenge.Parse(challenge);
-
- Assert.AreEqual("elwood.innosoft.com", parsed.Realm);
- Assert.AreEqual("OA6MG9tEQGm2hh", parsed.Nonce);
- Assert.Contains("auth", parsed.QopOptions);
- Assert.AreEqual("md5-sess", parsed.Algorithm);
- Assert.AreEqual("utf-8", parsed.Charset);
- }
-
- #endregion // Digest Challenge Parsing Tests
-
-
- #region Digest Response Tests
- //
- // Digest Response Tests
- //
-
- [Test]
- public void CanWriteResponse()
- {
- DigestResponse resp = new DigestResponse();
- resp.Username = "user";
- resp.Realm = "nowhere.com";
- resp.Nonce = "OA9BSXrbuRhWay";
- resp.Cnonce = "OA9BSuZWMSpW8m";
- resp.NonceCount = 16;
- resp.DigestUri = "acap/elwood.innosoft.com";
- resp.Response = "6084c6db3fede7352c551284490fd0fc";
- resp.Qop = "auth";
- resp.MaxBuffer = 65536;
- resp.Cipher = "3des";
- resp.Authzid = "user2";
- resp.AuthParam = "ap";
- resp.Charset = "utf-8";
-
- string expected = "username=\"user\",realm=\"nowhere.com\",nonce=\"OA9BSXrbuRhWay\",cnonce=\"OA9BSuZWMSpW8m\",nc=00000010,qop=auth,digest-uri=\"acap/elwood.innosoft.com\",response=\"6084c6db3fede7352c551284490fd0fc\",maxbuf=65536,charset=utf-8,cipher=3des,authzid=\"user2\",auth-param=\"ap\"";
- Assert.AreEqual(expected, resp.ToString());
- }
-
- [Test]
- public void CanWriteEscapedSecuence()
- {
- DigestResponse resp = new DigestResponse();
- resp.Username = "us\"er";
-
- string expected = "username=\"us\\\"er\",nc=00000000,maxbuf=0";
- Assert.AreEqual(expected, resp.ToString());
- }
-
- #endregion // Digest Response Tests
-
-
- #region Authentication Tests
- //
- // Authentication Tests
- //
-
- [Test]
- public void ReturnsRightMechanismName()
- {
- ISaslClient client = CreateClient();
-
- Assert.AreEqual("DIGEST-MD5", client.MechanismName);
- }
-
- [Test]
- public void HasInitialResponseReturnsFalse()
- {
- ISaslClient client = CreateClient();
-
- Assert.IsFalse(client.HasInitialResponse);
- }
-
- [Test]
- public void CanAuthenticate()
- {
- string challenge = "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8";
- DigestSaslClient client = CreateClient();
- client.Cnonce = "OA6MHXh6VqTrRk";
-
- byte[] bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
- string response = Encoding.UTF8.GetString(bresp);
- string expectedResp = "username=\"chris\",realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",cnonce=\"" +
- client.Cnonce + "\",nc=00000001,qop=auth,digest-uri=\"imap/elwood.innosoft.com\",response=\"d388dad90d4bbd760a152321f2143af7\",maxbuf=65536,charset=utf-8";
-
- Assert.AreEqual(expectedResp, response);
- Assert.IsFalse(client.IsComplete);
-
- string challenge2 = "rspauth=ea40f60335c427b5527b84dbabcdfffd";
- bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge2));
- // client responds with zero-length array
- Assert.AreEqual(0, bresp.Length);
- Assert.IsTrue(client.IsComplete);
- }
-
- [Test]
- [ExpectedException(typeof(ArgumentNullException))]
- public void ThrowsExceptionWhenChallengeIsMissing()
- {
- DigestSaslClient client = CreateClient();
- client.EvaluateChallenge(null);
- }
-
-
- [Test]
- [ExpectedException(typeof(SaslException))]
- public void ThrowsExceptionWhenNonceMissing()
- {
- string challenge = "realm=\"elwood.innosoft.com\"";
- DigestSaslClient client = CreateClient();
-
- client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
- }
-
- [Test]
- [ExpectedException(typeof(SaslException))]
- public void ThrowsExceptionWhenAlgorithmMissing()
- {
- string challenge = "realm=\"elwood.innosoft.com\",nonce=\"asdasadsad\"";
- DigestSaslClient client = CreateClient();
-
- client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
- }
-
- [Test]
- [ExpectedException(typeof(SaslException))]
- public void ThrowsExceptionWhenSecondChallengeInvalid()
- {
- string challenge = "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8";
- DigestSaslClient client = CreateClient();
-
- byte[] bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
- Encoding.UTF8.GetString(bresp);
-
- // repeat challenge 1, which is incorrect
- client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
- }
-
- private DigestSaslClient CreateClient()
- {
- return new DigestSaslClient(
- AUTHID, SERVERNAME, PROTOCOL,
- new Hashtable(), this
- );
- }
-
- void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
- {
- foreach ( ISaslCallback cb in callbacks )
- {
- if ( cb is NameCallback )
- {
- ((NameCallback)cb).Text = USERNAME;
- } else if ( cb is PasswordCallback )
- {
- ((PasswordCallback)cb).Text = PASSWORD;
- } else if ( cb is RealmCallback )
- {
- ((RealmCallback)cb).Text = SERVERNAME;
- }
- }
- }
-
- #endregion // Authentication Tests
-
-
- } // class DigestSaslClientTests
-
-} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+using NUnit.Framework;
+using Apache.Qpid.Sasl;
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Sasl.Tests.Mechanisms
+{
+ [TestFixture]
+ public class DigestSaslClientTests : ISaslCallbackHandler
+ {
+ private const string USERNAME = "chris";
+ private const string PASSWORD = "secret";
+ private const string AUTHID = null;
+ private const string PROTOCOL = "IMAP";
+ private const string SERVERNAME = "elwood.innosoft.com";
+
+ #region Digest Challenge Parsing Tests
+ //
+ // Digest Challenge Parsing Tests
+ //
+
+ [Test]
+ public void CanParseSimpleString()
+ {
+ string challenge = "realm=\"elwood.innosoft.com\", algorithm=md5-sess";
+ StringDictionary values = DigestChallenge.ParseParameters(challenge);
+ Assert.AreEqual(2, values.Count);
+ Assert.AreEqual("elwood.innosoft.com", values["realm"]);
+ Assert.AreEqual("md5-sess", values["algorithm"]);
+ }
+
+ [Test]
+ public void CanParseEscapedQuotes()
+ {
+ string challenge = "realm=\"elwood\\\".innosoft.com\", algorithm=md5-sess";
+ StringDictionary values = DigestChallenge.ParseParameters(challenge);
+ Assert.AreEqual(2, values.Count);
+ Assert.AreEqual("elwood\\\".innosoft.com", values["realm"]);
+ Assert.AreEqual("md5-sess", values["algorithm"]);
+ }
+
+ [Test]
+ public void CanParseEmbeddedDelimiter()
+ {
+ string challenge = "realm=\"elwood,innosoft.com\", algorithm=md5-sess";
+ StringDictionary values = DigestChallenge.ParseParameters(challenge);
+ Assert.AreEqual(2, values.Count);
+ Assert.AreEqual("elwood,innosoft.com", values["realm"]);
+ Assert.AreEqual("md5-sess", values["algorithm"]);
+ }
+
+ [Test]
+ public void CanParse1()
+ {
+ string challenge = "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8";
+ DigestChallenge parsed = DigestChallenge.Parse(challenge);
+
+ Assert.AreEqual("elwood.innosoft.com", parsed.Realm);
+ Assert.AreEqual("OA6MG9tEQGm2hh", parsed.Nonce);
+ Assert.Contains("auth", parsed.QopOptions);
+ Assert.AreEqual("md5-sess", parsed.Algorithm);
+ Assert.AreEqual("utf-8", parsed.Charset);
+ }
+
+ #endregion // Digest Challenge Parsing Tests
+
+
+ #region Digest Response Tests
+ //
+ // Digest Response Tests
+ //
+
+ [Test]
+ public void CanWriteResponse()
+ {
+ DigestResponse resp = new DigestResponse();
+ resp.Username = "user";
+ resp.Realm = "nowhere.com";
+ resp.Nonce = "OA9BSXrbuRhWay";
+ resp.Cnonce = "OA9BSuZWMSpW8m";
+ resp.NonceCount = 16;
+ resp.DigestUri = "acap/elwood.innosoft.com";
+ resp.Response = "6084c6db3fede7352c551284490fd0fc";
+ resp.Qop = "auth";
+ resp.MaxBuffer = 65536;
+ resp.Cipher = "3des";
+ resp.Authzid = "user2";
+ resp.AuthParam = "ap";
+ resp.Charset = "utf-8";
+
+ string expected = "username=\"user\",realm=\"nowhere.com\",nonce=\"OA9BSXrbuRhWay\",cnonce=\"OA9BSuZWMSpW8m\",nc=00000010,qop=auth,digest-uri=\"acap/elwood.innosoft.com\",response=\"6084c6db3fede7352c551284490fd0fc\",maxbuf=65536,charset=utf-8,cipher=3des,authzid=\"user2\",auth-param=\"ap\"";
+ Assert.AreEqual(expected, resp.ToString());
+ }
+
+ [Test]
+ public void CanWriteEscapedSecuence()
+ {
+ DigestResponse resp = new DigestResponse();
+ resp.Username = "us\"er";
+
+ string expected = "username=\"us\\\"er\",nc=00000000,maxbuf=0";
+ Assert.AreEqual(expected, resp.ToString());
+ }
+
+ #endregion // Digest Response Tests
+
+
+ #region Authentication Tests
+ //
+ // Authentication Tests
+ //
+
+ [Test]
+ public void ReturnsRightMechanismName()
+ {
+ ISaslClient client = CreateClient();
+
+ Assert.AreEqual("DIGEST-MD5", client.MechanismName);
+ }
+
+ [Test]
+ public void HasInitialResponseReturnsFalse()
+ {
+ ISaslClient client = CreateClient();
+
+ Assert.IsFalse(client.HasInitialResponse);
+ }
+
+ [Test]
+ public void CanAuthenticate()
+ {
+ string challenge = "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8";
+ DigestSaslClient client = CreateClient();
+ client.Cnonce = "OA6MHXh6VqTrRk";
+
+ byte[] bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
+ string response = Encoding.UTF8.GetString(bresp);
+ string expectedResp = "username=\"chris\",realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",cnonce=\"" +
+ client.Cnonce + "\",nc=00000001,qop=auth,digest-uri=\"imap/elwood.innosoft.com\",response=\"d388dad90d4bbd760a152321f2143af7\",maxbuf=65536,charset=utf-8";
+
+ Assert.AreEqual(expectedResp, response);
+ Assert.IsFalse(client.IsComplete);
+
+ string challenge2 = "rspauth=ea40f60335c427b5527b84dbabcdfffd";
+ bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge2));
+ // client responds with zero-length array
+ Assert.AreEqual(0, bresp.Length);
+ Assert.IsTrue(client.IsComplete);
+ }
+
+ [Test]
+ [ExpectedException(typeof(ArgumentNullException))]
+ public void ThrowsExceptionWhenChallengeIsMissing()
+ {
+ DigestSaslClient client = CreateClient();
+ client.EvaluateChallenge(null);
+ }
+
+
+ [Test]
+ [ExpectedException(typeof(SaslException))]
+ public void ThrowsExceptionWhenNonceMissing()
+ {
+ string challenge = "realm=\"elwood.innosoft.com\"";
+ DigestSaslClient client = CreateClient();
+
+ client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
+ }
+
+ [Test]
+ [ExpectedException(typeof(SaslException))]
+ public void ThrowsExceptionWhenAlgorithmMissing()
+ {
+ string challenge = "realm=\"elwood.innosoft.com\",nonce=\"asdasadsad\"";
+ DigestSaslClient client = CreateClient();
+
+ client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
+ }
+
+ [Test]
+ [ExpectedException(typeof(SaslException))]
+ public void ThrowsExceptionWhenSecondChallengeInvalid()
+ {
+ string challenge = "realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8";
+ DigestSaslClient client = CreateClient();
+
+ byte[] bresp = client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
+ Encoding.UTF8.GetString(bresp);
+
+ // repeat challenge 1, which is incorrect
+ client.EvaluateChallenge(Encoding.UTF8.GetBytes(challenge));
+ }
+
+ private DigestSaslClient CreateClient()
+ {
+ return new DigestSaslClient(
+ AUTHID, SERVERNAME, PROTOCOL,
+ new Hashtable(), this
+ );
+ }
+
+ void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
+ {
+ foreach ( ISaslCallback cb in callbacks )
+ {
+ if ( cb is NameCallback )
+ {
+ ((NameCallback)cb).Text = USERNAME;
+ } else if ( cb is PasswordCallback )
+ {
+ ((PasswordCallback)cb).Text = PASSWORD;
+ } else if ( cb is RealmCallback )
+ {
+ ((RealmCallback)cb).Text = SERVERNAME;
+ }
+ }
+ }
+
+ #endregion // Authentication Tests
+
+
+ } // class DigestSaslClientTests
+
+} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/ExternalSaslClientTests.cs b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/ExternalSaslClientTests.cs
index 1864a6c957..57efcf7614 100644
--- a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/ExternalSaslClientTests.cs
+++ b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/ExternalSaslClientTests.cs
@@ -1,71 +1,71 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-using NUnit.Framework;
-using Apache.Qpid.Sasl;
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Sasl.Tests.Mechanisms
-{
- [TestFixture]
- public class ExternalSaslClientTests : ISaslCallbackHandler
- {
- private const string AUTHID = "nobody@nowhere.com";
-
- [Test]
- public void ReturnsRightMechanismName()
- {
- ISaslClient client = new ExternalSaslClient(AUTHID, new Hashtable(), this);
-
- Assert.AreEqual("EXTERNAL", client.MechanismName);
- }
-
- [Test]
- public void HasInitialResponseReturnsTrue()
- {
- ISaslClient client = new ExternalSaslClient(AUTHID, new Hashtable(), this);
-
- Assert.IsTrue(client.HasInitialResponse);
- }
-
- [Test]
- public void CanEvaluateChallenge()
- {
- ISaslClient client = new ExternalSaslClient(AUTHID, new Hashtable(), this);
-
- Assert.IsFalse(client.IsComplete);
- byte[] response = client.EvaluateChallenge(new byte[0]);
- Assert.AreEqual(AUTHID, Encoding.UTF8.GetString(response));
-
- Assert.IsTrue(client.IsComplete);
- }
-
- void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
- {
- }
-
- } // class AnonymousSaslClientTests
-
-} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+using NUnit.Framework;
+using Apache.Qpid.Sasl;
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Sasl.Tests.Mechanisms
+{
+ [TestFixture]
+ public class ExternalSaslClientTests : ISaslCallbackHandler
+ {
+ private const string AUTHID = "nobody@nowhere.com";
+
+ [Test]
+ public void ReturnsRightMechanismName()
+ {
+ ISaslClient client = new ExternalSaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.AreEqual("EXTERNAL", client.MechanismName);
+ }
+
+ [Test]
+ public void HasInitialResponseReturnsTrue()
+ {
+ ISaslClient client = new ExternalSaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.IsTrue(client.HasInitialResponse);
+ }
+
+ [Test]
+ public void CanEvaluateChallenge()
+ {
+ ISaslClient client = new ExternalSaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.IsFalse(client.IsComplete);
+ byte[] response = client.EvaluateChallenge(new byte[0]);
+ Assert.AreEqual(AUTHID, Encoding.UTF8.GetString(response));
+
+ Assert.IsTrue(client.IsComplete);
+ }
+
+ void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
+ {
+ }
+
+ } // class AnonymousSaslClientTests
+
+} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/PlainSaslClientTests.cs b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/PlainSaslClientTests.cs
index 4c82f7b126..f4fc00e038 100644
--- a/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/PlainSaslClientTests.cs
+++ b/qpid/dotnet/Qpid.Sasl.Tests/Mechanisms/PlainSaslClientTests.cs
@@ -1,88 +1,88 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-using NUnit.Framework;
-using Apache.Qpid.Sasl;
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Sasl.Tests.Mechanisms
-{
- [TestFixture]
- public class PlainSaslClientTests : ISaslCallbackHandler
- {
- private const string USERNAME = "testuser";
- private const string PASSWORD = "thepasswd";
- private const string AUTHID = "theauth";
-
- [Test]
- public void ReturnsRightMechanismName()
- {
- ISaslClient client = new PlainSaslClient(AUTHID, new Hashtable(), this);
-
- Assert.AreEqual("PLAIN", client.MechanismName);
- }
-
- [Test]
- public void HasInitialResponseReturnsTrue()
- {
- ISaslClient client = new PlainSaslClient(AUTHID, new Hashtable(), this);
-
- Assert.IsTrue(client.HasInitialResponse);
- }
-
- [Test]
- public void CanEvaluateChallenge()
- {
- Hashtable props = new Hashtable();
- ISaslClient client = new PlainSaslClient(AUTHID, props, this);
-
- Assert.IsFalse(client.IsComplete);
- byte[] response = client.EvaluateChallenge(new byte[0]);
- string[] parts = Encoding.UTF8.GetString(response).Split('\0');
-
- Assert.AreEqual(3, parts.Length);
- Assert.AreEqual(AUTHID, parts[0]);
- Assert.AreEqual(USERNAME, parts[1]);
- Assert.AreEqual(PASSWORD, parts[2]);
- Assert.IsTrue(client.IsComplete);
- }
-
- void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
- {
- foreach ( ISaslCallback cb in callbacks )
- {
- if ( cb is NameCallback )
- {
- ((NameCallback)cb).Text = USERNAME;
- } else if ( cb is PasswordCallback )
- {
- ((PasswordCallback)cb).Text = PASSWORD;
- }
- }
- }
-
- } // class PlainSaslClientTests
-
-} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+using NUnit.Framework;
+using Apache.Qpid.Sasl;
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Sasl.Tests.Mechanisms
+{
+ [TestFixture]
+ public class PlainSaslClientTests : ISaslCallbackHandler
+ {
+ private const string USERNAME = "testuser";
+ private const string PASSWORD = "thepasswd";
+ private const string AUTHID = "theauth";
+
+ [Test]
+ public void ReturnsRightMechanismName()
+ {
+ ISaslClient client = new PlainSaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.AreEqual("PLAIN", client.MechanismName);
+ }
+
+ [Test]
+ public void HasInitialResponseReturnsTrue()
+ {
+ ISaslClient client = new PlainSaslClient(AUTHID, new Hashtable(), this);
+
+ Assert.IsTrue(client.HasInitialResponse);
+ }
+
+ [Test]
+ public void CanEvaluateChallenge()
+ {
+ Hashtable props = new Hashtable();
+ ISaslClient client = new PlainSaslClient(AUTHID, props, this);
+
+ Assert.IsFalse(client.IsComplete);
+ byte[] response = client.EvaluateChallenge(new byte[0]);
+ string[] parts = Encoding.UTF8.GetString(response).Split('\0');
+
+ Assert.AreEqual(3, parts.Length);
+ Assert.AreEqual(AUTHID, parts[0]);
+ Assert.AreEqual(USERNAME, parts[1]);
+ Assert.AreEqual(PASSWORD, parts[2]);
+ Assert.IsTrue(client.IsComplete);
+ }
+
+ void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
+ {
+ foreach ( ISaslCallback cb in callbacks )
+ {
+ if ( cb is NameCallback )
+ {
+ ((NameCallback)cb).Text = USERNAME;
+ } else if ( cb is PasswordCallback )
+ {
+ ((PasswordCallback)cb).Text = PASSWORD;
+ }
+ }
+ }
+
+ } // class PlainSaslClientTests
+
+} // namespace Apache.Qpid.Sasl.Tests.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl.Tests/SaslTests.cs b/qpid/dotnet/Qpid.Sasl.Tests/SaslTests.cs
index 5b27949b98..e7ae91d6b6 100644
--- a/qpid/dotnet/Qpid.Sasl.Tests/SaslTests.cs
+++ b/qpid/dotnet/Qpid.Sasl.Tests/SaslTests.cs
@@ -1,133 +1,133 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-using NUnit.Framework;
-using Apache.Qpid.Sasl;
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Sasl.Tests
-{
- [TestFixture]
- public class SaslTests : ISaslCallbackHandler
- {
-
- [Test]
- public void CanCreatePlain()
- {
- Hashtable props = new Hashtable();
- string[] mechanisms = new string[] { "PLAIN", "OTHER" };
- ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
-
- Assert.IsNotNull(client);
- Assert.IsInstanceOfType(typeof(PlainSaslClient), client);
- }
-
- [Test]
- public void CanCreateCramMD5()
- {
- Hashtable props = new Hashtable();
- string[] mechanisms = new string[] { "CRAM-MD5", "OTHER" };
- ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
-
- Assert.IsNotNull(client);
- Assert.IsInstanceOfType(typeof(CramMD5SaslClient), client);
- }
-
- [Test]
- public void CanCreateAnonymous()
- {
- Hashtable props = new Hashtable();
- string[] mechanisms = new string[] { "ANONYMOUS", "OTHER" };
- ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
-
- Assert.IsNotNull(client);
- Assert.IsInstanceOfType(typeof(AnonymousSaslClient), client);
- }
-
- [Test]
- public void CanCreateDigest()
- {
- Hashtable props = new Hashtable();
- string[] mechanisms = new string[] { "DIGEST-MD5", "OTHER" };
- ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
-
- Assert.IsNotNull(client);
- Assert.IsInstanceOfType(typeof(DigestSaslClient), client);
- }
-
- [Test]
- public void CanCreateExternal()
- {
- Hashtable props = new Hashtable();
- string[] mechanisms = new string[] { "EXTERNAL", "OTHER" };
- ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
-
- Assert.IsNotNull(client);
- Assert.IsInstanceOfType(typeof(ExternalSaslClient), client);
- }
-
- [Test]
- public void ReturnsNullIfNoFactoryFound()
- {
- Hashtable props = new Hashtable();
- props.Add(SaslProperties.PolicyNoPlainText, true);
- string[] mechanisms = new string[] { "PLAIN", "OTHER" };
- ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
-
- Assert.IsNull(client);
- }
-
- [Test]
- public void ParsesConfigurationSection()
- {
- // if the TEST mechanism is available, then we know
- // the configuration section worked!
- Hashtable props = new Hashtable();
- string[] mechanisms = new string[] { "TEST" };
- ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
-
- Assert.IsNotNull(client);
- Assert.IsInstanceOfType(typeof(TestSaslClient), client);
- }
-
- [Test]
- public void ChoosesStrongerMechanism()
- {
- Hashtable props = new Hashtable();
- string[] mechanisms = new string[] { "PLAIN", "OTHER", "CRAM-MD5" };
- ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
-
- Assert.IsNotNull(client);
- Assert.IsInstanceOfType(typeof(CramMD5SaslClient), client);
- }
-
-
- void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
- {
- }
-
- } // class SaslTests
-
-} // namespace Apache.Qpid.Sasl.Tests
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+using NUnit.Framework;
+using Apache.Qpid.Sasl;
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Sasl.Tests
+{
+ [TestFixture]
+ public class SaslTests : ISaslCallbackHandler
+ {
+
+ [Test]
+ public void CanCreatePlain()
+ {
+ Hashtable props = new Hashtable();
+ string[] mechanisms = new string[] { "PLAIN", "OTHER" };
+ ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
+
+ Assert.IsNotNull(client);
+ Assert.IsInstanceOfType(typeof(PlainSaslClient), client);
+ }
+
+ [Test]
+ public void CanCreateCramMD5()
+ {
+ Hashtable props = new Hashtable();
+ string[] mechanisms = new string[] { "CRAM-MD5", "OTHER" };
+ ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
+
+ Assert.IsNotNull(client);
+ Assert.IsInstanceOfType(typeof(CramMD5SaslClient), client);
+ }
+
+ [Test]
+ public void CanCreateAnonymous()
+ {
+ Hashtable props = new Hashtable();
+ string[] mechanisms = new string[] { "ANONYMOUS", "OTHER" };
+ ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
+
+ Assert.IsNotNull(client);
+ Assert.IsInstanceOfType(typeof(AnonymousSaslClient), client);
+ }
+
+ [Test]
+ public void CanCreateDigest()
+ {
+ Hashtable props = new Hashtable();
+ string[] mechanisms = new string[] { "DIGEST-MD5", "OTHER" };
+ ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
+
+ Assert.IsNotNull(client);
+ Assert.IsInstanceOfType(typeof(DigestSaslClient), client);
+ }
+
+ [Test]
+ public void CanCreateExternal()
+ {
+ Hashtable props = new Hashtable();
+ string[] mechanisms = new string[] { "EXTERNAL", "OTHER" };
+ ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
+
+ Assert.IsNotNull(client);
+ Assert.IsInstanceOfType(typeof(ExternalSaslClient), client);
+ }
+
+ [Test]
+ public void ReturnsNullIfNoFactoryFound()
+ {
+ Hashtable props = new Hashtable();
+ props.Add(SaslProperties.PolicyNoPlainText, true);
+ string[] mechanisms = new string[] { "PLAIN", "OTHER" };
+ ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
+
+ Assert.IsNull(client);
+ }
+
+ [Test]
+ public void ParsesConfigurationSection()
+ {
+ // if the TEST mechanism is available, then we know
+ // the configuration section worked!
+ Hashtable props = new Hashtable();
+ string[] mechanisms = new string[] { "TEST" };
+ ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
+
+ Assert.IsNotNull(client);
+ Assert.IsInstanceOfType(typeof(TestSaslClient), client);
+ }
+
+ [Test]
+ public void ChoosesStrongerMechanism()
+ {
+ Hashtable props = new Hashtable();
+ string[] mechanisms = new string[] { "PLAIN", "OTHER", "CRAM-MD5" };
+ ISaslClient client = Sasl.CreateClient(mechanisms, "", "", "", props, this);
+
+ Assert.IsNotNull(client);
+ Assert.IsInstanceOfType(typeof(CramMD5SaslClient), client);
+ }
+
+
+ void ISaslCallbackHandler.Handle(ISaslCallback[] callbacks)
+ {
+ }
+
+ } // class SaslTests
+
+} // namespace Apache.Qpid.Sasl.Tests
diff --git a/qpid/dotnet/Qpid.Sasl.Tests/TestClientFactory.cs b/qpid/dotnet/Qpid.Sasl.Tests/TestClientFactory.cs
index 73c68ea2b3..62099237e9 100644
--- a/qpid/dotnet/Qpid.Sasl.Tests/TestClientFactory.cs
+++ b/qpid/dotnet/Qpid.Sasl.Tests/TestClientFactory.cs
@@ -1,75 +1,75 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-using NUnit.Framework;
-using Apache.Qpid.Sasl;
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Sasl.Tests
-{
- public class TestClientFactory : ISaslClientFactory
- {
- public string[] GetSupportedMechanisms(IDictionary props)
- {
- return new string[] { TestSaslClient.Mechanism };
- }
-
- public ISaslClient CreateClient(string[] mechanisms, string authorizationId, string protocol, string serverName, IDictionary props, ISaslCallbackHandler handler)
- {
- foreach ( string mech in mechanisms )
- {
- if ( mech == TestSaslClient.Mechanism )
- return new TestSaslClient(props, handler);
- }
- return null;
- }
-
- } // class TestClientFactory
-
- internal class TestSaslClient : SaslClient
- {
- public const string Mechanism = "TEST";
-
- public override string MechanismName
- {
- get { return Mechanism; }
- }
- public override bool HasInitialResponse
- {
- get { return false; }
- }
-
- public TestSaslClient(IDictionary props, ISaslCallbackHandler handler)
- : base("", "", "", props, handler)
- {
- }
-
- public override byte[] EvaluateChallenge(byte[] challenge)
- {
- throw new NotImplementedException();
- }
- } // class TestSaslClient
-
-} // namespace Apache.Qpid.Sasl.Tests
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+using NUnit.Framework;
+using Apache.Qpid.Sasl;
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Sasl.Tests
+{
+ public class TestClientFactory : ISaslClientFactory
+ {
+ public string[] GetSupportedMechanisms(IDictionary props)
+ {
+ return new string[] { TestSaslClient.Mechanism };
+ }
+
+ public ISaslClient CreateClient(string[] mechanisms, string authorizationId, string protocol, string serverName, IDictionary props, ISaslCallbackHandler handler)
+ {
+ foreach ( string mech in mechanisms )
+ {
+ if ( mech == TestSaslClient.Mechanism )
+ return new TestSaslClient(props, handler);
+ }
+ return null;
+ }
+
+ } // class TestClientFactory
+
+ internal class TestSaslClient : SaslClient
+ {
+ public const string Mechanism = "TEST";
+
+ public override string MechanismName
+ {
+ get { return Mechanism; }
+ }
+ public override bool HasInitialResponse
+ {
+ get { return false; }
+ }
+
+ public TestSaslClient(IDictionary props, ISaslCallbackHandler handler)
+ : base("", "", "", props, handler)
+ {
+ }
+
+ public override byte[] EvaluateChallenge(byte[] challenge)
+ {
+ throw new NotImplementedException();
+ }
+ } // class TestSaslClient
+
+} // namespace Apache.Qpid.Sasl.Tests
diff --git a/qpid/dotnet/Qpid.Sasl/Callbacks.cs b/qpid/dotnet/Qpid.Sasl/Callbacks.cs
index a5913eb61e..f4fcc1c54b 100644
--- a/qpid/dotnet/Qpid.Sasl/Callbacks.cs
+++ b/qpid/dotnet/Qpid.Sasl/Callbacks.cs
@@ -1,139 +1,139 @@
-/*
- *
- * 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 System.Text;
-using System.Globalization;
-using System.Security.Cryptography;
-
-namespace Apache.Qpid.Sasl
-{
- /// <summary>
- /// Marker interface for Sasl Callbacks
- /// </summary>
- public interface ISaslCallback
- {
- } // interface ISaslCallback
-
- public abstract class TextSaslCallback : ISaslCallback
- {
- private string _prompt;
- private string _text;
- private string _defaultText;
-
- public string Prompt
- {
- get { return _prompt; }
- set { _prompt = value; }
- }
-
- public string Text
- {
- get {
- if ( _text == null || _text.Length == 0 )
- return DefaultText;
- else
- return _text;
- }
- set { _text = value; }
- }
-
- public string DefaultText
- {
- get { return _defaultText; }
- set { _defaultText = value; }
- }
-
- protected TextSaslCallback(string prompt, string text, string defaultText)
- {
- _prompt = prompt;
- _text = text;
- _defaultText = defaultText;
- }
-
- } // class TextSaslCallback
-
- public class NameCallback : TextSaslCallback
- {
- public NameCallback()
- : this(Environment.UserName)
- {
- }
- public NameCallback(string defaultText)
- : base("username:", "", defaultText)
- {
- }
- } // class NameCallback
-
- public class PasswordCallback : TextSaslCallback
- {
- public PasswordCallback()
- : base("password:", "", "")
- {
- }
-
- public byte[] HashedText
- {
- get
- {
- string _text = this.Text;
- System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
- byte[] bs = x.ComputeHash(Encoding.UTF8.GetBytes(_text));
- return bs;
- }
-
- }
- } // class PasswordCallback
-
- public class HashedPasswordCallback : TextSaslCallback
- {
- public HashedPasswordCallback()
- : base("password:", "", "")
- {
- }
-
- public byte[] HashedText
- {
- get {
- string _text = this.Text;
- System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
- _text = _text.PadRight(16, '\0');
- byte[] bs = x.ComputeHash(Encoding.UTF8.GetBytes(_text));
- return bs;
- }
- }
- } // class PasswordCallback
-
- public class RealmCallback : TextSaslCallback
- {
- public RealmCallback()
- : this("localhost")
- {
- }
- public RealmCallback(string defaultText)
- : base("realm:", "", defaultText)
- {
- }
- } // class RealmCallback
-
-} // namespace Apache.Qpid.Sasl
-
-
+/*
+ *
+ * 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 System.Text;
+using System.Globalization;
+using System.Security.Cryptography;
+
+namespace Apache.Qpid.Sasl
+{
+ /// <summary>
+ /// Marker interface for Sasl Callbacks
+ /// </summary>
+ public interface ISaslCallback
+ {
+ } // interface ISaslCallback
+
+ public abstract class TextSaslCallback : ISaslCallback
+ {
+ private string _prompt;
+ private string _text;
+ private string _defaultText;
+
+ public string Prompt
+ {
+ get { return _prompt; }
+ set { _prompt = value; }
+ }
+
+ public string Text
+ {
+ get {
+ if ( _text == null || _text.Length == 0 )
+ return DefaultText;
+ else
+ return _text;
+ }
+ set { _text = value; }
+ }
+
+ public string DefaultText
+ {
+ get { return _defaultText; }
+ set { _defaultText = value; }
+ }
+
+ protected TextSaslCallback(string prompt, string text, string defaultText)
+ {
+ _prompt = prompt;
+ _text = text;
+ _defaultText = defaultText;
+ }
+
+ } // class TextSaslCallback
+
+ public class NameCallback : TextSaslCallback
+ {
+ public NameCallback()
+ : this(Environment.UserName)
+ {
+ }
+ public NameCallback(string defaultText)
+ : base("username:", "", defaultText)
+ {
+ }
+ } // class NameCallback
+
+ public class PasswordCallback : TextSaslCallback
+ {
+ public PasswordCallback()
+ : base("password:", "", "")
+ {
+ }
+
+ public byte[] HashedText
+ {
+ get
+ {
+ string _text = this.Text;
+ System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
+ byte[] bs = x.ComputeHash(Encoding.UTF8.GetBytes(_text));
+ return bs;
+ }
+
+ }
+ } // class PasswordCallback
+
+ public class HashedPasswordCallback : TextSaslCallback
+ {
+ public HashedPasswordCallback()
+ : base("password:", "", "")
+ {
+ }
+
+ public byte[] HashedText
+ {
+ get {
+ string _text = this.Text;
+ System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
+ _text = _text.PadRight(16, '\0');
+ byte[] bs = x.ComputeHash(Encoding.UTF8.GetBytes(_text));
+ return bs;
+ }
+ }
+ } // class PasswordCallback
+
+ public class RealmCallback : TextSaslCallback
+ {
+ public RealmCallback()
+ : this("localhost")
+ {
+ }
+ public RealmCallback(string defaultText)
+ : base("realm:", "", defaultText)
+ {
+ }
+ } // class RealmCallback
+
+} // namespace Apache.Qpid.Sasl
+
+
diff --git a/qpid/dotnet/Qpid.Sasl/Configuration/SaslConfiguration.cs b/qpid/dotnet/Qpid.Sasl/Configuration/SaslConfiguration.cs
index 3446261724..7a71ec28da 100644
--- a/qpid/dotnet/Qpid.Sasl/Configuration/SaslConfiguration.cs
+++ b/qpid/dotnet/Qpid.Sasl/Configuration/SaslConfiguration.cs
@@ -1,90 +1,90 @@
-/*
- *
- * 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 System.Collections;
-using System.Configuration;
-using System.Text;
-using System.Xml;
-
-namespace Apache.Qpid.Sasl.Configuration
-{
- /// <summary>
- /// Represents an Sasl configuration section
- /// in the config file
- /// </summary>
- internal class SaslConfiguration
- {
- private IList _clientFactories;
-
- /// <summary>
- /// Set of configured client factores
- /// </summary>
- public IList ClientFactories
- {
- get { return _clientFactories; }
- }
-
- internal SaslConfiguration(IList clientFactoryTypes)
- {
- _clientFactories = new ArrayList();
- foreach ( Type type in clientFactoryTypes )
- {
- _clientFactories.Add(Activator.CreateInstance(type));
- }
- }
-
- /// <summary>
- /// Get the configuration for the library
- /// </summary>
- /// <returns>The configuration from app.config or a default configuration</returns>
- internal static SaslConfiguration GetConfiguration()
- {
- // 'obsolete' warning, but needed for .NET 1.1 compatibility
- SaslConfiguration config = (SaslConfiguration)
- ConfigurationSettings.GetConfig("qpid.sasl");
- if ( config == null )
- {
- // create default configuration
- IList clientFactories = GetDefaultClientFactories();
- config = new SaslConfiguration(clientFactories);
- }
- return config;
- }
-
- /// <summary>
- /// Create a list filled with the default client
- /// factories supported by the library
- /// </summary>
- /// <returns>The list of client factory types</returns>
- internal static IList GetDefaultClientFactories()
- {
- IList clientFactories = new ArrayList();
- clientFactories.Add(typeof(DefaultClientFactory));
- return clientFactories;
- }
-
-
- } // class SaslConfiguration
-
-} // namespace Apache.Qpid.Sasl.Configuration
-
-
+/*
+ *
+ * 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 System.Collections;
+using System.Configuration;
+using System.Text;
+using System.Xml;
+
+namespace Apache.Qpid.Sasl.Configuration
+{
+ /// <summary>
+ /// Represents an Sasl configuration section
+ /// in the config file
+ /// </summary>
+ internal class SaslConfiguration
+ {
+ private IList _clientFactories;
+
+ /// <summary>
+ /// Set of configured client factores
+ /// </summary>
+ public IList ClientFactories
+ {
+ get { return _clientFactories; }
+ }
+
+ internal SaslConfiguration(IList clientFactoryTypes)
+ {
+ _clientFactories = new ArrayList();
+ foreach ( Type type in clientFactoryTypes )
+ {
+ _clientFactories.Add(Activator.CreateInstance(type));
+ }
+ }
+
+ /// <summary>
+ /// Get the configuration for the library
+ /// </summary>
+ /// <returns>The configuration from app.config or a default configuration</returns>
+ internal static SaslConfiguration GetConfiguration()
+ {
+ // 'obsolete' warning, but needed for .NET 1.1 compatibility
+ SaslConfiguration config = (SaslConfiguration)
+ ConfigurationSettings.GetConfig("qpid.sasl");
+ if ( config == null )
+ {
+ // create default configuration
+ IList clientFactories = GetDefaultClientFactories();
+ config = new SaslConfiguration(clientFactories);
+ }
+ return config;
+ }
+
+ /// <summary>
+ /// Create a list filled with the default client
+ /// factories supported by the library
+ /// </summary>
+ /// <returns>The list of client factory types</returns>
+ internal static IList GetDefaultClientFactories()
+ {
+ IList clientFactories = new ArrayList();
+ clientFactories.Add(typeof(DefaultClientFactory));
+ return clientFactories;
+ }
+
+
+ } // class SaslConfiguration
+
+} // namespace Apache.Qpid.Sasl.Configuration
+
+
diff --git a/qpid/dotnet/Qpid.Sasl/Configuration/SaslConfigurationSectionHandler.cs b/qpid/dotnet/Qpid.Sasl/Configuration/SaslConfigurationSectionHandler.cs
index 21f6b92414..ea8669f8c4 100644
--- a/qpid/dotnet/Qpid.Sasl/Configuration/SaslConfigurationSectionHandler.cs
+++ b/qpid/dotnet/Qpid.Sasl/Configuration/SaslConfigurationSectionHandler.cs
@@ -1,84 +1,84 @@
-/*
- *
- * 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 System.Collections;
-using System.Configuration;
-using System.Text;
-using System.Xml;
-
-namespace Apache.Qpid.Sasl.Configuration
-{
- /// <summary>
- /// Defines the configuration section to configure extra
- /// Sasl client factories
- /// </summary>
- public class SaslConfigurationSectionHandler
- : IConfigurationSectionHandler
- {
- public object Create(object parent, object configContext, XmlNode section)
- {
- IList clientFactories = SaslConfiguration.GetDefaultClientFactories();
-
- foreach ( XmlNode node in section.ChildNodes )
- {
- if ( node.LocalName == "clientFactories" )
- {
- ProcessFactories(node, clientFactories);
- }
- }
-
- SaslConfiguration config = new SaslConfiguration(clientFactories);
- return config;
- }
-
-
- private void ProcessFactories(XmlNode node, IList factories)
- {
- foreach ( XmlNode child in node.ChildNodes )
- {
- Type type;
- switch ( child.LocalName )
- {
- case "add":
- type = Type.GetType(child.Attributes["type"].Value);
- if ( !factories.Contains(type) )
- factories.Add(type);
- break;
- case "remove":
- type = Type.GetType(child.Attributes["type"].Value);
- if ( factories.Contains(type) )
- factories.Remove(type);
- break;
- case "clear":
- factories.Clear();
- break;
- default:
- // gives obsolete warning but needed for .NET 1.1 support
- throw new ConfigurationException(string.Format("Unknown element '{0}' in section '{0}'", child.LocalName, node.LocalName));
- }
- }
- }
- } // class SaslConfigurationSectionHandler
-
-} // namespace Apache.Qpid.Sasl.Configuration
-
-
+/*
+ *
+ * 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 System.Collections;
+using System.Configuration;
+using System.Text;
+using System.Xml;
+
+namespace Apache.Qpid.Sasl.Configuration
+{
+ /// <summary>
+ /// Defines the configuration section to configure extra
+ /// Sasl client factories
+ /// </summary>
+ public class SaslConfigurationSectionHandler
+ : IConfigurationSectionHandler
+ {
+ public object Create(object parent, object configContext, XmlNode section)
+ {
+ IList clientFactories = SaslConfiguration.GetDefaultClientFactories();
+
+ foreach ( XmlNode node in section.ChildNodes )
+ {
+ if ( node.LocalName == "clientFactories" )
+ {
+ ProcessFactories(node, clientFactories);
+ }
+ }
+
+ SaslConfiguration config = new SaslConfiguration(clientFactories);
+ return config;
+ }
+
+
+ private void ProcessFactories(XmlNode node, IList factories)
+ {
+ foreach ( XmlNode child in node.ChildNodes )
+ {
+ Type type;
+ switch ( child.LocalName )
+ {
+ case "add":
+ type = Type.GetType(child.Attributes["type"].Value);
+ if ( !factories.Contains(type) )
+ factories.Add(type);
+ break;
+ case "remove":
+ type = Type.GetType(child.Attributes["type"].Value);
+ if ( factories.Contains(type) )
+ factories.Remove(type);
+ break;
+ case "clear":
+ factories.Clear();
+ break;
+ default:
+ // gives obsolete warning but needed for .NET 1.1 support
+ throw new ConfigurationException(string.Format("Unknown element '{0}' in section '{0}'", child.LocalName, node.LocalName));
+ }
+ }
+ }
+ } // class SaslConfigurationSectionHandler
+
+} // namespace Apache.Qpid.Sasl.Configuration
+
+
diff --git a/qpid/dotnet/Qpid.Sasl/DefaultClientFactory.cs b/qpid/dotnet/Qpid.Sasl/DefaultClientFactory.cs
index a38e5d50c7..744d7cae40 100644
--- a/qpid/dotnet/Qpid.Sasl/DefaultClientFactory.cs
+++ b/qpid/dotnet/Qpid.Sasl/DefaultClientFactory.cs
@@ -1,99 +1,99 @@
-/*
- *
- * 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 System.Collections;
-
-using Apache.Qpid.Sasl.Mechanisms;
-
-namespace Apache.Qpid.Sasl
-{
- public class DefaultClientFactory : ISaslClientFactory
- {
- private static readonly string[] SUPPORTED = new string[] {
- DigestSaslClient.Mechanism,
- CramMD5SaslClient.Mechanism,
- CramMD5HexSaslClient.Mechanism,
- PlainSaslClient.Mechanism,
- AnonymousSaslClient.Mechanism,
- ExternalSaslClient.Mechanism,
- };
-
- public string[] GetSupportedMechanisms(IDictionary props)
- {
- if ( props == null )
- throw new ArgumentNullException("props");
-
- ArrayList vetoed = new ArrayList();
-
- if ( props.Contains(SaslProperties.PolicyNoPlainText) ||
- props.Contains(SaslProperties.PolicyNoDictionary) ||
- props.Contains(SaslProperties.PolicyNoActive) ||
- props.Contains(SaslProperties.PolicyForwardSecrecy) ||
- props.Contains(SaslProperties.PolicyPassCredentials) )
- {
- vetoed.Add(CramMD5SaslClient.Mechanism);
- vetoed.Add(CramMD5HexSaslClient.Mechanism);
- vetoed.Add(PlainSaslClient.Mechanism);
- vetoed.Add(AnonymousSaslClient.Mechanism);
- vetoed.Add(ExternalSaslClient.Mechanism);
- }
- if ( props.Contains(SaslProperties.PolicyNoAnonymous) )
- {
- vetoed.Add(AnonymousSaslClient.Mechanism);
- }
-
- ArrayList available = new ArrayList();
- foreach ( string mech in SUPPORTED )
- {
- if ( !vetoed.Contains(mech) )
- available.Add(mech);
- }
- return (string[])available.ToArray(typeof(string));
- }
-
- public ISaslClient CreateClient(
- string[] mechanisms, string authorizationId,
- string protocol, string serverName,
- IDictionary props, ISaslCallbackHandler handler
- )
- {
- IList mechs = mechanisms;
- if ( mechs.Contains(ExternalSaslClient.Mechanism) )
- return new ExternalSaslClient(authorizationId, props, handler);
- if ( mechs.Contains(DigestSaslClient.Mechanism) )
- return new DigestSaslClient(authorizationId, serverName, protocol, props, handler);
- if ( mechs.Contains(CramMD5SaslClient.Mechanism) )
- return new CramMD5SaslClient(authorizationId, props, handler);
- if ( mechs.Contains(CramMD5HexSaslClient.Mechanism) )
- return new CramMD5HexSaslClient(authorizationId, props, handler);
- if ( mechs.Contains(PlainSaslClient.Mechanism) )
- return new PlainSaslClient(authorizationId, props, handler);
- if ( mechs.Contains(AnonymousSaslClient.Mechanism) )
- return new AnonymousSaslClient(authorizationId, props, handler);
- // unknown mechanism
- return null;
- }
- } // class DefaultClientFactory
-
-} // namespace Apache.Qpid.Sasl
-
-
+/*
+ *
+ * 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 System.Collections;
+
+using Apache.Qpid.Sasl.Mechanisms;
+
+namespace Apache.Qpid.Sasl
+{
+ public class DefaultClientFactory : ISaslClientFactory
+ {
+ private static readonly string[] SUPPORTED = new string[] {
+ DigestSaslClient.Mechanism,
+ CramMD5SaslClient.Mechanism,
+ CramMD5HexSaslClient.Mechanism,
+ PlainSaslClient.Mechanism,
+ AnonymousSaslClient.Mechanism,
+ ExternalSaslClient.Mechanism,
+ };
+
+ public string[] GetSupportedMechanisms(IDictionary props)
+ {
+ if ( props == null )
+ throw new ArgumentNullException("props");
+
+ ArrayList vetoed = new ArrayList();
+
+ if ( props.Contains(SaslProperties.PolicyNoPlainText) ||
+ props.Contains(SaslProperties.PolicyNoDictionary) ||
+ props.Contains(SaslProperties.PolicyNoActive) ||
+ props.Contains(SaslProperties.PolicyForwardSecrecy) ||
+ props.Contains(SaslProperties.PolicyPassCredentials) )
+ {
+ vetoed.Add(CramMD5SaslClient.Mechanism);
+ vetoed.Add(CramMD5HexSaslClient.Mechanism);
+ vetoed.Add(PlainSaslClient.Mechanism);
+ vetoed.Add(AnonymousSaslClient.Mechanism);
+ vetoed.Add(ExternalSaslClient.Mechanism);
+ }
+ if ( props.Contains(SaslProperties.PolicyNoAnonymous) )
+ {
+ vetoed.Add(AnonymousSaslClient.Mechanism);
+ }
+
+ ArrayList available = new ArrayList();
+ foreach ( string mech in SUPPORTED )
+ {
+ if ( !vetoed.Contains(mech) )
+ available.Add(mech);
+ }
+ return (string[])available.ToArray(typeof(string));
+ }
+
+ public ISaslClient CreateClient(
+ string[] mechanisms, string authorizationId,
+ string protocol, string serverName,
+ IDictionary props, ISaslCallbackHandler handler
+ )
+ {
+ IList mechs = mechanisms;
+ if ( mechs.Contains(ExternalSaslClient.Mechanism) )
+ return new ExternalSaslClient(authorizationId, props, handler);
+ if ( mechs.Contains(DigestSaslClient.Mechanism) )
+ return new DigestSaslClient(authorizationId, serverName, protocol, props, handler);
+ if ( mechs.Contains(CramMD5SaslClient.Mechanism) )
+ return new CramMD5SaslClient(authorizationId, props, handler);
+ if ( mechs.Contains(CramMD5HexSaslClient.Mechanism) )
+ return new CramMD5HexSaslClient(authorizationId, props, handler);
+ if ( mechs.Contains(PlainSaslClient.Mechanism) )
+ return new PlainSaslClient(authorizationId, props, handler);
+ if ( mechs.Contains(AnonymousSaslClient.Mechanism) )
+ return new AnonymousSaslClient(authorizationId, props, handler);
+ // unknown mechanism
+ return null;
+ }
+ } // class DefaultClientFactory
+
+} // namespace Apache.Qpid.Sasl
+
+
diff --git a/qpid/dotnet/Qpid.Sasl/ISaslCallbackHandler.cs b/qpid/dotnet/Qpid.Sasl/ISaslCallbackHandler.cs
index 0dfc482333..c2638f245e 100644
--- a/qpid/dotnet/Qpid.Sasl/ISaslCallbackHandler.cs
+++ b/qpid/dotnet/Qpid.Sasl/ISaslCallbackHandler.cs
@@ -1,35 +1,35 @@
-/*
- *
- * 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 System.Text;
-
-namespace Apache.Qpid.Sasl
-{
- public interface ISaslCallbackHandler
- {
- void Handle(ISaslCallback[] callbacks);
-
- } // interface ISaslCallbackHandler
-
-} // namespace Apache.Qpid.Sasl
-
-
+/*
+ *
+ * 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 System.Text;
+
+namespace Apache.Qpid.Sasl
+{
+ public interface ISaslCallbackHandler
+ {
+ void Handle(ISaslCallback[] callbacks);
+
+ } // interface ISaslCallbackHandler
+
+} // namespace Apache.Qpid.Sasl
+
+
diff --git a/qpid/dotnet/Qpid.Sasl/ISaslClient.cs b/qpid/dotnet/Qpid.Sasl/ISaslClient.cs
index 526cc1f43a..668ca05d26 100644
--- a/qpid/dotnet/Qpid.Sasl/ISaslClient.cs
+++ b/qpid/dotnet/Qpid.Sasl/ISaslClient.cs
@@ -1,42 +1,42 @@
-/*
- *
- * 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 System.Text;
-
-namespace Apache.Qpid.Sasl
-{
- public interface ISaslClient
- {
- string MechanismName { get; }
- bool HasInitialResponse { get; }
- bool IsComplete { get; }
-
- byte[] EvaluateChallenge(byte[] challenge);
- object GetNegotiatedProperty(string propName);
- byte[] Unwrap(byte[] buffer, int offset, int length);
- byte[] Wrap(byte[] buffer, int offset, int lenght);
-
- } // interface ISaslClient
-
-} // namespace Apache.Qpid.Sasl
-
-
+/*
+ *
+ * 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 System.Text;
+
+namespace Apache.Qpid.Sasl
+{
+ public interface ISaslClient
+ {
+ string MechanismName { get; }
+ bool HasInitialResponse { get; }
+ bool IsComplete { get; }
+
+ byte[] EvaluateChallenge(byte[] challenge);
+ object GetNegotiatedProperty(string propName);
+ byte[] Unwrap(byte[] buffer, int offset, int length);
+ byte[] Wrap(byte[] buffer, int offset, int lenght);
+
+ } // interface ISaslClient
+
+} // namespace Apache.Qpid.Sasl
+
+
diff --git a/qpid/dotnet/Qpid.Sasl/ISaslClientFactory.cs b/qpid/dotnet/Qpid.Sasl/ISaslClientFactory.cs
index fc81057ec4..f052e07ad9 100644
--- a/qpid/dotnet/Qpid.Sasl/ISaslClientFactory.cs
+++ b/qpid/dotnet/Qpid.Sasl/ISaslClientFactory.cs
@@ -1,40 +1,40 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-namespace Apache.Qpid.Sasl
-{
- public interface ISaslClientFactory
- {
- string[] GetSupportedMechanisms(IDictionary props);
- ISaslClient CreateClient(
- string[] mechanisms, string authorizationId,
- string protocol, string serverName,
- IDictionary props, ISaslCallbackHandler handler
- );
- } // interface ISaslClientFactory
-
-} // namespace Apache.Qpid.Sasl
-
-
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+namespace Apache.Qpid.Sasl
+{
+ public interface ISaslClientFactory
+ {
+ string[] GetSupportedMechanisms(IDictionary props);
+ ISaslClient CreateClient(
+ string[] mechanisms, string authorizationId,
+ string protocol, string serverName,
+ IDictionary props, ISaslCallbackHandler handler
+ );
+ } // interface ISaslClientFactory
+
+} // namespace Apache.Qpid.Sasl
+
+
diff --git a/qpid/dotnet/Qpid.Sasl/MD5HMAC.cs b/qpid/dotnet/Qpid.Sasl/MD5HMAC.cs
index 134332284a..7e310c5364 100644
--- a/qpid/dotnet/Qpid.Sasl/MD5HMAC.cs
+++ b/qpid/dotnet/Qpid.Sasl/MD5HMAC.cs
@@ -1,115 +1,115 @@
-/*
- *
- * 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 System.Security.Cryptography;
-
-namespace Apache.Qpid.Sasl
-{
- /// <summary>
- /// Rough HMAC MD5 implementation as presented in
- /// RFC 2104. Used because the HMACMD5 class in the
- /// .NET framework is not available in v1.1.
- /// </summary>
- public sealed class MD5HMAC : IDisposable
- {
- private const int BLOCK_LEN = 64;
- private MD5 _hash;
- private byte[] _key;
- private byte[] _ipad;
- private byte[] _opad;
-
- public MD5HMAC(byte[] key)
- {
- if ( key == null || key.Length == 0 )
- throw new ArgumentNullException("key");
-
- _hash = new MD5CryptoServiceProvider();
-
- byte[] theKey = key;
- if ( theKey.Length > BLOCK_LEN )
- {
- theKey = _hash.ComputeHash(theKey);
- }
- // pad key with 0's up to BLOCK_LEN
- _key = new byte[BLOCK_LEN];
- Array.Copy(theKey, _key, theKey.Length);
-
- CreatePads();
- }
-
- public byte[] ComputeHash(byte[] input)
- {
- // H(K XOR opad, H(K XOR ipad, text))
- return H(_opad, H(_ipad, input));
- }
-
- public void Dispose()
- {
- if ( _hash != null )
- {
- ((IDisposable)_hash).Dispose();
- _hash = null;
- }
- }
-
- #region Private Methods
- //
- // Private Methods
- //
-
- private void CreatePads()
- {
- _ipad = new byte[BLOCK_LEN];
- _opad = new byte[BLOCK_LEN];
- for ( int i = 0; i < BLOCK_LEN; i++ )
- {
- _ipad[i] = 0x36;
- _opad[i] = 0x5c;
- }
-
- XOR(_ipad, _key);
- XOR(_opad, _key);
- }
-
- private static void XOR(byte[] dest, byte[] other)
- {
- // assume both are same size
- for ( int i = 0; i < dest.Length; i++ )
- {
- dest[i] ^= other[i];
- }
- }
-
- private byte[] H(byte[] v1, byte[] v2)
- {
- byte[] total = new byte[v1.Length + v2.Length];
- Array.Copy(v1, total, v1.Length);
- Array.Copy(v2, 0, total, v1.Length, v2.Length);
-
- return _hash.ComputeHash(total);
- }
-
- #endregion // Private Methods
-
- } // class MD5HMAC
-
-} // namespace Apache.Qpid.Sasl
+/*
+ *
+ * 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 System.Security.Cryptography;
+
+namespace Apache.Qpid.Sasl
+{
+ /// <summary>
+ /// Rough HMAC MD5 implementation as presented in
+ /// RFC 2104. Used because the HMACMD5 class in the
+ /// .NET framework is not available in v1.1.
+ /// </summary>
+ public sealed class MD5HMAC : IDisposable
+ {
+ private const int BLOCK_LEN = 64;
+ private MD5 _hash;
+ private byte[] _key;
+ private byte[] _ipad;
+ private byte[] _opad;
+
+ public MD5HMAC(byte[] key)
+ {
+ if ( key == null || key.Length == 0 )
+ throw new ArgumentNullException("key");
+
+ _hash = new MD5CryptoServiceProvider();
+
+ byte[] theKey = key;
+ if ( theKey.Length > BLOCK_LEN )
+ {
+ theKey = _hash.ComputeHash(theKey);
+ }
+ // pad key with 0's up to BLOCK_LEN
+ _key = new byte[BLOCK_LEN];
+ Array.Copy(theKey, _key, theKey.Length);
+
+ CreatePads();
+ }
+
+ public byte[] ComputeHash(byte[] input)
+ {
+ // H(K XOR opad, H(K XOR ipad, text))
+ return H(_opad, H(_ipad, input));
+ }
+
+ public void Dispose()
+ {
+ if ( _hash != null )
+ {
+ ((IDisposable)_hash).Dispose();
+ _hash = null;
+ }
+ }
+
+ #region Private Methods
+ //
+ // Private Methods
+ //
+
+ private void CreatePads()
+ {
+ _ipad = new byte[BLOCK_LEN];
+ _opad = new byte[BLOCK_LEN];
+ for ( int i = 0; i < BLOCK_LEN; i++ )
+ {
+ _ipad[i] = 0x36;
+ _opad[i] = 0x5c;
+ }
+
+ XOR(_ipad, _key);
+ XOR(_opad, _key);
+ }
+
+ private static void XOR(byte[] dest, byte[] other)
+ {
+ // assume both are same size
+ for ( int i = 0; i < dest.Length; i++ )
+ {
+ dest[i] ^= other[i];
+ }
+ }
+
+ private byte[] H(byte[] v1, byte[] v2)
+ {
+ byte[] total = new byte[v1.Length + v2.Length];
+ Array.Copy(v1, total, v1.Length);
+ Array.Copy(v2, 0, total, v1.Length, v2.Length);
+
+ return _hash.ComputeHash(total);
+ }
+
+ #endregion // Private Methods
+
+ } // class MD5HMAC
+
+} // namespace Apache.Qpid.Sasl
diff --git a/qpid/dotnet/Qpid.Sasl/Mechanisms/AnonymousSaslClient.cs b/qpid/dotnet/Qpid.Sasl/Mechanisms/AnonymousSaslClient.cs
index 5e8c56ff51..e550d10d97 100644
--- a/qpid/dotnet/Qpid.Sasl/Mechanisms/AnonymousSaslClient.cs
+++ b/qpid/dotnet/Qpid.Sasl/Mechanisms/AnonymousSaslClient.cs
@@ -1,69 +1,69 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-namespace Apache.Qpid.Sasl.Mechanisms
-{
- /// <summary>
- /// Implements the ANONYMOUS authentication mechanism
- /// as outlined in RFC 2245
- /// </summary>
- public class AnonymousSaslClient : SaslClient
- {
- public const string Mechanism = "ANONYMOUS";
-
- public AnonymousSaslClient(
- string authid, IDictionary properties,
- ISaslCallbackHandler handler)
- : base(authid, null, null, properties, handler)
- {
- }
-
- #region ISaslClient Implementation
- //
- // ISaslClient Implementation
- //
-
- public override string MechanismName
- {
- get { return Mechanism; }
- }
-
- public override bool HasInitialResponse
- {
- get { return true; }
- }
-
- public override byte[] EvaluateChallenge(byte[] challenge)
- {
- // ignore challenge
- SetComplete();
- return Encoding.UTF8.GetBytes(AuthorizationId);
- }
-
- #endregion // ISaslClient Implementation
-
- } // class AnonymousSaslClient
-
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+namespace Apache.Qpid.Sasl.Mechanisms
+{
+ /// <summary>
+ /// Implements the ANONYMOUS authentication mechanism
+ /// as outlined in RFC 2245
+ /// </summary>
+ public class AnonymousSaslClient : SaslClient
+ {
+ public const string Mechanism = "ANONYMOUS";
+
+ public AnonymousSaslClient(
+ string authid, IDictionary properties,
+ ISaslCallbackHandler handler)
+ : base(authid, null, null, properties, handler)
+ {
+ }
+
+ #region ISaslClient Implementation
+ //
+ // ISaslClient Implementation
+ //
+
+ public override string MechanismName
+ {
+ get { return Mechanism; }
+ }
+
+ public override bool HasInitialResponse
+ {
+ get { return true; }
+ }
+
+ public override byte[] EvaluateChallenge(byte[] challenge)
+ {
+ // ignore challenge
+ SetComplete();
+ return Encoding.UTF8.GetBytes(AuthorizationId);
+ }
+
+ #endregion // ISaslClient Implementation
+
+ } // class AnonymousSaslClient
+
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs b/qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs
index b58d0f2b1c..3cce0e3a2d 100644
--- a/qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs
+++ b/qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5HexSaslClient.cs
@@ -1,93 +1,93 @@
-/*
- *
- * 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 System.Collections;
-using System.Security.Cryptography;
-using System.Text;
-
-namespace Apache.Qpid.Sasl.Mechanisms
-{
- /// <summary>
- /// Implements the CRAM-MD5 authentication mechanism as outlined
- /// in RFC 2195
- /// </summary>
- public class CramMD5HexSaslClient : SaslClient
- {
- public const string Mechanism = "CRAM-MD5-HEX";
- private const int MinPwdLen = 16;
-
- public CramMD5HexSaslClient(
- string authorizationId,
- IDictionary properties,
- ISaslCallbackHandler handler)
- : base(authorizationId, null, null, properties, handler)
- {
- }
-
- #region ISaslClient Implementation
- //
- // ISaslClient Implementation
- //
-
- public override string MechanismName
- {
- get { return Mechanism; }
- }
-
- public override bool HasInitialResponse
- {
- get { return false; }
- }
-
-
- public override byte[] EvaluateChallenge(byte[] challenge)
- {
- if ( challenge == null || challenge.Length == 0 )
- throw new ArgumentNullException("challenge");
-
-
- NameCallback nameCB = new NameCallback(AuthorizationId);
- PasswordCallback pwdCB = new PasswordCallback();
- ISaslCallback[] callbacks = { nameCB, pwdCB };
- Handler.Handle(callbacks);
-
- string username = nameCB.Text;
-
- //Encode the Hashed Password as Hex
- byte[] passwd = Encoding.UTF8.GetBytes(ToHex(pwdCB.HashedText));
-
- string s = System.Text.UTF8Encoding.UTF8.GetString(challenge);
-
- using ( HMAC hmac = new HMACMD5(passwd) )
- {
- byte[] value = hmac.ComputeHash(challenge);
- string encoded = ToHex(value);
- SetComplete();
- return Encoding.UTF8.GetBytes(username + " " + encoded);
- }
- }
-
- #endregion // ISaslClient Implementation
-
- } // class CramMD5HashedSaslClient
-
+/*
+ *
+ * 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 System.Collections;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Apache.Qpid.Sasl.Mechanisms
+{
+ /// <summary>
+ /// Implements the CRAM-MD5 authentication mechanism as outlined
+ /// in RFC 2195
+ /// </summary>
+ public class CramMD5HexSaslClient : SaslClient
+ {
+ public const string Mechanism = "CRAM-MD5-HEX";
+ private const int MinPwdLen = 16;
+
+ public CramMD5HexSaslClient(
+ string authorizationId,
+ IDictionary properties,
+ ISaslCallbackHandler handler)
+ : base(authorizationId, null, null, properties, handler)
+ {
+ }
+
+ #region ISaslClient Implementation
+ //
+ // ISaslClient Implementation
+ //
+
+ public override string MechanismName
+ {
+ get { return Mechanism; }
+ }
+
+ public override bool HasInitialResponse
+ {
+ get { return false; }
+ }
+
+
+ public override byte[] EvaluateChallenge(byte[] challenge)
+ {
+ if ( challenge == null || challenge.Length == 0 )
+ throw new ArgumentNullException("challenge");
+
+
+ NameCallback nameCB = new NameCallback(AuthorizationId);
+ PasswordCallback pwdCB = new PasswordCallback();
+ ISaslCallback[] callbacks = { nameCB, pwdCB };
+ Handler.Handle(callbacks);
+
+ string username = nameCB.Text;
+
+ //Encode the Hashed Password as Hex
+ byte[] passwd = Encoding.UTF8.GetBytes(ToHex(pwdCB.HashedText));
+
+ string s = System.Text.UTF8Encoding.UTF8.GetString(challenge);
+
+ using ( HMAC hmac = new HMACMD5(passwd) )
+ {
+ byte[] value = hmac.ComputeHash(challenge);
+ string encoded = ToHex(value);
+ SetComplete();
+ return Encoding.UTF8.GetBytes(username + " " + encoded);
+ }
+ }
+
+ #endregion // ISaslClient Implementation
+
+ } // class CramMD5HashedSaslClient
+
} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5SaslClient.cs b/qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5SaslClient.cs
index 672cc64c6a..56b0f6ecd4 100644
--- a/qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5SaslClient.cs
+++ b/qpid/dotnet/Qpid.Sasl/Mechanisms/CramMD5SaslClient.cs
@@ -1,91 +1,91 @@
-/*
- *
- * 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 System.Collections;
-using System.Security.Cryptography;
-using System.Text;
-
-namespace Apache.Qpid.Sasl.Mechanisms
-{
- /// <summary>
- /// Implements the CRAM-MD5 authentication mechanism as outlined
- /// in RFC 2195
- /// </summary>
- public class CramMD5SaslClient : SaslClient
- {
- public const string Mechanism = "CRAM-MD5";
- private const int MinPwdLen = 16;
-
- public CramMD5SaslClient(
- string authorizationId,
- IDictionary properties,
- ISaslCallbackHandler handler)
- : base(authorizationId, null, null, properties, handler)
- {
- }
-
- #region ISaslClient Implementation
- //
- // ISaslClient Implementation
- //
-
- public override string MechanismName
- {
- get { return Mechanism; }
- }
-
- public override bool HasInitialResponse
- {
- get { return false; }
- }
-
- public override byte[] EvaluateChallenge(byte[] challenge)
- {
- if ( challenge == null || challenge.Length == 0 )
- throw new ArgumentNullException("challenge");
-
- NameCallback nameCB = new NameCallback(AuthorizationId);
- PasswordCallback pwdCB = new PasswordCallback();
- ISaslCallback[] callbacks = { nameCB, pwdCB };
- Handler.Handle(callbacks);
-
- string username = nameCB.Text;
- string passwd = pwdCB.Text.PadRight(MinPwdLen, '\0');
-
- byte[] secret = Encoding.UTF8.GetBytes(passwd);
-
- //using ( HMAC hmac = new HMACMD5(secret) )
- using ( MD5HMAC hmac = new MD5HMAC(secret) )
- {
- byte[] value = hmac.ComputeHash(challenge);
- string encoded = ToHex(value);
- SetComplete();
- return Encoding.UTF8.GetBytes(username + " " + encoded);
- }
-
- }
-
- #endregion // ISaslClient Implementation
-
- } // class CramMD5SaslClient
-
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Apache.Qpid.Sasl.Mechanisms
+{
+ /// <summary>
+ /// Implements the CRAM-MD5 authentication mechanism as outlined
+ /// in RFC 2195
+ /// </summary>
+ public class CramMD5SaslClient : SaslClient
+ {
+ public const string Mechanism = "CRAM-MD5";
+ private const int MinPwdLen = 16;
+
+ public CramMD5SaslClient(
+ string authorizationId,
+ IDictionary properties,
+ ISaslCallbackHandler handler)
+ : base(authorizationId, null, null, properties, handler)
+ {
+ }
+
+ #region ISaslClient Implementation
+ //
+ // ISaslClient Implementation
+ //
+
+ public override string MechanismName
+ {
+ get { return Mechanism; }
+ }
+
+ public override bool HasInitialResponse
+ {
+ get { return false; }
+ }
+
+ public override byte[] EvaluateChallenge(byte[] challenge)
+ {
+ if ( challenge == null || challenge.Length == 0 )
+ throw new ArgumentNullException("challenge");
+
+ NameCallback nameCB = new NameCallback(AuthorizationId);
+ PasswordCallback pwdCB = new PasswordCallback();
+ ISaslCallback[] callbacks = { nameCB, pwdCB };
+ Handler.Handle(callbacks);
+
+ string username = nameCB.Text;
+ string passwd = pwdCB.Text.PadRight(MinPwdLen, '\0');
+
+ byte[] secret = Encoding.UTF8.GetBytes(passwd);
+
+ //using ( HMAC hmac = new HMACMD5(secret) )
+ using ( MD5HMAC hmac = new MD5HMAC(secret) )
+ {
+ byte[] value = hmac.ComputeHash(challenge);
+ string encoded = ToHex(value);
+ SetComplete();
+ return Encoding.UTF8.GetBytes(username + " " + encoded);
+ }
+
+ }
+
+ #endregion // ISaslClient Implementation
+
+ } // class CramMD5SaslClient
+
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/Mechanisms/DigestSaslClient.cs b/qpid/dotnet/Qpid.Sasl/Mechanisms/DigestSaslClient.cs
index 59d3a88991..79843587c7 100644
--- a/qpid/dotnet/Qpid.Sasl/Mechanisms/DigestSaslClient.cs
+++ b/qpid/dotnet/Qpid.Sasl/Mechanisms/DigestSaslClient.cs
@@ -1,576 +1,576 @@
-/*
- *
- * 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 System.Collections;
-using System.Collections.Specialized;
-using System.Globalization;
-using System.Security.Cryptography;
-using System.Text;
-
-namespace Apache.Qpid.Sasl.Mechanisms
-{
-
- /// <summary>
- /// Implements the DIGEST MD5 authentication mechanism
- /// as outlined in RFC 2831
- /// </summary>
- public class DigestSaslClient : SaslClient
- {
- public const string Mechanism = "DIGEST-MD5";
- private static readonly MD5 _md5 = new MD5CryptoServiceProvider();
- private int _state;
- private string _cnonce;
- private Encoding _encoding = Encoding.UTF8;
-
- public string Cnonce
- {
- get { return _cnonce; }
- set { _cnonce = value; }
- }
-
- public DigestSaslClient(
- string authid, string serverName, string protocol,
- IDictionary properties, ISaslCallbackHandler handler)
- : base(authid, serverName, protocol, properties, handler)
- {
- _cnonce = Guid.NewGuid().ToString("N");
- }
-
- #region ISaslClient Implementation
- //
- // ISaslClient Implementation
- //
-
- public override string MechanismName
- {
- get { return Mechanism; }
- }
-
- public override bool HasInitialResponse
- {
- get { return false; }
- }
-
- public override byte[] EvaluateChallenge(byte[] challenge)
- {
- if ( challenge == null || challenge.Length <= 0 )
- throw new ArgumentNullException("challenge");
-
- switch ( _state++ )
- {
- case 0: return OnInitialChallenge(challenge);
- case 1: return OnFinalResponse(challenge);
- }
- throw new SaslException("Invalid State for authentication");
- }
-
- #endregion // ISaslClient Implementation
-
-
- #region Private Methods
- //
- // Private Methods
- //
-
- /// <summary>
- /// Process the first challenge from the server
- /// and calculate a response
- /// </summary>
- /// <param name="challenge">The server issued challenge</param>
- /// <returns>Client response</returns>
- private byte[] OnInitialChallenge(byte[] challenge)
- {
- DigestChallenge dch =
- DigestChallenge.Parse(_encoding.GetString(challenge));
- // validate input challenge
- if ( dch.Nonce == null || dch.Nonce.Length == 0 )
- throw new SaslException("Nonce value missing in server challenge");
- if ( dch.Algorithm != "md5-sess" )
- throw new SaslException("Invalid or missing algorithm value in server challenge");
-
-
- NameCallback nameCB = new NameCallback(AuthorizationId);
- PasswordCallback pwdCB = new PasswordCallback();
- RealmCallback realmCB = new RealmCallback(dch.Realm);
- ISaslCallback[] callbacks = { nameCB, pwdCB, realmCB };
- Handler.Handle(callbacks);
-
- DigestResponse response = new DigestResponse();
- response.Username = nameCB.Text;
- response.Realm = realmCB.Text;
- response.Nonce = dch.Nonce;
- response.Cnonce = Cnonce;
- response.NonceCount = 1;
- response.Qop = DigestQop.Auth; // only auth supported for now
- response.DigestUri = Protocol.ToLower() + "/" + ServerName;
- response.MaxBuffer = dch.MaxBuffer;
- response.Charset = dch.Charset;
- response.Cipher = null; // not supported for now
- response.Authzid = AuthorizationId;
- response.AuthParam = dch.AuthParam;
-
- response.Response = CalculateResponse(
- nameCB.Text, realmCB.Text, pwdCB.Text,
- dch.Nonce, response.NonceCount, response.Qop, response.DigestUri
- );
-
- return _encoding.GetBytes(response.ToString());
- }
-
- /// <summary>
- /// Process the second server challenge
- /// </summary>
- /// <param name="challenge">Server issued challenge</param>
- /// <returns>The client response</returns>
- private byte[] OnFinalResponse(byte[] challenge)
- {
- DigestChallenge dch =
- DigestChallenge.Parse(_encoding.GetString(challenge));
-
- if ( dch.Rspauth == null || dch.Rspauth.Length == 0 )
- throw new SaslException("Expected 'rspauth' in server challenge not found");
-
- SetComplete();
- return new byte[0];
- }
-
-
-
- /// <summary>
- /// Calculate the response field of the client response
- /// </summary>
- /// <param name="username">The user name</param>
- /// <param name="realm">The realm</param>
- /// <param name="passwd">The user's password</param>
- /// <param name="nonce">Server nonce value</param>
- /// <param name="nc">Client nonce count (always 1)</param>
- /// <param name="qop">Quality of Protection</param>
- /// <param name="digestUri">Digest-URI</param>
- /// <returns>The value for the response field</returns>
- private string CalculateResponse(
- string username, string realm, string passwd,
- string nonce, int nc, string qop, string digestUri
- )
- {
- string a1 = CalcHexA1(username, realm, passwd, nonce);
- string a2 = CalcHexA2(digestUri, qop);
-
- string ncs = nc.ToString("x8", CultureInfo.InvariantCulture);
- StringBuilder prekd = new StringBuilder();
- prekd.Append(a1).Append(':').Append(nonce).Append(':')
- .Append(ncs).Append(':').Append(Cnonce)
- .Append(':').Append(qop).Append(':').Append(a2);
-
- return ToHex(CalcH(_encoding.GetBytes(prekd.ToString())));
- }
-
- private string CalcHexA1(
- string username, string realm,
- string passwd, string nonce
- )
- {
- bool hasAuthId = AuthorizationId != null && AuthorizationId.Length > 0;
-
- string premd = username + ":" + realm + ":" + passwd;
- byte[] temp1 = CalcH(_encoding.GetBytes(premd));
-
-
- int a1len = 16 + 1 + nonce.Length + 1 + Cnonce.Length;
- if ( hasAuthId )
- a1len += 1 + AuthorizationId.Length;
-
- byte[] buffer = new byte[a1len];
- Array.Copy(temp1, buffer, temp1.Length);
-
- string p2 = ":" + nonce + ":" + Cnonce;
- if ( hasAuthId )
- p2 += ":" + AuthorizationId;
-
- byte[] temp2 = _encoding.GetBytes(p2);
- Array.Copy(temp2, 0, buffer, 16, temp2.Length);
-
- return ToHex(CalcH(buffer));
- }
-
- private string CalcHexA2(string digestUri, string qop)
- {
- string a2 = "AUTHENTICATE:" + digestUri;
- if ( qop != DigestQop.Auth )
- a2 += ":00000000000000000000000000000000";
- return ToHex(CalcH(_encoding.GetBytes(a2)));
- }
-
- private static byte[] CalcH(byte[] value)
- {
- return _md5.ComputeHash(value);
- }
-
- #endregion // Private Methods
-
-
- } // class DigestSaslClient
-
-
- /// <summary>
- /// Available QOP options in the DIGEST scheme
- /// </summary>
- public sealed class DigestQop
- {
- public const string Auth = "auth";
- public const string AuthInt = "auth-int";
- public const string AuthConf = "auth-conf";
- } // class DigestQop
-
-
- /// <summary>
- /// Represents and parses a digest server challenge
- /// </summary>
- public class DigestChallenge
- {
- private string _realm = "localhost";
- private string _nonce;
- private string[] _qopOptions = { DigestQop.Auth };
- private bool _stale;
- private int _maxBuffer = 65536;
- private string _charset = "ISO 8859-1";
- private string _algorithm;
- private string[] _cipherOptions;
- private string _authParam;
- private string _rspauth;
-
- #region Properties
- //
- // Properties
- //
-
- public string Realm
- {
- get { return _realm; }
- }
-
- public string Nonce
- {
- get { return _nonce; }
- }
-
- public string[] QopOptions
- {
- get { return _qopOptions; }
- }
-
- public bool Stale
- {
- get { return _stale; }
- }
-
- public int MaxBuffer
- {
- get { return _maxBuffer; }
- set { _maxBuffer = value; }
- }
-
- public string Charset
- {
- get { return _charset; }
- }
-
- public string Algorithm
- {
- get { return _algorithm; }
- }
-
- public string[] CipherOptions
- {
- get { return _cipherOptions; }
- }
-
- public string AuthParam
- {
- get { return _authParam; }
- }
-
- public string Rspauth
- {
- get { return _rspauth; }
- }
-
- #endregion // Properties
-
- public static DigestChallenge Parse(string challenge)
- {
- DigestChallenge parsed = new DigestChallenge();
- StringDictionary parts = ParseParameters(challenge);
- foreach ( string optname in parts.Keys )
- {
- switch ( optname )
- {
- case "realm":
- parsed._realm = parts[optname];
- break;
- case "nonce":
- parsed._nonce = parts[optname];
- break;
- case "qop-options":
- parsed._qopOptions = GetOptions(parts[optname]);
- break;
- case "cipher-opts":
- parsed._cipherOptions = GetOptions(parts[optname]);
- break;
- case "stale":
- parsed._stale = Convert.ToBoolean(parts[optname], CultureInfo.InvariantCulture);
- break;
- case "maxbuf":
- parsed._maxBuffer = Convert.ToInt32(parts[optname], CultureInfo.InvariantCulture);
- break;
- case "charset":
- parsed._charset = parts[optname];
- break;
- case "algorithm":
- parsed._algorithm = parts[optname];
- break;
- case "auth-param":
- parsed._authParam = parts[optname];
- break;
- case "rspauth":
- parsed._rspauth = parts[optname];
- break;
- }
- }
-
- return parsed;
- }
-
-
- public static StringDictionary ParseParameters(string source)
- {
- if ( source == null )
- throw new ArgumentNullException("source");
-
- StringDictionary ret = new StringDictionary();
-
- string remaining = source.Trim();
- while ( remaining.Length > 0 )
- {
- int equals = remaining.IndexOf('=');
- if ( equals < 0 )
- break;
-
- string optname = remaining.Substring(0, equals).Trim();
- remaining = remaining.Substring(equals + 1);
-
- string value = ParseQuoted(ref remaining);
- ret[optname] = value.Trim();
- }
- return ret;
- }
-
- private static string ParseQuoted(ref string str)
- {
- string ns = str.TrimStart();
-
- int start = 0;
- bool quoted = ns[0] == '\"';
- if ( quoted ) start++;
- bool inquotes = quoted;
- bool escaped = false;
-
- int pos = start;
- for ( ; pos < ns.Length; pos++ )
- {
- if ( !inquotes && ns[pos] == ',' )
- break;
-
- // at end of quotes?
- if ( quoted && !escaped && ns[pos] == '\"' )
- inquotes = false;
- // is this char an escape for the next one?
- escaped = inquotes && ns[pos] == '\\';
- }
- // pos has end of string
- string value = ns.Substring(start, pos-start).Trim();
- if ( quoted )
- {
- // remove trailing quote
- value = value.Substring(0, value.Length - 1);
- }
- str = ns.Substring(pos < ns.Length-1 ? pos+1 : pos);
- return value;
- }
-
- private static string[] GetOptions(string value)
- {
- return value.Split(' ');
- }
-
- } // class DigestChallenge
-
-
- /// <summary>
- /// Represents and knows how to write a
- /// digest client response
- /// </summary>
- public class DigestResponse
- {
- private string _username;
- private string _realm;
- private string _nonce;
- private string _cnonce;
- private int _nonceCount;
- private string _qop;
- private string _digestUri;
- private string _response;
- private int _maxBuffer;
- private string _charset;
- private string _cipher;
- private string _authzid;
- private string _authParam;
-
- #region Properties
- //
- // Properties
- //
-
- public string Username
- {
- get { return _username; }
- set { _username = value; }
- }
-
- public string Realm
- {
- get { return _realm; }
- set { _realm = value; }
- }
-
- public string Nonce
- {
- get { return _nonce; }
- set { _nonce = value; }
- }
-
- public string Cnonce
- {
- get { return _cnonce; }
- set { _cnonce = value; }
- }
-
- public int NonceCount
- {
- get { return _nonceCount; }
- set { _nonceCount = value; }
- }
-
- public string Qop
- {
- get { return _qop; }
- set { _qop = value; }
- }
-
- public string DigestUri
- {
- get { return _digestUri; }
- set { _digestUri = value; }
- }
-
- public string Response
- {
- get { return _response; }
- set { _response = value; }
- }
-
- public int MaxBuffer
- {
- get { return _maxBuffer; }
- set { _maxBuffer = value; }
- }
-
- public string Charset
- {
- get { return _charset; }
- set { _charset = value; }
- }
-
- public string Cipher
- {
- get { return _cipher; }
- set { _cipher = value; }
- }
-
- public string Authzid
- {
- get { return _authzid; }
- set { _authzid = value; }
- }
-
- public string AuthParam
- {
- get { return _authParam; }
- set { _authParam = value; }
- }
-
- #endregion // Properties
-
-
- public override string ToString()
- {
- StringBuilder buffer = new StringBuilder();
- Pair(buffer, "username", Username, true);
- Pair(buffer, "realm", Realm, true);
- Pair(buffer, "nonce", Nonce, true);
- Pair(buffer, "cnonce", Cnonce, true);
- string nc = NonceCount.ToString("x8", CultureInfo.InvariantCulture);
- Pair(buffer, "nc", nc, false);
- Pair(buffer, "qop", Qop, false);
- Pair(buffer, "digest-uri", DigestUri, true);
- Pair(buffer, "response", Response, true);
- string maxBuffer = MaxBuffer.ToString(CultureInfo.InvariantCulture);
- Pair(buffer, "maxbuf", maxBuffer, false);
- Pair(buffer, "charset", Charset, false);
- Pair(buffer, "cipher", Cipher, false);
- Pair(buffer, "authzid", Authzid, true);
- Pair(buffer, "auth-param", AuthParam, true);
-
- return buffer.ToString().TrimEnd(',');
- }
-
- private static void Pair(StringBuilder buffer, string name, string value, bool quoted)
- {
- if ( value != null && value.Length > 0 )
- {
- buffer.Append(name);
- buffer.Append('=');
- if ( quoted )
- {
- buffer.Append('\"');
- buffer.Append(value.Replace("\"", "\\\""));
- buffer.Append('\"');
- } else
- {
- buffer.Append(value);
- }
- buffer.Append(',');
- }
- }
-
- } // class DigestResponse
-
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Collections.Specialized;
+using System.Globalization;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Apache.Qpid.Sasl.Mechanisms
+{
+
+ /// <summary>
+ /// Implements the DIGEST MD5 authentication mechanism
+ /// as outlined in RFC 2831
+ /// </summary>
+ public class DigestSaslClient : SaslClient
+ {
+ public const string Mechanism = "DIGEST-MD5";
+ private static readonly MD5 _md5 = new MD5CryptoServiceProvider();
+ private int _state;
+ private string _cnonce;
+ private Encoding _encoding = Encoding.UTF8;
+
+ public string Cnonce
+ {
+ get { return _cnonce; }
+ set { _cnonce = value; }
+ }
+
+ public DigestSaslClient(
+ string authid, string serverName, string protocol,
+ IDictionary properties, ISaslCallbackHandler handler)
+ : base(authid, serverName, protocol, properties, handler)
+ {
+ _cnonce = Guid.NewGuid().ToString("N");
+ }
+
+ #region ISaslClient Implementation
+ //
+ // ISaslClient Implementation
+ //
+
+ public override string MechanismName
+ {
+ get { return Mechanism; }
+ }
+
+ public override bool HasInitialResponse
+ {
+ get { return false; }
+ }
+
+ public override byte[] EvaluateChallenge(byte[] challenge)
+ {
+ if ( challenge == null || challenge.Length <= 0 )
+ throw new ArgumentNullException("challenge");
+
+ switch ( _state++ )
+ {
+ case 0: return OnInitialChallenge(challenge);
+ case 1: return OnFinalResponse(challenge);
+ }
+ throw new SaslException("Invalid State for authentication");
+ }
+
+ #endregion // ISaslClient Implementation
+
+
+ #region Private Methods
+ //
+ // Private Methods
+ //
+
+ /// <summary>
+ /// Process the first challenge from the server
+ /// and calculate a response
+ /// </summary>
+ /// <param name="challenge">The server issued challenge</param>
+ /// <returns>Client response</returns>
+ private byte[] OnInitialChallenge(byte[] challenge)
+ {
+ DigestChallenge dch =
+ DigestChallenge.Parse(_encoding.GetString(challenge));
+ // validate input challenge
+ if ( dch.Nonce == null || dch.Nonce.Length == 0 )
+ throw new SaslException("Nonce value missing in server challenge");
+ if ( dch.Algorithm != "md5-sess" )
+ throw new SaslException("Invalid or missing algorithm value in server challenge");
+
+
+ NameCallback nameCB = new NameCallback(AuthorizationId);
+ PasswordCallback pwdCB = new PasswordCallback();
+ RealmCallback realmCB = new RealmCallback(dch.Realm);
+ ISaslCallback[] callbacks = { nameCB, pwdCB, realmCB };
+ Handler.Handle(callbacks);
+
+ DigestResponse response = new DigestResponse();
+ response.Username = nameCB.Text;
+ response.Realm = realmCB.Text;
+ response.Nonce = dch.Nonce;
+ response.Cnonce = Cnonce;
+ response.NonceCount = 1;
+ response.Qop = DigestQop.Auth; // only auth supported for now
+ response.DigestUri = Protocol.ToLower() + "/" + ServerName;
+ response.MaxBuffer = dch.MaxBuffer;
+ response.Charset = dch.Charset;
+ response.Cipher = null; // not supported for now
+ response.Authzid = AuthorizationId;
+ response.AuthParam = dch.AuthParam;
+
+ response.Response = CalculateResponse(
+ nameCB.Text, realmCB.Text, pwdCB.Text,
+ dch.Nonce, response.NonceCount, response.Qop, response.DigestUri
+ );
+
+ return _encoding.GetBytes(response.ToString());
+ }
+
+ /// <summary>
+ /// Process the second server challenge
+ /// </summary>
+ /// <param name="challenge">Server issued challenge</param>
+ /// <returns>The client response</returns>
+ private byte[] OnFinalResponse(byte[] challenge)
+ {
+ DigestChallenge dch =
+ DigestChallenge.Parse(_encoding.GetString(challenge));
+
+ if ( dch.Rspauth == null || dch.Rspauth.Length == 0 )
+ throw new SaslException("Expected 'rspauth' in server challenge not found");
+
+ SetComplete();
+ return new byte[0];
+ }
+
+
+
+ /// <summary>
+ /// Calculate the response field of the client response
+ /// </summary>
+ /// <param name="username">The user name</param>
+ /// <param name="realm">The realm</param>
+ /// <param name="passwd">The user's password</param>
+ /// <param name="nonce">Server nonce value</param>
+ /// <param name="nc">Client nonce count (always 1)</param>
+ /// <param name="qop">Quality of Protection</param>
+ /// <param name="digestUri">Digest-URI</param>
+ /// <returns>The value for the response field</returns>
+ private string CalculateResponse(
+ string username, string realm, string passwd,
+ string nonce, int nc, string qop, string digestUri
+ )
+ {
+ string a1 = CalcHexA1(username, realm, passwd, nonce);
+ string a2 = CalcHexA2(digestUri, qop);
+
+ string ncs = nc.ToString("x8", CultureInfo.InvariantCulture);
+ StringBuilder prekd = new StringBuilder();
+ prekd.Append(a1).Append(':').Append(nonce).Append(':')
+ .Append(ncs).Append(':').Append(Cnonce)
+ .Append(':').Append(qop).Append(':').Append(a2);
+
+ return ToHex(CalcH(_encoding.GetBytes(prekd.ToString())));
+ }
+
+ private string CalcHexA1(
+ string username, string realm,
+ string passwd, string nonce
+ )
+ {
+ bool hasAuthId = AuthorizationId != null && AuthorizationId.Length > 0;
+
+ string premd = username + ":" + realm + ":" + passwd;
+ byte[] temp1 = CalcH(_encoding.GetBytes(premd));
+
+
+ int a1len = 16 + 1 + nonce.Length + 1 + Cnonce.Length;
+ if ( hasAuthId )
+ a1len += 1 + AuthorizationId.Length;
+
+ byte[] buffer = new byte[a1len];
+ Array.Copy(temp1, buffer, temp1.Length);
+
+ string p2 = ":" + nonce + ":" + Cnonce;
+ if ( hasAuthId )
+ p2 += ":" + AuthorizationId;
+
+ byte[] temp2 = _encoding.GetBytes(p2);
+ Array.Copy(temp2, 0, buffer, 16, temp2.Length);
+
+ return ToHex(CalcH(buffer));
+ }
+
+ private string CalcHexA2(string digestUri, string qop)
+ {
+ string a2 = "AUTHENTICATE:" + digestUri;
+ if ( qop != DigestQop.Auth )
+ a2 += ":00000000000000000000000000000000";
+ return ToHex(CalcH(_encoding.GetBytes(a2)));
+ }
+
+ private static byte[] CalcH(byte[] value)
+ {
+ return _md5.ComputeHash(value);
+ }
+
+ #endregion // Private Methods
+
+
+ } // class DigestSaslClient
+
+
+ /// <summary>
+ /// Available QOP options in the DIGEST scheme
+ /// </summary>
+ public sealed class DigestQop
+ {
+ public const string Auth = "auth";
+ public const string AuthInt = "auth-int";
+ public const string AuthConf = "auth-conf";
+ } // class DigestQop
+
+
+ /// <summary>
+ /// Represents and parses a digest server challenge
+ /// </summary>
+ public class DigestChallenge
+ {
+ private string _realm = "localhost";
+ private string _nonce;
+ private string[] _qopOptions = { DigestQop.Auth };
+ private bool _stale;
+ private int _maxBuffer = 65536;
+ private string _charset = "ISO 8859-1";
+ private string _algorithm;
+ private string[] _cipherOptions;
+ private string _authParam;
+ private string _rspauth;
+
+ #region Properties
+ //
+ // Properties
+ //
+
+ public string Realm
+ {
+ get { return _realm; }
+ }
+
+ public string Nonce
+ {
+ get { return _nonce; }
+ }
+
+ public string[] QopOptions
+ {
+ get { return _qopOptions; }
+ }
+
+ public bool Stale
+ {
+ get { return _stale; }
+ }
+
+ public int MaxBuffer
+ {
+ get { return _maxBuffer; }
+ set { _maxBuffer = value; }
+ }
+
+ public string Charset
+ {
+ get { return _charset; }
+ }
+
+ public string Algorithm
+ {
+ get { return _algorithm; }
+ }
+
+ public string[] CipherOptions
+ {
+ get { return _cipherOptions; }
+ }
+
+ public string AuthParam
+ {
+ get { return _authParam; }
+ }
+
+ public string Rspauth
+ {
+ get { return _rspauth; }
+ }
+
+ #endregion // Properties
+
+ public static DigestChallenge Parse(string challenge)
+ {
+ DigestChallenge parsed = new DigestChallenge();
+ StringDictionary parts = ParseParameters(challenge);
+ foreach ( string optname in parts.Keys )
+ {
+ switch ( optname )
+ {
+ case "realm":
+ parsed._realm = parts[optname];
+ break;
+ case "nonce":
+ parsed._nonce = parts[optname];
+ break;
+ case "qop-options":
+ parsed._qopOptions = GetOptions(parts[optname]);
+ break;
+ case "cipher-opts":
+ parsed._cipherOptions = GetOptions(parts[optname]);
+ break;
+ case "stale":
+ parsed._stale = Convert.ToBoolean(parts[optname], CultureInfo.InvariantCulture);
+ break;
+ case "maxbuf":
+ parsed._maxBuffer = Convert.ToInt32(parts[optname], CultureInfo.InvariantCulture);
+ break;
+ case "charset":
+ parsed._charset = parts[optname];
+ break;
+ case "algorithm":
+ parsed._algorithm = parts[optname];
+ break;
+ case "auth-param":
+ parsed._authParam = parts[optname];
+ break;
+ case "rspauth":
+ parsed._rspauth = parts[optname];
+ break;
+ }
+ }
+
+ return parsed;
+ }
+
+
+ public static StringDictionary ParseParameters(string source)
+ {
+ if ( source == null )
+ throw new ArgumentNullException("source");
+
+ StringDictionary ret = new StringDictionary();
+
+ string remaining = source.Trim();
+ while ( remaining.Length > 0 )
+ {
+ int equals = remaining.IndexOf('=');
+ if ( equals < 0 )
+ break;
+
+ string optname = remaining.Substring(0, equals).Trim();
+ remaining = remaining.Substring(equals + 1);
+
+ string value = ParseQuoted(ref remaining);
+ ret[optname] = value.Trim();
+ }
+ return ret;
+ }
+
+ private static string ParseQuoted(ref string str)
+ {
+ string ns = str.TrimStart();
+
+ int start = 0;
+ bool quoted = ns[0] == '\"';
+ if ( quoted ) start++;
+ bool inquotes = quoted;
+ bool escaped = false;
+
+ int pos = start;
+ for ( ; pos < ns.Length; pos++ )
+ {
+ if ( !inquotes && ns[pos] == ',' )
+ break;
+
+ // at end of quotes?
+ if ( quoted && !escaped && ns[pos] == '\"' )
+ inquotes = false;
+ // is this char an escape for the next one?
+ escaped = inquotes && ns[pos] == '\\';
+ }
+ // pos has end of string
+ string value = ns.Substring(start, pos-start).Trim();
+ if ( quoted )
+ {
+ // remove trailing quote
+ value = value.Substring(0, value.Length - 1);
+ }
+ str = ns.Substring(pos < ns.Length-1 ? pos+1 : pos);
+ return value;
+ }
+
+ private static string[] GetOptions(string value)
+ {
+ return value.Split(' ');
+ }
+
+ } // class DigestChallenge
+
+
+ /// <summary>
+ /// Represents and knows how to write a
+ /// digest client response
+ /// </summary>
+ public class DigestResponse
+ {
+ private string _username;
+ private string _realm;
+ private string _nonce;
+ private string _cnonce;
+ private int _nonceCount;
+ private string _qop;
+ private string _digestUri;
+ private string _response;
+ private int _maxBuffer;
+ private string _charset;
+ private string _cipher;
+ private string _authzid;
+ private string _authParam;
+
+ #region Properties
+ //
+ // Properties
+ //
+
+ public string Username
+ {
+ get { return _username; }
+ set { _username = value; }
+ }
+
+ public string Realm
+ {
+ get { return _realm; }
+ set { _realm = value; }
+ }
+
+ public string Nonce
+ {
+ get { return _nonce; }
+ set { _nonce = value; }
+ }
+
+ public string Cnonce
+ {
+ get { return _cnonce; }
+ set { _cnonce = value; }
+ }
+
+ public int NonceCount
+ {
+ get { return _nonceCount; }
+ set { _nonceCount = value; }
+ }
+
+ public string Qop
+ {
+ get { return _qop; }
+ set { _qop = value; }
+ }
+
+ public string DigestUri
+ {
+ get { return _digestUri; }
+ set { _digestUri = value; }
+ }
+
+ public string Response
+ {
+ get { return _response; }
+ set { _response = value; }
+ }
+
+ public int MaxBuffer
+ {
+ get { return _maxBuffer; }
+ set { _maxBuffer = value; }
+ }
+
+ public string Charset
+ {
+ get { return _charset; }
+ set { _charset = value; }
+ }
+
+ public string Cipher
+ {
+ get { return _cipher; }
+ set { _cipher = value; }
+ }
+
+ public string Authzid
+ {
+ get { return _authzid; }
+ set { _authzid = value; }
+ }
+
+ public string AuthParam
+ {
+ get { return _authParam; }
+ set { _authParam = value; }
+ }
+
+ #endregion // Properties
+
+
+ public override string ToString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ Pair(buffer, "username", Username, true);
+ Pair(buffer, "realm", Realm, true);
+ Pair(buffer, "nonce", Nonce, true);
+ Pair(buffer, "cnonce", Cnonce, true);
+ string nc = NonceCount.ToString("x8", CultureInfo.InvariantCulture);
+ Pair(buffer, "nc", nc, false);
+ Pair(buffer, "qop", Qop, false);
+ Pair(buffer, "digest-uri", DigestUri, true);
+ Pair(buffer, "response", Response, true);
+ string maxBuffer = MaxBuffer.ToString(CultureInfo.InvariantCulture);
+ Pair(buffer, "maxbuf", maxBuffer, false);
+ Pair(buffer, "charset", Charset, false);
+ Pair(buffer, "cipher", Cipher, false);
+ Pair(buffer, "authzid", Authzid, true);
+ Pair(buffer, "auth-param", AuthParam, true);
+
+ return buffer.ToString().TrimEnd(',');
+ }
+
+ private static void Pair(StringBuilder buffer, string name, string value, bool quoted)
+ {
+ if ( value != null && value.Length > 0 )
+ {
+ buffer.Append(name);
+ buffer.Append('=');
+ if ( quoted )
+ {
+ buffer.Append('\"');
+ buffer.Append(value.Replace("\"", "\\\""));
+ buffer.Append('\"');
+ } else
+ {
+ buffer.Append(value);
+ }
+ buffer.Append(',');
+ }
+ }
+
+ } // class DigestResponse
+
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/Mechanisms/ExternalSaslClient.cs b/qpid/dotnet/Qpid.Sasl/Mechanisms/ExternalSaslClient.cs
index 5b513bda87..fec0d2d3c2 100644
--- a/qpid/dotnet/Qpid.Sasl/Mechanisms/ExternalSaslClient.cs
+++ b/qpid/dotnet/Qpid.Sasl/Mechanisms/ExternalSaslClient.cs
@@ -1,69 +1,69 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-namespace Apache.Qpid.Sasl.Mechanisms
-{
- /// <summary>
- /// Implements the EXTERNAL authentication mechanism
- /// as outlined in RFC 2222
- /// </summary>
- public class ExternalSaslClient : SaslClient
- {
- public const string Mechanism = "EXTERNAL";
-
- public ExternalSaslClient(
- string authid, IDictionary properties,
- ISaslCallbackHandler handler)
- : base(authid, null, null, properties, handler)
- {
- }
-
- #region ISaslClient Implementation
- //
- // ISaslClient Implementation
- //
-
- public override string MechanismName
- {
- get { return Mechanism; }
- }
-
- public override bool HasInitialResponse
- {
- get { return true; }
- }
-
- public override byte[] EvaluateChallenge(byte[] challenge)
- {
- // ignore challenge
- SetComplete();
- return Encoding.UTF8.GetBytes(AuthorizationId);
- }
-
- #endregion // ISaslClient Implementation
-
- } // class ExternalSaslClient
-
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+namespace Apache.Qpid.Sasl.Mechanisms
+{
+ /// <summary>
+ /// Implements the EXTERNAL authentication mechanism
+ /// as outlined in RFC 2222
+ /// </summary>
+ public class ExternalSaslClient : SaslClient
+ {
+ public const string Mechanism = "EXTERNAL";
+
+ public ExternalSaslClient(
+ string authid, IDictionary properties,
+ ISaslCallbackHandler handler)
+ : base(authid, null, null, properties, handler)
+ {
+ }
+
+ #region ISaslClient Implementation
+ //
+ // ISaslClient Implementation
+ //
+
+ public override string MechanismName
+ {
+ get { return Mechanism; }
+ }
+
+ public override bool HasInitialResponse
+ {
+ get { return true; }
+ }
+
+ public override byte[] EvaluateChallenge(byte[] challenge)
+ {
+ // ignore challenge
+ SetComplete();
+ return Encoding.UTF8.GetBytes(AuthorizationId);
+ }
+
+ #endregion // ISaslClient Implementation
+
+ } // class ExternalSaslClient
+
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/Mechanisms/PlainSaslClient.cs b/qpid/dotnet/Qpid.Sasl/Mechanisms/PlainSaslClient.cs
index 3addeb2e83..534be171b7 100644
--- a/qpid/dotnet/Qpid.Sasl/Mechanisms/PlainSaslClient.cs
+++ b/qpid/dotnet/Qpid.Sasl/Mechanisms/PlainSaslClient.cs
@@ -1,81 +1,81 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-namespace Apache.Qpid.Sasl.Mechanisms
-{
-
- /// <summary>
- /// Implements the PLAIN authentication mechanism
- /// as outlined in RFC 4616
- /// </summary>
- public class PlainSaslClient : SaslClient
- {
- public const string Mechanism = "PLAIN";
-
- public PlainSaslClient(
- string authid, IDictionary properties,
- ISaslCallbackHandler handler)
- : base(authid, null, null, properties, handler)
- {
- }
-
- #region ISaslClient Implementation
- //
- // ISaslClient Implementation
- //
-
- public override string MechanismName
- {
- get { return Mechanism; }
- }
-
- public override bool HasInitialResponse
- {
- get { return true; }
- }
-
- public override byte[] EvaluateChallenge(byte[] challenge)
- {
- // ignore challenge
-
- NameCallback nameCB = new NameCallback();
- PasswordCallback pwdCB = new PasswordCallback();
- ISaslCallback[] callbacks = { nameCB, pwdCB };
- Handler.Handle(callbacks);
-
- string username = nameCB.Text;
- string authid = AuthorizationId;
- string passwd = pwdCB.Text;
-
- string response =
- string.Format("{0}\0{1}\0{2}", authid, username, passwd);
- SetComplete();
- return Encoding.UTF8.GetBytes(response);
- }
-
- #endregion // ISaslClient Implementation
-
- } // class PlainSaslClient
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+namespace Apache.Qpid.Sasl.Mechanisms
+{
+
+ /// <summary>
+ /// Implements the PLAIN authentication mechanism
+ /// as outlined in RFC 4616
+ /// </summary>
+ public class PlainSaslClient : SaslClient
+ {
+ public const string Mechanism = "PLAIN";
+
+ public PlainSaslClient(
+ string authid, IDictionary properties,
+ ISaslCallbackHandler handler)
+ : base(authid, null, null, properties, handler)
+ {
+ }
+
+ #region ISaslClient Implementation
+ //
+ // ISaslClient Implementation
+ //
+
+ public override string MechanismName
+ {
+ get { return Mechanism; }
+ }
+
+ public override bool HasInitialResponse
+ {
+ get { return true; }
+ }
+
+ public override byte[] EvaluateChallenge(byte[] challenge)
+ {
+ // ignore challenge
+
+ NameCallback nameCB = new NameCallback();
+ PasswordCallback pwdCB = new PasswordCallback();
+ ISaslCallback[] callbacks = { nameCB, pwdCB };
+ Handler.Handle(callbacks);
+
+ string username = nameCB.Text;
+ string authid = AuthorizationId;
+ string passwd = pwdCB.Text;
+
+ string response =
+ string.Format("{0}\0{1}\0{2}", authid, username, passwd);
+ SetComplete();
+ return Encoding.UTF8.GetBytes(response);
+ }
+
+ #endregion // ISaslClient Implementation
+
+ } // class PlainSaslClient
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs b/qpid/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs
index 8afdefa23a..5245b97d1f 100644
--- a/qpid/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs
+++ b/qpid/dotnet/Qpid.Sasl/Properties/AssemblyInfo.cs
@@ -1,57 +1,57 @@
-/*
- *
- * 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 System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Apache.Qpid.Sasl")]
-[assembly: AssemblyDescription("Built from svn revision number: ")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("Apache.Qpid.Sasl")]
-[assembly: AssemblyCopyright("Apache Software Foundation")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("27ea23e4-6f84-4a54-8f1f-5725e6d767cc")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Revision and Build Numbers
-// by using the '*' as shown below:
-[assembly: AssemblyVersion("0.5.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
-[assembly: CLSCompliant(true)]
+/*
+ *
+ * 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 System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Apache.Qpid.Sasl")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("Apache.Qpid.Sasl")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("27ea23e4-6f84-4a54-8f1f-5725e6d767cc")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("0.5.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: CLSCompliant(true)]
diff --git a/qpid/dotnet/Qpid.Sasl/Sasl.cs b/qpid/dotnet/Qpid.Sasl/Sasl.cs
index 5a744a30d9..2f7bacb939 100644
--- a/qpid/dotnet/Qpid.Sasl/Sasl.cs
+++ b/qpid/dotnet/Qpid.Sasl/Sasl.cs
@@ -1,115 +1,115 @@
-/*
- *
- * 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 System.Collections;
-using System.Configuration;
-using System.Text;
-
-using Apache.Qpid.Sasl.Configuration;
-
-namespace Apache.Qpid.Sasl
-{
- /// <summary>
- /// Static class used to access the SASL functionality.
- /// The core SASL mechanism is described in RFC 2222.
- /// </summary>
- /// <remarks>
- /// Only client side mechanisms are implemented.
- /// <para>
- /// New client side factories can be added programatically using the
- /// RegisterClientFactory method, or through the application
- /// configuration file, like this:
- /// </para>
- /// <example><![CDATA[
- /// <configuration>
- /// <configSections>
- /// <section name="qpid.sasl" type="Apache.Qpid.Sasl.Configuration.SaslConfigurationSectionHandler, Apache.Qpid.Sasl"/>
- /// </configSections>
- ///
- /// <qpid.sasl>
- /// <clientFactories>
- /// <add type="Apache.Qpid.Sasl.Tests.TestClientFactory, Apache.Qpid.Sasl.Tests"/>
- /// </clientFactories>
- /// </qpid.sasl>
- /// </configuration>
- /// ]]></example>
- /// </remarks>
- public sealed class Sasl
- {
- private static IList _clientFactories;
-
-
- static Sasl()
- {
- SaslConfiguration config = SaslConfiguration.GetConfiguration();
- _clientFactories = config.ClientFactories;
- }
- private Sasl()
- {
- }
-
- public static ISaslClient CreateClient(
- string[] mechanisms, string authorizationId,
- string protocol, string serverName,
- IDictionary props, ISaslCallbackHandler handler
- )
- {
- ISaslClientFactory factory = FindFactory(mechanisms, props);
- if ( factory == null )
- return null;
-
- return factory.CreateClient (
- mechanisms, authorizationId,
- protocol, serverName, props, handler
- );
- }
-
- public static void RegisterClientFactory(ISaslClientFactory factory)
- {
- lock ( _clientFactories )
- {
- _clientFactories.Add(factory);
- }
- }
-
- private static ISaslClientFactory FindFactory(string[] mechanisms, IDictionary props)
- {
- lock ( _clientFactories )
- {
- foreach ( ISaslClientFactory factory in _clientFactories )
- {
- string[] mechs = factory.GetSupportedMechanisms(props);
- foreach ( string m1 in mechs )
- {
- foreach (string m2 in mechanisms )
- {
- if ( m1 == m2 )
- return factory;
- }
- }
- }
- return null;
- }
- }
- } // class Sasl
-
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Configuration;
+using System.Text;
+
+using Apache.Qpid.Sasl.Configuration;
+
+namespace Apache.Qpid.Sasl
+{
+ /// <summary>
+ /// Static class used to access the SASL functionality.
+ /// The core SASL mechanism is described in RFC 2222.
+ /// </summary>
+ /// <remarks>
+ /// Only client side mechanisms are implemented.
+ /// <para>
+ /// New client side factories can be added programatically using the
+ /// RegisterClientFactory method, or through the application
+ /// configuration file, like this:
+ /// </para>
+ /// <example><![CDATA[
+ /// <configuration>
+ /// <configSections>
+ /// <section name="qpid.sasl" type="Apache.Qpid.Sasl.Configuration.SaslConfigurationSectionHandler, Apache.Qpid.Sasl"/>
+ /// </configSections>
+ ///
+ /// <qpid.sasl>
+ /// <clientFactories>
+ /// <add type="Apache.Qpid.Sasl.Tests.TestClientFactory, Apache.Qpid.Sasl.Tests"/>
+ /// </clientFactories>
+ /// </qpid.sasl>
+ /// </configuration>
+ /// ]]></example>
+ /// </remarks>
+ public sealed class Sasl
+ {
+ private static IList _clientFactories;
+
+
+ static Sasl()
+ {
+ SaslConfiguration config = SaslConfiguration.GetConfiguration();
+ _clientFactories = config.ClientFactories;
+ }
+ private Sasl()
+ {
+ }
+
+ public static ISaslClient CreateClient(
+ string[] mechanisms, string authorizationId,
+ string protocol, string serverName,
+ IDictionary props, ISaslCallbackHandler handler
+ )
+ {
+ ISaslClientFactory factory = FindFactory(mechanisms, props);
+ if ( factory == null )
+ return null;
+
+ return factory.CreateClient (
+ mechanisms, authorizationId,
+ protocol, serverName, props, handler
+ );
+ }
+
+ public static void RegisterClientFactory(ISaslClientFactory factory)
+ {
+ lock ( _clientFactories )
+ {
+ _clientFactories.Add(factory);
+ }
+ }
+
+ private static ISaslClientFactory FindFactory(string[] mechanisms, IDictionary props)
+ {
+ lock ( _clientFactories )
+ {
+ foreach ( ISaslClientFactory factory in _clientFactories )
+ {
+ string[] mechs = factory.GetSupportedMechanisms(props);
+ foreach ( string m1 in mechs )
+ {
+ foreach (string m2 in mechanisms )
+ {
+ if ( m1 == m2 )
+ return factory;
+ }
+ }
+ }
+ return null;
+ }
+ }
+ } // class Sasl
+
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/SaslClient.cs b/qpid/dotnet/Qpid.Sasl/SaslClient.cs
index 1390b1b352..a22013181b 100644
--- a/qpid/dotnet/Qpid.Sasl/SaslClient.cs
+++ b/qpid/dotnet/Qpid.Sasl/SaslClient.cs
@@ -1,145 +1,145 @@
-/*
- *
- * 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 System.Collections;
-using System.Globalization;
-using System.Text;
-
-namespace Apache.Qpid.Sasl
-{
- public abstract class SaslClient : ISaslClient
- {
- private bool _isComplete;
- private IDictionary _properties;
- private string _authorizationId;
- private string _serverName;
- private string _protocol;
- private ISaslCallbackHandler _handler;
-
- protected string AuthorizationId
- {
- get { return _authorizationId; }
- }
- protected string ServerName
- {
- get { return _serverName; }
- }
-
- protected string Protocol
- {
- get { return _protocol; }
- }
-
- protected ISaslCallbackHandler Handler
- {
- get { return _handler; }
- }
-
- protected IDictionary Properties
- {
- get { return _properties; }
- }
-
- protected SaslClient(
- string authid, string serverName,
- string protocol, IDictionary properties,
- ISaslCallbackHandler handler)
- {
- if ( properties == null )
- throw new ArgumentNullException("properties");
- if ( handler == null )
- throw new ArgumentNullException("handler");
-
- _authorizationId = authid==null ? "" : authid;
- _serverName = serverName;
- _protocol = protocol;
- _properties = properties;
- _handler = handler;
-
- if ( _serverName == null || _serverName.Length == 0 )
- {
- _serverName = System.Net.Dns.GetHostName();
- }
- }
-
-
-
-
- #region ISaslClient Implementation
- //
- // ISaslClient Implementation
- //
-
- public abstract string MechanismName { get; }
-
- public abstract bool HasInitialResponse { get; }
-
- public bool IsComplete
- {
- get { return _isComplete; }
- }
-
- public abstract byte[] EvaluateChallenge(byte[] challenge);
-
- public virtual object GetNegotiatedProperty(string propName)
- {
- return null;
- }
-
- public virtual byte[] Unwrap(byte[] buffer, int offset, int length)
- {
- throw new NotImplementedException();
- }
-
- public virtual byte[] Wrap(byte[] buffer, int offset, int lenght)
- {
- throw new NotImplementedException();
- }
-
- #endregion // ISaslClient Implementation
-
-
- #region Helper Methods
- //
- // Helper Methods
- //
-
- protected void SetComplete()
- {
- _isComplete = true;
- }
-
- protected static string ToHex(byte[] buffer)
- {
- StringBuilder builder = new StringBuilder();
- foreach ( byte b in buffer )
- {
- builder.Append(b.ToString("x2", CultureInfo.InvariantCulture));
- }
- return builder.ToString();
- }
-
- #endregion // Helper Methods
-
- } // class SaslClient
-
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Globalization;
+using System.Text;
+
+namespace Apache.Qpid.Sasl
+{
+ public abstract class SaslClient : ISaslClient
+ {
+ private bool _isComplete;
+ private IDictionary _properties;
+ private string _authorizationId;
+ private string _serverName;
+ private string _protocol;
+ private ISaslCallbackHandler _handler;
+
+ protected string AuthorizationId
+ {
+ get { return _authorizationId; }
+ }
+ protected string ServerName
+ {
+ get { return _serverName; }
+ }
+
+ protected string Protocol
+ {
+ get { return _protocol; }
+ }
+
+ protected ISaslCallbackHandler Handler
+ {
+ get { return _handler; }
+ }
+
+ protected IDictionary Properties
+ {
+ get { return _properties; }
+ }
+
+ protected SaslClient(
+ string authid, string serverName,
+ string protocol, IDictionary properties,
+ ISaslCallbackHandler handler)
+ {
+ if ( properties == null )
+ throw new ArgumentNullException("properties");
+ if ( handler == null )
+ throw new ArgumentNullException("handler");
+
+ _authorizationId = authid==null ? "" : authid;
+ _serverName = serverName;
+ _protocol = protocol;
+ _properties = properties;
+ _handler = handler;
+
+ if ( _serverName == null || _serverName.Length == 0 )
+ {
+ _serverName = System.Net.Dns.GetHostName();
+ }
+ }
+
+
+
+
+ #region ISaslClient Implementation
+ //
+ // ISaslClient Implementation
+ //
+
+ public abstract string MechanismName { get; }
+
+ public abstract bool HasInitialResponse { get; }
+
+ public bool IsComplete
+ {
+ get { return _isComplete; }
+ }
+
+ public abstract byte[] EvaluateChallenge(byte[] challenge);
+
+ public virtual object GetNegotiatedProperty(string propName)
+ {
+ return null;
+ }
+
+ public virtual byte[] Unwrap(byte[] buffer, int offset, int length)
+ {
+ throw new NotImplementedException();
+ }
+
+ public virtual byte[] Wrap(byte[] buffer, int offset, int lenght)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion // ISaslClient Implementation
+
+
+ #region Helper Methods
+ //
+ // Helper Methods
+ //
+
+ protected void SetComplete()
+ {
+ _isComplete = true;
+ }
+
+ protected static string ToHex(byte[] buffer)
+ {
+ StringBuilder builder = new StringBuilder();
+ foreach ( byte b in buffer )
+ {
+ builder.Append(b.ToString("x2", CultureInfo.InvariantCulture));
+ }
+ return builder.ToString();
+ }
+
+ #endregion // Helper Methods
+
+ } // class SaslClient
+
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/SaslException.cs b/qpid/dotnet/Qpid.Sasl/SaslException.cs
index 8f6e00a7ba..d770ee63fd 100644
--- a/qpid/dotnet/Qpid.Sasl/SaslException.cs
+++ b/qpid/dotnet/Qpid.Sasl/SaslException.cs
@@ -1,56 +1,56 @@
-/*
- *
- * 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 System.Collections;
-using System.Runtime.Serialization;
-using System.Text;
-
-namespace Apache.Qpid.Sasl
-{
- /// <summary>
- /// Reports an exception during the processing of an SASL
- /// Operation. Only used for authentication-relared errors
- /// </summary>
- [Serializable]
- public class SaslException : Exception
- {
- public SaslException()
- {
- }
-
- public SaslException(string message)
- : base(message)
- {
- }
- public SaslException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
-
- protected SaslException(SerializationInfo info, StreamingContext ctxt)
- : base(info, ctxt)
- {
- }
-
- } // class SaslException
-
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Runtime.Serialization;
+using System.Text;
+
+namespace Apache.Qpid.Sasl
+{
+ /// <summary>
+ /// Reports an exception during the processing of an SASL
+ /// Operation. Only used for authentication-relared errors
+ /// </summary>
+ [Serializable]
+ public class SaslException : Exception
+ {
+ public SaslException()
+ {
+ }
+
+ public SaslException(string message)
+ : base(message)
+ {
+ }
+ public SaslException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
+
+ protected SaslException(SerializationInfo info, StreamingContext ctxt)
+ : base(info, ctxt)
+ {
+ }
+
+ } // class SaslException
+
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/Qpid.Sasl/SaslProperties.cs b/qpid/dotnet/Qpid.Sasl/SaslProperties.cs
index 0658acda21..f9ad1c68cd 100644
--- a/qpid/dotnet/Qpid.Sasl/SaslProperties.cs
+++ b/qpid/dotnet/Qpid.Sasl/SaslProperties.cs
@@ -1,42 +1,42 @@
-/*
- *
- * 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 System.Collections;
-using System.Text;
-
-namespace Apache.Qpid.Sasl
-{
- public sealed class SaslProperties
- {
- public const string PolicyNoPlainText = "NOPLAINTEXT";
- public const string PolicyNoActive = "NOACTIVE";
- public const string PolicyNoDictionary = "NODICTIONARY";
- public const string PolicyNoAnonymous = "NOANONYMOUS";
- public const string PolicyForwardSecrecy = "FORWARD_SECRECY";
- public const string PolicyPassCredentials = "PASS_CREDENTIALS";
-
- public const string Qop = "QOP";
- public const string Strength = "STRENGTH";
-
- } // class SaslProperties
-
-} // namespace Apache.Qpid.Sasl.Mechanisms
+/*
+ *
+ * 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 System.Collections;
+using System.Text;
+
+namespace Apache.Qpid.Sasl
+{
+ public sealed class SaslProperties
+ {
+ public const string PolicyNoPlainText = "NOPLAINTEXT";
+ public const string PolicyNoActive = "NOACTIVE";
+ public const string PolicyNoDictionary = "NODICTIONARY";
+ public const string PolicyNoAnonymous = "NOANONYMOUS";
+ public const string PolicyForwardSecrecy = "FORWARD_SECRECY";
+ public const string PolicyPassCredentials = "PASS_CREDENTIALS";
+
+ public const string Qop = "QOP";
+ public const string Strength = "STRENGTH";
+
+ } // class SaslProperties
+
+} // namespace Apache.Qpid.Sasl.Mechanisms
diff --git a/qpid/dotnet/TestClient/Program.cs b/qpid/dotnet/TestClient/Program.cs
index c612708e8e..f4b2db568e 100644
--- a/qpid/dotnet/TestClient/Program.cs
+++ b/qpid/dotnet/TestClient/Program.cs
@@ -1,30 +1,30 @@
-/*
- *
- * 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.
- *
- */
-namespace TopicListener
-{
- class Program
- {
- static void Main(string[] args)
- {
- Apache.Qpid.Integration.Tests.interop.TestClient.Main(args);
- }
- }
-}
+/*
+ *
+ * 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.
+ *
+ */
+namespace TopicListener
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Apache.Qpid.Integration.Tests.interop.TestClient.Main(args);
+ }
+ }
+}
diff --git a/qpid/dotnet/TestClient/Properties/AssemblyInfo.cs b/qpid/dotnet/TestClient/Properties/AssemblyInfo.cs
index 0214cbdd9d..e8ffbc5aba 100644
--- a/qpid/dotnet/TestClient/Properties/AssemblyInfo.cs
+++ b/qpid/dotnet/TestClient/Properties/AssemblyInfo.cs
@@ -1,53 +1,53 @@
-/*
- *
- * 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.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("TestClient")]
-[assembly: AssemblyDescription("Built from svn revision number: ")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("TestClient")]
-[assembly: AssemblyCopyright("Apache Software Foundation")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("1c2db1cd-239f-495a-b6b4-c815ea534489")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("0.5.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+/*
+ *
+ * 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TestClient")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("TestClient")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1c2db1cd-239f-495a-b6b4-c815ea534489")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.5.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/TopicListener/Program.cs b/qpid/dotnet/TopicListener/Program.cs
index 468aeafe43..14626d6134 100644
--- a/qpid/dotnet/TopicListener/Program.cs
+++ b/qpid/dotnet/TopicListener/Program.cs
@@ -1,30 +1,30 @@
-/*
- *
- * 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.
- *
- */
-namespace TopicListener
-{
- class Program
- {
- static void Main(string[] args)
- {
- Apache.Qpid.Client.Tests.interop.TopicListener.Main(args);
- }
- }
-}
+/*
+ *
+ * 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.
+ *
+ */
+namespace TopicListener
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Apache.Qpid.Client.Tests.interop.TopicListener.Main(args);
+ }
+ }
+}
diff --git a/qpid/dotnet/TopicListener/Properties/AssemblyInfo.cs b/qpid/dotnet/TopicListener/Properties/AssemblyInfo.cs
index 2ae8521a4f..1fe9bb8249 100644
--- a/qpid/dotnet/TopicListener/Properties/AssemblyInfo.cs
+++ b/qpid/dotnet/TopicListener/Properties/AssemblyInfo.cs
@@ -1,53 +1,53 @@
-/*
- *
- * 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.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("TopicListener")]
-[assembly: AssemblyDescription("Built from svn revision number: ")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("TopicListener")]
-[assembly: AssemblyCopyright("Apache Software Foundation")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("1c2db1cd-239f-495a-b6b4-c815ea534489")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("0.5.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+/*
+ *
+ * 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TopicListener")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("TopicListener")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1c2db1cd-239f-495a-b6b4-c815ea534489")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.5.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/qpid/dotnet/TopicPublisher/Program.cs b/qpid/dotnet/TopicPublisher/Program.cs
index 895ecf7d21..b5209b9317 100644
--- a/qpid/dotnet/TopicPublisher/Program.cs
+++ b/qpid/dotnet/TopicPublisher/Program.cs
@@ -1,30 +1,30 @@
-/*
- *
- * 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.
- *
- */
-namespace TopicPublisher
-{
- class Program
- {
- static void Main(string[] args)
- {
- Apache.Qpid.Client.Tests.interop.TopicPublisher.Main(args);
- }
- }
-}
+/*
+ *
+ * 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.
+ *
+ */
+namespace TopicPublisher
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Apache.Qpid.Client.Tests.interop.TopicPublisher.Main(args);
+ }
+ }
+}
diff --git a/qpid/dotnet/TopicPublisher/Properties/AssemblyInfo.cs b/qpid/dotnet/TopicPublisher/Properties/AssemblyInfo.cs
index 324f725b61..051b34ee37 100644
--- a/qpid/dotnet/TopicPublisher/Properties/AssemblyInfo.cs
+++ b/qpid/dotnet/TopicPublisher/Properties/AssemblyInfo.cs
@@ -1,53 +1,53 @@
-/*
- *
- * 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.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("TopicPublisher")]
-[assembly: AssemblyDescription("Built from svn revision number: ")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("Apache Software Foundation")]
-[assembly: AssemblyProduct("TopicPublisher")]
-[assembly: AssemblyCopyright("Apache Software Foundation")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("93fa1c32-c0f8-47e5-b167-dc581e33eb9b")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-[assembly: AssemblyVersion("0.5.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+/*
+ *
+ * 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.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TopicPublisher")]
+[assembly: AssemblyDescription("Built from svn revision number: ")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Apache Software Foundation")]
+[assembly: AssemblyProduct("TopicPublisher")]
+[assembly: AssemblyCopyright("Apache Software Foundation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("93fa1c32-c0f8-47e5-b167-dc581e33eb9b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("0.5.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]