NO-JIRA - Global Reformat
diff --git a/docs/nms-docs.csproj b/docs/nms-docs.csproj
index ca51350..0dc39e5 100644
--- a/docs/nms-docs.csproj
+++ b/docs/nms-docs.csproj
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
+
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -18,16 +19,16 @@
<Project Sdk="Microsoft.NET.Sdk">
- <PropertyGroup>
- <TargetFramework>netstandard2.0</TargetFramework>
- <RootNamespace>nms_docs</RootNamespace>
- </PropertyGroup>
+ <PropertyGroup>
+ <TargetFramework>netstandard2.0</TargetFramework>
+ <RootNamespace>nms_docs</RootNamespace>
+ </PropertyGroup>
- <ItemGroup>
- <PackageReference Include="docfx.console" Version="2.43.1">
- <PrivateAssets>all</PrivateAssets>
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
- </PackageReference>
- </ItemGroup>
+ <ItemGroup>
+ <PackageReference Include="docfx.console" Version="2.43.1">
+ <PrivateAssets>all</PrivateAssets>
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+ </PackageReference>
+ </ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/src/nms-api/IBytesMessage.cs b/src/nms-api/IBytesMessage.cs
index 3011ca2..d3eab86 100644
--- a/src/nms-api/IBytesMessage.cs
+++ b/src/nms-api/IBytesMessage.cs
@@ -14,473 +14,472 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- ///
- /// A BytesMessage object is used to send a message containing a stream of uninterpreted
- /// bytes. It inherits from the Message interface and adds a bytes message body. The
- /// receiver of the message supplies the interpretation of the bytes.
- ///
- /// This message type is for client encoding of existing message formats. If possible,
- /// one of the other self-defining message types should be used instead.
- ///
- /// Although the NMS API allows the use of message properties with byte messages, they
- /// are typically not used, since the inclusion of properties may affect the format.
- ///
- /// When the message is first created, and when ClearBody is called, the body of the
- /// message is in write-only mode. After the first call to Reset has been made, the
- /// message body is in read-only mode. After a message has been sent, the client that
- /// sent it can retain and modify it without affecting the message that has been sent.
- /// The same message object can be sent multiple times. When a message has been received,
- /// the provider has called Reset so that the message body is in read-only mode for the
- /// client.
- ///
- /// If ClearBody is called on a message in read-only mode, the message body is cleared and
- /// the message is in write-only mode.
- ///
- /// If a client attempts to read a message in write-only mode, a MessageNotReadableException
- /// is thrown.
- ///
- /// If a client attempts to write a message in read-only mode, a MessageNotWriteableException
- /// is thrown.
- /// </summary>
- public interface IBytesMessage : IMessage
- {
- byte[] Content { get; set; }
+ /// <summary>
+ ///
+ /// A BytesMessage object is used to send a message containing a stream of uninterpreted
+ /// bytes. It inherits from the Message interface and adds a bytes message body. The
+ /// receiver of the message supplies the interpretation of the bytes.
+ ///
+ /// This message type is for client encoding of existing message formats. If possible,
+ /// one of the other self-defining message types should be used instead.
+ ///
+ /// Although the NMS API allows the use of message properties with byte messages, they
+ /// are typically not used, since the inclusion of properties may affect the format.
+ ///
+ /// When the message is first created, and when ClearBody is called, the body of the
+ /// message is in write-only mode. After the first call to Reset has been made, the
+ /// message body is in read-only mode. After a message has been sent, the client that
+ /// sent it can retain and modify it without affecting the message that has been sent.
+ /// The same message object can be sent multiple times. When a message has been received,
+ /// the provider has called Reset so that the message body is in read-only mode for the
+ /// client.
+ ///
+ /// If ClearBody is called on a message in read-only mode, the message body is cleared and
+ /// the message is in write-only mode.
+ ///
+ /// If a client attempts to read a message in write-only mode, a MessageNotReadableException
+ /// is thrown.
+ ///
+ /// If a client attempts to write a message in read-only mode, a MessageNotWriteableException
+ /// is thrown.
+ /// </summary>
+ public interface IBytesMessage : IMessage
+ {
+ byte[] Content { get; set; }
- /// <value>
- /// Gets the number of bytes of the message body when the message is in read-only mode.
- /// The value returned can be used to allocate a byte array. The value returned is the
- /// entire length of the message body, regardless of where the pointer for reading the
- /// message is currently located.
- /// </value>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- long BodyLength { get; }
+ /// <value>
+ /// Gets the number of bytes of the message body when the message is in read-only mode.
+ /// The value returned can be used to allocate a byte array. The value returned is the
+ /// entire length of the message body, regardless of where the pointer for reading the
+ /// message is currently located.
+ /// </value>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ long BodyLength { get; }
- /// <summary>
- /// Reads a byte from the Message Stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Byte"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- byte ReadByte();
+ /// <summary>
+ /// Reads a byte from the Message Stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Byte"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ byte ReadByte();
- /// <summary>
- /// Writes a byte to the Message stream.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Byte"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteByte( byte value );
+ /// <summary>
+ /// Writes a byte to the Message stream.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Byte"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteByte(byte value);
- /// <summary>
- /// Reads a boolean from the Message Stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Boolean"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- bool ReadBoolean();
+ /// <summary>
+ /// Reads a boolean from the Message Stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ bool ReadBoolean();
- /// <summary>
- /// Write a one byte value to the message stream representing the boolean
- /// value passed.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Boolean"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteBoolean( bool value );
+ /// <summary>
+ /// Write a one byte value to the message stream representing the boolean
+ /// value passed.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Boolean"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteBoolean(bool value);
- /// <summary>
- /// Reads a char from the Message Stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Char"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- char ReadChar();
+ /// <summary>
+ /// Reads a char from the Message Stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Char"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ char ReadChar();
- /// <summary>
- /// Write a two byte value to the message stream representing the character
- /// value passed. High byte first.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Char"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteChar( char value );
+ /// <summary>
+ /// Write a two byte value to the message stream representing the character
+ /// value passed. High byte first.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Char"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteChar(char value);
- /// <summary>
- /// Reads a Short from the Message Stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Int16"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- short ReadInt16();
+ /// <summary>
+ /// Reads a Short from the Message Stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Int16"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ short ReadInt16();
- /// <summary>
- /// Write a two byte value to the message stream representing the short
- /// value passed. High byte first.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Int16"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteInt16( short value );
+ /// <summary>
+ /// Write a two byte value to the message stream representing the short
+ /// value passed. High byte first.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Int16"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteInt16(short value);
- /// <summary>
- /// Reads an int from the Message Stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Int32"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- int ReadInt32();
+ /// <summary>
+ /// Reads an int from the Message Stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Int32"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ int ReadInt32();
- /// <summary>
- /// Write a four byte value to the message stream representing the integer
- /// value passed. High byte first.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Int32"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteInt32( int value );
+ /// <summary>
+ /// Write a four byte value to the message stream representing the integer
+ /// value passed. High byte first.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteInt32(int value);
- /// <summary>
- /// Reads a long from the Message Stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Int64"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- long ReadInt64();
+ /// <summary>
+ /// Reads a long from the Message Stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Int64"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ long ReadInt64();
- /// <summary>
- /// Write a eight byte value to the message stream representing the long
- /// value passed. High byte first.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Int64"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteInt64( long value );
+ /// <summary>
+ /// Write a eight byte value to the message stream representing the long
+ /// value passed. High byte first.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Int64"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteInt64(long value);
- /// <summary>
- /// Reads a float from the Message Stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Single"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- float ReadSingle();
+ /// <summary>
+ /// Reads a float from the Message Stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Single"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ float ReadSingle();
- /// <summary>
- /// Write a four byte value to the message stream representing the float
- /// value passed. High byte first.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Single"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteSingle( float value );
+ /// <summary>
+ /// Write a four byte value to the message stream representing the float
+ /// value passed. High byte first.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Single"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteSingle(float value);
- /// <summary>
- /// Reads an double from the Message Stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.Double"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- double ReadDouble();
+ /// <summary>
+ /// Reads an double from the Message Stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.Double"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ double ReadDouble();
- /// <summary>
- /// Write a eight byte value to the message stream representing the double
- /// value passed. High byte first.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Double"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteDouble( double value );
+ /// <summary>
+ /// Write a eight byte value to the message stream representing the double
+ /// value passed. High byte first.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Double"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteDouble(double value);
- /// <summary>
- /// Reads a byte array from the bytes message stream.
- ///
- /// If the length of array value is less than the number of bytes remaining to
- /// be read from the stream, the array should be filled. A subsequent call reads
- /// the next increment, and so on.
- ///
- /// If the number of bytes remaining in the stream is less than the length of array
- /// value, the bytes should be read into the array. The return value of the total number
- /// of bytes read will be less than the length of the array, indicating that there are
- /// no more bytes left to be read from the stream. The next read of the stream returns -1.
- /// </summary>
- /// <param name="value">
- /// The byte array that will be used as a buffer to read into.
- /// </param>
- /// <returns>
- /// A <see cref="System.Int32"/>
- /// The number of bytes read into the passed byte array, or -1 if there are no more
- /// bytes left to be read from the stream.
- /// </returns>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- int ReadBytes( byte[] value );
+ /// <summary>
+ /// Reads a byte array from the bytes message stream.
+ ///
+ /// If the length of array value is less than the number of bytes remaining to
+ /// be read from the stream, the array should be filled. A subsequent call reads
+ /// the next increment, and so on.
+ ///
+ /// If the number of bytes remaining in the stream is less than the length of array
+ /// value, the bytes should be read into the array. The return value of the total number
+ /// of bytes read will be less than the length of the array, indicating that there are
+ /// no more bytes left to be read from the stream. The next read of the stream returns -1.
+ /// </summary>
+ /// <param name="value">
+ /// The byte array that will be used as a buffer to read into.
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Int32"/>
+ /// The number of bytes read into the passed byte array, or -1 if there are no more
+ /// bytes left to be read from the stream.
+ /// </returns>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ int ReadBytes(byte[] value);
- /// <summary>
- /// Reads a portion of the bytes message stream.
- ///
- /// If the length of array value is less than the number of bytes remaining to be
- /// read from the stream, the array should be filled. A subsequent call reads the
- /// next increment, and so on.
- ///
- /// If the number of bytes remaining in the stream is less than the length of array
- /// value, the bytes should be read into the array. The return value of the total
- /// number of bytes read will be less than the length of the array, indicating that
- /// there are no more bytes left to be read from the stream. The next read of the
- /// stream returns -1.
- ///
- /// If length is negative, or length is greater than the length of the array value,
- /// then an Exception is thrown. No bytes will be read from the stream for this
- /// exception case.
- /// </summary>
- /// <param name="value">
- /// The byte array that will be used as a buffer to read into.
- /// </param>
- /// <param name="length">
- /// The amount of bytes to read into the buffer.
- /// </param>
- /// <returns>
- /// A <see cref="System.Int32"/>
- /// The number of bytes read into the passed byte array, or -1 if there are no more
- /// bytes left to be read from the stream.
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- int ReadBytes( byte[] value, int length );
+ /// <summary>
+ /// Reads a portion of the bytes message stream.
+ ///
+ /// If the length of array value is less than the number of bytes remaining to be
+ /// read from the stream, the array should be filled. A subsequent call reads the
+ /// next increment, and so on.
+ ///
+ /// If the number of bytes remaining in the stream is less than the length of array
+ /// value, the bytes should be read into the array. The return value of the total
+ /// number of bytes read will be less than the length of the array, indicating that
+ /// there are no more bytes left to be read from the stream. The next read of the
+ /// stream returns -1.
+ ///
+ /// If length is negative, or length is greater than the length of the array value,
+ /// then an Exception is thrown. No bytes will be read from the stream for this
+ /// exception case.
+ /// </summary>
+ /// <param name="value">
+ /// The byte array that will be used as a buffer to read into.
+ /// </param>
+ /// <param name="length">
+ /// The amount of bytes to read into the buffer.
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Int32"/>
+ /// The number of bytes read into the passed byte array, or -1 if there are no more
+ /// bytes left to be read from the stream.
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ int ReadBytes(byte[] value, int length);
- /// <summary>
- /// Writes a byte array to the bytes message stream.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Byte"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteBytes( byte[] value );
+ /// <summary>
+ /// Writes a byte array to the bytes message stream.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Byte"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteBytes(byte[] value);
- /// <summary>
- /// Writes a portion of a byte array to the bytes message stream.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Byte"/>
- /// </param>
- /// <param name="offset">
- /// A <see cref="System.Int32"/>
- /// </param>
- /// <param name="length">
- /// A <see cref="System.Int32"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteBytes( byte[] value, int offset, int length );
+ /// <summary>
+ /// Writes a portion of a byte array to the bytes message stream.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Byte"/>
+ /// </param>
+ /// <param name="offset">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <param name="length">
+ /// A <see cref="System.Int32"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteBytes(byte[] value, int offset, int length);
- /// <summary>
- /// Reads a string that has been encoded using a modified UTF-8 format from the bytes
- /// message stream.
- /// </summary>
- /// <returns>
- /// A <see cref="System.String"/>
- /// </returns>
- /// <exception cref="Apache.NMS.MessageNotReadableException">
- /// Thrown when the Message is in write-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageEOFException">
- /// Thrown when an unexpected end of bytes has been reached.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- string ReadString();
+ /// <summary>
+ /// Reads a string that has been encoded using a modified UTF-8 format from the bytes
+ /// message stream.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
+ /// <exception cref="Apache.NMS.MessageNotReadableException">
+ /// Thrown when the Message is in write-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageEOFException">
+ /// Thrown when an unexpected end of bytes has been reached.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ string ReadString();
- /// <summary>
- /// Writes a string to the bytes message stream using UTF-8 encoding in a
- /// machine-independent manner.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.String"/>
- /// </param>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteString( string value );
+ /// <summary>
+ /// Writes a string to the bytes message stream using UTF-8 encoding in a
+ /// machine-independent manner.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteString(string value);
- /// <summary>
- /// Writes an object to the bytes message stream.
- ///
- /// This method works only for the objectified primitive object types
- /// (Int32, Double, Boolean ...), String objects, and byte arrays.
- /// </summary>
- /// <param name="value">
- /// A <see cref="System.Object"/>
- /// the object in the .NET programming language to be written; it must not be null
- /// </param>
- /// <exception cref="Apache.NMS.MessageFormatException">
- /// Thrown when the Message has an invalid format.
- /// </exception>
- /// <exception cref="Apache.NMS.MessageNotWriteableException">
- /// Thrown when the Message is in read-only mode.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void WriteObject( System.Object value );
+ /// <summary>
+ /// Writes an object to the bytes message stream.
+ ///
+ /// This method works only for the objectified primitive object types
+ /// (Int32, Double, Boolean ...), String objects, and byte arrays.
+ /// </summary>
+ /// <param name="value">
+ /// A <see cref="System.Object"/>
+ /// the object in the .NET programming language to be written; it must not be null
+ /// </param>
+ /// <exception cref="Apache.NMS.MessageFormatException">
+ /// Thrown when the Message has an invalid format.
+ /// </exception>
+ /// <exception cref="Apache.NMS.MessageNotWriteableException">
+ /// Thrown when the Message is in read-only mode.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void WriteObject(System.Object value);
- /// <summary>
- /// Puts the message body in read-only mode and repositions the stream of bytes to the beginning.
- /// </summary>
- /// <exception cref="Apache.NMS.MessageFormatException">
- /// Thrown when the Message has an invalid format.
- /// </exception>
- /// <exception cref="Apache.NMS.NMSException">
- /// Thrown when there is an unhandled exception thrown from the provider.
- /// </exception>
- void Reset();
-
- }
-}
-
+ /// <summary>
+ /// Puts the message body in read-only mode and repositions the stream of bytes to the beginning.
+ /// </summary>
+ /// <exception cref="Apache.NMS.MessageFormatException">
+ /// Thrown when the Message has an invalid format.
+ /// </exception>
+ /// <exception cref="Apache.NMS.NMSException">
+ /// Thrown when there is an unhandled exception thrown from the provider.
+ /// </exception>
+ void Reset();
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IConnection.cs b/src/nms-api/IConnection.cs
index d2cac6f..7d1f057 100644
--- a/src/nms-api/IConnection.cs
+++ b/src/nms-api/IConnection.cs
@@ -14,158 +14,159 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS
{
- /// <summary>
- /// The mode used to acknowledge messages after they are consumed
- /// </summary>
- public enum AcknowledgementMode
- {
- /// <summary>
- /// With this acknowledgment mode, the session will not
- /// acknowledge receipt of a message since the broker assumes
- /// successful receipt of a message after the onMessage handler
- /// has returned without error.
- /// </summary>
- AutoAcknowledge,
+ /// <summary>
+ /// The mode used to acknowledge messages after they are consumed
+ /// </summary>
+ public enum AcknowledgementMode
+ {
+ /// <summary>
+ /// With this acknowledgment mode, the session will not
+ /// acknowledge receipt of a message since the broker assumes
+ /// successful receipt of a message after the onMessage handler
+ /// has returned without error.
+ /// </summary>
+ AutoAcknowledge,
- /// <summary>
- /// With this acknowledgment mode, the session automatically
- /// acknowledges a client's receipt of a message either when
- /// the session has successfully returned from a call to receive
- /// or when the message listener the session has called to
- /// process the message successfully returns. Acknowlegements
- /// may be delayed in this mode to increase performance at
- /// the cost of the message being redelivered this client fails.
- /// </summary>
- DupsOkAcknowledge,
+ /// <summary>
+ /// With this acknowledgment mode, the session automatically
+ /// acknowledges a client's receipt of a message either when
+ /// the session has successfully returned from a call to receive
+ /// or when the message listener the session has called to
+ /// process the message successfully returns. Acknowlegements
+ /// may be delayed in this mode to increase performance at
+ /// the cost of the message being redelivered this client fails.
+ /// </summary>
+ DupsOkAcknowledge,
- /// <summary>
- /// With this acknowledgment mode, the client acknowledges a
- /// consumed message by calling the message's acknowledge method.
- /// This acknowledgement acknowledges the given message and all
- /// unacknowedged messages that have preceeded it for the session
- /// in which the message was delivered.
- /// </summary>
- ClientAcknowledge,
+ /// <summary>
+ /// With this acknowledgment mode, the client acknowledges a
+ /// consumed message by calling the message's acknowledge method.
+ /// This acknowledgement acknowledges the given message and all
+ /// unacknowedged messages that have preceeded it for the session
+ /// in which the message was delivered.
+ /// </summary>
+ ClientAcknowledge,
- /// <summary>
- /// Messages will be consumed when the transaction commits.
- /// </summary>
- Transactional,
+ /// <summary>
+ /// Messages will be consumed when the transaction commits.
+ /// </summary>
+ Transactional,
- /// <summary>
- /// With this acknowledgment mode, the client acknowledges a
- /// consumed message by calling the message's acknowledge method.
- /// This acknowledgement mode allows the client to acknowledge a
- /// single message. This mode is not required to be supported by
- /// all NMS providers, however the provider should throw an appropriate
- /// exception to indicate that the mode is unsupported.
- /// </summary>
- IndividualAcknowledge
- }
+ /// <summary>
+ /// With this acknowledgment mode, the client acknowledges a
+ /// consumed message by calling the message's acknowledge method.
+ /// This acknowledgement mode allows the client to acknowledge a
+ /// single message. This mode is not required to be supported by
+ /// all NMS providers, however the provider should throw an appropriate
+ /// exception to indicate that the mode is unsupported.
+ /// </summary>
+ IndividualAcknowledge
+ }
- /// <summary>
- /// A delegate that can receive transport level exceptions.
- /// </summary>
- public delegate void ExceptionListener(Exception exception);
+ /// <summary>
+ /// A delegate that can receive transport level exceptions.
+ /// </summary>
+ public delegate void ExceptionListener(Exception exception);
- /// <summary>
- /// A delegate that is used by Fault tolerant NMS Implementation to notify their
- /// clients that the Connection is not currently active to due some error.
- /// </summary>
- public delegate void ConnectionInterruptedListener();
+ /// <summary>
+ /// A delegate that is used by Fault tolerant NMS Implementation to notify their
+ /// clients that the Connection is not currently active to due some error.
+ /// </summary>
+ public delegate void ConnectionInterruptedListener();
- /// <summary>
- /// A delegate that is used by Fault tolerant NMS Implementation to notify their
- /// clients that the Connection that was interrupted has now been restored.
- /// </summary>
- public delegate void ConnectionResumedListener();
+ /// <summary>
+ /// A delegate that is used by Fault tolerant NMS Implementation to notify their
+ /// clients that the Connection that was interrupted has now been restored.
+ /// </summary>
+ public delegate void ConnectionResumedListener();
- /// <summary>
- /// Represents a connection with a message broker
- /// </summary>
- public interface IConnection : IDisposable, IStartable, IStoppable
- {
- /// <summary>
- /// Creates a new session to work on this connection
- /// </summary>
- ISession CreateSession();
+ /// <summary>
+ /// Represents a connection with a message broker
+ /// </summary>
+ public interface IConnection : IDisposable, IStartable, IStoppable
+ {
+ /// <summary>
+ /// Creates a new session to work on this connection
+ /// </summary>
+ ISession CreateSession();
- /// <summary>
- /// Creates a new session to work on this connection
- /// </summary>
- ISession CreateSession(AcknowledgementMode acknowledgementMode);
+ /// <summary>
+ /// Creates a new session to work on this connection
+ /// </summary>
+ ISession CreateSession(AcknowledgementMode acknowledgementMode);
- /// <summary>
- /// Closes the connection.
- /// </summary>
- void Close();
+ /// <summary>
+ /// Closes the connection.
+ /// </summary>
+ void Close();
- /// <summary>
- /// An asynchronous listener which can be notified if an error occurs
- /// </summary>
- event ExceptionListener ExceptionListener;
+ /// <summary>
+ /// An asynchronous listener which can be notified if an error occurs
+ /// </summary>
+ event ExceptionListener ExceptionListener;
- /// <summary>
- /// An asynchronous listener that is notified when a Fault tolerant connection
- /// has been interrupted.
- /// </summary>
- event ConnectionInterruptedListener ConnectionInterruptedListener;
+ /// <summary>
+ /// An asynchronous listener that is notified when a Fault tolerant connection
+ /// has been interrupted.
+ /// </summary>
+ event ConnectionInterruptedListener ConnectionInterruptedListener;
- /// <summary>
- /// An asynchronous listener that is notified when a Fault tolerant connection
- /// has been resumed.
- /// </summary>
- event ConnectionResumedListener ConnectionResumedListener;
+ /// <summary>
+ /// An asynchronous listener that is notified when a Fault tolerant connection
+ /// has been resumed.
+ /// </summary>
+ event ConnectionResumedListener ConnectionResumedListener;
- /// <summary>
- /// A Delegate that is called each time a Message is dispatched to allow the client to do
- /// any necessary transformations on the received message before it is delivered. The
- /// Connection sets the provided delegate instance on each Session it creates which then
- /// passes that along to the Consumers it creates.
- /// </summary>
- ConsumerTransformerDelegate ConsumerTransformer { get; set; }
+ /// <summary>
+ /// A Delegate that is called each time a Message is dispatched to allow the client to do
+ /// any necessary transformations on the received message before it is delivered. The
+ /// Connection sets the provided delegate instance on each Session it creates which then
+ /// passes that along to the Consumers it creates.
+ /// </summary>
+ ConsumerTransformerDelegate ConsumerTransformer { get; set; }
- /// <summary>
- /// A delegate that is called each time a Message is sent from this Producer which allows
- /// the application to perform any needed transformations on the Message before it is sent.
- /// The Connection sets the provided delegate instance on each Session it creates which then
- /// passes that along to the Producer it creates.
- /// </summary>
- ProducerTransformerDelegate ProducerTransformer { get; set; }
+ /// <summary>
+ /// A delegate that is called each time a Message is sent from this Producer which allows
+ /// the application to perform any needed transformations on the Message before it is sent.
+ /// The Connection sets the provided delegate instance on each Session it creates which then
+ /// passes that along to the Producer it creates.
+ /// </summary>
+ ProducerTransformerDelegate ProducerTransformer { get; set; }
- #region Attributes
+ #region Attributes
- /// <summary>
- /// The default timeout for network requests.
- /// </summary>
- TimeSpan RequestTimeout { get; set; }
+ /// <summary>
+ /// The default timeout for network requests.
+ /// </summary>
+ TimeSpan RequestTimeout { get; set; }
- /// <summary>
- /// The default acknowledgement mode
- /// </summary>
- AcknowledgementMode AcknowledgementMode { get; set; }
+ /// <summary>
+ /// The default acknowledgement mode
+ /// </summary>
+ AcknowledgementMode AcknowledgementMode { get; set; }
- /// <summary>
- /// Sets the unique clienet ID for this connection before Start() or returns the
- /// unique client ID after the connection has started
- /// </summary>
- string ClientId { get; set; }
+ /// <summary>
+ /// Sets the unique clienet ID for this connection before Start() or returns the
+ /// unique client ID after the connection has started
+ /// </summary>
+ string ClientId { get; set; }
- /// <summary>
- /// Get/or set the redelivery policy for this connection.
- /// </summary>
- IRedeliveryPolicy RedeliveryPolicy { get; set; }
+ /// <summary>
+ /// Get/or set the redelivery policy for this connection.
+ /// </summary>
+ IRedeliveryPolicy RedeliveryPolicy { get; set; }
- /// <summary>
- /// Gets the Meta Data for the NMS Connection instance.
- /// </summary>
- IConnectionMetaData MetaData{ get; }
+ /// <summary>
+ /// Gets the Meta Data for the NMS Connection instance.
+ /// </summary>
+ IConnectionMetaData MetaData { get; }
- #endregion
+ #endregion
#region Connection Management methods
@@ -183,5 +184,5 @@
void PurgeTempDestinations();
#endregion
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IConnectionFactory.cs b/src/nms-api/IConnectionFactory.cs
index dc7fd28..c77e8e7 100644
--- a/src/nms-api/IConnectionFactory.cs
+++ b/src/nms-api/IConnectionFactory.cs
@@ -19,69 +19,69 @@
namespace Apache.NMS
{
- /// <summary>
- /// A Factory of IConnection objects
- /// </summary>
- public interface IConnectionFactory
- {
- /// <summary>
- /// Creates a new connection
- /// </summary>
- IConnection CreateConnection();
+ /// <summary>
+ /// A Factory of IConnection objects
+ /// </summary>
+ public interface IConnectionFactory
+ {
+ /// <summary>
+ /// Creates a new connection
+ /// </summary>
+ IConnection CreateConnection();
- /// <summary>
- /// Creates a new connection with the given user name and password
- /// </summary>
- IConnection CreateConnection(string userName, string password);
-
- /// <summary>
- /// Creates a new context
- /// </summary>
- INMSContext CreateContext();
-
- /// <summary>
- /// Creates a new context with the given acknowledgement mode.
- /// </summary>
- INMSContext CreateContext(AcknowledgementMode acknowledgementMode);
+ /// <summary>
+ /// Creates a new connection with the given user name and password
+ /// </summary>
+ IConnection CreateConnection(string userName, string password);
- /// <summary>
- /// Creates a new context with the given user name and password
- /// </summary>
- INMSContext CreateContext(string userName, string password);
+ /// <summary>
+ /// Creates a new context
+ /// </summary>
+ INMSContext CreateContext();
- /// <summary>
- /// Creates a new context with the given user name, password and acknowledgement mode
- /// </summary>
- INMSContext CreateContext(string userName, string password, AcknowledgementMode acknowledgementMode);
-
+ /// <summary>
+ /// Creates a new context with the given acknowledgement mode.
+ /// </summary>
+ INMSContext CreateContext(AcknowledgementMode acknowledgementMode);
- /// <summary>
- /// Get/or set the broker Uri.
- /// </summary>
- Uri BrokerUri { get; set; }
+ /// <summary>
+ /// Creates a new context with the given user name and password
+ /// </summary>
+ INMSContext CreateContext(string userName, string password);
- /// <summary>
- /// Get/or set the redelivery policy that new IConnection objects are
- /// assigned upon creation.
- /// </summary>
- IRedeliveryPolicy RedeliveryPolicy { get; set; }
+ /// <summary>
+ /// Creates a new context with the given user name, password and acknowledgement mode
+ /// </summary>
+ INMSContext CreateContext(string userName, string password, AcknowledgementMode acknowledgementMode);
- /// <summary>
- /// A Delegate that is called each time a Message is dispatched to allow the client to do
- /// any necessary transformations on the received message before it is delivered. The
- /// ConnectionFactory sets the provided delegate instance on each Connection instance that
- /// is created from this factory, each connection in turn passes the delegate along to each
- /// Session it creates which then passes that along to the Consumers it creates.
- /// </summary>
- ConsumerTransformerDelegate ConsumerTransformer { get; set; }
- /// <summary>
- /// A delegate that is called each time a Message is sent from this Producer which allows
- /// the application to perform any needed transformations on the Message before it is sent.
- /// The ConnectionFactory sets the provided delegate instance on each Connection instance that
- /// is created from this factory, each connection in turn passes the delegate along to each
- /// Session it creates which then passes that along to the Producers it creates.
- /// </summary>
- ProducerTransformerDelegate ProducerTransformer { get; set; }
- }
-}
+ /// <summary>
+ /// Get/or set the broker Uri.
+ /// </summary>
+ Uri BrokerUri { get; set; }
+
+ /// <summary>
+ /// Get/or set the redelivery policy that new IConnection objects are
+ /// assigned upon creation.
+ /// </summary>
+ IRedeliveryPolicy RedeliveryPolicy { get; set; }
+
+ /// <summary>
+ /// A Delegate that is called each time a Message is dispatched to allow the client to do
+ /// any necessary transformations on the received message before it is delivered. The
+ /// ConnectionFactory sets the provided delegate instance on each Connection instance that
+ /// is created from this factory, each connection in turn passes the delegate along to each
+ /// Session it creates which then passes that along to the Consumers it creates.
+ /// </summary>
+ ConsumerTransformerDelegate ConsumerTransformer { get; set; }
+
+ /// <summary>
+ /// A delegate that is called each time a Message is sent from this Producer which allows
+ /// the application to perform any needed transformations on the Message before it is sent.
+ /// The ConnectionFactory sets the provided delegate instance on each Connection instance that
+ /// is created from this factory, each connection in turn passes the delegate along to each
+ /// Session it creates which then passes that along to the Producers it creates.
+ /// </summary>
+ ProducerTransformerDelegate ProducerTransformer { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IConnectionMetaData.cs b/src/nms-api/IConnectionMetaData.cs
index 773aa63..167fd05 100644
--- a/src/nms-api/IConnectionMetaData.cs
+++ b/src/nms-api/IConnectionMetaData.cs
@@ -25,41 +25,41 @@
/// <value>
/// Get the Major version number of the NMS API this Provider supports.
/// </value>
- int NMSMajorVersion{ get; }
-
+ int NMSMajorVersion { get; }
+
/// <value>
/// Get the Minor version number of the NMS API this Provider supports.
/// </value>
- int NMSMinorVersion{ get; }
-
+ int NMSMinorVersion { get; }
+
/// <value>
/// Get the name of this NMS Provider.
/// </value>
- string NMSProviderName{ get; }
-
+ string NMSProviderName { get; }
+
/// <value>
/// Gets a formatted string detailing the NMS API version this Provider supports.
/// </value>
- string NMSVersion{ get; }
-
+ string NMSVersion { get; }
+
/// <value>
/// Gets a String array of all the NMSX property names this NMS Provider supports.
/// </value>
- string[] NMSXPropertyNames{ get; }
-
+ string[] NMSXPropertyNames { get; }
+
/// <value>
/// Gets the Providers Major version number.
/// </value>
- int ProviderMajorVersion{ get; }
+ int ProviderMajorVersion { get; }
/// <value>
/// Gets the Providers Minor version number.
/// </value>
- int ProviderMinorVersion{ get; }
+ int ProviderMinorVersion { get; }
/// <value>
/// Gets a formatted string detailing the version of this NMS Provider.
/// </value>
- string ProviderVersion{ get; }
+ string ProviderVersion { get; }
}
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/IDestination.cs b/src/nms-api/IDestination.cs
index 7f960c4..da5caca 100644
--- a/src/nms-api/IDestination.cs
+++ b/src/nms-api/IDestination.cs
@@ -14,30 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// Represents the type of the destination such as a queue or topic.
- /// </summary>
- public enum DestinationType
- {
- Queue,
- Topic,
- TemporaryQueue,
- TemporaryTopic
- }
+ /// <summary>
+ /// Represents the type of the destination such as a queue or topic.
+ /// </summary>
+ public enum DestinationType
+ {
+ Queue,
+ Topic,
+ TemporaryQueue,
+ TemporaryTopic
+ }
- /// <summary>
- /// A base interface for destinations such as queues or topics
- /// </summary>
- public interface IDestination : System.IDisposable
- {
- DestinationType DestinationType { get; }
-
- bool IsTopic { get; }
- bool IsQueue { get; }
- bool IsTemporary { get; }
- }
-}
+ /// <summary>
+ /// A base interface for destinations such as queues or topics
+ /// </summary>
+ public interface IDestination : System.IDisposable
+ {
+ DestinationType DestinationType { get; }
-
+ bool IsTopic { get; }
+ bool IsQueue { get; }
+ bool IsTemporary { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IMapMessage.cs b/src/nms-api/IMapMessage.cs
index 591e26a..2fe1956 100644
--- a/src/nms-api/IMapMessage.cs
+++ b/src/nms-api/IMapMessage.cs
@@ -14,15 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
-
- /// <summary>
- /// Represents a Map message which contains key and value pairs which are
- /// of primitive types
- /// </summary>
- public interface IMapMessage : IMessage
- {
- IPrimitiveMap Body { get; }
- }
-}
+ /// <summary>
+ /// Represents a Map message which contains key and value pairs which are
+ /// of primitive types
+ /// </summary>
+ public interface IMapMessage : IMessage
+ {
+ IPrimitiveMap Body { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IMessage.cs b/src/nms-api/IMessage.cs
index fbb1207..0e04c63 100644
--- a/src/nms-api/IMessage.cs
+++ b/src/nms-api/IMessage.cs
@@ -14,104 +14,105 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS
{
- /// <summary>
- /// Represents a message either to be sent to a message broker or received from a message broker.
- /// </summary>
- public interface IMessage
- {
- /// <summary>
- /// If using client acknowledgement mode on the session, then this method will acknowledge that the
- /// message has been processed correctly.
- /// </summary>
- void Acknowledge();
+ /// <summary>
+ /// Represents a message either to be sent to a message broker or received from a message broker.
+ /// </summary>
+ public interface IMessage
+ {
+ /// <summary>
+ /// If using client acknowledgement mode on the session, then this method will acknowledge that the
+ /// message has been processed correctly.
+ /// </summary>
+ void Acknowledge();
- /// <summary>
- /// Clears out the message body. Clearing a message's body does not clear its header
- /// values or property entries.
- ///
- /// If this message body was read-only, calling this method leaves the message body in
- /// the same state as an empty body in a newly created message.
- /// </summary>
- void ClearBody();
+ /// <summary>
+ /// Clears out the message body. Clearing a message's body does not clear its header
+ /// values or property entries.
+ ///
+ /// If this message body was read-only, calling this method leaves the message body in
+ /// the same state as an empty body in a newly created message.
+ /// </summary>
+ void ClearBody();
- /// <summary>
- /// Clears a message's properties.
- ///
- /// The message's header fields and body are not cleared.
- /// </summary>
- void ClearProperties();
+ /// <summary>
+ /// Clears a message's properties.
+ ///
+ /// The message's header fields and body are not cleared.
+ /// </summary>
+ void ClearProperties();
- /// <summary>
- /// Provides access to the message properties (headers).
- /// </summary>
- IPrimitiveMap Properties { get; }
+ /// <summary>
+ /// Provides access to the message properties (headers).
+ /// </summary>
+ IPrimitiveMap Properties { get; }
- /// <summary>
- /// The correlation ID used to correlate messages from conversations or long running business processes.
- /// </summary>
- string NMSCorrelationID { get; set; }
+ /// <summary>
+ /// The correlation ID used to correlate messages from conversations or long running business processes.
+ /// </summary>
+ string NMSCorrelationID { get; set; }
- /// <summary>
- /// The destination of the message. This property is set by the IMessageProducer.
- /// </summary>
- IDestination NMSDestination { get; set; }
+ /// <summary>
+ /// The destination of the message. This property is set by the IMessageProducer.
+ /// </summary>
+ IDestination NMSDestination { get; set; }
- /// <summary>
- /// The amount of time for which this message is valid. Zero if this message does not expire.
- /// </summary>
- TimeSpan NMSTimeToLive { get; set; }
+ /// <summary>
+ /// The amount of time for which this message is valid. Zero if this message does not expire.
+ /// </summary>
+ TimeSpan NMSTimeToLive { get; set; }
- /// <summary>
- /// The message ID which is set by the provider.
- /// </summary>
- string NMSMessageId { get; set; }
+ /// <summary>
+ /// The message ID which is set by the provider.
+ /// </summary>
+ string NMSMessageId { get; set; }
- /// <summary>
- /// Whether or not this message is persistent.
- /// </summary>
- MsgDeliveryMode NMSDeliveryMode { get; set; }
+ /// <summary>
+ /// Whether or not this message is persistent.
+ /// </summary>
+ MsgDeliveryMode NMSDeliveryMode { get; set; }
- /// <summary>
- /// The Priority of this message.
- /// </summary>
- MsgPriority NMSPriority { get; set; }
+ /// <summary>
+ /// The Priority of this message.
+ /// </summary>
+ MsgPriority NMSPriority { get; set; }
- /// <summary>
- /// Returns true if this message has been redelivered to this or another consumer before being acknowledged successfully.
- /// </summary>
- bool NMSRedelivered { get; set; }
+ /// <summary>
+ /// Returns true if this message has been redelivered to this or another consumer before being acknowledged successfully.
+ /// </summary>
+ bool NMSRedelivered { get; set; }
- /// <summary>
- /// The destination that the consumer of this message should send replies to
- /// </summary>
- IDestination NMSReplyTo { get; set; }
+ /// <summary>
+ /// The destination that the consumer of this message should send replies to
+ /// </summary>
+ IDestination NMSReplyTo { get; set; }
- /// <summary>
- /// The timestamp of when the message was pubished in UTC time. If the publisher disables setting
- /// the timestamp on the message, the time will be set to the start of the UNIX epoc (1970-01-01 00:00:00).
- /// </summary>
- DateTime NMSTimestamp { get; set; }
+ /// <summary>
+ /// The timestamp of when the message was pubished in UTC time. If the publisher disables setting
+ /// the timestamp on the message, the time will be set to the start of the UNIX epoc (1970-01-01 00:00:00).
+ /// </summary>
+ DateTime NMSTimestamp { get; set; }
- /// <summary>
- /// The type name of this message.
- /// </summary>
- string NMSType { get; set; }
-
- /// <summary>
- /// When a message is sent, the NMSDeliveryTime header field is
+ /// <summary>
+ /// The type name of this message.
+ /// </summary>
+ string NMSType { get; set; }
+
+ /// <summary>
+ /// When a message is sent, the NMSDeliveryTime header field is
/// left unassigned. After completion of the send or
/// publish method, it holds the delivery time of the message.
/// This is the the difference, measured in milliseconds,
/// between the delivery time and midnight, January 1, 1970 UTC.
///
- /// A message's delivery time is the earliest time when a JMS provider may
- /// deliver the message to a consumer. The provider must not deliver messages
- /// before the delivery time has been reached.
- /// <summary>
- DateTime NMSDeliveryTime { get; set; }
- }
-}
+ /// A message's delivery time is the earliest time when a JMS provider may
+ /// deliver the message to a consumer. The provider must not deliver messages
+ /// before the delivery time has been reached.
+ /// <summary>
+ DateTime NMSDeliveryTime { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IMessageConsumer.cs b/src/nms-api/IMessageConsumer.cs
index 3b17318..25349b6 100644
--- a/src/nms-api/IMessageConsumer.cs
+++ b/src/nms-api/IMessageConsumer.cs
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
/// <summary>
@@ -75,8 +76,5 @@
/// any necessary transformations on the received message before it is delivered.
/// </summary>
ConsumerTransformerDelegate ConsumerTransformer { get; set; }
-
}
-}
-
-
+}
\ No newline at end of file
diff --git a/src/nms-api/IMessageProducer.cs b/src/nms-api/IMessageProducer.cs
index d3b6e74..364048b 100644
--- a/src/nms-api/IMessageProducer.cs
+++ b/src/nms-api/IMessageProducer.cs
@@ -14,49 +14,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.Threading.Tasks;
namespace Apache.NMS
{
- public delegate void CompletionListener(IMessage message, Exception e);
+ public delegate void CompletionListener(IMessage message, Exception e);
- /// <summary>
- /// A delegate that a client can register that will be called each time a Producer's send method is
- /// called to allow the client to Transform a sent message from one type to another, StreamMessage to
- /// TextMessage, ObjectMessage to TextMessage containing XML, etc. This allows a client to create a
- /// producer that will automatically transform a message to a type that some receiving client is
- /// capable of processing or adding additional information to a sent message such as additional message
- /// headers, etc. For messages that do not need to be processed the client should return null from
- /// this method, in this case the original message will be sent.
- /// </summary>
- public delegate IMessage ProducerTransformerDelegate(ISession session, IMessageProducer producer, IMessage message);
+ /// <summary>
+ /// A delegate that a client can register that will be called each time a Producer's send method is
+ /// called to allow the client to Transform a sent message from one type to another, StreamMessage to
+ /// TextMessage, ObjectMessage to TextMessage containing XML, etc. This allows a client to create a
+ /// producer that will automatically transform a message to a type that some receiving client is
+ /// capable of processing or adding additional information to a sent message such as additional message
+ /// headers, etc. For messages that do not need to be processed the client should return null from
+ /// this method, in this case the original message will be sent.
+ /// </summary>
+ public delegate IMessage ProducerTransformerDelegate(ISession session, IMessageProducer producer, IMessage message);
- /// <summary>
- /// An object capable of sending messages to some destination
- /// </summary>
- public interface IMessageProducer : System.IDisposable
- {
- /// <summary>
- /// Sends the message to the default destination for this producer
- /// </summary>
- void Send(IMessage message);
+ /// <summary>
+ /// An object capable of sending messages to some destination
+ /// </summary>
+ public interface IMessageProducer : System.IDisposable
+ {
+ /// <summary>
+ /// Sends the message to the default destination for this producer
+ /// </summary>
+ void Send(IMessage message);
- /// <summary>
- /// Sends the message to the default destination with the explicit QoS configuration
- /// </summary>
- void Send(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive);
+ /// <summary>
+ /// Sends the message to the default destination with the explicit QoS configuration
+ /// </summary>
+ void Send(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive);
- /// <summary>
- /// Sends the message to the given destination
- /// </summary>
- void Send(IDestination destination, IMessage message);
+ /// <summary>
+ /// Sends the message to the given destination
+ /// </summary>
+ void Send(IDestination destination, IMessage message);
- /// <summary>
- /// Sends the message to the given destination with the explicit QoS configuration
- /// </summary>
- void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive);
+ /// <summary>
+ /// Sends the message to the given destination with the explicit QoS configuration
+ /// </summary>
+ void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority,
+ TimeSpan timeToLive);
/// <summary>
/// Sends the message to the default destination for this producer
@@ -66,7 +68,8 @@
/// <summary>
/// Sends the message to the default destination with the explicit QoS configuration
/// </summary>
- void Send(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive, CompletionListener completionListener);
+ void Send(IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive,
+ CompletionListener completionListener);
/// <summary>
/// Sends the message to the given destination
@@ -76,7 +79,8 @@
/// <summary>
/// Sends the message to the given destination with the explicit QoS configuration
/// </summary>
- void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive, CompletionListener completionListener);
+ void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority,
+ TimeSpan timeToLive, CompletionListener completionListener);
/// <summary>
/// Sends the message to the default destination for this producer
@@ -96,76 +100,77 @@
/// <summary>
/// Sends the message to the given destination with the explicit QoS configuration
/// </summary>
- Task SendAsync(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive);
+ Task SendAsync(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority,
+ TimeSpan timeToLive);
- /// <summary>
- /// Close the producer.
- /// </summary>
- void Close();
+ /// <summary>
+ /// Close the producer.
+ /// </summary>
+ void Close();
- /// <summary>
- /// A delegate that is called each time a Message is sent from this Producer which allows
- /// the application to perform any needed transformations on the Message before it is sent.
- /// </summary>
- ProducerTransformerDelegate ProducerTransformer { get; set; }
+ /// <summary>
+ /// A delegate that is called each time a Message is sent from this Producer which allows
+ /// the application to perform any needed transformations on the Message before it is sent.
+ /// </summary>
+ ProducerTransformerDelegate ProducerTransformer { get; set; }
- MsgDeliveryMode DeliveryMode { get; set; }
+ MsgDeliveryMode DeliveryMode { get; set; }
- TimeSpan TimeToLive { get; set; }
+ TimeSpan TimeToLive { get; set; }
- TimeSpan RequestTimeout { get; set; }
+ TimeSpan RequestTimeout { get; set; }
- MsgPriority Priority { get; set; }
+ MsgPriority Priority { get; set; }
- bool DisableMessageID { get; set; }
+ bool DisableMessageID { get; set; }
- bool DisableMessageTimestamp { get; set; }
-
- TimeSpan DeliveryDelay { get; set; }
+ bool DisableMessageTimestamp { get; set; }
- #region Factory methods to create messages
+ TimeSpan DeliveryDelay { get; set; }
- /// <summary>
- /// Creates a new message with an empty body
- /// </summary>
- IMessage CreateMessage();
+ #region Factory methods to create messages
- /// <summary>
- /// Creates a new text message with an empty body
- /// </summary>
- ITextMessage CreateTextMessage();
+ /// <summary>
+ /// Creates a new message with an empty body
+ /// </summary>
+ IMessage CreateMessage();
- /// <summary>
- /// Creates a new text message with the given body
- /// </summary>
- ITextMessage CreateTextMessage(string text);
+ /// <summary>
+ /// Creates a new text message with an empty body
+ /// </summary>
+ ITextMessage CreateTextMessage();
- /// <summary>
- /// Creates a new Map message which contains primitive key and value pairs
- /// </summary>
- IMapMessage CreateMapMessage();
+ /// <summary>
+ /// Creates a new text message with the given body
+ /// </summary>
+ ITextMessage CreateTextMessage(string text);
- /// <summary>
- /// Creates a new Object message containing the given .NET object as the body
- /// </summary>
- IObjectMessage CreateObjectMessage(object body);
+ /// <summary>
+ /// Creates a new Map message which contains primitive key and value pairs
+ /// </summary>
+ IMapMessage CreateMapMessage();
- /// <summary>
- /// Creates a new binary message
- /// </summary>
- IBytesMessage CreateBytesMessage();
+ /// <summary>
+ /// Creates a new Object message containing the given .NET object as the body
+ /// </summary>
+ IObjectMessage CreateObjectMessage(object body);
- /// <summary>
- /// Creates a new binary message with the given body
- /// </summary>
- IBytesMessage CreateBytesMessage(byte[] body);
+ /// <summary>
+ /// Creates a new binary message
+ /// </summary>
+ IBytesMessage CreateBytesMessage();
- /// <summary>
- /// Creates a new stream message
- /// </summary>
- IStreamMessage CreateStreamMessage();
+ /// <summary>
+ /// Creates a new binary message with the given body
+ /// </summary>
+ IBytesMessage CreateBytesMessage(byte[] body);
- #endregion
- }
-}
+ /// <summary>
+ /// Creates a new stream message
+ /// </summary>
+ IStreamMessage CreateStreamMessage();
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/INMSConsumer.cs b/src/nms-api/INMSConsumer.cs
index f084db9..f981ac3 100644
--- a/src/nms-api/INMSConsumer.cs
+++ b/src/nms-api/INMSConsumer.cs
@@ -14,64 +14,63 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS
{
+ /// <summary>
+ /// An object capable of sending messages to some destination
+ /// </summary>
+ public interface INMSConsumer : System.IDisposable
+ {
+ string MessageSelector { get; }
- /// <summary>
- /// An object capable of sending messages to some destination
- /// </summary>
- public interface INMSConsumer : System.IDisposable
- {
+ /// <summary>
+ /// Waits until a message is available and returns it
+ /// </summary>
+ IMessage Receive();
- string MessageSelector { get; }
+ /// <summary>
+ /// If a message is available within the timeout duration it is returned otherwise this method returns null
+ /// </summary>
+ IMessage Receive(TimeSpan timeout);
- /// <summary>
- /// Waits until a message is available and returns it
- /// </summary>
- IMessage Receive();
-
- /// <summary>
- /// If a message is available within the timeout duration it is returned otherwise this method returns null
- /// </summary>
- IMessage Receive(TimeSpan timeout);
-
- /// <summary>
- /// Receives the next message if one is immediately available for delivery on the client side
- /// otherwise this method returns null. It is never an error for this method to return null, the
- /// time of Message availability varies so your client cannot rely on this method to receive a
- /// message immediately after one has been sent.
- /// </summary>
- IMessage ReceiveNoWait();
+ /// <summary>
+ /// Receives the next message if one is immediately available for delivery on the client side
+ /// otherwise this method returns null. It is never an error for this method to return null, the
+ /// time of Message availability varies so your client cannot rely on this method to receive a
+ /// message immediately after one has been sent.
+ /// </summary>
+ IMessage ReceiveNoWait();
- T ReceiveBody<T>();
-
- T ReceiveBody<T>(TimeSpan timeout);
+ T ReceiveBody<T>();
- T ReceiveBodyNoWait<T>();
-
-
- /// <summary>
- /// An asynchronous listener which can be used to consume messages asynchronously
- /// </summary>
- event MessageListener Listener;
+ T ReceiveBody<T>(TimeSpan timeout);
- /// <summary>
- /// Closes the message consumer.
- /// </summary>
- /// <remarks>
- /// Clients should close message consumers when they are not needed.
- /// This call blocks until a receive or message listener in progress has completed.
- /// A blocked message consumer receive call returns null when this message consumer is closed.
- /// </remarks>
- void Close();
+ T ReceiveBodyNoWait<T>();
- /// <summary>
- /// A Delegate that is called each time a Message is dispatched to allow the client to do
- /// any necessary transformations on the received message before it is delivered.
- /// </summary>
- ConsumerTransformerDelegate ConsumerTransformer { get; set; }
- }
-}
+
+ /// <summary>
+ /// An asynchronous listener which can be used to consume messages asynchronously
+ /// </summary>
+ event MessageListener Listener;
+
+ /// <summary>
+ /// Closes the message consumer.
+ /// </summary>
+ /// <remarks>
+ /// Clients should close message consumers when they are not needed.
+ /// This call blocks until a receive or message listener in progress has completed.
+ /// A blocked message consumer receive call returns null when this message consumer is closed.
+ /// </remarks>
+ void Close();
+
+ /// <summary>
+ /// A Delegate that is called each time a Message is dispatched to allow the client to do
+ /// any necessary transformations on the received message before it is delivered.
+ /// </summary>
+ ConsumerTransformerDelegate ConsumerTransformer { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/INMSContext.cs b/src/nms-api/INMSContext.cs
index 4aada4f..535793b 100644
--- a/src/nms-api/INMSContext.cs
+++ b/src/nms-api/INMSContext.cs
@@ -14,47 +14,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS
{
+ /// <summary>
+ /// A INMSContext is the main interface in the simplified NMS API
+ /// introduced for NMS 2.0. This combines in a single object the functionality of
+ /// two separate objects from the NMS 1.x API: an IConnection and an ISession.
+ ///
+ /// This is comparable to JMS 2.0 API that extended JMS 1.x API
+ /// </summary>
+ public interface INMSContext : IDisposable, IStartable, IStoppable
+ {
+ INMSContext CreateContext(AcknowledgementMode acknowledgementMode);
- /// <summary>
- /// A INMSContext is the main interface in the simplified NMS API
- /// introduced for NMS 2.0. This combines in a single object the functionality of
- /// two separate objects from the NMS 1.x API: an IConnection and an ISession.
- ///
- /// This is comparable to JMS 2.0 API that extended JMS 1.x API
- /// </summary>
- public interface INMSContext : IDisposable, IStartable, IStoppable
- {
+ /// <summary>
+ /// Creates a producer of messages
+ /// </summary>
+ INMSProducer CreateProducer();
- INMSContext CreateContext(AcknowledgementMode acknowledgementMode);
-
- /// <summary>
- /// Creates a producer of messages
- /// </summary>
- INMSProducer CreateProducer();
-
-
- /// <summary>
- /// Creates a consumer of messages on a given destination
- /// </summary>
- INMSConsumer CreateConsumer(IDestination destination);
- /// <summary>
- /// Creates a consumer of messages on a given destination with a selector
- /// </summary>
- INMSConsumer CreateConsumer(IDestination destination, string selector);
+ /// <summary>
+ /// Creates a consumer of messages on a given destination
+ /// </summary>
+ INMSConsumer CreateConsumer(IDestination destination);
- /// <summary>
- /// Creates a consumer of messages on a given destination with a selector
- /// </summary>
- INMSConsumer CreateConsumer(IDestination destination, string selector, bool noLocal);
+ /// <summary>
+ /// Creates a consumer of messages on a given destination with a selector
+ /// </summary>
+ INMSConsumer CreateConsumer(IDestination destination, string selector);
- INMSConsumer CreateDurableConsumer(ITopic destination, string subscriptionName);
+ /// <summary>
+ /// Creates a consumer of messages on a given destination with a selector
+ /// </summary>
+ INMSConsumer CreateConsumer(IDestination destination, string selector, bool noLocal);
- INMSConsumer CreateDurableConsumer(ITopic destination, string subscriptionName, string selector);
+ INMSConsumer CreateDurableConsumer(ITopic destination, string subscriptionName);
+
+ INMSConsumer CreateDurableConsumer(ITopic destination, string subscriptionName, string selector);
/// <summary>
/// Creates a named durable consumer of messages on a given destination with a selector
@@ -70,122 +69,121 @@
INMSConsumer CreateSharedDurableConsumer(ITopic destination, string subscriptionName, string selector);
-
void Unsubscribe(string name);
- /// <summary>
- /// Creates a QueueBrowser object to peek at the messages on the specified queue.
- /// </summary>
- /// <param name="queue">
- /// A <see cref="IQueue"/>
- /// </param>
- /// <returns>
- /// A <see cref="IQueueBrowser"/>
- /// </returns>
- /// <exception cref="System.NotSupportedException">
- /// If the Prodiver does not support creation of Queue Browsers.
- /// </exception>
- IQueueBrowser CreateBrowser(IQueue queue);
+ /// <summary>
+ /// Creates a QueueBrowser object to peek at the messages on the specified queue.
+ /// </summary>
+ /// <param name="queue">
+ /// A <see cref="IQueue"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="IQueueBrowser"/>
+ /// </returns>
+ /// <exception cref="System.NotSupportedException">
+ /// If the Prodiver does not support creation of Queue Browsers.
+ /// </exception>
+ IQueueBrowser CreateBrowser(IQueue queue);
- /// <summary>
- /// Creates a QueueBrowser object to peek at the messages on the specified queue
- /// using a message selector.
- /// </summary>
- /// <param name="queue">
- /// A <see cref="IQueue"/>
- /// </param>
- /// <param name="selector">
- /// A <see cref="System.String"/>
- /// </param>
- /// <returns>
- /// A <see cref="IQueueBrowser"/>
- /// </returns>
- /// <exception cref="System.NotSupportedException">
- /// If the Prodiver does not support creation of Queue Browsers.
- /// </exception>
- IQueueBrowser CreateBrowser(IQueue queue, string selector);
+ /// <summary>
+ /// Creates a QueueBrowser object to peek at the messages on the specified queue
+ /// using a message selector.
+ /// </summary>
+ /// <param name="queue">
+ /// A <see cref="IQueue"/>
+ /// </param>
+ /// <param name="selector">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="IQueueBrowser"/>
+ /// </returns>
+ /// <exception cref="System.NotSupportedException">
+ /// If the Prodiver does not support creation of Queue Browsers.
+ /// </exception>
+ IQueueBrowser CreateBrowser(IQueue queue, string selector);
- /// <summary>
- /// Returns the queue for the given name
- /// </summary>
- IQueue GetQueue(string name);
+ /// <summary>
+ /// Returns the queue for the given name
+ /// </summary>
+ IQueue GetQueue(string name);
- /// <summary>
- /// Returns the topic for the given name
- /// </summary>
- ITopic GetTopic(string name);
+ /// <summary>
+ /// Returns the topic for the given name
+ /// </summary>
+ ITopic GetTopic(string name);
- /// <summary>
- /// Creates a temporary queue
- /// </summary>
- ITemporaryQueue CreateTemporaryQueue();
+ /// <summary>
+ /// Creates a temporary queue
+ /// </summary>
+ ITemporaryQueue CreateTemporaryQueue();
- /// <summary>
- /// Creates a temporary topic
- /// </summary>
- ITemporaryTopic CreateTemporaryTopic();
+ /// <summary>
+ /// Creates a temporary topic
+ /// </summary>
+ ITemporaryTopic CreateTemporaryTopic();
- // Factory methods to create messages
+ // Factory methods to create messages
- /// <summary>
- /// Creates a new message with an empty body
- /// </summary>
- IMessage CreateMessage();
+ /// <summary>
+ /// Creates a new message with an empty body
+ /// </summary>
+ IMessage CreateMessage();
- /// <summary>
- /// Creates a new text message with an empty body
- /// </summary>
- ITextMessage CreateTextMessage();
+ /// <summary>
+ /// Creates a new text message with an empty body
+ /// </summary>
+ ITextMessage CreateTextMessage();
- /// <summary>
- /// Creates a new text message with the given body
- /// </summary>
- ITextMessage CreateTextMessage(string text);
+ /// <summary>
+ /// Creates a new text message with the given body
+ /// </summary>
+ ITextMessage CreateTextMessage(string text);
- /// <summary>
- /// Creates a new Map message which contains primitive key and value pairs
- /// </summary>
- IMapMessage CreateMapMessage();
+ /// <summary>
+ /// Creates a new Map message which contains primitive key and value pairs
+ /// </summary>
+ IMapMessage CreateMapMessage();
- /// <summary>
- /// Creates a new Object message containing the given .NET object as the body
- /// </summary>
- IObjectMessage CreateObjectMessage(object body);
+ /// <summary>
+ /// Creates a new Object message containing the given .NET object as the body
+ /// </summary>
+ IObjectMessage CreateObjectMessage(object body);
- /// <summary>
- /// Creates a new binary message
- /// </summary>
- IBytesMessage CreateBytesMessage();
+ /// <summary>
+ /// Creates a new binary message
+ /// </summary>
+ IBytesMessage CreateBytesMessage();
- /// <summary>
- /// Creates a new binary message with the given body
- /// </summary>
- IBytesMessage CreateBytesMessage(byte[] body);
+ /// <summary>
+ /// Creates a new binary message with the given body
+ /// </summary>
+ IBytesMessage CreateBytesMessage(byte[] body);
- /// <summary>
- /// Creates a new stream message
- /// </summary>
- IStreamMessage CreateStreamMessage();
+ /// <summary>
+ /// Creates a new stream message
+ /// </summary>
+ IStreamMessage CreateStreamMessage();
- /// <summary>
- /// Closes the session. There is no need to close the producers and consumers
- /// of a closed session.
- /// </summary>
- void Close();
+ /// <summary>
+ /// Closes the session. There is no need to close the producers and consumers
+ /// of a closed session.
+ /// </summary>
+ void Close();
- /// <summary>
- /// A Delegate that is called each time a Message is dispatched to allow the client to do
- /// any necessary transformations on the received message before it is delivered.
- /// The Session instance sets the delegate on each Consumer it creates.
- /// </summary>
- ConsumerTransformerDelegate ConsumerTransformer { get; set; }
+ /// <summary>
+ /// A Delegate that is called each time a Message is dispatched to allow the client to do
+ /// any necessary transformations on the received message before it is delivered.
+ /// The Session instance sets the delegate on each Consumer it creates.
+ /// </summary>
+ ConsumerTransformerDelegate ConsumerTransformer { get; set; }
- /// <summary>
- /// A delegate that is called each time a Message is sent from this Producer which allows
- /// the application to perform any needed transformations on the Message before it is sent.
- /// The Session instance sets the delegate on each Producer it creates.
- /// </summary>
- ProducerTransformerDelegate ProducerTransformer { get; set; }
+ /// <summary>
+ /// A delegate that is called each time a Message is sent from this Producer which allows
+ /// the application to perform any needed transformations on the Message before it is sent.
+ /// The Session instance sets the delegate on each Producer it creates.
+ /// </summary>
+ ProducerTransformerDelegate ProducerTransformer { get; set; }
/// <summary>
/// Stops all Message delivery in this session and restarts it again
@@ -197,24 +195,24 @@
/// order. It is not valid to call this method on a Transacted Session.
/// </summary>
void Recover();
-
+
void Acknowledge();
- #region Transaction methods
+ #region Transaction methods
- /// <summary>
- /// If this is a transactional session then commit all message
- /// send and acknowledgements for producers and consumers in this session
- /// </summary>
- void Commit();
+ /// <summary>
+ /// If this is a transactional session then commit all message
+ /// send and acknowledgements for producers and consumers in this session
+ /// </summary>
+ void Commit();
- /// <summary>
- /// If this is a transactional session then rollback all message
- /// send and acknowledgements for producers and consumers in this session
- /// </summary>
- void Rollback();
+ /// <summary>
+ /// If this is a transactional session then rollback all message
+ /// send and acknowledgements for producers and consumers in this session
+ /// </summary>
+ void Rollback();
- #endregion
+ #endregion
#region Session Events
@@ -238,32 +236,32 @@
/// has been resumed.
/// </summary>
event ConnectionResumedListener ConnectionResumedListener;
-
+
#endregion
- #region Attributes
+ #region Attributes
- TimeSpan RequestTimeout { get; set; }
+ TimeSpan RequestTimeout { get; set; }
- bool Transacted { get; }
+ bool Transacted { get; }
- AcknowledgementMode AcknowledgementMode { get; }
-
- String ClientID { get; set; }
+ AcknowledgementMode AcknowledgementMode { get; }
- #endregion
-
- /// <summary>
- /// For a long running Connection that creates many temp destinations
- /// this method will close and destroy all previously created temp
- /// destinations to reduce resource consumption. This can be useful
- /// when the Connection is pooled or otherwise used for long periods
- /// of time. Only locally created temp destinations should be removed
- /// by this call.
- /// NOTE: This is an optional operation and for NMS providers that
- /// do not support this functionality the method should just return
- /// without throwing any exceptions.
- /// </summary>
- void PurgeTempDestinations();
- }
-}
+ String ClientID { get; set; }
+
+ #endregion
+
+ /// <summary>
+ /// For a long running Connection that creates many temp destinations
+ /// this method will close and destroy all previously created temp
+ /// destinations to reduce resource consumption. This can be useful
+ /// when the Connection is pooled or otherwise used for long periods
+ /// of time. Only locally created temp destinations should be removed
+ /// by this call.
+ /// NOTE: This is an optional operation and for NMS providers that
+ /// do not support this functionality the method should just return
+ /// without throwing any exceptions.
+ /// </summary>
+ void PurgeTempDestinations();
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/INMSProducer.cs b/src/nms-api/INMSProducer.cs
index 961ef48..12dcb65 100644
--- a/src/nms-api/INMSProducer.cs
+++ b/src/nms-api/INMSProducer.cs
@@ -14,140 +14,138 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.Threading.Tasks;
namespace Apache.NMS
{
- /// <summary>
- /// An object capable of sending messages to some destination
- /// </summary>
- public interface INMSProducer : System.IDisposable
- {
+ /// <summary>
+ /// An object capable of sending messages to some destination
+ /// </summary>
+ public interface INMSProducer : System.IDisposable
+ {
+ INMSProducer Send(IDestination destination, IMessage message);
- INMSProducer Send(IDestination destination, IMessage message);
-
- INMSProducer Send(IDestination destination, String body);
-
- INMSProducer Send(IDestination destination, IPrimitiveMap body);
+ INMSProducer Send(IDestination destination, String body);
- INMSProducer Send(IDestination destination, byte[] body);
+ INMSProducer Send(IDestination destination, IPrimitiveMap body);
- INMSProducer Send(IDestination destination, object body);
+ INMSProducer Send(IDestination destination, byte[] body);
- Task<INMSProducer> SendAsync(IDestination destination, IMessage message);
-
- Task<INMSProducer> SendAsync(IDestination destination, String body);
-
- Task<INMSProducer> SendAsync(IDestination destination, IPrimitiveMap body);
+ INMSProducer Send(IDestination destination, object body);
- Task<INMSProducer> SendAsync(IDestination destination, byte[] body);
+ Task<INMSProducer> SendAsync(IDestination destination, IMessage message);
- Task<INMSProducer> SendAsync(IDestination destination, object body);
+ Task<INMSProducer> SendAsync(IDestination destination, String body);
- INMSProducer SetAsync(CompletionListener completionListener);
+ Task<INMSProducer> SendAsync(IDestination destination, IPrimitiveMap body);
- CompletionListener GetAsync();
+ Task<INMSProducer> SendAsync(IDestination destination, byte[] body);
- /// <summary>
- /// Provides access to the message properties (headers).
- /// </summary>
- IPrimitiveMap Properties { get; }
-
- /// <summary>
- /// Clears a message's properties.
- ///
- /// The message's header fields and body are not cleared.
- /// </summary>
- void ClearProperties();
-
- /// <summary>
- /// The correlation ID used to correlate messages from conversations or long running business processes.
- /// </summary>
- string NMSCorrelationID { get; set; }
+ Task<INMSProducer> SendAsync(IDestination destination, object body);
+
+ INMSProducer SetAsync(CompletionListener completionListener);
+
+ CompletionListener GetAsync();
+
+ /// <summary>
+ /// Provides access to the message properties (headers).
+ /// </summary>
+ IPrimitiveMap Properties { get; }
+
+ /// <summary>
+ /// Clears a message's properties.
+ ///
+ /// The message's header fields and body are not cleared.
+ /// </summary>
+ void ClearProperties();
+
+ /// <summary>
+ /// The correlation ID used to correlate messages from conversations or long running business processes.
+ /// </summary>
+ string NMSCorrelationID { get; set; }
- /// <summary>
- /// The destination that the consumer of this message should send replies to
- /// </summary>
- IDestination NMSReplyTo { get; set; }
+ /// <summary>
+ /// The destination that the consumer of this message should send replies to
+ /// </summary>
+ IDestination NMSReplyTo { get; set; }
- /// <summary>
- /// Specifies that messages sent using this NMSProducer will
- /// have their NMSType header value set to the specified message type.
- /// </summary>
- string NMSType { get; set; }
-
-
-
+ /// <summary>
+ /// Specifies that messages sent using this NMSProducer will
+ /// have their NMSType header value set to the specified message type.
+ /// </summary>
+ string NMSType { get; set; }
- /// <summary>
- /// A delegate that is called each time a Message is sent from this Producer which allows
- /// the application to perform any needed transformations on the Message before it is sent.
- /// </summary>
- ProducerTransformerDelegate ProducerTransformer { get; set; }
- MsgDeliveryMode DeliveryMode { get; set; }
+ /// <summary>
+ /// A delegate that is called each time a Message is sent from this Producer which allows
+ /// the application to perform any needed transformations on the Message before it is sent.
+ /// </summary>
+ ProducerTransformerDelegate ProducerTransformer { get; set; }
- TimeSpan DeliveryDelay { get; set; }
+ MsgDeliveryMode DeliveryMode { get; set; }
- TimeSpan TimeToLive { get; set; }
+ TimeSpan DeliveryDelay { get; set; }
- TimeSpan RequestTimeout { get; set; }
+ TimeSpan TimeToLive { get; set; }
- MsgPriority Priority { get; set; }
+ TimeSpan RequestTimeout { get; set; }
- bool DisableMessageID { get; set; }
+ MsgPriority Priority { get; set; }
- bool DisableMessageTimestamp { get; set; }
+ bool DisableMessageID { get; set; }
- #region Factory methods to create messages
+ bool DisableMessageTimestamp { get; set; }
- /// <summary>
- /// Creates a new message with an empty body
- /// </summary>
- IMessage CreateMessage();
+ #region Factory methods to create messages
- /// <summary>
- /// Creates a new text message with an empty body
- /// </summary>
- ITextMessage CreateTextMessage();
+ /// <summary>
+ /// Creates a new message with an empty body
+ /// </summary>
+ IMessage CreateMessage();
- /// <summary>
- /// Creates a new text message with the given body
- /// </summary>
- ITextMessage CreateTextMessage(string text);
+ /// <summary>
+ /// Creates a new text message with an empty body
+ /// </summary>
+ ITextMessage CreateTextMessage();
- /// <summary>
- /// Creates a new Map message which contains primitive key and value pairs
- /// </summary>
- IMapMessage CreateMapMessage();
+ /// <summary>
+ /// Creates a new text message with the given body
+ /// </summary>
+ ITextMessage CreateTextMessage(string text);
- /// <summary>
- /// Creates a new Object message containing the given .NET object as the body
- /// </summary>
- IObjectMessage CreateObjectMessage(object body);
+ /// <summary>
+ /// Creates a new Map message which contains primitive key and value pairs
+ /// </summary>
+ IMapMessage CreateMapMessage();
- /// <summary>
- /// Creates a new binary message
- /// </summary>
- IBytesMessage CreateBytesMessage();
+ /// <summary>
+ /// Creates a new Object message containing the given .NET object as the body
+ /// </summary>
+ IObjectMessage CreateObjectMessage(object body);
- /// <summary>
- /// Creates a new binary message with the given body
- /// </summary>
- IBytesMessage CreateBytesMessage(byte[] body);
+ /// <summary>
+ /// Creates a new binary message
+ /// </summary>
+ IBytesMessage CreateBytesMessage();
- /// <summary>
- /// Creates a new stream message
- /// </summary>
- IStreamMessage CreateStreamMessage();
+ /// <summary>
+ /// Creates a new binary message with the given body
+ /// </summary>
+ IBytesMessage CreateBytesMessage(byte[] body);
- #endregion
- /// <summary>
- /// Close the producer.
- /// </summary>
- void Close();
+ /// <summary>
+ /// Creates a new stream message
+ /// </summary>
+ IStreamMessage CreateStreamMessage();
- }
-}
+ #endregion
+
+ /// <summary>
+ /// Close the producer.
+ /// </summary>
+ void Close();
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/INetTxConnection.cs b/src/nms-api/INetTxConnection.cs
index 12ce89c..56b56e3 100644
--- a/src/nms-api/INetTxConnection.cs
+++ b/src/nms-api/INetTxConnection.cs
@@ -17,6 +17,7 @@
#if !NETCF
using System.Transactions;
+
#endif
namespace Apache.NMS
@@ -46,5 +47,4 @@
INetTxSession CreateNetTxSession(Transaction tx, bool enlistsNativeMsDtcResource);
#endif
}
-}
-
+}
\ No newline at end of file
diff --git a/src/nms-api/INetTxConnectionFactory.cs b/src/nms-api/INetTxConnectionFactory.cs
index 4e5cb2e..df41f1f 100644
--- a/src/nms-api/INetTxConnectionFactory.cs
+++ b/src/nms-api/INetTxConnectionFactory.cs
@@ -43,5 +43,4 @@
/// </summary>
INetTxConnection CreateNetTxConnection(string userName, string password);
}
-}
-
+}
\ No newline at end of file
diff --git a/src/nms-api/INetTxSession.cs b/src/nms-api/INetTxSession.cs
index 603460e..e84072d 100644
--- a/src/nms-api/INetTxSession.cs
+++ b/src/nms-api/INetTxSession.cs
@@ -17,6 +17,7 @@
#if !NETCF
using System.Transactions;
+
#endif
namespace Apache.NMS
@@ -53,5 +54,4 @@
bool EnlistsMsDtcNativeResource { get; set; }
#endif
}
-}
-
+}
\ No newline at end of file
diff --git a/src/nms-api/IObjectMessage.cs b/src/nms-api/IObjectMessage.cs
index f7a439f..155fa72 100644
--- a/src/nms-api/IObjectMessage.cs
+++ b/src/nms-api/IObjectMessage.cs
@@ -14,13 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// Represents an Object message which contains a serializable .Net object.
- /// </summary>
- public interface IObjectMessage : IMessage
- {
- object Body { get; set; }
- }
-}
+ /// <summary>
+ /// Represents an Object message which contains a serializable .Net object.
+ /// </summary>
+ public interface IObjectMessage : IMessage
+ {
+ object Body { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IPrimitiveMap.cs b/src/nms-api/IPrimitiveMap.cs
index a976241..cdea5d2 100644
--- a/src/nms-api/IPrimitiveMap.cs
+++ b/src/nms-api/IPrimitiveMap.cs
@@ -14,65 +14,66 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System.Collections;
namespace Apache.NMS
{
- /// <summary>
- /// Represents a Map of primitive types where the keys are all string instances
- /// and the values are strings or numbers.
- /// </summary>
- public interface IPrimitiveMap
- {
- void Clear();
+ /// <summary>
+ /// Represents a Map of primitive types where the keys are all string instances
+ /// and the values are strings or numbers.
+ /// </summary>
+ public interface IPrimitiveMap
+ {
+ void Clear();
- bool Contains(object key);
+ bool Contains(object key);
- void Remove(object key);
+ void Remove(object key);
- int Count { get; }
+ int Count { get; }
- ICollection Keys { get; }
+ ICollection Keys { get; }
- ICollection Values { get; }
+ ICollection Values { get; }
- object this[string key] { get; set; }
+ object this[string key] { get; set; }
- string GetString(string key);
- void SetString(string key, string value);
+ string GetString(string key);
+ void SetString(string key, string value);
- bool GetBool(string key);
- void SetBool(string key, bool value);
+ bool GetBool(string key);
+ void SetBool(string key, bool value);
- byte GetByte(string key);
- void SetByte(string key, byte value);
+ byte GetByte(string key);
+ void SetByte(string key, byte value);
- char GetChar(string key);
- void SetChar(string key, char value);
+ char GetChar(string key);
+ void SetChar(string key, char value);
- short GetShort(string key);
- void SetShort(string key, short value);
+ short GetShort(string key);
+ void SetShort(string key, short value);
- int GetInt(string key);
- void SetInt(string key, int value);
+ int GetInt(string key);
+ void SetInt(string key, int value);
- long GetLong(string key);
- void SetLong(string key, long value);
+ long GetLong(string key);
+ void SetLong(string key, long value);
- float GetFloat(string key);
- void SetFloat(string key, float value);
+ float GetFloat(string key);
+ void SetFloat(string key, float value);
- double GetDouble(string key);
- void SetDouble(string key, double value);
+ double GetDouble(string key);
+ void SetDouble(string key, double value);
- IList GetList(string key);
- void SetList(string key, IList list);
-
- void SetBytes(string key, byte[] value);
- void SetBytes(string key, byte[] value, int offset, int length);
- byte[] GetBytes(string key);
+ IList GetList(string key);
+ void SetList(string key, IList list);
- IDictionary GetDictionary(string key);
- void SetDictionary(string key, IDictionary dictionary);
- }
-}
+ void SetBytes(string key, byte[] value);
+ void SetBytes(string key, byte[] value, int offset, int length);
+ byte[] GetBytes(string key);
+
+ IDictionary GetDictionary(string key);
+ void SetDictionary(string key, IDictionary dictionary);
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IQueue.cs b/src/nms-api/IQueue.cs
index 6246296..58abb0f 100644
--- a/src/nms-api/IQueue.cs
+++ b/src/nms-api/IQueue.cs
@@ -14,16 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// Represents a queue in a message broker. A message sent to a queue is delivered
- /// to at most one consumer on the queue.
- /// </summary>
- public interface IQueue : IDestination
- {
- string QueueName { get; }
- }
-}
-
-
+ /// <summary>
+ /// Represents a queue in a message broker. A message sent to a queue is delivered
+ /// to at most one consumer on the queue.
+ /// </summary>
+ public interface IQueue : IDestination
+ {
+ string QueueName { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IQueueBrowser.cs b/src/nms-api/IQueueBrowser.cs
index b6540a0..172c045 100644
--- a/src/nms-api/IQueueBrowser.cs
+++ b/src/nms-api/IQueueBrowser.cs
@@ -55,6 +55,5 @@
/// doe to some internal error.
/// </exception>
IQueue Queue { get; }
-
}
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/IRedeliveryPolicy.cs b/src/nms-api/IRedeliveryPolicy.cs
index adc0cdd..3cd636e 100644
--- a/src/nms-api/IRedeliveryPolicy.cs
+++ b/src/nms-api/IRedeliveryPolicy.cs
@@ -27,7 +27,7 @@
/// to concurrent consumers.
/// </summary>
/// <value>The collision avoidance factor.</value>
- int CollisionAvoidancePercent{ get; set; }
+ int CollisionAvoidancePercent { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to [use collision avoidance].
@@ -35,20 +35,20 @@
/// <value>
/// <c>true</c> if [use collision avoidance]; otherwise, <c>false</c>.
/// </value>
- bool UseCollisionAvoidance{ get; set; }
+ bool UseCollisionAvoidance { get; set; }
/// <summary>
/// The time in milliseconds to initially delay a redelivery
/// </summary>
/// <value>The initial redelivery delay.</value>
- int InitialRedeliveryDelay{ get; set; }
+ int InitialRedeliveryDelay { get; set; }
/// <summary>
/// Gets or sets the maximum redeliveries. A value less than zero indicates
/// that there is no maximum and the NMS provider should retry forever.
/// </summary>
/// <value>The maximum redeliveries.</value>
- int MaximumRedeliveries{ get; set; }
+ int MaximumRedeliveries { get; set; }
/// <summary>
/// The time in milliseconds to delay a redelivery
@@ -63,13 +63,12 @@
/// <value>
/// <c>true</c> if [use exponential back off]; otherwise, <c>false</c>.
/// </value>
- bool UseExponentialBackOff{ get; set; }
+ bool UseExponentialBackOff { get; set; }
/// <summary>
/// Gets or sets the back off multiplier.
/// </summary>
/// <value>The back off multiplier.</value>
- int BackOffMultiplier{ get; set; }
-
+ int BackOffMultiplier { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/ISession.cs b/src/nms-api/ISession.cs
index 0468a44..cfd168f 100644
--- a/src/nms-api/ISession.cs
+++ b/src/nms-api/ISession.cs
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS
@@ -24,181 +25,181 @@
/// </summary>
public delegate void SessionTxEventDelegate(ISession session);
- /// <summary>
- /// Represents a single unit of work on an IConnection.
- /// So the ISession can be used to perform transactional receive and sends
- /// </summary>
- public interface ISession : IDisposable
- {
- /// <summary>
- /// Creates a producer of messages
- /// </summary>
- IMessageProducer CreateProducer();
+ /// <summary>
+ /// Represents a single unit of work on an IConnection.
+ /// So the ISession can be used to perform transactional receive and sends
+ /// </summary>
+ public interface ISession : IDisposable
+ {
+ /// <summary>
+ /// Creates a producer of messages
+ /// </summary>
+ IMessageProducer CreateProducer();
- /// <summary>
- /// Creates a producer of messages on a given destination
- /// </summary>
- IMessageProducer CreateProducer(IDestination destination);
+ /// <summary>
+ /// Creates a producer of messages on a given destination
+ /// </summary>
+ IMessageProducer CreateProducer(IDestination destination);
- /// <summary>
- /// Creates a consumer of messages on a given destination
- /// </summary>
- IMessageConsumer CreateConsumer(IDestination destination);
+ /// <summary>
+ /// Creates a consumer of messages on a given destination
+ /// </summary>
+ IMessageConsumer CreateConsumer(IDestination destination);
- /// <summary>
- /// Creates a consumer of messages on a given destination with a selector
- /// </summary>
- IMessageConsumer CreateConsumer(IDestination destination, string selector);
+ /// <summary>
+ /// Creates a consumer of messages on a given destination with a selector
+ /// </summary>
+ IMessageConsumer CreateConsumer(IDestination destination, string selector);
- /// <summary>
- /// Creates a consumer of messages on a given destination with a selector
- /// </summary>
- IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal);
-
- IMessageConsumer CreateDurableConsumer(ITopic destination, string name);
+ /// <summary>
+ /// Creates a consumer of messages on a given destination with a selector
+ /// </summary>
+ IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal);
- IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector);
+ IMessageConsumer CreateDurableConsumer(ITopic destination, string name);
- /// <summary>
- /// Creates a named durable consumer of messages on a given destination with a selector
- /// </summary>
- IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal);
+ IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector);
- IMessageConsumer CreateSharedConsumer(ITopic destination, string name);
+ /// <summary>
+ /// Creates a named durable consumer of messages on a given destination with a selector
+ /// </summary>
+ IMessageConsumer CreateDurableConsumer(ITopic destination, string name, string selector, bool noLocal);
- IMessageConsumer CreateSharedConsumer(ITopic destination, string name, string selector);
+ IMessageConsumer CreateSharedConsumer(ITopic destination, string name);
- IMessageConsumer CreateSharedDurableConsumer(ITopic destination, string name);
+ IMessageConsumer CreateSharedConsumer(ITopic destination, string name, string selector);
- IMessageConsumer CreateSharedDurableConsumer(ITopic destination, string name, string selector);
+ IMessageConsumer CreateSharedDurableConsumer(ITopic destination, string name);
- /// <summary>
- /// Deletes a durable consumer created with CreateDurableConsumer().
- /// </summary>
- /// <param name="name">Name of the durable consumer</param>
- [Obsolete("should use unsubscribe instead")]
- void DeleteDurableConsumer(string name);
+ IMessageConsumer CreateSharedDurableConsumer(ITopic destination, string name, string selector);
- void Unsubscribe(string name);
+ /// <summary>
+ /// Deletes a durable consumer created with CreateDurableConsumer().
+ /// </summary>
+ /// <param name="name">Name of the durable consumer</param>
+ [Obsolete("should use unsubscribe instead")]
+ void DeleteDurableConsumer(string name);
- /// <summary>
- /// Creates a QueueBrowser object to peek at the messages on the specified queue.
- /// </summary>
- /// <param name="queue">
- /// A <see cref="IQueue"/>
- /// </param>
- /// <returns>
- /// A <see cref="IQueueBrowser"/>
- /// </returns>
- /// <exception cref="System.NotSupportedException">
- /// If the Prodiver does not support creation of Queue Browsers.
- /// </exception>
- IQueueBrowser CreateBrowser(IQueue queue);
+ void Unsubscribe(string name);
- /// <summary>
- /// Creates a QueueBrowser object to peek at the messages on the specified queue
- /// using a message selector.
- /// </summary>
- /// <param name="queue">
- /// A <see cref="IQueue"/>
- /// </param>
- /// <param name="selector">
- /// A <see cref="System.String"/>
- /// </param>
- /// <returns>
- /// A <see cref="IQueueBrowser"/>
- /// </returns>
- /// <exception cref="System.NotSupportedException">
- /// If the Prodiver does not support creation of Queue Browsers.
- /// </exception>
- IQueueBrowser CreateBrowser(IQueue queue, string selector);
+ /// <summary>
+ /// Creates a QueueBrowser object to peek at the messages on the specified queue.
+ /// </summary>
+ /// <param name="queue">
+ /// A <see cref="IQueue"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="IQueueBrowser"/>
+ /// </returns>
+ /// <exception cref="System.NotSupportedException">
+ /// If the Prodiver does not support creation of Queue Browsers.
+ /// </exception>
+ IQueueBrowser CreateBrowser(IQueue queue);
- /// <summary>
- /// Returns the queue for the given name
- /// </summary>
- IQueue GetQueue(string name);
+ /// <summary>
+ /// Creates a QueueBrowser object to peek at the messages on the specified queue
+ /// using a message selector.
+ /// </summary>
+ /// <param name="queue">
+ /// A <see cref="IQueue"/>
+ /// </param>
+ /// <param name="selector">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="IQueueBrowser"/>
+ /// </returns>
+ /// <exception cref="System.NotSupportedException">
+ /// If the Prodiver does not support creation of Queue Browsers.
+ /// </exception>
+ IQueueBrowser CreateBrowser(IQueue queue, string selector);
- /// <summary>
- /// Returns the topic for the given name
- /// </summary>
- ITopic GetTopic(string name);
+ /// <summary>
+ /// Returns the queue for the given name
+ /// </summary>
+ IQueue GetQueue(string name);
- /// <summary>
- /// Creates a temporary queue
- /// </summary>
- ITemporaryQueue CreateTemporaryQueue();
+ /// <summary>
+ /// Returns the topic for the given name
+ /// </summary>
+ ITopic GetTopic(string name);
- /// <summary>
- /// Creates a temporary topic
- /// </summary>
- ITemporaryTopic CreateTemporaryTopic();
+ /// <summary>
+ /// Creates a temporary queue
+ /// </summary>
+ ITemporaryQueue CreateTemporaryQueue();
- /// <summary>
- /// Delete a destination (Queue, Topic, Temp Queue, Temp Topic).
- /// </summary>
- void DeleteDestination(IDestination destination);
+ /// <summary>
+ /// Creates a temporary topic
+ /// </summary>
+ ITemporaryTopic CreateTemporaryTopic();
- // Factory methods to create messages
+ /// <summary>
+ /// Delete a destination (Queue, Topic, Temp Queue, Temp Topic).
+ /// </summary>
+ void DeleteDestination(IDestination destination);
- /// <summary>
- /// Creates a new message with an empty body
- /// </summary>
- IMessage CreateMessage();
+ // Factory methods to create messages
- /// <summary>
- /// Creates a new text message with an empty body
- /// </summary>
- ITextMessage CreateTextMessage();
+ /// <summary>
+ /// Creates a new message with an empty body
+ /// </summary>
+ IMessage CreateMessage();
- /// <summary>
- /// Creates a new text message with the given body
- /// </summary>
- ITextMessage CreateTextMessage(string text);
+ /// <summary>
+ /// Creates a new text message with an empty body
+ /// </summary>
+ ITextMessage CreateTextMessage();
- /// <summary>
- /// Creates a new Map message which contains primitive key and value pairs
- /// </summary>
- IMapMessage CreateMapMessage();
+ /// <summary>
+ /// Creates a new text message with the given body
+ /// </summary>
+ ITextMessage CreateTextMessage(string text);
- /// <summary>
- /// Creates a new Object message containing the given .NET object as the body
- /// </summary>
- IObjectMessage CreateObjectMessage(object body);
+ /// <summary>
+ /// Creates a new Map message which contains primitive key and value pairs
+ /// </summary>
+ IMapMessage CreateMapMessage();
- /// <summary>
- /// Creates a new binary message
- /// </summary>
- IBytesMessage CreateBytesMessage();
+ /// <summary>
+ /// Creates a new Object message containing the given .NET object as the body
+ /// </summary>
+ IObjectMessage CreateObjectMessage(object body);
- /// <summary>
- /// Creates a new binary message with the given body
- /// </summary>
- IBytesMessage CreateBytesMessage(byte[] body);
+ /// <summary>
+ /// Creates a new binary message
+ /// </summary>
+ IBytesMessage CreateBytesMessage();
- /// <summary>
- /// Creates a new stream message
- /// </summary>
- IStreamMessage CreateStreamMessage();
+ /// <summary>
+ /// Creates a new binary message with the given body
+ /// </summary>
+ IBytesMessage CreateBytesMessage(byte[] body);
- /// <summary>
- /// Closes the session. There is no need to close the producers and consumers
- /// of a closed session.
- /// </summary>
- void Close();
+ /// <summary>
+ /// Creates a new stream message
+ /// </summary>
+ IStreamMessage CreateStreamMessage();
- /// <summary>
- /// A Delegate that is called each time a Message is dispatched to allow the client to do
- /// any necessary transformations on the received message before it is delivered.
- /// The Session instance sets the delegate on each Consumer it creates.
- /// </summary>
- ConsumerTransformerDelegate ConsumerTransformer { get; set; }
+ /// <summary>
+ /// Closes the session. There is no need to close the producers and consumers
+ /// of a closed session.
+ /// </summary>
+ void Close();
- /// <summary>
- /// A delegate that is called each time a Message is sent from this Producer which allows
- /// the application to perform any needed transformations on the Message before it is sent.
- /// The Session instance sets the delegate on each Producer it creates.
- /// </summary>
- ProducerTransformerDelegate ProducerTransformer { get; set; }
+ /// <summary>
+ /// A Delegate that is called each time a Message is dispatched to allow the client to do
+ /// any necessary transformations on the received message before it is delivered.
+ /// The Session instance sets the delegate on each Consumer it creates.
+ /// </summary>
+ ConsumerTransformerDelegate ConsumerTransformer { get; set; }
+
+ /// <summary>
+ /// A delegate that is called each time a Message is sent from this Producer which allows
+ /// the application to perform any needed transformations on the Message before it is sent.
+ /// The Session instance sets the delegate on each Producer it creates.
+ /// </summary>
+ ProducerTransformerDelegate ProducerTransformer { get; set; }
/// <summary>
/// Stops all Message delivery in this session and restarts it again
@@ -210,24 +211,24 @@
/// order. It is not valid to call this method on a Transacted Session.
/// </summary>
void Recover();
-
- void Acknowledge();
- #region Transaction methods
+ void Acknowledge();
- /// <summary>
- /// If this is a transactional session then commit all message
- /// send and acknowledgements for producers and consumers in this session
- /// </summary>
- void Commit();
+ #region Transaction methods
- /// <summary>
- /// If this is a transactional session then rollback all message
- /// send and acknowledgements for producers and consumers in this session
- /// </summary>
- void Rollback();
+ /// <summary>
+ /// If this is a transactional session then commit all message
+ /// send and acknowledgements for producers and consumers in this session
+ /// </summary>
+ void Commit();
- #endregion
+ /// <summary>
+ /// If this is a transactional session then rollback all message
+ /// send and acknowledgements for producers and consumers in this session
+ /// </summary>
+ void Rollback();
+
+ #endregion
#region Session Events
@@ -237,14 +238,14 @@
#endregion
- #region Attributes
+ #region Attributes
- TimeSpan RequestTimeout { get; set; }
+ TimeSpan RequestTimeout { get; set; }
- bool Transacted { get; }
+ bool Transacted { get; }
- AcknowledgementMode AcknowledgementMode { get; }
+ AcknowledgementMode AcknowledgementMode { get; }
- #endregion
- }
-}
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IStartable.cs b/src/nms-api/IStartable.cs
index b1f96c7..5e388b4 100644
--- a/src/nms-api/IStartable.cs
+++ b/src/nms-api/IStartable.cs
@@ -14,16 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// A lifecycle for NMS objects to indicate they can be started
- /// </summary>
- public interface IStartable
- {
- void Start();
- bool IsStarted { get; }
- }
-}
-
-
+ /// <summary>
+ /// A lifecycle for NMS objects to indicate they can be started
+ /// </summary>
+ public interface IStartable
+ {
+ void Start();
+ bool IsStarted { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IStoppable.cs b/src/nms-api/IStoppable.cs
index b1d15eb..ad88977 100644
--- a/src/nms-api/IStoppable.cs
+++ b/src/nms-api/IStoppable.cs
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// A lifecycle for NMS objects to indicate they can be stopped
- /// </summary>
- public interface IStoppable
- {
- void Stop();
- }
-}
-
+ /// <summary>
+ /// A lifecycle for NMS objects to indicate they can be stopped
+ /// </summary>
+ public interface IStoppable
+ {
+ void Stop();
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IStreamMessage.cs b/src/nms-api/IStreamMessage.cs
index e650d37..6809333 100644
--- a/src/nms-api/IStreamMessage.cs
+++ b/src/nms-api/IStreamMessage.cs
@@ -18,7 +18,7 @@
using System;
namespace Apache.NMS
-{
+{
/// <summary>
/// A StreamMessage object is used to send a stream of primitive types in the
/// .NET programming language. It is filled and read sequentially. It inherits
@@ -73,7 +73,6 @@
/// </summary>
public interface IStreamMessage : IMessage
{
-
/// <summary>
/// Reads a boolean from the stream message.
/// </summary>
@@ -93,7 +92,7 @@
/// if the message is in write-only mode.
/// </exception>
bool ReadBoolean();
-
+
/// <summary>
/// Reads a byte from the stream message.
/// </summary>
@@ -113,7 +112,7 @@
/// if the message is in write-only mode.
/// </exception>
byte ReadByte();
-
+
/// <summary>
/// Reads a byte array field from the stream message into the specified byte[]
/// object (the read buffer).
@@ -158,7 +157,7 @@
/// </exception>
/// <seealso cref="ReadObject"/>
int ReadBytes(byte[] value);
-
+
/// <summary>
/// Reads a char from the stream message.
/// </summary>
@@ -178,7 +177,7 @@
/// if the message is in write-only mode.
/// </exception>
char ReadChar();
-
+
/// <summary>
/// Reads a short from the stream message.
/// </summary>
@@ -198,7 +197,7 @@
/// if the message is in write-only mode.
/// </exception>
short ReadInt16();
-
+
/// <summary>
/// Reads a int from the stream message.
/// </summary>
@@ -218,7 +217,7 @@
/// if the message is in write-only mode.
/// </exception>
int ReadInt32();
-
+
/// <summary>
/// Reads a long from the stream message.
/// </summary>
@@ -238,7 +237,7 @@
/// if the message is in write-only mode.
/// </exception>
long ReadInt64();
-
+
/// <summary>
/// Reads a float from the stream message.
/// </summary>
@@ -258,7 +257,7 @@
/// if the message is in write-only mode.
/// </exception>
float ReadSingle();
-
+
/// <summary>
/// Reads a double from the stream message.
/// </summary>
@@ -278,7 +277,7 @@
/// if the message is in write-only mode.
/// </exception>
double ReadDouble();
-
+
/// <summary>
/// Reads a string from the stream message.
/// </summary>
@@ -298,7 +297,7 @@
/// if the message is in write-only mode.
/// </exception>
string ReadString();
-
+
/// <summary>
/// Reads a Object from the stream message.
/// </summary>
@@ -318,7 +317,7 @@
/// if the message is in write-only mode.
/// </exception>
Object ReadObject();
-
+
/// <summary>
/// Writes a boolean to the stream message.
/// </summary>
@@ -404,7 +403,7 @@
/// if the message is in read-only mode.
/// </exception>
void WriteChar(char value);
-
+
/// <summary>
/// Writes a short to the stream message.
/// </summary>
@@ -418,7 +417,7 @@
/// if the message is in read-only mode.
/// </exception>
void WriteInt16(short value);
-
+
/// <summary>
/// Writes a int to the stream message.
/// </summary>
@@ -432,7 +431,7 @@
/// if the message is in read-only mode.
/// </exception>
void WriteInt32(int value);
-
+
/// <summary>
/// Writes a long to the stream message.
/// </summary>
@@ -446,7 +445,7 @@
/// if the message is in read-only mode.
/// </exception>
void WriteInt64(long value);
-
+
/// <summary>
/// Writes a float to the stream message.
/// </summary>
@@ -460,7 +459,7 @@
/// if the message is in read-only mode.
/// </exception>
void WriteSingle(float value);
-
+
/// <summary>
/// Writes a double to the stream message.
/// </summary>
@@ -474,7 +473,7 @@
/// if the message is in read-only mode.
/// </exception>
void WriteDouble(double value);
-
+
/// <summary>
/// Writes a string to the stream message.
/// </summary>
@@ -488,7 +487,7 @@
/// if the message is in read-only mode.
/// </exception>
void WriteString(string value);
-
+
/// <summary>
/// Writes a boolean to the stream message.
/// </summary>
@@ -513,6 +512,5 @@
/// Thrown when there is an unhandled exception thrown from the provider.
/// </exception>
void Reset();
-
}
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/ITemporaryQueue.cs b/src/nms-api/ITemporaryQueue.cs
index ef1ea59..5950841 100644
--- a/src/nms-api/ITemporaryQueue.cs
+++ b/src/nms-api/ITemporaryQueue.cs
@@ -14,25 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// Represents a temporary queue which exists for the duration
- /// of the IConnection which created it.
- /// </summary>
- public interface ITemporaryQueue : IQueue
- {
- /// <summary>
- /// Deletes this Temporary Destination, If there are existing receivers
- /// still using it, a NMSException will be thrown.
- /// </summary>
+ /// <summary>
+ /// Represents a temporary queue which exists for the duration
+ /// of the IConnection which created it.
+ /// </summary>
+ public interface ITemporaryQueue : IQueue
+ {
+ /// <summary>
+ /// Deletes this Temporary Destination, If there are existing receivers
+ /// still using it, a NMSException will be thrown.
+ /// </summary>
/// <exception cref="Apache.NMS.NMSException">
/// If NMS Provider fails to Delete the Temp Destination or the client does
/// not support this operation.
/// </exception>
- void Delete();
-
- }
-}
-
-
+ void Delete();
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/ITemporaryTopic.cs b/src/nms-api/ITemporaryTopic.cs
index 08a2f9d..c942ddc 100644
--- a/src/nms-api/ITemporaryTopic.cs
+++ b/src/nms-api/ITemporaryTopic.cs
@@ -14,24 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// Represents a temporary topic which exists for the duration
- /// of the IConnection which created it.
- /// </summary>
- public interface ITemporaryTopic : ITopic
- {
- /// <summary>
- /// Deletes this Temporary Destination, If there are existing receivers
- /// still using it, a NMSException will be thrown.
- /// </summary>
+ /// <summary>
+ /// Represents a temporary topic which exists for the duration
+ /// of the IConnection which created it.
+ /// </summary>
+ public interface ITemporaryTopic : ITopic
+ {
+ /// <summary>
+ /// Deletes this Temporary Destination, If there are existing receivers
+ /// still using it, a NMSException will be thrown.
+ /// </summary>
/// <exception cref="Apache.NMS.NMSException">
/// If NMS Provider fails to Delete the Temp Destination or the client does
/// not support this operation.
/// </exception>
- void Delete();
- }
-}
-
-
+ void Delete();
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/ITextMessage.cs b/src/nms-api/ITextMessage.cs
index c810852..51956e2 100644
--- a/src/nms-api/ITextMessage.cs
+++ b/src/nms-api/ITextMessage.cs
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// Represents a text based message
- /// </summary>
- public interface ITextMessage : IMessage
- {
- string Text { get; set; }
- }
-}
-
+ /// <summary>
+ /// Represents a text based message
+ /// </summary>
+ public interface ITextMessage : IMessage
+ {
+ string Text { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/ITopic.cs b/src/nms-api/ITopic.cs
index 059285f..d87b72e 100644
--- a/src/nms-api/ITopic.cs
+++ b/src/nms-api/ITopic.cs
@@ -14,14 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- /// <summary>
- /// Represents a topic in a message broker. A message sent to a topic
- /// is delivered to all consumers on the topic who are interested in the message.
- /// </summary>
- public interface ITopic : IDestination
- {
- string TopicName { get; }
- }
-}
+ /// <summary>
+ /// Represents a topic in a message broker. A message sent to a topic
+ /// is delivered to all consumers on the topic who are interested in the message.
+ /// </summary>
+ public interface ITopic : IDestination
+ {
+ string TopicName { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/ITrace.cs b/src/nms-api/ITrace.cs
index 472788c..00d2cfb 100644
--- a/src/nms-api/ITrace.cs
+++ b/src/nms-api/ITrace.cs
@@ -17,31 +17,29 @@
namespace Apache.NMS
{
- /// <summary>
- /// The ITrace interface is used internally by ActiveMQ to log messages.
- /// The client aplication may provide an implementation of ITrace if it wishes to
- /// route messages to a specific destination.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Use the <see cref="Tracer"/> class to register an instance of ITrace as the
- /// active trace destination.
- /// </para>
- /// </remarks>
- public interface ITrace
- {
- void Debug(string message);
- void Info(string message);
- void Warn(string message);
- void Error(string message);
- void Fatal(string message);
+ /// <summary>
+ /// The ITrace interface is used internally by ActiveMQ to log messages.
+ /// The client aplication may provide an implementation of ITrace if it wishes to
+ /// route messages to a specific destination.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Use the <see cref="Tracer"/> class to register an instance of ITrace as the
+ /// active trace destination.
+ /// </para>
+ /// </remarks>
+ public interface ITrace
+ {
+ void Debug(string message);
+ void Info(string message);
+ void Warn(string message);
+ void Error(string message);
+ void Fatal(string message);
- bool IsDebugEnabled { get; }
- bool IsInfoEnabled { get; }
- bool IsWarnEnabled { get; }
- bool IsErrorEnabled { get; }
- bool IsFatalEnabled { get; }
- }
-}
-
-
+ bool IsDebugEnabled { get; }
+ bool IsInfoEnabled { get; }
+ bool IsWarnEnabled { get; }
+ bool IsErrorEnabled { get; }
+ bool IsFatalEnabled { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/IllegalStateException.cs b/src/nms-api/IllegalStateException.cs
index abed448..d2e2839 100644
--- a/src/nms-api/IllegalStateException.cs
+++ b/src/nms-api/IllegalStateException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class IllegalStateException : NMSException
- {
- public IllegalStateException()
- : base()
- {
- }
+ [Serializable]
+ public class IllegalStateException : NMSException
+ {
+ public IllegalStateException()
+ : base()
+ {
+ }
- public IllegalStateException(string message)
- : base(message)
- {
- }
+ public IllegalStateException(string message)
+ : base(message)
+ {
+ }
- public IllegalStateException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public IllegalStateException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public IllegalStateException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public IllegalStateException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public IllegalStateException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public IllegalStateException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the IllegalStateException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected IllegalStateException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the IllegalStateException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected IllegalStateException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/InvalidClientIDException.cs b/src/nms-api/InvalidClientIDException.cs
index d83c3ee..7d3f7f1 100644
--- a/src/nms-api/InvalidClientIDException.cs
+++ b/src/nms-api/InvalidClientIDException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class InvalidClientIDException : NMSException
- {
- public InvalidClientIDException()
- : base()
- {
- }
+ [Serializable]
+ public class InvalidClientIDException : NMSException
+ {
+ public InvalidClientIDException()
+ : base()
+ {
+ }
- public InvalidClientIDException(string message)
- : base(message)
- {
- }
+ public InvalidClientIDException(string message)
+ : base(message)
+ {
+ }
- public InvalidClientIDException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public InvalidClientIDException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public InvalidClientIDException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public InvalidClientIDException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public InvalidClientIDException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public InvalidClientIDException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the InvalidClientIDException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected InvalidClientIDException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the InvalidClientIDException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected InvalidClientIDException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/InvalidDestinationException.cs b/src/nms-api/InvalidDestinationException.cs
index a297500..d0d24d9 100644
--- a/src/nms-api/InvalidDestinationException.cs
+++ b/src/nms-api/InvalidDestinationException.cs
@@ -19,56 +19,56 @@
namespace Apache.NMS
{
- /// <summary>
- /// An attempt is made to access an invalid destination
- /// </summary>
- [Serializable]
- public class InvalidDestinationException : NMSException
- {
- public InvalidDestinationException()
- : base()
- {
- }
+ /// <summary>
+ /// An attempt is made to access an invalid destination
+ /// </summary>
+ [Serializable]
+ public class InvalidDestinationException : NMSException
+ {
+ public InvalidDestinationException()
+ : base()
+ {
+ }
- public InvalidDestinationException(string message)
- : base(message)
- {
- }
+ public InvalidDestinationException(string message)
+ : base(message)
+ {
+ }
- public InvalidDestinationException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public InvalidDestinationException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public InvalidDestinationException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public InvalidDestinationException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public InvalidDestinationException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public InvalidDestinationException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the InvalidDestinationException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected InvalidDestinationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the InvalidDestinationException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected InvalidDestinationException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
-
-
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/InvalidSelectorException.cs b/src/nms-api/InvalidSelectorException.cs
index 8b76f22..b5c3840 100644
--- a/src/nms-api/InvalidSelectorException.cs
+++ b/src/nms-api/InvalidSelectorException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class InvalidSelectorException : NMSException
- {
- public InvalidSelectorException()
- : base()
- {
- }
+ [Serializable]
+ public class InvalidSelectorException : NMSException
+ {
+ public InvalidSelectorException()
+ : base()
+ {
+ }
- public InvalidSelectorException(string message)
- : base(message)
- {
- }
+ public InvalidSelectorException(string message)
+ : base(message)
+ {
+ }
- public InvalidSelectorException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public InvalidSelectorException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public InvalidSelectorException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public InvalidSelectorException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public InvalidSelectorException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public InvalidSelectorException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the InvalidSelectorException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected InvalidSelectorException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the InvalidSelectorException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected InvalidSelectorException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/MessageConsumerExtensions.cs b/src/nms-api/MessageConsumerExtensions.cs
index a95e4dc..fe49b87 100644
--- a/src/nms-api/MessageConsumerExtensions.cs
+++ b/src/nms-api/MessageConsumerExtensions.cs
@@ -1,18 +1,18 @@
-/*
- * 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.
+/*
+ * 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;
@@ -49,4 +49,4 @@
}
}
#endif
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/MessageEOFException.cs b/src/nms-api/MessageEOFException.cs
index 1b25688..e6e5d19 100644
--- a/src/nms-api/MessageEOFException.cs
+++ b/src/nms-api/MessageEOFException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class MessageEOFException : NMSException
- {
- public MessageEOFException()
- : base()
- {
- }
+ [Serializable]
+ public class MessageEOFException : NMSException
+ {
+ public MessageEOFException()
+ : base()
+ {
+ }
- public MessageEOFException(string message)
- : base(message)
- {
- }
+ public MessageEOFException(string message)
+ : base(message)
+ {
+ }
- public MessageEOFException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public MessageEOFException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public MessageEOFException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public MessageEOFException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public MessageEOFException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public MessageEOFException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the MessageEOFException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected MessageEOFException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the MessageEOFException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected MessageEOFException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/MessageExtensions.cs b/src/nms-api/MessageExtensions.cs
index f30abcd..a0bb9c2 100644
--- a/src/nms-api/MessageExtensions.cs
+++ b/src/nms-api/MessageExtensions.cs
@@ -13,28 +13,28 @@
* 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;
using System.Text;
-using Apache.NMS.Util;
-
-namespace Apache.NMS
-{
-#if NET_3_5 || MONO
- public static class MessageExtensions
- {
- /// <summary>
- /// Deserializes the object from Xml, and returns it.
- /// </summary>
- public static object ToObject(this IMessage message)
+using Apache.NMS.Util;
+
+namespace Apache.NMS
+{
+#if NET_3_5 || MONO
+ public static class MessageExtensions
+ {
+ /// <summary>
+ /// Deserializes the object from Xml, and returns it.
+ /// </summary>
+ public static object ToObject(this IMessage message)
{
return ToObject<object>(message);
- }
-
- /// <summary>
- /// Deserializes the object from Xml, and returns it.
- /// </summary>
+ }
+
+ /// <summary>
+ /// Deserializes the object from Xml, and returns it.
+ /// </summary>
public static T ToObject<T>(this IMessage message) where T : class
{
try
@@ -51,6 +51,6 @@
return null;
}
- }
-#endif
-}
+ }
+#endif
+}
\ No newline at end of file
diff --git a/src/nms-api/MessageFormatException.cs b/src/nms-api/MessageFormatException.cs
index 3d85c52..09ce623 100644
--- a/src/nms-api/MessageFormatException.cs
+++ b/src/nms-api/MessageFormatException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class MessageFormatException : NMSException
- {
- public MessageFormatException()
- : base()
- {
- }
+ [Serializable]
+ public class MessageFormatException : NMSException
+ {
+ public MessageFormatException()
+ : base()
+ {
+ }
- public MessageFormatException(string message)
- : base(message)
- {
- }
+ public MessageFormatException(string message)
+ : base(message)
+ {
+ }
- public MessageFormatException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public MessageFormatException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public MessageFormatException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public MessageFormatException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public MessageFormatException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public MessageFormatException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the MessageFormatException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected MessageFormatException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the MessageFormatException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected MessageFormatException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/MessageNotReadableException.cs b/src/nms-api/MessageNotReadableException.cs
index 34ca89d..6008c73 100644
--- a/src/nms-api/MessageNotReadableException.cs
+++ b/src/nms-api/MessageNotReadableException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class MessageNotReadableException : NMSException
- {
- public MessageNotReadableException()
- : base()
- {
- }
+ [Serializable]
+ public class MessageNotReadableException : NMSException
+ {
+ public MessageNotReadableException()
+ : base()
+ {
+ }
- public MessageNotReadableException(string message)
- : base(message)
- {
- }
+ public MessageNotReadableException(string message)
+ : base(message)
+ {
+ }
- public MessageNotReadableException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public MessageNotReadableException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public MessageNotReadableException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public MessageNotReadableException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public MessageNotReadableException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public MessageNotReadableException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the MessageNotReadableException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected MessageNotReadableException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the MessageNotReadableException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected MessageNotReadableException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/MessageNotWriteableException.cs b/src/nms-api/MessageNotWriteableException.cs
index a5b6dde..8ba6c2e 100644
--- a/src/nms-api/MessageNotWriteableException.cs
+++ b/src/nms-api/MessageNotWriteableException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class MessageNotWriteableException : NMSException
- {
- public MessageNotWriteableException()
- : base()
- {
- }
+ [Serializable]
+ public class MessageNotWriteableException : NMSException
+ {
+ public MessageNotWriteableException()
+ : base()
+ {
+ }
- public MessageNotWriteableException(string message)
- : base(message)
- {
- }
+ public MessageNotWriteableException(string message)
+ : base(message)
+ {
+ }
- public MessageNotWriteableException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public MessageNotWriteableException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public MessageNotWriteableException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public MessageNotWriteableException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public MessageNotWriteableException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public MessageNotWriteableException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the MessageNotWriteableException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected MessageNotWriteableException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the MessageNotWriteableException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected MessageNotWriteableException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/MessageProducerExtensions.cs b/src/nms-api/MessageProducerExtensions.cs
index a270ff7..4bf8c87 100644
--- a/src/nms-api/MessageProducerExtensions.cs
+++ b/src/nms-api/MessageProducerExtensions.cs
@@ -1,18 +1,18 @@
-/*
- * 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.
+/*
+ * 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;
@@ -65,4 +65,4 @@
}
}
#endif
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/NMSConnectionException.cs b/src/nms-api/NMSConnectionException.cs
index 095636c..ceedaa2 100644
--- a/src/nms-api/NMSConnectionException.cs
+++ b/src/nms-api/NMSConnectionException.cs
@@ -19,53 +19,56 @@
namespace Apache.NMS
{
- /// <summary>
- /// Represents a connection failure.
- /// </summary>
- [Serializable]
- public class NMSConnectionException : NMSException
- {
- public NMSConnectionException()
- : base()
- {
- }
+ /// <summary>
+ /// Represents a connection failure.
+ /// </summary>
+ [Serializable]
+ public class NMSConnectionException : NMSException
+ {
+ public NMSConnectionException()
+ : base()
+ {
+ }
- public NMSConnectionException(string message)
- : base(message)
- {
- }
+ public NMSConnectionException(string message)
+ : base(message)
+ {
+ }
- public NMSConnectionException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public NMSConnectionException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public NMSConnectionException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public NMSConnectionException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public NMSConnectionException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public NMSConnectionException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the NMSConnectionException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected NMSConnectionException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the NMSConnectionException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected NMSConnectionException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/NMSConnectionFactory.cs b/src/nms-api/NMSConnectionFactory.cs
index 8f26581..8ccdb56 100644
--- a/src/nms-api/NMSConnectionFactory.cs
+++ b/src/nms-api/NMSConnectionFactory.cs
@@ -21,421 +21,436 @@
using System.IO;
using System.Reflection;
using System.Xml;
-
using Apache.NMS.Util;
namespace Apache.NMS
{
- /// <summary>
- /// Provider implementation mapping class.
- /// </summary>
- public class ProviderFactoryInfo
- {
- public string assemblyFileName;
- public string factoryClassName;
+ /// <summary>
+ /// Provider implementation mapping class.
+ /// </summary>
+ public class ProviderFactoryInfo
+ {
+ public string assemblyFileName;
+ public string factoryClassName;
- public ProviderFactoryInfo(string aFileName, string fClassName)
- {
- assemblyFileName = aFileName;
- factoryClassName = fClassName;
- }
- }
+ public ProviderFactoryInfo(string aFileName, string fClassName)
+ {
+ assemblyFileName = aFileName;
+ factoryClassName = fClassName;
+ }
+ }
- /// <summary>
- /// Implementation of a factory for <see cref="IConnection" /> instances.
- /// </summary>
- public class NMSConnectionFactory : IConnectionFactory
- {
- protected readonly IConnectionFactory factory;
- protected static readonly Dictionary<string, ProviderFactoryInfo> schemaProviderFactoryMap;
+ /// <summary>
+ /// Implementation of a factory for <see cref="IConnection" /> instances.
+ /// </summary>
+ public class NMSConnectionFactory : IConnectionFactory
+ {
+ protected readonly IConnectionFactory factory;
+ protected static readonly Dictionary<string, ProviderFactoryInfo> schemaProviderFactoryMap;
- /// <summary>
- /// Static class constructor
- /// </summary>
- static NMSConnectionFactory()
- {
- schemaProviderFactoryMap = new Dictionary<string, ProviderFactoryInfo>();
- schemaProviderFactoryMap["activemq"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.ConnectionFactory");
- schemaProviderFactoryMap["activemqnettx"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.NetTxConnectionFactory");
- schemaProviderFactoryMap["tcp"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.ConnectionFactory");
- schemaProviderFactoryMap["ems"] = new ProviderFactoryInfo("Apache.NMS.EMS", "Apache.NMS.EMS.ConnectionFactory");
- schemaProviderFactoryMap["mqtt"] = new ProviderFactoryInfo("Apache.NMS.MQTT", "Apache.NMS.MQTT.ConnectionFactory");
- schemaProviderFactoryMap["msmq"] = new ProviderFactoryInfo("Apache.NMS.MSMQ", "Apache.NMS.MSMQ.ConnectionFactory");
- schemaProviderFactoryMap["stomp"] = new ProviderFactoryInfo("Apache.NMS.Stomp", "Apache.NMS.Stomp.ConnectionFactory");
- schemaProviderFactoryMap["xms"] = new ProviderFactoryInfo("Apache.NMS.XMS", "Apache.NMS.XMS.ConnectionFactory");
- schemaProviderFactoryMap["zmq"] = new ProviderFactoryInfo("Apache.NMS.ZMQ", "Apache.NMS.ZMQ.ConnectionFactory");
- schemaProviderFactoryMap["amqp"] = new ProviderFactoryInfo("Apache.NMS.AMQP", "Apache.NMS.AMQP.ConnectionFactory");
- }
+ /// <summary>
+ /// Static class constructor
+ /// </summary>
+ static NMSConnectionFactory()
+ {
+ schemaProviderFactoryMap = new Dictionary<string, ProviderFactoryInfo>();
+ schemaProviderFactoryMap["activemq"] =
+ new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.ConnectionFactory");
+ schemaProviderFactoryMap["activemqnettx"] = new ProviderFactoryInfo("Apache.NMS.ActiveMQ",
+ "Apache.NMS.ActiveMQ.NetTxConnectionFactory");
+ schemaProviderFactoryMap["tcp"] =
+ new ProviderFactoryInfo("Apache.NMS.ActiveMQ", "Apache.NMS.ActiveMQ.ConnectionFactory");
+ schemaProviderFactoryMap["ems"] =
+ new ProviderFactoryInfo("Apache.NMS.EMS", "Apache.NMS.EMS.ConnectionFactory");
+ schemaProviderFactoryMap["mqtt"] =
+ new ProviderFactoryInfo("Apache.NMS.MQTT", "Apache.NMS.MQTT.ConnectionFactory");
+ schemaProviderFactoryMap["msmq"] =
+ new ProviderFactoryInfo("Apache.NMS.MSMQ", "Apache.NMS.MSMQ.ConnectionFactory");
+ schemaProviderFactoryMap["stomp"] =
+ new ProviderFactoryInfo("Apache.NMS.Stomp", "Apache.NMS.Stomp.ConnectionFactory");
+ schemaProviderFactoryMap["xms"] =
+ new ProviderFactoryInfo("Apache.NMS.XMS", "Apache.NMS.XMS.ConnectionFactory");
+ schemaProviderFactoryMap["zmq"] =
+ new ProviderFactoryInfo("Apache.NMS.ZMQ", "Apache.NMS.ZMQ.ConnectionFactory");
+ schemaProviderFactoryMap["amqp"] =
+ new ProviderFactoryInfo("Apache.NMS.AMQP", "Apache.NMS.AMQP.ConnectionFactory");
+ }
- /// <summary>
- /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object.
- /// Any additional parameters are optional, but will typically include a Client ID string.
- /// </summary>
- /// <param name="providerURI">The URI for the ActiveMQ provider.</param>
- /// <param name="constructorParams">Optional parameters to use when creating the ConnectionFactory.</param>
- public NMSConnectionFactory(string providerURI, params object[] constructorParams)
- : this(URISupport.CreateCompatibleUri(providerURI), constructorParams)
- {
- }
+ /// <summary>
+ /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object.
+ /// Any additional parameters are optional, but will typically include a Client ID string.
+ /// </summary>
+ /// <param name="providerURI">The URI for the ActiveMQ provider.</param>
+ /// <param name="constructorParams">Optional parameters to use when creating the ConnectionFactory.</param>
+ public NMSConnectionFactory(string providerURI, params object[] constructorParams)
+ : this(URISupport.CreateCompatibleUri(providerURI), constructorParams)
+ {
+ }
- /// <summary>
- /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object.
- /// Any additional parameters are optional, but will typically include a Client ID string.
- /// </summary>
- /// <param name="uriProvider">The URI for the ActiveMQ provider.</param>
- /// <param name="constructorParams">Optional parameters to use when creating the ConnectionFactory.</param>
- public NMSConnectionFactory(Uri uriProvider, params object[] constructorParams)
- {
- this.factory = CreateConnectionFactory(uriProvider, constructorParams);
- }
+ /// <summary>
+ /// The ConnectionFactory object must define a constructor that takes as a minimum a Uri object.
+ /// Any additional parameters are optional, but will typically include a Client ID string.
+ /// </summary>
+ /// <param name="uriProvider">The URI for the ActiveMQ provider.</param>
+ /// <param name="constructorParams">Optional parameters to use when creating the ConnectionFactory.</param>
+ public NMSConnectionFactory(Uri uriProvider, params object[] constructorParams)
+ {
+ this.factory = CreateConnectionFactory(uriProvider, constructorParams);
+ }
- /// <summary>
- /// Create a connection factory that can create connections for the given scheme in the URI.
- /// </summary>
- /// <param name="uriProvider">The URI for the ActiveMQ provider.</param>
- /// <param name="constructorParams">Optional parameters to use when creating the ConnectionFactory.</param>
- /// <returns>A <see cref="IConnectionFactory" /> implementation that will be used.</returns>
- public static IConnectionFactory CreateConnectionFactory(Uri uriProvider, params object[] constructorParams)
- {
- IConnectionFactory connectionFactory = null;
+ /// <summary>
+ /// Create a connection factory that can create connections for the given scheme in the URI.
+ /// </summary>
+ /// <param name="uriProvider">The URI for the ActiveMQ provider.</param>
+ /// <param name="constructorParams">Optional parameters to use when creating the ConnectionFactory.</param>
+ /// <returns>A <see cref="IConnectionFactory" /> implementation that will be used.</returns>
+ public static IConnectionFactory CreateConnectionFactory(Uri uriProvider, params object[] constructorParams)
+ {
+ IConnectionFactory connectionFactory = null;
- try
- {
- Type factoryType = GetTypeForScheme(uriProvider.Scheme);
+ try
+ {
+ Type factoryType = GetTypeForScheme(uriProvider.Scheme);
- // If an implementation was found, try to instantiate it.
- if(factoryType != null)
- {
+ // If an implementation was found, try to instantiate it.
+ if (factoryType != null)
+ {
#if NETCF
// Compact framework does not allow the activator ta pass parameters to a constructor.
connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType);
connectionFactory.BrokerUri = uriProvider;
#else
- object[] parameters = MakeParameterArray(uriProvider, constructorParams);
- connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType, parameters);
+ object[] parameters = MakeParameterArray(uriProvider, constructorParams);
+ connectionFactory = (IConnectionFactory) Activator.CreateInstance(factoryType, parameters);
#endif
- }
+ }
- if(null == connectionFactory)
- {
- throw new NMSConnectionException("No IConnectionFactory implementation found for connection URI: " + uriProvider);
- }
- }
- catch(NMSConnectionException)
- {
- throw;
- }
- catch(Exception ex)
- {
- throw new NMSConnectionException("Could not create the IConnectionFactory implementation: " + ex.Message, ex);
- }
+ if (null == connectionFactory)
+ {
+ throw new NMSConnectionException("No IConnectionFactory implementation found for connection URI: " +
+ uriProvider);
+ }
+ }
+ catch (NMSConnectionException)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ throw new NMSConnectionException(
+ "Could not create the IConnectionFactory implementation: " + ex.Message, ex);
+ }
- return connectionFactory;
- }
+ return connectionFactory;
+ }
- /// <summary>
- /// Finds the <see cref="System.Type" /> associated with the given scheme.
- /// </summary>
- /// <param name="scheme">The scheme (e.g. <c>tcp</c>, <c>activemq</c> or <c>stomp</c>).</param>
- /// <returns>The <see cref="System.Type" /> of the ConnectionFactory that will be used
- /// to create the connection for the specified <paramref name="scheme" />.</returns>
- private static Type GetTypeForScheme(string scheme)
- {
- string[] paths = GetConfigSearchPaths();
- string assemblyFileName;
- string factoryClassName;
- Type factoryType = null;
+ /// <summary>
+ /// Finds the <see cref="System.Type" /> associated with the given scheme.
+ /// </summary>
+ /// <param name="scheme">The scheme (e.g. <c>tcp</c>, <c>activemq</c> or <c>stomp</c>).</param>
+ /// <returns>The <see cref="System.Type" /> of the ConnectionFactory that will be used
+ /// to create the connection for the specified <paramref name="scheme" />.</returns>
+ private static Type GetTypeForScheme(string scheme)
+ {
+ string[] paths = GetConfigSearchPaths();
+ string assemblyFileName;
+ string factoryClassName;
+ Type factoryType = null;
- Tracer.DebugFormat("Locating provider for scheme: {0}", scheme);
- if(LookupConnectionFactoryInfo(paths, scheme, out assemblyFileName, out factoryClassName))
- {
- Assembly assembly = null;
+ Tracer.DebugFormat("Locating provider for scheme: {0}", scheme);
+ if (LookupConnectionFactoryInfo(paths, scheme, out assemblyFileName, out factoryClassName))
+ {
+ Assembly assembly = null;
- Tracer.DebugFormat("Attempting to load provider assembly: {0}", assemblyFileName);
- try
- {
- assembly = Assembly.Load(assemblyFileName);
- if(null != assembly)
- {
- Tracer.Debug("Succesfully loaded provider.");
- }
- }
- catch(Exception ex)
- {
- Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message);
- assembly = null;
- }
+ Tracer.DebugFormat("Attempting to load provider assembly: {0}", assemblyFileName);
+ try
+ {
+ assembly = Assembly.Load(assemblyFileName);
+ if (null != assembly)
+ {
+ Tracer.Debug("Succesfully loaded provider.");
+ }
+ }
+ catch (Exception ex)
+ {
+ Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message);
+ assembly = null;
+ }
- if(null == assembly)
- {
- foreach(string path in paths)
- {
- string fullpath = Path.Combine(path, assemblyFileName) + ".dll";
+ if (null == assembly)
+ {
+ foreach (string path in paths)
+ {
+ string fullpath = Path.Combine(path, assemblyFileName) + ".dll";
- Tracer.DebugFormat("Looking for: {0}", fullpath);
- if(File.Exists(fullpath))
- {
- Tracer.Debug("\tAssembly found! Attempting to load...");
- try
- {
- assembly = Assembly.LoadFrom(fullpath);
- }
- catch(Exception ex)
- {
- Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message);
- assembly = null;
- }
+ Tracer.DebugFormat("Looking for: {0}", fullpath);
+ if (File.Exists(fullpath))
+ {
+ Tracer.Debug("\tAssembly found! Attempting to load...");
+ try
+ {
+ assembly = Assembly.LoadFrom(fullpath);
+ }
+ catch (Exception ex)
+ {
+ Tracer.ErrorFormat("Exception loading assembly failed: {0}", ex.Message);
+ assembly = null;
+ }
- if(null != assembly)
- {
- Tracer.Debug("Successfully loaded provider.");
- break;
- }
+ if (null != assembly)
+ {
+ Tracer.Debug("Successfully loaded provider.");
+ break;
+ }
- Tracer.Debug("Failed to load provider. Continuing search...");
- }
- }
- }
+ Tracer.Debug("Failed to load provider. Continuing search...");
+ }
+ }
+ }
- if(null != assembly)
- {
+ if (null != assembly)
+ {
#if NETCF
factoryType = assembly.GetType(factoryClassName, true);
#else
- factoryType = assembly.GetType(factoryClassName, true, true);
+ factoryType = assembly.GetType(factoryClassName, true, true);
#endif
- if(null == factoryType)
- {
- Tracer.Fatal("Failed to load class factory from provider.");
- }
- }
- else
- {
- Tracer.Fatal("Failed to load provider assembly.");
- }
- }
+ if (null == factoryType)
+ {
+ Tracer.Fatal("Failed to load class factory from provider.");
+ }
+ }
+ else
+ {
+ Tracer.Fatal("Failed to load provider assembly.");
+ }
+ }
- return factoryType;
- }
+ return factoryType;
+ }
- /// <summary>
- /// Lookup the connection factory assembly filename and class name.
- /// Read an external configuration file that maps scheme to provider implementation.
- /// Load XML config files named: nmsprovider-{scheme}.config
- /// Following is a sample configuration file named nmsprovider-jms.config. Replace
- /// the parenthesis with angle brackets for proper XML formatting.
- ///
- /// (?xml version="1.0" encoding="utf-8" ?)
- /// (configuration)
- /// (provider assembly="MyCompany.NMS.JMSProvider.dll" classFactory="MyCompany.NMS.JMSProvider.ConnectionFactory"/)
- /// (/configuration)
- ///
- /// This configuration file would be loaded and parsed when a connection uri with a scheme of 'jms'
- /// is used for the provider. In this example the connection string might look like:
- /// jms://localhost:7222
- ///
- /// </summary>
- /// <param name="paths">Folder paths to look in.</param>
- /// <param name="scheme">The scheme.</param>
- /// <param name="assemblyFileName">Name of the assembly file.</param>
- /// <param name="factoryClassName">Name of the factory class.</param>
- /// <returns><c>true</c> if the configuration file for the specified <paramref name="scheme" /> could
- /// be found; otherwise, <c>false</c>.</returns>
- private static bool LookupConnectionFactoryInfo(string[] paths, string scheme, out string assemblyFileName, out string factoryClassName)
- {
- bool foundFactory = false;
- string schemeLower = scheme.ToLower();
- ProviderFactoryInfo pfi;
+ /// <summary>
+ /// Lookup the connection factory assembly filename and class name.
+ /// Read an external configuration file that maps scheme to provider implementation.
+ /// Load XML config files named: nmsprovider-{scheme}.config
+ /// Following is a sample configuration file named nmsprovider-jms.config. Replace
+ /// the parenthesis with angle brackets for proper XML formatting.
+ ///
+ /// (?xml version="1.0" encoding="utf-8" ?)
+ /// (configuration)
+ /// (provider assembly="MyCompany.NMS.JMSProvider.dll" classFactory="MyCompany.NMS.JMSProvider.ConnectionFactory"/)
+ /// (/configuration)
+ ///
+ /// This configuration file would be loaded and parsed when a connection uri with a scheme of 'jms'
+ /// is used for the provider. In this example the connection string might look like:
+ /// jms://localhost:7222
+ ///
+ /// </summary>
+ /// <param name="paths">Folder paths to look in.</param>
+ /// <param name="scheme">The scheme.</param>
+ /// <param name="assemblyFileName">Name of the assembly file.</param>
+ /// <param name="factoryClassName">Name of the factory class.</param>
+ /// <returns><c>true</c> if the configuration file for the specified <paramref name="scheme" /> could
+ /// be found; otherwise, <c>false</c>.</returns>
+ private static bool LookupConnectionFactoryInfo(string[] paths, string scheme, out string assemblyFileName,
+ out string factoryClassName)
+ {
+ bool foundFactory = false;
+ string schemeLower = scheme.ToLower();
+ ProviderFactoryInfo pfi;
- // Look for a custom configuration to handle this scheme.
- string configFileName = String.Format("nmsprovider-{0}.config", schemeLower);
+ // Look for a custom configuration to handle this scheme.
+ string configFileName = String.Format("nmsprovider-{0}.config", schemeLower);
- assemblyFileName = String.Empty;
- factoryClassName = String.Empty;
+ assemblyFileName = String.Empty;
+ factoryClassName = String.Empty;
- Tracer.DebugFormat("Attempting to locate provider configuration: {0}", configFileName);
- foreach(string path in paths)
- {
- string fullpath = Path.Combine(path, configFileName);
- Tracer.DebugFormat("Looking for: {0}", fullpath);
+ Tracer.DebugFormat("Attempting to locate provider configuration: {0}", configFileName);
+ foreach (string path in paths)
+ {
+ string fullpath = Path.Combine(path, configFileName);
+ Tracer.DebugFormat("Looking for: {0}", fullpath);
- try
- {
- if(File.Exists(fullpath))
- {
- Tracer.DebugFormat("\tConfiguration file found in {0}", fullpath);
- XmlDocument configDoc = new XmlDocument();
+ try
+ {
+ if (File.Exists(fullpath))
+ {
+ Tracer.DebugFormat("\tConfiguration file found in {0}", fullpath);
+ XmlDocument configDoc = new XmlDocument();
- configDoc.Load(fullpath);
- XmlElement providerNode = (XmlElement) configDoc.SelectSingleNode("/configuration/provider");
+ configDoc.Load(fullpath);
+ XmlElement providerNode = (XmlElement) configDoc.SelectSingleNode("/configuration/provider");
- if(null != providerNode)
- {
- assemblyFileName = providerNode.GetAttribute("assembly");
- factoryClassName = providerNode.GetAttribute("classFactory");
- if(!String.IsNullOrEmpty(assemblyFileName) && !String.IsNullOrEmpty(factoryClassName))
- {
- foundFactory = true;
- Tracer.DebugFormat("Selected custom provider for {0}: {1}, {2}", schemeLower, assemblyFileName, factoryClassName);
- break;
- }
- }
- }
- }
- catch(Exception ex)
- {
- Tracer.DebugFormat("Exception while scanning {0}: {1}", fullpath, ex.Message);
- }
- }
+ if (null != providerNode)
+ {
+ assemblyFileName = providerNode.GetAttribute("assembly");
+ factoryClassName = providerNode.GetAttribute("classFactory");
+ if (!String.IsNullOrEmpty(assemblyFileName) && !String.IsNullOrEmpty(factoryClassName))
+ {
+ foundFactory = true;
+ Tracer.DebugFormat("Selected custom provider for {0}: {1}, {2}", schemeLower,
+ assemblyFileName, factoryClassName);
+ break;
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Tracer.DebugFormat("Exception while scanning {0}: {1}", fullpath, ex.Message);
+ }
+ }
- if(!foundFactory)
- {
- // Check for standard provider implementations.
- if(schemaProviderFactoryMap.TryGetValue(schemeLower, out pfi))
- {
- assemblyFileName = pfi.assemblyFileName;
- factoryClassName = pfi.factoryClassName;
- foundFactory = true;
- Tracer.DebugFormat("Selected standard provider for {0}: {1}, {2}", schemeLower, assemblyFileName, factoryClassName);
- }
- }
+ if (!foundFactory)
+ {
+ // Check for standard provider implementations.
+ if (schemaProviderFactoryMap.TryGetValue(schemeLower, out pfi))
+ {
+ assemblyFileName = pfi.assemblyFileName;
+ factoryClassName = pfi.factoryClassName;
+ foundFactory = true;
+ Tracer.DebugFormat("Selected standard provider for {0}: {1}, {2}", schemeLower, assemblyFileName,
+ factoryClassName);
+ }
+ }
- return foundFactory;
- }
+ return foundFactory;
+ }
- /// <summary>
- /// Get an array of search paths to look for config files.
- /// </summary>
- /// <returns>
- /// A collection of search paths, including the current directory, the current AppDomain's
- /// BaseDirectory and the current AppDomain's RelativeSearchPath.
- /// </returns>
- private static string[] GetConfigSearchPaths()
- {
- ArrayList pathList = new ArrayList();
+ /// <summary>
+ /// Get an array of search paths to look for config files.
+ /// </summary>
+ /// <returns>
+ /// A collection of search paths, including the current directory, the current AppDomain's
+ /// BaseDirectory and the current AppDomain's RelativeSearchPath.
+ /// </returns>
+ private static string[] GetConfigSearchPaths()
+ {
+ ArrayList pathList = new ArrayList();
- // Check the current folder first.
- pathList.Add("");
+ // Check the current folder first.
+ pathList.Add("");
#if !NETCF
- try
- {
- AppDomain currentDomain = AppDomain.CurrentDomain;
+ try
+ {
+ AppDomain currentDomain = AppDomain.CurrentDomain;
- // Check the folder the assembly is located in.
- Assembly executingAssembly = Assembly.GetExecutingAssembly();
- try
- {
- pathList.Add(Path.GetDirectoryName(executingAssembly.Location));
- }
- catch(Exception ex)
- {
- Tracer.DebugFormat("Error parsing executing assembly location: {0} : {1}", executingAssembly.Location, ex.Message);
- }
+ // Check the folder the assembly is located in.
+ Assembly executingAssembly = Assembly.GetExecutingAssembly();
+ try
+ {
+ pathList.Add(Path.GetDirectoryName(executingAssembly.Location));
+ }
+ catch (Exception ex)
+ {
+ Tracer.DebugFormat("Error parsing executing assembly location: {0} : {1}",
+ executingAssembly.Location, ex.Message);
+ }
- if(null != currentDomain.BaseDirectory)
- {
- pathList.Add(currentDomain.BaseDirectory);
- }
+ if (null != currentDomain.BaseDirectory)
+ {
+ pathList.Add(currentDomain.BaseDirectory);
+ }
- if(null != currentDomain.RelativeSearchPath)
- {
- pathList.Add(currentDomain.RelativeSearchPath);
- }
- }
- catch(Exception ex)
- {
- Tracer.DebugFormat("Error configuring search paths: {0}", ex.Message);
- }
+ if (null != currentDomain.RelativeSearchPath)
+ {
+ pathList.Add(currentDomain.RelativeSearchPath);
+ }
+ }
+ catch (Exception ex)
+ {
+ Tracer.DebugFormat("Error configuring search paths: {0}", ex.Message);
+ }
#endif
- return (string[]) pathList.ToArray(typeof(string));
- }
+ return (string[]) pathList.ToArray(typeof(string));
+ }
- /// <summary>
- /// Converts a <c>params object[]</c> collection into a plain <c>object[]</c>s, to pass to the constructor.
- /// </summary>
- /// <param name="firstParam">The first parameter in the collection.</param>
- /// <param name="varParams">The remaining parameters.</param>
- /// <returns>An array of <see cref="Object" /> instances.</returns>
- private static object[] MakeParameterArray(object firstParam, params object[] varParams)
- {
- ArrayList paramList = new ArrayList();
- paramList.Add(firstParam);
- foreach(object param in varParams)
- {
- paramList.Add(param);
- }
+ /// <summary>
+ /// Converts a <c>params object[]</c> collection into a plain <c>object[]</c>s, to pass to the constructor.
+ /// </summary>
+ /// <param name="firstParam">The first parameter in the collection.</param>
+ /// <param name="varParams">The remaining parameters.</param>
+ /// <returns>An array of <see cref="Object" /> instances.</returns>
+ private static object[] MakeParameterArray(object firstParam, params object[] varParams)
+ {
+ ArrayList paramList = new ArrayList();
+ paramList.Add(firstParam);
+ foreach (object param in varParams)
+ {
+ paramList.Add(param);
+ }
- return paramList.ToArray();
- }
+ return paramList.ToArray();
+ }
- /// <summary>
- /// Creates a new connection.
- /// </summary>
- /// <returns>An <see cref="IConnection" /> created by the requested ConnectionFactory.</returns>
- public IConnection CreateConnection()
- {
- return this.factory.CreateConnection();
- }
+ /// <summary>
+ /// Creates a new connection.
+ /// </summary>
+ /// <returns>An <see cref="IConnection" /> created by the requested ConnectionFactory.</returns>
+ public IConnection CreateConnection()
+ {
+ return this.factory.CreateConnection();
+ }
- /// <summary>
- /// Creates a new connection with the given <paramref name="userName" /> and <paramref name="password" /> credentials.
- /// </summary>
- /// <param name="userName">The username to use when establishing the connection.</param>
- /// <param name="password">The password to use when establishing the connection.</param>
- /// <returns>An <see cref="IConnection" /> created by the requested ConnectionFactory.</returns>
- public IConnection CreateConnection(string userName, string password)
- {
- return this.factory.CreateConnection(userName, password);
- }
-
- public INMSContext CreateContext()
- {
- return this.factory.CreateContext();
- }
-
- public INMSContext CreateContext(AcknowledgementMode acknowledgementMode)
- {
- return this.factory.CreateContext(acknowledgementMode);
- }
-
- public INMSContext CreateContext(string userName, string password)
- {
- return this.factory.CreateContext(userName, password);
- }
-
- public INMSContext CreateContext(string userName, string password, AcknowledgementMode acknowledgementMode)
- {
- return this.factory.CreateContext(userName, password, acknowledgementMode);
- }
+ /// <summary>
+ /// Creates a new connection with the given <paramref name="userName" /> and <paramref name="password" /> credentials.
+ /// </summary>
+ /// <param name="userName">The username to use when establishing the connection.</param>
+ /// <param name="password">The password to use when establishing the connection.</param>
+ /// <returns>An <see cref="IConnection" /> created by the requested ConnectionFactory.</returns>
+ public IConnection CreateConnection(string userName, string password)
+ {
+ return this.factory.CreateConnection(userName, password);
+ }
- /// <summary>
- /// Get/or set the broker Uri.
- /// </summary>
- public Uri BrokerUri
- {
- get { return ConnectionFactory.BrokerUri; }
- set { ConnectionFactory.BrokerUri = value; }
- }
+ public INMSContext CreateContext()
+ {
+ return this.factory.CreateContext();
+ }
- /// <summary>
- /// The actual IConnectionFactory implementation that is being used. This implementation
- /// depends on the scheme of the URI used when constructed.
- /// </summary>
- public IConnectionFactory ConnectionFactory
- {
- get { return factory; }
- }
+ public INMSContext CreateContext(AcknowledgementMode acknowledgementMode)
+ {
+ return this.factory.CreateContext(acknowledgementMode);
+ }
- /// <summary>
- /// Get/or Set the IRedeliveryPolicy instance using the IConnectionFactory implementation
- /// that is being used.
- /// </summary>
- public IRedeliveryPolicy RedeliveryPolicy
- {
- get { return this.factory.RedeliveryPolicy; }
- set { this.factory.RedeliveryPolicy = value; }
- }
+ public INMSContext CreateContext(string userName, string password)
+ {
+ return this.factory.CreateContext(userName, password);
+ }
+
+ public INMSContext CreateContext(string userName, string password, AcknowledgementMode acknowledgementMode)
+ {
+ return this.factory.CreateContext(userName, password, acknowledgementMode);
+ }
+
+ /// <summary>
+ /// Get/or set the broker Uri.
+ /// </summary>
+ public Uri BrokerUri
+ {
+ get { return ConnectionFactory.BrokerUri; }
+ set { ConnectionFactory.BrokerUri = value; }
+ }
+
+ /// <summary>
+ /// The actual IConnectionFactory implementation that is being used. This implementation
+ /// depends on the scheme of the URI used when constructed.
+ /// </summary>
+ public IConnectionFactory ConnectionFactory
+ {
+ get { return factory; }
+ }
+
+ /// <summary>
+ /// Get/or Set the IRedeliveryPolicy instance using the IConnectionFactory implementation
+ /// that is being used.
+ /// </summary>
+ public IRedeliveryPolicy RedeliveryPolicy
+ {
+ get { return this.factory.RedeliveryPolicy; }
+ set { this.factory.RedeliveryPolicy = value; }
+ }
/// <summary>
/// Get/or Set the ConsumerTransformerDelegate using the IConnectionFactory implementation
@@ -456,5 +471,5 @@
get { return this.factory.ProducerTransformer; }
set { this.factory.ProducerTransformer = value; }
}
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/NMSConstants.cs b/src/nms-api/NMSConstants.cs
index 001f21d..6b50fbf 100644
--- a/src/nms-api/NMSConstants.cs
+++ b/src/nms-api/NMSConstants.cs
@@ -20,45 +20,43 @@
namespace Apache.NMS
{
- /// <summary>
- /// Define an enumerated array of message priorities.
- /// </summary>
- public enum MsgPriority
- {
- Lowest = 0,
- VeryLow = 1,
- Low = 2,
- AboveLow = 3,
- BelowNormal = 4,
- Normal = 5,
- AboveNormal = 6,
- High = 7,
- VeryHigh = 8,
- Highest = 9
- }
+ /// <summary>
+ /// Define an enumerated array of message priorities.
+ /// </summary>
+ public enum MsgPriority
+ {
+ Lowest = 0,
+ VeryLow = 1,
+ Low = 2,
+ AboveLow = 3,
+ BelowNormal = 4,
+ Normal = 5,
+ AboveNormal = 6,
+ High = 7,
+ VeryHigh = 8,
+ Highest = 9
+ }
- /// <summary>
- /// Define an enumerated array of message delivery modes. Provider-specific
- /// values can be used to extend this enumerated mode. TIBCO is known to
- /// provide a third value of ReliableDelivery. At minimum, a provider must
- /// support Persistent and NonPersistent.
- /// </summary>
- public enum MsgDeliveryMode
- {
- Persistent,
- NonPersistent
- }
+ /// <summary>
+ /// Define an enumerated array of message delivery modes. Provider-specific
+ /// values can be used to extend this enumerated mode. TIBCO is known to
+ /// provide a third value of ReliableDelivery. At minimum, a provider must
+ /// support Persistent and NonPersistent.
+ /// </summary>
+ public enum MsgDeliveryMode
+ {
+ Persistent,
+ NonPersistent
+ }
- /// <summary>
- /// Defines a number of constants
- /// </summary>
- public class NMSConstants
- {
- public const MsgPriority defaultPriority = MsgPriority.Normal;
- public const MsgDeliveryMode defaultDeliveryMode = MsgDeliveryMode.Persistent;
- public static readonly TimeSpan defaultTimeToLive = TimeSpan.Zero;
- public static readonly TimeSpan defaultRequestTimeout = TimeSpan.FromMilliseconds(Timeout.Infinite);
- }
-}
-
-
+ /// <summary>
+ /// Defines a number of constants
+ /// </summary>
+ public class NMSConstants
+ {
+ public const MsgPriority defaultPriority = MsgPriority.Normal;
+ public const MsgDeliveryMode defaultDeliveryMode = MsgDeliveryMode.Persistent;
+ public static readonly TimeSpan defaultTimeToLive = TimeSpan.Zero;
+ public static readonly TimeSpan defaultRequestTimeout = TimeSpan.FromMilliseconds(Timeout.Infinite);
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/NMSException.cs b/src/nms-api/NMSException.cs
index b33cadc..b21a6a8 100644
--- a/src/nms-api/NMSException.cs
+++ b/src/nms-api/NMSException.cs
@@ -19,77 +19,81 @@
namespace Apache.NMS
{
- /// <summary>
- /// Represents an NMS exception
- /// </summary>
- [Serializable]
- public class NMSException : Exception
- {
- protected string exceptionErrorCode;
+ /// <summary>
+ /// Represents an NMS exception
+ /// </summary>
+ [Serializable]
+ public class NMSException : Exception
+ {
+ protected string exceptionErrorCode;
- public NMSException()
- : base()
- {
- }
+ public NMSException()
+ : base()
+ {
+ }
- public NMSException(string message)
- : base(message)
- {
- }
+ public NMSException(string message)
+ : base(message)
+ {
+ }
- public NMSException(string message, string errorCode)
- : this(message)
- {
- exceptionErrorCode = errorCode;
- }
+ public NMSException(string message, string errorCode)
+ : this(message)
+ {
+ exceptionErrorCode = errorCode;
+ }
- public NMSException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public NMSException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public NMSException(string message, string errorCode, Exception innerException)
- : base(message, innerException)
- {
- exceptionErrorCode = errorCode;
- }
+ public NMSException(string message, string errorCode, Exception innerException)
+ : base(message, innerException)
+ {
+ exceptionErrorCode = errorCode;
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the NMSException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected NMSException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- exceptionErrorCode = info.GetString("NMSException.exceptionErrorCode");
- }
+ /// <summary>
+ /// Initializes a new instance of the NMSException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected NMSException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ exceptionErrorCode = info.GetString("NMSException.exceptionErrorCode");
+ }
- /// <summary>
- /// When overridden in a derived class, sets the SerializationInfo with information about the exception.
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- {
- base.GetObjectData(info, context);
- info.AddValue("NMSException.exceptionErrorCode", exceptionErrorCode);
- }
+ /// <summary>
+ /// When overridden in a derived class, sets the SerializationInfo with information about the exception.
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ {
+ base.GetObjectData(info, context);
+ info.AddValue("NMSException.exceptionErrorCode", exceptionErrorCode);
+ }
#endif
- #endregion
- /// <summary>
- /// Returns the error code for the exception, if one has been provided.
- /// </summary>
- public string ErrorCode
- {
- get { return exceptionErrorCode; }
- }
- }
-}
+ #endregion
+
+ /// <summary>
+ /// Returns the error code for the exception, if one has been provided.
+ /// </summary>
+ public string ErrorCode
+ {
+ get { return exceptionErrorCode; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/NMSSecurityException.cs b/src/nms-api/NMSSecurityException.cs
index d7c7faa..3c43e66 100644
--- a/src/nms-api/NMSSecurityException.cs
+++ b/src/nms-api/NMSSecurityException.cs
@@ -19,53 +19,56 @@
namespace Apache.NMS
{
- /// <summary>
- /// Represents a security failure.
- /// </summary>
- [Serializable]
- public class NMSSecurityException : NMSException
- {
- public NMSSecurityException()
- : base()
- {
- }
+ /// <summary>
+ /// Represents a security failure.
+ /// </summary>
+ [Serializable]
+ public class NMSSecurityException : NMSException
+ {
+ public NMSSecurityException()
+ : base()
+ {
+ }
- public NMSSecurityException(string message)
- : base(message)
- {
- }
+ public NMSSecurityException(string message)
+ : base(message)
+ {
+ }
- public NMSSecurityException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public NMSSecurityException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public NMSSecurityException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public NMSSecurityException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public NMSSecurityException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public NMSSecurityException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the NMSSecurityException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected NMSSecurityException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the NMSSecurityException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected NMSSecurityException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/ResourceAllocationException.cs b/src/nms-api/ResourceAllocationException.cs
index 21a954f..59ac1dd 100644
--- a/src/nms-api/ResourceAllocationException.cs
+++ b/src/nms-api/ResourceAllocationException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class ResourceAllocationException : NMSException
- {
- public ResourceAllocationException()
- : base()
- {
- }
+ [Serializable]
+ public class ResourceAllocationException : NMSException
+ {
+ public ResourceAllocationException()
+ : base()
+ {
+ }
- public ResourceAllocationException(string message)
- : base(message)
- {
- }
+ public ResourceAllocationException(string message)
+ : base(message)
+ {
+ }
- public ResourceAllocationException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public ResourceAllocationException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public ResourceAllocationException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public ResourceAllocationException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public ResourceAllocationException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public ResourceAllocationException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the ResourceAllocationException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected ResourceAllocationException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the ResourceAllocationException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected ResourceAllocationException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/SessionExtensions.cs b/src/nms-api/SessionExtensions.cs
index 850aa9d..241c9ed 100644
--- a/src/nms-api/SessionExtensions.cs
+++ b/src/nms-api/SessionExtensions.cs
@@ -1,18 +1,18 @@
-/*
- * 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.
+/*
+ * 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.Text;
@@ -98,4 +98,4 @@
}
}
#endif
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/Tracer.cs b/src/nms-api/Tracer.cs
index 90bb441..264a3b9 100644
--- a/src/nms-api/Tracer.cs
+++ b/src/nms-api/Tracer.cs
@@ -14,126 +14,127 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
namespace Apache.NMS
{
- public sealed class Tracer
- {
- private static ITrace s_trace = null;
+ public sealed class Tracer
+ {
+ private static ITrace s_trace = null;
- // prevent instantiation of this class. All methods are static.
- private Tracer()
- {
- }
+ // prevent instantiation of this class. All methods are static.
+ private Tracer()
+ {
+ }
- public static ITrace Trace
- {
- get { return s_trace; }
- set { s_trace = value; }
- }
+ public static ITrace Trace
+ {
+ get { return s_trace; }
+ set { s_trace = value; }
+ }
- public static bool IsDebugEnabled
- {
- get { return s_trace != null && s_trace.IsDebugEnabled; }
- }
+ public static bool IsDebugEnabled
+ {
+ get { return s_trace != null && s_trace.IsDebugEnabled; }
+ }
- public static bool IsInfoEnabled
- {
- get { return s_trace != null && s_trace.IsInfoEnabled; }
- }
+ public static bool IsInfoEnabled
+ {
+ get { return s_trace != null && s_trace.IsInfoEnabled; }
+ }
- public static bool IsWarnEnabled
- {
- get { return s_trace != null && s_trace.IsWarnEnabled; }
- }
+ public static bool IsWarnEnabled
+ {
+ get { return s_trace != null && s_trace.IsWarnEnabled; }
+ }
- public static bool IsErrorEnabled
- {
- get { return s_trace != null && s_trace.IsErrorEnabled; }
- }
+ public static bool IsErrorEnabled
+ {
+ get { return s_trace != null && s_trace.IsErrorEnabled; }
+ }
- public static bool IsFatalEnabled
- {
- get { return s_trace != null && s_trace.IsFatalEnabled; }
- }
+ public static bool IsFatalEnabled
+ {
+ get { return s_trace != null && s_trace.IsFatalEnabled; }
+ }
- public static void Debug(object message)
- {
- if(IsDebugEnabled)
- {
- s_trace.Debug(message.ToString());
- }
- }
+ public static void Debug(object message)
+ {
+ if (IsDebugEnabled)
+ {
+ s_trace.Debug(message.ToString());
+ }
+ }
- public static void DebugFormat(string format, params object[] args)
- {
- if(IsDebugEnabled)
- {
- s_trace.Debug(string.Format(format, args));
- }
- }
+ public static void DebugFormat(string format, params object[] args)
+ {
+ if (IsDebugEnabled)
+ {
+ s_trace.Debug(string.Format(format, args));
+ }
+ }
- public static void Info(object message)
- {
- if(IsInfoEnabled)
- {
- s_trace.Info(message.ToString());
- }
- }
+ public static void Info(object message)
+ {
+ if (IsInfoEnabled)
+ {
+ s_trace.Info(message.ToString());
+ }
+ }
- public static void InfoFormat(string format, params object[] args)
- {
- if(IsInfoEnabled)
- {
- s_trace.Info(string.Format(format, args));
- }
- }
+ public static void InfoFormat(string format, params object[] args)
+ {
+ if (IsInfoEnabled)
+ {
+ s_trace.Info(string.Format(format, args));
+ }
+ }
- public static void Warn(object message)
- {
- if(IsWarnEnabled)
- {
- s_trace.Warn(message.ToString());
- }
- }
+ public static void Warn(object message)
+ {
+ if (IsWarnEnabled)
+ {
+ s_trace.Warn(message.ToString());
+ }
+ }
- public static void WarnFormat(string format, params object[] args)
- {
- if(IsWarnEnabled)
- {
- s_trace.Warn(string.Format(format, args));
- }
- }
+ public static void WarnFormat(string format, params object[] args)
+ {
+ if (IsWarnEnabled)
+ {
+ s_trace.Warn(string.Format(format, args));
+ }
+ }
- public static void Error(object message)
- {
- if(IsErrorEnabled)
- {
- s_trace.Error(message.ToString());
- }
- }
+ public static void Error(object message)
+ {
+ if (IsErrorEnabled)
+ {
+ s_trace.Error(message.ToString());
+ }
+ }
- public static void ErrorFormat(string format, params object[] args)
- {
- if(IsErrorEnabled)
- {
- s_trace.Error(string.Format(format, args));
- }
- }
+ public static void ErrorFormat(string format, params object[] args)
+ {
+ if (IsErrorEnabled)
+ {
+ s_trace.Error(string.Format(format, args));
+ }
+ }
- public static void Fatal(object message)
- {
- if(IsFatalEnabled)
- {
- s_trace.Fatal(message.ToString());
- }
- }
+ public static void Fatal(object message)
+ {
+ if (IsFatalEnabled)
+ {
+ s_trace.Fatal(message.ToString());
+ }
+ }
- public static void FatalFormat(string format, params object[] args)
- {
- if(IsFatalEnabled)
- {
- s_trace.Fatal(string.Format(format, args));
- }
- }
- }
-}
+ public static void FatalFormat(string format, params object[] args)
+ {
+ if (IsFatalEnabled)
+ {
+ s_trace.Fatal(string.Format(format, args));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/TransactionInProgressException.cs b/src/nms-api/TransactionInProgressException.cs
index b42c873..6016219 100644
--- a/src/nms-api/TransactionInProgressException.cs
+++ b/src/nms-api/TransactionInProgressException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class TransactionInProgressException : NMSException
- {
- public TransactionInProgressException()
- : base()
- {
- }
+ [Serializable]
+ public class TransactionInProgressException : NMSException
+ {
+ public TransactionInProgressException()
+ : base()
+ {
+ }
- public TransactionInProgressException(string message)
- : base(message)
- {
- }
+ public TransactionInProgressException(string message)
+ : base(message)
+ {
+ }
- public TransactionInProgressException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public TransactionInProgressException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public TransactionInProgressException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public TransactionInProgressException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public TransactionInProgressException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public TransactionInProgressException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the TransactionInProgressException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected TransactionInProgressException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the TransactionInProgressException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected TransactionInProgressException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/TransactionRolledBackException.cs b/src/nms-api/TransactionRolledBackException.cs
index bd496dc..f302bd3 100644
--- a/src/nms-api/TransactionRolledBackException.cs
+++ b/src/nms-api/TransactionRolledBackException.cs
@@ -21,50 +21,53 @@
namespace Apache.NMS
{
- [Serializable]
- public class TransactionRolledBackException : NMSException
- {
- public TransactionRolledBackException()
- : base()
- {
- }
+ [Serializable]
+ public class TransactionRolledBackException : NMSException
+ {
+ public TransactionRolledBackException()
+ : base()
+ {
+ }
- public TransactionRolledBackException(string message)
- : base(message)
- {
- }
+ public TransactionRolledBackException(string message)
+ : base(message)
+ {
+ }
- public TransactionRolledBackException(string message, string errorCode)
- : base(message, errorCode)
- {
- }
+ public TransactionRolledBackException(string message, string errorCode)
+ : base(message, errorCode)
+ {
+ }
- public TransactionRolledBackException(string message, Exception innerException)
- : base(message, innerException)
- {
- }
+ public TransactionRolledBackException(string message, Exception innerException)
+ : base(message, innerException)
+ {
+ }
- public TransactionRolledBackException(string message, string errorCode, Exception innerException)
- : base(message, errorCode, innerException)
- {
- }
+ public TransactionRolledBackException(string message, string errorCode, Exception innerException)
+ : base(message, errorCode, innerException)
+ {
+ }
- #region ISerializable interface implementation
+ #region ISerializable interface implementation
+
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the TransactionRolledBackException class with serialized data.
- /// Throws System.ArgumentNullException if the info parameter is null.
- /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
- /// </summary>
- /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
- protected TransactionRolledBackException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the TransactionRolledBackException class with serialized data.
+ /// Throws System.ArgumentNullException if the info parameter is null.
+ /// Throws System.Runtime.Serialization.SerializationException if the class name is null or System.Exception.HResult is zero (0).
+ /// </summary>
+ /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
+ protected TransactionRolledBackException(System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context)
+ : base(info, context)
+ {
+ }
#endif
- #endregion
- }
-}
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/Atomic.cs b/src/nms-api/Util/Atomic.cs
index e6298ea..7e4989c 100644
--- a/src/nms-api/Util/Atomic.cs
+++ b/src/nms-api/Util/Atomic.cs
@@ -19,71 +19,71 @@
namespace Apache.NMS.Util
{
- public class AtomicReference<T>
- {
- protected T atomicValue;
+ public class AtomicReference<T>
+ {
+ protected T atomicValue;
- public T Value
- {
- get
- {
- lock(this)
- {
- return atomicValue;
- }
- }
- set
- {
- lock(this)
- {
- atomicValue = value;
- }
- }
- }
-
- public AtomicReference()
- {
- atomicValue = default(T);
- }
+ public T Value
+ {
+ get
+ {
+ lock (this)
+ {
+ return atomicValue;
+ }
+ }
+ set
+ {
+ lock (this)
+ {
+ atomicValue = value;
+ }
+ }
+ }
- public AtomicReference(T defaultValue)
- {
- atomicValue = defaultValue;
- }
+ public AtomicReference()
+ {
+ atomicValue = default(T);
+ }
- public T GetAndSet(T value)
- {
- lock(this)
- {
- T ret = atomicValue;
- atomicValue = value;
- return ret;
- }
- }
- }
-
- public class Atomic<T> : AtomicReference<T> where T : IComparable
- {
- public Atomic() : base()
- {
- }
-
- public Atomic(T defaultValue) : base(defaultValue)
- {
- }
-
- public bool CompareAndSet(T expected, T newValue)
- {
- lock(this)
- {
- if(0 == atomicValue.CompareTo(expected))
- {
- atomicValue = newValue;
- return true;
- }
-
- return false;
- }
- }
- }
-}
+ public AtomicReference(T defaultValue)
+ {
+ atomicValue = defaultValue;
+ }
+
+ public T GetAndSet(T value)
+ {
+ lock (this)
+ {
+ T ret = atomicValue;
+ atomicValue = value;
+ return ret;
+ }
+ }
+ }
+
+ public class Atomic<T> : AtomicReference<T> where T : IComparable
+ {
+ public Atomic() : base()
+ {
+ }
+
+ public Atomic(T defaultValue) : base(defaultValue)
+ {
+ }
+
+ public bool CompareAndSet(T expected, T newValue)
+ {
+ lock (this)
+ {
+ if (0 == atomicValue.CompareTo(expected))
+ {
+ atomicValue = newValue;
+ return true;
+ }
+
+ return false;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/Convert.cs b/src/nms-api/Util/Convert.cs
index e932067..a4d81ef 100644
--- a/src/nms-api/Util/Convert.cs
+++ b/src/nms-api/Util/Convert.cs
@@ -20,143 +20,143 @@
namespace Apache.NMS.Util
{
- public class NMSConvert
- {
- /// <summary>
- /// Convert the acknowledgment mode string into AcknowledgementMode enum.
- /// </summary>
- /// <param name="ackText"></param>
- /// <returns>Equivalent enum value. If unknown string is encounted, it will default to AutoAcknowledge.</returns>
- public static AcknowledgementMode ToAcknowledgementMode(string ackText)
- {
- if(String.Compare(ackText, "AutoAcknowledge", true) == 0)
- {
- return AcknowledgementMode.AutoAcknowledge;
- }
- else if(String.Compare(ackText, "ClientAcknowledge", true) == 0)
- {
- return AcknowledgementMode.ClientAcknowledge;
- }
- else if(String.Compare(ackText, "IndividualAcknowledge", true) == 0)
- {
- return AcknowledgementMode.IndividualAcknowledge;
- }
- else if(String.Compare(ackText, "DupsOkAcknowledge", true) == 0)
- {
- return AcknowledgementMode.DupsOkAcknowledge;
- }
- else if(String.Compare(ackText, "Transactional", true) == 0)
- {
- return AcknowledgementMode.Transactional;
- }
- else
- {
- return AcknowledgementMode.AutoAcknowledge;
- }
- }
+ public class NMSConvert
+ {
+ /// <summary>
+ /// Convert the acknowledgment mode string into AcknowledgementMode enum.
+ /// </summary>
+ /// <param name="ackText"></param>
+ /// <returns>Equivalent enum value. If unknown string is encounted, it will default to AutoAcknowledge.</returns>
+ public static AcknowledgementMode ToAcknowledgementMode(string ackText)
+ {
+ if (String.Compare(ackText, "AutoAcknowledge", true) == 0)
+ {
+ return AcknowledgementMode.AutoAcknowledge;
+ }
+ else if (String.Compare(ackText, "ClientAcknowledge", true) == 0)
+ {
+ return AcknowledgementMode.ClientAcknowledge;
+ }
+ else if (String.Compare(ackText, "IndividualAcknowledge", true) == 0)
+ {
+ return AcknowledgementMode.IndividualAcknowledge;
+ }
+ else if (String.Compare(ackText, "DupsOkAcknowledge", true) == 0)
+ {
+ return AcknowledgementMode.DupsOkAcknowledge;
+ }
+ else if (String.Compare(ackText, "Transactional", true) == 0)
+ {
+ return AcknowledgementMode.Transactional;
+ }
+ else
+ {
+ return AcknowledgementMode.AutoAcknowledge;
+ }
+ }
- /// <summary>
- /// Convert an object into a text message. The object must be serializable to XML.
- /// </summary>
+ /// <summary>
+ /// Convert an object into a text message. The object must be serializable to XML.
+ /// </summary>
#if NET_3_5 || MONO
[Obsolete]
#endif
- public static ITextMessage ToXmlMessage(IMessageProducer producer, object obj)
- {
- return SerializeObjToMessage(producer.CreateTextMessage(), obj);
- }
+ public static ITextMessage ToXmlMessage(IMessageProducer producer, object obj)
+ {
+ return SerializeObjToMessage(producer.CreateTextMessage(), obj);
+ }
- /// <summary>
- /// Convert an object into a text message. The object must be serializable to XML.
- /// </summary>
+ /// <summary>
+ /// Convert an object into a text message. The object must be serializable to XML.
+ /// </summary>
#if NET_3_5 || MONO
[Obsolete]
#endif
- public static ITextMessage ToXmlMessage(ISession session, object obj)
- {
- return SerializeObjToMessage(session.CreateTextMessage(), obj);
- }
+ public static ITextMessage ToXmlMessage(ISession session, object obj)
+ {
+ return SerializeObjToMessage(session.CreateTextMessage(), obj);
+ }
- /// <summary>
- /// Convert a text message into an object. The object must be serializable from XML.
- /// </summary>
+ /// <summary>
+ /// Convert a text message into an object. The object must be serializable from XML.
+ /// </summary>
#if NET_3_5 || MONO
[Obsolete]
#endif
- public static object FromXmlMessage(IMessage message)
- {
- return DeserializeObjFromMessage(message);
- }
+ public static object FromXmlMessage(IMessage message)
+ {
+ return DeserializeObjFromMessage(message);
+ }
- /// <summary>
- /// Serialize the object as XML into the Text body of the message.
- /// Set the NMSType to the full name of the object type.
- /// </summary>
- /// <param name="message"></param>
- /// <param name="obj"></param>
- /// <returns></returns>
- internal static ITextMessage SerializeObjToMessage(ITextMessage message, object obj)
- {
- // Embed the type into the message
- message.NMSType = obj.GetType().FullName;
- message.Text = XmlUtil.Serialize(obj);
- return message;
- }
+ /// <summary>
+ /// Serialize the object as XML into the Text body of the message.
+ /// Set the NMSType to the full name of the object type.
+ /// </summary>
+ /// <param name="message"></param>
+ /// <param name="obj"></param>
+ /// <returns></returns>
+ internal static ITextMessage SerializeObjToMessage(ITextMessage message, object obj)
+ {
+ // Embed the type into the message
+ message.NMSType = obj.GetType().FullName;
+ message.Text = XmlUtil.Serialize(obj);
+ return message;
+ }
- /// <summary>
- /// Deserialize the object from the text message. The object must be serializable from XML.
- /// </summary>
- /// <param name="message"></param>
- /// <returns></returns>
- internal static object DeserializeObjFromMessage(IMessage message)
- {
- ITextMessage textMessage = message as ITextMessage;
+ /// <summary>
+ /// Deserialize the object from the text message. The object must be serializable from XML.
+ /// </summary>
+ /// <param name="message"></param>
+ /// <returns></returns>
+ internal static object DeserializeObjFromMessage(IMessage message)
+ {
+ ITextMessage textMessage = message as ITextMessage;
- if(null == textMessage)
- {
- return null;
- }
+ if (null == textMessage)
+ {
+ return null;
+ }
- if(string.IsNullOrEmpty(textMessage.NMSType))
- {
- Tracer.ErrorFormat("NMSType not set on message. Could not deserializing XML object.");
- return null;
- }
+ if (string.IsNullOrEmpty(textMessage.NMSType))
+ {
+ Tracer.ErrorFormat("NMSType not set on message. Could not deserializing XML object.");
+ return null;
+ }
- Type objType = GetRuntimeType(textMessage.NMSType);
- if(null == objType)
- {
- Tracer.ErrorFormat("Could not load type for {0} while deserializing XML object.", textMessage.NMSType);
- return null;
- }
+ Type objType = GetRuntimeType(textMessage.NMSType);
+ if (null == objType)
+ {
+ Tracer.ErrorFormat("Could not load type for {0} while deserializing XML object.", textMessage.NMSType);
+ return null;
+ }
- return XmlUtil.Deserialize(objType, textMessage.Text);
- }
+ return XmlUtil.Deserialize(objType, textMessage.Text);
+ }
- /// <summary>
- /// Get the runtime type for the class name. This routine will search all loaded
- /// assemblies in the current App Domain to find the type.
- /// </summary>
- /// <param name="typeName">Full name of the type.</param>
- /// <returns>Type object if found, or null if not found.</returns>
- private static Type GetRuntimeType(string typeName)
- {
- Type objType = null;
+ /// <summary>
+ /// Get the runtime type for the class name. This routine will search all loaded
+ /// assemblies in the current App Domain to find the type.
+ /// </summary>
+ /// <param name="typeName">Full name of the type.</param>
+ /// <returns>Type object if found, or null if not found.</returns>
+ private static Type GetRuntimeType(string typeName)
+ {
+ Type objType = null;
#if NETCF
objType = Assembly.GetCallingAssembly().GetType(typeName, false);
#else
- foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
- {
- objType = assembly.GetType(typeName, false, true);
- if(null != objType)
- {
- break;
- }
- }
+ foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ objType = assembly.GetType(typeName, false, true);
+ if (null != objType)
+ {
+ break;
+ }
+ }
#endif
- return objType;
- }
- }
-}
+ return objType;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/CountDownLatch.cs b/src/nms-api/Util/CountDownLatch.cs
index d311732..6b1001f 100644
--- a/src/nms-api/Util/CountDownLatch.cs
+++ b/src/nms-api/Util/CountDownLatch.cs
@@ -14,52 +14,53 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.Threading;
namespace Apache.NMS.Util
{
- public class CountDownLatch
- {
- private readonly ManualResetEvent mutex = new ManualResetEvent(false);
- private int remaining;
+ public class CountDownLatch
+ {
+ private readonly ManualResetEvent mutex = new ManualResetEvent(false);
+ private int remaining;
- public CountDownLatch(int i)
- {
- remaining = i;
- }
+ public CountDownLatch(int i)
+ {
+ remaining = i;
+ }
/// <summary>
/// Decrement the count, releasing any waiting Threads when the count reaches Zero.
/// </summary>
- public void countDown()
- {
- lock(mutex)
- {
- if(remaining > 0)
- {
- remaining--;
- if(0 == remaining)
- {
- mutex.Set();
- }
- }
- }
- }
+ public void countDown()
+ {
+ lock (mutex)
+ {
+ if (remaining > 0)
+ {
+ remaining--;
+ if (0 == remaining)
+ {
+ mutex.Set();
+ }
+ }
+ }
+ }
/// <summary>
/// Gets the current count for this Latch.
/// </summary>
- public int Remaining
- {
- get
- {
- lock(mutex)
- {
- return remaining;
- }
- }
- }
+ public int Remaining
+ {
+ get
+ {
+ lock (mutex)
+ {
+ return remaining;
+ }
+ }
+ }
/// <summary>
/// Causes the current Thread to wait for the count to reach zero, unless
@@ -74,14 +75,14 @@
/// Causes the current thread to wait until the latch has counted down to zero, unless
/// the thread is interrupted, or the specified waiting time elapses.
/// </summary>
- public bool await(TimeSpan timeout)
- {
- return mutex.WaitOne((int) timeout.TotalMilliseconds, false);
- }
+ public bool await(TimeSpan timeout)
+ {
+ return mutex.WaitOne((int) timeout.TotalMilliseconds, false);
+ }
- public WaitHandle AsyncWaitHandle
- {
- get { return mutex; }
- }
- }
-}
+ public WaitHandle AsyncWaitHandle
+ {
+ get { return mutex; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/DateUtils.cs b/src/nms-api/Util/DateUtils.cs
index c369951..7be24ff 100644
--- a/src/nms-api/Util/DateUtils.cs
+++ b/src/nms-api/Util/DateUtils.cs
@@ -14,51 +14,53 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS.Util
{
- public class DateUtils
- {
- /// <summary>
- /// The start of the Windows epoch
- /// </summary>
- public static readonly DateTime windowsEpoch = new DateTime(1601, 1, 1, 0, 0, 0, 0);
- /// <summary>
- /// The start of the Java epoch
- /// </summary>
- public static readonly DateTime javaEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0);
-
- /// <summary>
- /// The difference between the Windows epoch and the Java epoch
- /// in milliseconds.
- /// </summary>
- public static readonly long epochDiff; /* = 1164447360000L; */
+ public class DateUtils
+ {
+ /// <summary>
+ /// The start of the Windows epoch
+ /// </summary>
+ public static readonly DateTime windowsEpoch = new DateTime(1601, 1, 1, 0, 0, 0, 0);
- static DateUtils()
- {
- epochDiff = (javaEpoch.ToFileTimeUtc() - windowsEpoch.ToFileTimeUtc())
- / TimeSpan.TicksPerMillisecond;
- }
+ /// <summary>
+ /// The start of the Java epoch
+ /// </summary>
+ public static readonly DateTime javaEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0);
- public static long ToJavaTime(DateTime dateTime)
- {
- return (dateTime.ToFileTime() / TimeSpan.TicksPerMillisecond) - epochDiff;
- }
+ /// <summary>
+ /// The difference between the Windows epoch and the Java epoch
+ /// in milliseconds.
+ /// </summary>
+ public static readonly long epochDiff; /* = 1164447360000L; */
- public static DateTime ToDateTime(long javaTime)
- {
- return DateTime.FromFileTime((javaTime + epochDiff) * TimeSpan.TicksPerMillisecond);
- }
+ static DateUtils()
+ {
+ epochDiff = (javaEpoch.ToFileTimeUtc() - windowsEpoch.ToFileTimeUtc())
+ / TimeSpan.TicksPerMillisecond;
+ }
- public static long ToJavaTimeUtc(DateTime dateTime)
- {
- return (dateTime.ToFileTimeUtc() / TimeSpan.TicksPerMillisecond) - epochDiff;
- }
+ public static long ToJavaTime(DateTime dateTime)
+ {
+ return (dateTime.ToFileTime() / TimeSpan.TicksPerMillisecond) - epochDiff;
+ }
- public static DateTime ToDateTimeUtc(long javaTime)
- {
- return DateTime.FromFileTimeUtc((javaTime + epochDiff) * TimeSpan.TicksPerMillisecond);
- }
- }
-}
+ public static DateTime ToDateTime(long javaTime)
+ {
+ return DateTime.FromFileTime((javaTime + epochDiff) * TimeSpan.TicksPerMillisecond);
+ }
+
+ public static long ToJavaTimeUtc(DateTime dateTime)
+ {
+ return (dateTime.ToFileTimeUtc() / TimeSpan.TicksPerMillisecond) - epochDiff;
+ }
+
+ public static DateTime ToDateTimeUtc(long javaTime)
+ {
+ return DateTime.FromFileTimeUtc((javaTime + epochDiff) * TimeSpan.TicksPerMillisecond);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/EndianBinaryReader.cs b/src/nms-api/Util/EndianBinaryReader.cs
index 8fd3ecf..26fdd5f 100644
--- a/src/nms-api/Util/EndianBinaryReader.cs
+++ b/src/nms-api/Util/EndianBinaryReader.cs
@@ -20,173 +20,175 @@
namespace Apache.NMS.Util
{
- /// <summary>
- /// A BinaryWriter that switches the endian orientation of the read operations so that they
- /// are compatible across platforms.
- /// </summary>
- [CLSCompliant(false)]
- public class EndianBinaryReader : BinaryReader
- {
- public EndianBinaryReader(Stream input)
- : base(input)
- {
- }
+ /// <summary>
+ /// A BinaryWriter that switches the endian orientation of the read operations so that they
+ /// are compatible across platforms.
+ /// </summary>
+ [CLSCompliant(false)]
+ public class EndianBinaryReader : BinaryReader
+ {
+ public EndianBinaryReader(Stream input)
+ : base(input)
+ {
+ }
- /// <summary>
- /// Method Read
- /// </summary>
- /// <returns>An int</returns>
- /// <param name="buffer">A char[]</param>
- /// <param name="index">An int</param>
- /// <param name="count">An int</param>
- public override int Read(char[] buffer, int index, int count)
- {
- int size = base.Read(buffer, index, count);
- for(int i = 0; i < size; i++)
- {
- buffer[index + i] = EndianSupport.SwitchEndian(buffer[index + i]);
- }
- return size;
- }
-
- /// <summary>
- /// Method ReadChars
- /// </summary>
- /// <returns>A char[]</returns>
- /// <param name="count">An int</param>
- public override char[] ReadChars(int count)
- {
- char[] rc = base.ReadChars(count);
- if(rc != null)
- {
- for(int i = 0; i < rc.Length; i++)
- {
- rc[i] = EndianSupport.SwitchEndian(rc[i]);
- }
- }
- return rc;
- }
-
- /// <summary>
- /// Method ReadInt16
- /// </summary>
- /// <returns>A short</returns>
- public override short ReadInt16()
- {
- return EndianSupport.SwitchEndian(base.ReadInt16());
- }
-
- /// <summary>
- /// Method ReadChar
- /// </summary>
- /// <returns>A char</returns>
- public override char ReadChar()
- {
- return (char) (
- (((char) ((byte) (base.ReadByte()))) << 8) |
- (((char) ((byte) (base.ReadByte()))))
- );
-
- // return EndianSupport.SwitchEndian(base.ReadChar());
- }
-
- /// <summary>
- /// Method ReadInt64
- /// </summary>
- /// <returns>A long</returns>
- public override long ReadInt64()
- {
- return EndianSupport.SwitchEndian(base.ReadInt64());
- }
-
- /// <summary>
- /// Method ReadUInt64
- /// </summary>
- /// <returns>An ulong</returns>
- public override ulong ReadUInt64()
- {
- return EndianSupport.SwitchEndian(base.ReadUInt64());
- }
-
- /// <summary>
- /// Method ReadUInt32
- /// </summary>
- /// <returns>An uint</returns>
- public override uint ReadUInt32()
- {
- return EndianSupport.SwitchEndian(base.ReadUInt32());
- }
-
- /// <summary>
- /// Method ReadUInt16
- /// </summary>
- /// <returns>An ushort</returns>
- public override ushort ReadUInt16()
- {
- return EndianSupport.SwitchEndian(base.ReadUInt16());
- }
-
- /// <summary>
- /// Method ReadInt32
- /// </summary>
- /// <returns>An int</returns>
- public override int ReadInt32()
- {
- int x = base.ReadInt32();
- int y = EndianSupport.SwitchEndian(x);
- return y;
- }
-
- /// <summary>
- /// Method ReadString
- /// </summary>
- /// <returns>A string</returns>
- public override String ReadString()
- {
- return ReadString16();
- }
-
- /// <summary>
- /// Method ReadString16, reads a String value encoded in the Java modified
- /// UTF-8 format with a length index encoded as a 16bit unsigned short.
- /// </summary>
- /// <returns>A string</returns>
- public String ReadString16()
- {
- int utfLength = ReadUInt16();
-
- if(utfLength < 0)
- {
- return null;
- }
- else if(utfLength == 0)
+ /// <summary>
+ /// Method Read
+ /// </summary>
+ /// <returns>An int</returns>
+ /// <param name="buffer">A char[]</param>
+ /// <param name="index">An int</param>
+ /// <param name="count">An int</param>
+ public override int Read(char[] buffer, int index, int count)
+ {
+ int size = base.Read(buffer, index, count);
+ for (int i = 0; i < size; i++)
{
- return "";
+ buffer[index + i] = EndianSupport.SwitchEndian(buffer[index + i]);
}
- return doReadString(utfLength);
- }
+ return size;
+ }
- /// <summary>
- /// Method ReadString32, reads a String value encoded in the Java modified
- /// UTF-8 format with a length index encoded as a singed integer value.
- /// </summary>
- /// <returns>A string</returns>
- public String ReadString32()
- {
- int utfLength = ReadInt32();
+ /// <summary>
+ /// Method ReadChars
+ /// </summary>
+ /// <returns>A char[]</returns>
+ /// <param name="count">An int</param>
+ public override char[] ReadChars(int count)
+ {
+ char[] rc = base.ReadChars(count);
+ if (rc != null)
+ {
+ for (int i = 0; i < rc.Length; i++)
+ {
+ rc[i] = EndianSupport.SwitchEndian(rc[i]);
+ }
+ }
- if(utfLength < 0)
+ return rc;
+ }
+
+ /// <summary>
+ /// Method ReadInt16
+ /// </summary>
+ /// <returns>A short</returns>
+ public override short ReadInt16()
+ {
+ return EndianSupport.SwitchEndian(base.ReadInt16());
+ }
+
+ /// <summary>
+ /// Method ReadChar
+ /// </summary>
+ /// <returns>A char</returns>
+ public override char ReadChar()
+ {
+ return (char) (
+ (((char) ((byte) (base.ReadByte()))) << 8) |
+ (((char) ((byte) (base.ReadByte()))))
+ );
+
+ // return EndianSupport.SwitchEndian(base.ReadChar());
+ }
+
+ /// <summary>
+ /// Method ReadInt64
+ /// </summary>
+ /// <returns>A long</returns>
+ public override long ReadInt64()
+ {
+ return EndianSupport.SwitchEndian(base.ReadInt64());
+ }
+
+ /// <summary>
+ /// Method ReadUInt64
+ /// </summary>
+ /// <returns>An ulong</returns>
+ public override ulong ReadUInt64()
+ {
+ return EndianSupport.SwitchEndian(base.ReadUInt64());
+ }
+
+ /// <summary>
+ /// Method ReadUInt32
+ /// </summary>
+ /// <returns>An uint</returns>
+ public override uint ReadUInt32()
+ {
+ return EndianSupport.SwitchEndian(base.ReadUInt32());
+ }
+
+ /// <summary>
+ /// Method ReadUInt16
+ /// </summary>
+ /// <returns>An ushort</returns>
+ public override ushort ReadUInt16()
+ {
+ return EndianSupport.SwitchEndian(base.ReadUInt16());
+ }
+
+ /// <summary>
+ /// Method ReadInt32
+ /// </summary>
+ /// <returns>An int</returns>
+ public override int ReadInt32()
+ {
+ int x = base.ReadInt32();
+ int y = EndianSupport.SwitchEndian(x);
+ return y;
+ }
+
+ /// <summary>
+ /// Method ReadString
+ /// </summary>
+ /// <returns>A string</returns>
+ public override String ReadString()
+ {
+ return ReadString16();
+ }
+
+ /// <summary>
+ /// Method ReadString16, reads a String value encoded in the Java modified
+ /// UTF-8 format with a length index encoded as a 16bit unsigned short.
+ /// </summary>
+ /// <returns>A string</returns>
+ public String ReadString16()
+ {
+ int utfLength = ReadUInt16();
+
+ if (utfLength < 0)
{
return null;
- }
- else if(utfLength == 0)
+ }
+ else if (utfLength == 0)
{
return "";
}
return doReadString(utfLength);
- }
+ }
+
+ /// <summary>
+ /// Method ReadString32, reads a String value encoded in the Java modified
+ /// UTF-8 format with a length index encoded as a singed integer value.
+ /// </summary>
+ /// <returns>A string</returns>
+ public String ReadString32()
+ {
+ int utfLength = ReadInt32();
+
+ if (utfLength < 0)
+ {
+ return null;
+ }
+ else if (utfLength == 0)
+ {
+ return "";
+ }
+
+ return doReadString(utfLength);
+ }
private string doReadString(int utfLength)
{
@@ -194,10 +196,10 @@
byte[] buffer = new byte[utfLength];
int bytesRead = 0;
- while(bytesRead < utfLength)
+ while (bytesRead < utfLength)
{
int rc = Read(buffer, bytesRead, utfLength - bytesRead);
- if(rc == 0)
+ if (rc == 0)
{
throw new IOException("premature end of stream");
}
@@ -209,38 +211,37 @@
int index = 0;
byte a = 0;
- while(count < utfLength)
+ while (count < utfLength)
{
- if((result[index] = (char) buffer[count++]) < 0x80)
+ if ((result[index] = (char) buffer[count++]) < 0x80)
{
index++;
}
- else if(((a = (byte) result[index]) & 0xE0) == 0xC0)
+ else if (((a = (byte) result[index]) & 0xE0) == 0xC0)
{
- if(count >= utfLength)
+ if (count >= utfLength)
{
throw new IOException("Invalid UTF-8 encoding found, start of two byte char found at end.");
}
byte b = buffer[count++];
- if((b & 0xC0) != 0x80)
+ if ((b & 0xC0) != 0x80)
{
throw new IOException("Invalid UTF-8 encoding found, byte two does not start with 0x80.");
}
result[index++] = (char) (((a & 0x1F) << 6) | (b & 0x3F));
}
- else if((a & 0xF0) == 0xE0)
+ else if ((a & 0xF0) == 0xE0)
{
-
- if(count + 1 >= utfLength)
+ if (count + 1 >= utfLength)
{
throw new IOException("Invalid UTF-8 encoding found, start of three byte char found at end.");
}
byte b = buffer[count++];
byte c = buffer[count++];
- if(((b & 0xC0) != 0x80) || ((c & 0xC0) != 0x80))
+ if (((b & 0xC0) != 0x80) || ((c & 0xC0) != 0x80))
{
throw new IOException("Invalid UTF-8 encoding found, byte two does not start with 0x80.");
}
@@ -254,23 +255,23 @@
}
}
- return new String(result, 0, index);
+ return new String(result, 0, index);
}
- public override float ReadSingle()
- {
- return EndianSupport.SwitchEndian(base.ReadSingle());
- }
+ public override float ReadSingle()
+ {
+ return EndianSupport.SwitchEndian(base.ReadSingle());
+ }
- public override double ReadDouble()
- {
- return EndianSupport.SwitchEndian(base.ReadDouble());
- }
+ public override double ReadDouble()
+ {
+ return EndianSupport.SwitchEndian(base.ReadDouble());
+ }
- protected static Exception CreateDataFormatException()
- {
- // TODO: implement a better exception
- return new IOException("Data format error!");
- }
- }
-}
+ protected static Exception CreateDataFormatException()
+ {
+ // TODO: implement a better exception
+ return new IOException("Data format error!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/EndianBinaryWriter.cs b/src/nms-api/Util/EndianBinaryWriter.cs
index 288491e..9c2540b 100644
--- a/src/nms-api/Util/EndianBinaryWriter.cs
+++ b/src/nms-api/Util/EndianBinaryWriter.cs
@@ -20,276 +20,277 @@
namespace Apache.NMS.Util
{
- /// <summary>
- /// A BinaryWriter that switches the endian orientation of the write operations so that they
- /// are compatible across platforms.
- /// </summary>
- [CLSCompliant(false)]
- public class EndianBinaryWriter : BinaryWriter
- {
- public const int MAXSTRINGLEN = short.MaxValue;
+ /// <summary>
+ /// A BinaryWriter that switches the endian orientation of the write operations so that they
+ /// are compatible across platforms.
+ /// </summary>
+ [CLSCompliant(false)]
+ public class EndianBinaryWriter : BinaryWriter
+ {
+ public const int MAXSTRINGLEN = short.MaxValue;
- public EndianBinaryWriter(Stream output)
- : base(output)
- {
- }
+ public EndianBinaryWriter(Stream output)
+ : base(output)
+ {
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="value">A long</param>
- public override void Write(long value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="value">A long</param>
+ public override void Write(long value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="value">An ushort</param>
- public override void Write(ushort value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="value">An ushort</param>
+ public override void Write(ushort value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="value">An int</param>
- public override void Write(int value)
- {
- int x = EndianSupport.SwitchEndian(value);
- base.Write(x);
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="value">An int</param>
+ public override void Write(int value)
+ {
+ int x = EndianSupport.SwitchEndian(value);
+ base.Write(x);
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="chars">A char[]</param>
- /// <param name="index">An int</param>
- /// <param name="count">An int</param>
- public override void Write(char[] chars, int index, int count)
- {
- char[] t = new char[count];
- for(int i = 0; i < count; i++)
- {
- t[index + i] = EndianSupport.SwitchEndian(t[index + i]);
- }
- base.Write(t);
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="chars">A char[]</param>
+ /// <param name="index">An int</param>
+ /// <param name="count">An int</param>
+ public override void Write(char[] chars, int index, int count)
+ {
+ char[] t = new char[count];
+ for (int i = 0; i < count; i++)
+ {
+ t[index + i] = EndianSupport.SwitchEndian(t[index + i]);
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="chars">A char[]</param>
- public override void Write(char[] chars)
- {
- Write(chars, 0, chars.Length);
- }
+ base.Write(t);
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="value">An uint</param>
- public override void Write(uint value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="chars">A char[]</param>
+ public override void Write(char[] chars)
+ {
+ Write(chars, 0, chars.Length);
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="ch">A char</param>
- public override void Write(char ch)
- {
- base.Write((byte) ((ch >> 8) & 0xFF));
- base.Write((byte) (ch & 0xFF));
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="value">An uint</param>
+ public override void Write(uint value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="value">An ulong</param>
- public override void Write(ulong value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="ch">A char</param>
+ public override void Write(char ch)
+ {
+ base.Write((byte) ((ch >> 8) & 0xFF));
+ base.Write((byte) (ch & 0xFF));
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="value">A short</param>
- public override void Write(short value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="value">An ulong</param>
+ public override void Write(ulong value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
- /// <summary>
- /// Method Write, writes a string to the output using the WriteString16
- /// method.
- /// </summary>
- /// <param name="text">A string</param>
- public override void Write(String text)
- {
- WriteString16(text);
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="value">A short</param>
+ public override void Write(short value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
- /// <summary>
- /// Method WriteString16, writes a string to the output using the Java
- /// standard modified UTF-8 encoding with an unsigned short value written first to
- /// indicate the length of the encoded data, the short is read as an unsigned
- /// value so the max amount of data this method can write is 65535 encoded bytes.
- ///
- /// Unlike the WriteString32 method this method does not encode the length
- /// value to -1 if the string is null, this is to match the behaviour of
- /// the Java DataOuputStream class's writeUTF method.
- ///
- /// Because modified UTF-8 encding can result in a number of bytes greater that
- /// the size of the String this method must first check that the encoding proces
- /// will not result in a value that cannot be written becuase it is greater than
- /// the max value of an unsigned short.
- /// </summary>
- /// <param name="text">A string</param>
- public void WriteString16(String text)
- {
- if(text != null)
- {
- if(text.Length > ushort.MaxValue)
- {
- throw new IOException(
- String.Format(
- "Cannot marshall string longer than: {0} characters, supplied string was: " +
- "{1} characters", ushort.MaxValue, text.Length));
- }
+ /// <summary>
+ /// Method Write, writes a string to the output using the WriteString16
+ /// method.
+ /// </summary>
+ /// <param name="text">A string</param>
+ public override void Write(String text)
+ {
+ WriteString16(text);
+ }
- char[] charr = text.ToCharArray();
- uint utfLength = CountUtf8Bytes(charr);
+ /// <summary>
+ /// Method WriteString16, writes a string to the output using the Java
+ /// standard modified UTF-8 encoding with an unsigned short value written first to
+ /// indicate the length of the encoded data, the short is read as an unsigned
+ /// value so the max amount of data this method can write is 65535 encoded bytes.
+ ///
+ /// Unlike the WriteString32 method this method does not encode the length
+ /// value to -1 if the string is null, this is to match the behaviour of
+ /// the Java DataOuputStream class's writeUTF method.
+ ///
+ /// Because modified UTF-8 encding can result in a number of bytes greater that
+ /// the size of the String this method must first check that the encoding proces
+ /// will not result in a value that cannot be written becuase it is greater than
+ /// the max value of an unsigned short.
+ /// </summary>
+ /// <param name="text">A string</param>
+ public void WriteString16(String text)
+ {
+ if (text != null)
+ {
+ if (text.Length > ushort.MaxValue)
+ {
+ throw new IOException(
+ String.Format(
+ "Cannot marshall string longer than: {0} characters, supplied string was: " +
+ "{1} characters", ushort.MaxValue, text.Length));
+ }
- if(utfLength > ushort.MaxValue)
- {
- throw new IOException(
- String.Format(
- "Cannot marshall an encoded string longer than: {0} bytes, supplied" +
- "string requires: {1} characters to encode", ushort.MaxValue, utfLength));
- }
+ char[] charr = text.ToCharArray();
+ uint utfLength = CountUtf8Bytes(charr);
- byte[] bytearr = new byte[utfLength];
- encodeUTF8toBuffer(charr, bytearr);
+ if (utfLength > ushort.MaxValue)
+ {
+ throw new IOException(
+ String.Format(
+ "Cannot marshall an encoded string longer than: {0} bytes, supplied" +
+ "string requires: {1} characters to encode", ushort.MaxValue, utfLength));
+ }
- Write((ushort) utfLength);
- Write(bytearr);
- }
- }
+ byte[] bytearr = new byte[utfLength];
+ encodeUTF8toBuffer(charr, bytearr);
- /// <summary>
- /// Method WriteString32, writes a string to the output using the Openwire
- /// standard modified UTF-8 encoding which an int value written first to
- /// indicate the length of the encoded data, the int is read as an signed
- /// value so the max amount of data this method can write is 2^31 encoded bytes.
- ///
- /// In the case of a null value being passed this method writes a -1 to the
- /// stream to indicate that the string is null.
- ///
- /// Because modified UTF-8 encding can result in a number of bytes greater that
- /// the size of the String this method must first check that the encoding proces
- /// will not result in a value that cannot be written becuase it is greater than
- /// the max value of an int.
- /// </summary>
- /// <param name="text">A string</param>
- public void WriteString32(String text)
- {
- if(text != null)
- {
- char[] charr = text.ToCharArray();
- uint utfLength = CountUtf8Bytes(charr);
+ Write((ushort) utfLength);
+ Write(bytearr);
+ }
+ }
- if(utfLength > int.MaxValue)
- {
- throw new IOException(
- String.Format(
- "Cannot marshall an encoded string longer than: {0} bytes, supplied" +
- "string requires: {1} characters to encode", int.MaxValue, utfLength));
- }
+ /// <summary>
+ /// Method WriteString32, writes a string to the output using the Openwire
+ /// standard modified UTF-8 encoding which an int value written first to
+ /// indicate the length of the encoded data, the int is read as an signed
+ /// value so the max amount of data this method can write is 2^31 encoded bytes.
+ ///
+ /// In the case of a null value being passed this method writes a -1 to the
+ /// stream to indicate that the string is null.
+ ///
+ /// Because modified UTF-8 encding can result in a number of bytes greater that
+ /// the size of the String this method must first check that the encoding proces
+ /// will not result in a value that cannot be written becuase it is greater than
+ /// the max value of an int.
+ /// </summary>
+ /// <param name="text">A string</param>
+ public void WriteString32(String text)
+ {
+ if (text != null)
+ {
+ char[] charr = text.ToCharArray();
+ uint utfLength = CountUtf8Bytes(charr);
- byte[] bytearr = new byte[utfLength];
- encodeUTF8toBuffer(charr, bytearr);
+ if (utfLength > int.MaxValue)
+ {
+ throw new IOException(
+ String.Format(
+ "Cannot marshall an encoded string longer than: {0} bytes, supplied" +
+ "string requires: {1} characters to encode", int.MaxValue, utfLength));
+ }
- Write(utfLength);
- Write(bytearr);
- }
- else
- {
- Write((int) -1);
- }
- }
+ byte[] bytearr = new byte[utfLength];
+ encodeUTF8toBuffer(charr, bytearr);
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="value">A double</param>
- public override void Write(float value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
+ Write(utfLength);
+ Write(bytearr);
+ }
+ else
+ {
+ Write((int) -1);
+ }
+ }
- /// <summary>
- /// Method Write
- /// </summary>
- /// <param name="value">A double</param>
- public override void Write(double value)
- {
- base.Write(EndianSupport.SwitchEndian(value));
- }
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="value">A double</param>
+ public override void Write(float value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
- private static uint CountUtf8Bytes(char[] chars)
- {
- uint utfLength = 0;
- int c = 0;
+ /// <summary>
+ /// Method Write
+ /// </summary>
+ /// <param name="value">A double</param>
+ public override void Write(double value)
+ {
+ base.Write(EndianSupport.SwitchEndian(value));
+ }
- for(int i = 0; i < chars.Length; i++)
- {
- c = chars[i];
- if((c >= 0x0001) && (c <= 0x007F))
- {
- utfLength++;
- }
- else if(c > 0x07FF)
- {
- utfLength += 3;
- }
- else
- {
- utfLength += 2;
- }
- }
+ private static uint CountUtf8Bytes(char[] chars)
+ {
+ uint utfLength = 0;
+ int c = 0;
- return utfLength;
- }
+ for (int i = 0; i < chars.Length; i++)
+ {
+ c = chars[i];
+ if ((c >= 0x0001) && (c <= 0x007F))
+ {
+ utfLength++;
+ }
+ else if (c > 0x07FF)
+ {
+ utfLength += 3;
+ }
+ else
+ {
+ utfLength += 2;
+ }
+ }
- private static void encodeUTF8toBuffer(char[] chars, byte[] buffer)
- {
- int c = 0;
- int count = 0;
+ return utfLength;
+ }
- for(int i = 0; i < chars.Length; i++)
- {
- c = chars[i];
- if((c >= 0x0001) && (c <= 0x007F))
- {
- buffer[count++] = (byte) c;
- }
- else if(c > 0x07FF)
- {
- buffer[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
- buffer[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
- buffer[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
- }
- else
- {
- buffer[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
- buffer[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
- }
- }
- }
- }
-}
+ private static void encodeUTF8toBuffer(char[] chars, byte[] buffer)
+ {
+ int c = 0;
+ int count = 0;
+
+ for (int i = 0; i < chars.Length; i++)
+ {
+ c = chars[i];
+ if ((c >= 0x0001) && (c <= 0x007F))
+ {
+ buffer[count++] = (byte) c;
+ }
+ else if (c > 0x07FF)
+ {
+ buffer[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
+ buffer[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
+ buffer[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ }
+ else
+ {
+ buffer[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
+ buffer[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/EndianSupport.cs b/src/nms-api/Util/EndianSupport.cs
index f9fd058..bc8c158 100644
--- a/src/nms-api/Util/EndianSupport.cs
+++ b/src/nms-api/Util/EndianSupport.cs
@@ -14,84 +14,84 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.IO;
namespace Apache.NMS.Util
{
- /// <summary>
- /// Support class that switches from one endian to the other.
- /// </summary>
- [CLSCompliant(false)]
- public class EndianSupport
- {
-
+ /// <summary>
+ /// Support class that switches from one endian to the other.
+ /// </summary>
+ [CLSCompliant(false)]
+ public class EndianSupport
+ {
public static char SwitchEndian(char x)
{
- return (char) (
- (((char)( (byte)(x) )) << 8 ) |
- (((char)( (byte)(x >> 8) )) )
- );
+ return (char) (
+ (((char) ((byte) (x))) << 8) |
+ (((char) ((byte) (x >> 8))))
+ );
}
-
+
public static short SwitchEndian(short x)
{
- return (short) (
- (((ushort)( (byte)(x) )) << 8 ) |
- (((ushort)( (byte)(x >> 8) )) )
- );
+ return (short) (
+ (((ushort) ((byte) (x))) << 8) |
+ (((ushort) ((byte) (x >> 8))))
+ );
}
-
+
public static int SwitchEndian(int x)
{
- return
- (((int)( (byte)(x) )) << 24 ) |
- (((int)( (byte)(x >> 8) )) << 16 ) |
- (((int)( (byte)(x >> 16) )) << 8 ) |
- (((int)( (byte)(x >> 24) )) );
+ return
+ (((int) ((byte) (x))) << 24) |
+ (((int) ((byte) (x >> 8))) << 16) |
+ (((int) ((byte) (x >> 16))) << 8) |
+ (((int) ((byte) (x >> 24))));
}
-
+
public static long SwitchEndian(long x)
{
- return
- (((long)( (byte)(x ) )) << 56 ) |
- (((long)( (byte)(x >> 8) )) << 48 ) |
- (((long)( (byte)(x >> 16) )) << 40 ) |
- (((long)( (byte)(x >> 24) )) << 32 ) |
- (((long)( (byte)(x >> 32) )) << 24 ) |
- (((long)( (byte)(x >> 40) )) << 16 ) |
- (((long)( (byte)(x >> 48) )) << 8 ) |
- (((long)( (byte)(x >> 56) )) );
+ return
+ (((long) ((byte) (x))) << 56) |
+ (((long) ((byte) (x >> 8))) << 48) |
+ (((long) ((byte) (x >> 16))) << 40) |
+ (((long) ((byte) (x >> 24))) << 32) |
+ (((long) ((byte) (x >> 32))) << 24) |
+ (((long) ((byte) (x >> 40))) << 16) |
+ (((long) ((byte) (x >> 48))) << 8) |
+ (((long) ((byte) (x >> 56))));
}
-
+
public static ushort SwitchEndian(ushort x)
{
- return (ushort) (
- (((ushort)( (byte)(x) )) << 8 ) |
- (((ushort)( (byte)(x >> 8) )) )
- );
+ return (ushort) (
+ (((ushort) ((byte) (x))) << 8) |
+ (((ushort) ((byte) (x >> 8))))
+ );
}
-
+
public static uint SwitchEndian(uint x)
{
- return
- (((uint)( (byte)(x ) )) << 24 ) |
- (((uint)( (byte)(x >> 8) )) << 16 ) |
- (((uint)( (byte)(x >> 16) )) << 8 ) |
- (((uint)( (byte)(x >> 24) )) );
+ return
+ (((uint) ((byte) (x))) << 24) |
+ (((uint) ((byte) (x >> 8))) << 16) |
+ (((uint) ((byte) (x >> 16))) << 8) |
+ (((uint) ((byte) (x >> 24))));
}
-
+
public static ulong SwitchEndian(ulong x)
{
- return
- (((ulong)( (byte)(x ) )) << 56 ) |
- (((ulong)( (byte)(x >> 8) )) << 48 ) |
- (((ulong)( (byte)(x >> 16) )) << 40 ) |
- (((ulong)( (byte)(x >> 24) )) << 32 ) |
- (((ulong)( (byte)(x >> 32) )) << 24 ) |
- (((ulong)( (byte)(x >> 40) )) << 16 ) |
- (((ulong)( (byte)(x >> 48) )) << 8 ) |
- (((ulong)( (byte)(x >> 56) )) );
+ return
+ (((ulong) ((byte) (x))) << 56) |
+ (((ulong) ((byte) (x >> 8))) << 48) |
+ (((ulong) ((byte) (x >> 16))) << 40) |
+ (((ulong) ((byte) (x >> 24))) << 32) |
+ (((ulong) ((byte) (x >> 32))) << 24) |
+ (((ulong) ((byte) (x >> 40))) << 16) |
+ (((ulong) ((byte) (x >> 48))) << 8) |
+ (((ulong) ((byte) (x >> 56))));
}
public static double SwitchEndian(double x)
@@ -105,7 +105,7 @@
return br.ReadDouble();
}
-
+
public static float SwitchEndian(float x)
{
MemoryStream ms = new MemoryStream();
@@ -116,18 +116,19 @@
BinaryReader br = new BinaryReader(ms);
return br.ReadSingle();
}
-
+
public static byte[] SwitchEndian(byte[] x)
{
byte[] rc = new byte[x.Length];
- int j = x.Length-1;
- for(int i=0; i < x.Length; i++ ) {
+ int j = x.Length - 1;
+ for (int i = 0; i < x.Length; i++)
+ {
rc[i] = x[j];
j--;
}
+
return rc;
}
}
-}
-
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/MessagePropertyIntercepter.cs b/src/nms-api/Util/MessagePropertyIntercepter.cs
index badb195..abf2ab7 100644
--- a/src/nms-api/Util/MessagePropertyIntercepter.cs
+++ b/src/nms-api/Util/MessagePropertyIntercepter.cs
@@ -20,7 +20,7 @@
namespace Apache.NMS.Util
{
- /// <summary>
+ /// <summary>
/// Utility class used to set NMS properties via introspection for IMessage derived
/// instances. This class allows IMessage classes to define Message specific properties
/// that can be accessed using the standard property get / set semantics.
@@ -34,72 +34,72 @@
/// read-only therefore there is no exception thrown if the message itself is in the
/// read-only property mode.
/// </summary>
- public class MessagePropertyIntercepter : PrimitiveMapInterceptor
- {
- private const BindingFlags publicBinding = BindingFlags.Public | BindingFlags.Instance;
- private readonly Type messageType;
+ public class MessagePropertyIntercepter : PrimitiveMapInterceptor
+ {
+ private const BindingFlags publicBinding = BindingFlags.Public | BindingFlags.Instance;
+ private readonly Type messageType;
- public MessagePropertyIntercepter(IMessage message, IPrimitiveMap properties)
+ public MessagePropertyIntercepter(IMessage message, IPrimitiveMap properties)
: base(message, properties)
- {
- this.messageType = message.GetType();
- }
+ {
+ this.messageType = message.GetType();
+ }
public MessagePropertyIntercepter(IMessage message, IPrimitiveMap properties, bool readOnly)
: base(message, properties, readOnly)
{
this.messageType = message.GetType();
}
-
- protected override object GetObjectProperty(string name)
- {
- PropertyInfo propertyInfo = this.messageType.GetProperty(name, publicBinding);
- if(name.StartsWith("NMS"))
- {
- if(null != propertyInfo && propertyInfo.CanRead)
- {
- return propertyInfo.GetValue(this.message, null);
- }
- else
- {
- FieldInfo fieldInfo = this.messageType.GetField(name, publicBinding);
-
- if(null != fieldInfo)
- {
- return fieldInfo.GetValue(this.message);
- }
- }
- }
-
- return base.GetObjectProperty(name);
- }
+ protected override object GetObjectProperty(string name)
+ {
+ PropertyInfo propertyInfo = this.messageType.GetProperty(name, publicBinding);
- protected override void SetObjectProperty(string name, object value)
- {
- PropertyInfo propertyInfo = this.messageType.GetProperty(name, publicBinding);
+ if (name.StartsWith("NMS"))
+ {
+ if (null != propertyInfo && propertyInfo.CanRead)
+ {
+ return propertyInfo.GetValue(this.message, null);
+ }
+ else
+ {
+ FieldInfo fieldInfo = this.messageType.GetField(name, publicBinding);
- if(!name.StartsWith("NMS"))
- {
+ if (null != fieldInfo)
+ {
+ return fieldInfo.GetValue(this.message);
+ }
+ }
+ }
+
+ return base.GetObjectProperty(name);
+ }
+
+ protected override void SetObjectProperty(string name, object value)
+ {
+ PropertyInfo propertyInfo = this.messageType.GetProperty(name, publicBinding);
+
+ if (!name.StartsWith("NMS"))
+ {
base.SetObjectProperty(name, value);
- }
- else if(null != propertyInfo && propertyInfo.CanWrite)
- {
- propertyInfo.SetValue(this.message, value, null);
- }
- else
- {
- FieldInfo fieldInfo = this.messageType.GetField(name, publicBinding);
+ }
+ else if (null != propertyInfo && propertyInfo.CanWrite)
+ {
+ propertyInfo.SetValue(this.message, value, null);
+ }
+ else
+ {
+ FieldInfo fieldInfo = this.messageType.GetField(name, publicBinding);
- if(null != fieldInfo && !fieldInfo.IsLiteral && !fieldInfo.IsInitOnly)
- {
- fieldInfo.SetValue(this.message, value);
- }
- else
- {
+ if (null != fieldInfo && !fieldInfo.IsLiteral && !fieldInfo.IsInitOnly)
+ {
+ fieldInfo.SetValue(this.message, value);
+ }
+ else
+ {
base.SetObjectProperty(name, value);
- }
- }
- }
- }
-}
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/MessageTransformation.cs b/src/nms-api/Util/MessageTransformation.cs
index 8b54403..075489d 100644
--- a/src/nms-api/Util/MessageTransformation.cs
+++ b/src/nms-api/Util/MessageTransformation.cs
@@ -21,23 +21,23 @@
/// Base Utility class for conversion between IMessage type objects for different
/// NMS providers.
/// </summary>
- public abstract class MessageTransformation
- {
+ public abstract class MessageTransformation
+ {
protected MessageTransformation()
- {
- }
+ {
+ }
public T TransformMessage<T>(IMessage message)
{
- if(message is T)
+ if (message is T)
{
return (T) message;
}
else
{
IMessage result = null;
-
- if(message is IBytesMessage)
+
+ if (message is IBytesMessage)
{
IBytesMessage bytesMsg = message as IBytesMessage;
bytesMsg.Reset();
@@ -45,7 +45,7 @@
try
{
- for(;;)
+ for (;;)
{
// Reads a byte from the message stream until the stream is empty
msg.WriteByte(bytesMsg.ReadByte());
@@ -57,19 +57,19 @@
result = msg;
}
- else if(message is IMapMessage)
+ else if (message is IMapMessage)
{
IMapMessage mapMsg = message as IMapMessage;
IMapMessage msg = DoCreateMapMessage();
- foreach(string key in mapMsg.Body.Keys)
+ foreach (string key in mapMsg.Body.Keys)
{
msg.Body[key] = mapMsg.Body[key];
}
result = msg;
}
- else if(message is IObjectMessage)
+ else if (message is IObjectMessage)
{
IObjectMessage objMsg = message as IObjectMessage;
IObjectMessage msg = DoCreateObjectMessage();
@@ -77,7 +77,7 @@
result = msg;
}
- else if(message is IStreamMessage)
+ else if (message is IStreamMessage)
{
IStreamMessage streamMessage = message as IStreamMessage;
streamMessage.Reset();
@@ -87,7 +87,7 @@
try
{
- while((obj = streamMessage.ReadObject()) != null)
+ while ((obj = streamMessage.ReadObject()) != null)
{
msg.WriteObject(obj);
}
@@ -98,7 +98,7 @@
result = msg;
}
- else if(message is ITextMessage)
+ else if (message is ITextMessage)
{
ITextMessage textMsg = message as ITextMessage;
ITextMessage msg = DoCreateTextMessage();
@@ -138,7 +138,7 @@
toMessage.NMSTimestamp = fromMessage.NMSTimestamp;
toMessage.NMSTimeToLive = fromMessage.NMSTimeToLive;
- foreach(string key in fromMessage.Properties.Keys)
+ foreach (string key in fromMessage.Properties.Keys)
{
toMessage.Properties[key] = fromMessage.Properties[key];
}
@@ -162,7 +162,7 @@
toMessage.NMSTimestamp = fromMessage.NMSTimestamp;
toMessage.NMSTimeToLive = fromMessage.NMSTimeToLive;
- foreach(string key in fromMessage.Properties.Keys)
+ foreach (string key in fromMessage.Properties.Keys)
{
toMessage.Properties[key] = fromMessage.Properties[key];
}
@@ -181,7 +181,5 @@
protected abstract void DoPostProcessMessage(IMessage message);
#endregion
-
- }
-}
-
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/NMSExceptionSupport.cs b/src/nms-api/Util/NMSExceptionSupport.cs
index 59a68dd..6e23d45 100644
--- a/src/nms-api/Util/NMSExceptionSupport.cs
+++ b/src/nms-api/Util/NMSExceptionSupport.cs
@@ -18,60 +18,64 @@
using System;
namespace Apache.NMS.Util
-{
+{
public sealed class NMSExceptionSupport
{
private NMSExceptionSupport()
- {
+ {
}
-
+
public static NMSException Create(string message, string errorCode, Exception cause)
{
NMSException exception = new NMSException(message, errorCode, cause);
return exception;
}
-
+
public static NMSException Create(string message, Exception cause)
{
NMSException exception = new NMSException(message, cause);
return exception;
}
-
+
public static NMSException Create(Exception cause)
{
- if(cause is NMSException)
+ if (cause is NMSException)
{
return (NMSException) cause;
}
+
string msg = cause.Message;
- if(msg == null || msg.Length == 0)
+ if (msg == null || msg.Length == 0)
{
msg = cause.ToString();
}
+
NMSException exception = new NMSException(msg, cause);
return exception;
}
-
- public static MessageEOFException CreateMessageEOFException(Exception cause)
+
+ public static MessageEOFException CreateMessageEOFException(Exception cause)
{
string msg = cause.Message;
- if (msg == null || msg.Length == 0)
+ if (msg == null || msg.Length == 0)
{
msg = cause.ToString();
}
+
MessageEOFException exception = new MessageEOFException(msg, cause);
return exception;
}
-
- public static MessageFormatException CreateMessageFormatException(Exception cause)
+
+ public static MessageFormatException CreateMessageFormatException(Exception cause)
{
string msg = cause.Message;
- if (msg == null || msg.Length == 0)
+ if (msg == null || msg.Length == 0)
{
msg = cause.ToString();
}
+
MessageFormatException exception = new MessageFormatException(msg, cause);
return exception;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/PrimitiveMap.cs b/src/nms-api/Util/PrimitiveMap.cs
index e62cfa1..05220af 100644
--- a/src/nms-api/Util/PrimitiveMap.cs
+++ b/src/nms-api/Util/PrimitiveMap.cs
@@ -21,595 +21,608 @@
namespace Apache.NMS.Util
{
- /// <summary>
- /// A default implementation of IPrimitiveMap
- /// </summary>
- public class PrimitiveMap : IPrimitiveMap
- {
- public const byte NULL = 0;
- public const byte BOOLEAN_TYPE = 1;
- public const byte BYTE_TYPE = 2;
- public const byte CHAR_TYPE = 3;
- public const byte SHORT_TYPE = 4;
- public const byte INTEGER_TYPE = 5;
- public const byte LONG_TYPE = 6;
- public const byte DOUBLE_TYPE = 7;
- public const byte FLOAT_TYPE = 8;
- public const byte STRING_TYPE = 9;
- public const byte BYTE_ARRAY_TYPE = 10;
- public const byte MAP_TYPE = 11;
- public const byte LIST_TYPE = 12;
- public const byte BIG_STRING_TYPE = 13;
+ /// <summary>
+ /// A default implementation of IPrimitiveMap
+ /// </summary>
+ public class PrimitiveMap : IPrimitiveMap
+ {
+ public const byte NULL = 0;
+ public const byte BOOLEAN_TYPE = 1;
+ public const byte BYTE_TYPE = 2;
+ public const byte CHAR_TYPE = 3;
+ public const byte SHORT_TYPE = 4;
+ public const byte INTEGER_TYPE = 5;
+ public const byte LONG_TYPE = 6;
+ public const byte DOUBLE_TYPE = 7;
+ public const byte FLOAT_TYPE = 8;
+ public const byte STRING_TYPE = 9;
+ public const byte BYTE_ARRAY_TYPE = 10;
+ public const byte MAP_TYPE = 11;
+ public const byte LIST_TYPE = 12;
+ public const byte BIG_STRING_TYPE = 13;
- private IDictionary dictionary = Hashtable.Synchronized(new Hashtable());
+ private IDictionary dictionary = Hashtable.Synchronized(new Hashtable());
- public void Clear()
- {
- dictionary.Clear();
- }
+ public void Clear()
+ {
+ dictionary.Clear();
+ }
- public bool Contains(Object key)
- {
- return dictionary.Contains(key);
- }
+ public bool Contains(Object key)
+ {
+ return dictionary.Contains(key);
+ }
- public void Remove(Object key)
- {
- dictionary.Remove(key);
- }
+ public void Remove(Object key)
+ {
+ dictionary.Remove(key);
+ }
- public int Count
- {
- get { return dictionary.Count; }
- }
+ public int Count
+ {
+ get { return dictionary.Count; }
+ }
- public ICollection Keys
- {
- get { lock(dictionary.SyncRoot) return new ArrayList(dictionary.Keys); }
- }
+ public ICollection Keys
+ {
+ get
+ {
+ lock (dictionary.SyncRoot) return new ArrayList(dictionary.Keys);
+ }
+ }
- public ICollection Values
- {
- get { lock(dictionary.SyncRoot) return new ArrayList(dictionary.Values); }
- }
+ public ICollection Values
+ {
+ get
+ {
+ lock (dictionary.SyncRoot) return new ArrayList(dictionary.Values);
+ }
+ }
- public object this[string key]
- {
- get { return GetValue(key); }
- set
- {
- CheckValidType(value);
- SetValue(key, value);
- }
- }
+ public object this[string key]
+ {
+ get { return GetValue(key); }
+ set
+ {
+ CheckValidType(value);
+ SetValue(key, value);
+ }
+ }
- public string GetString(string key)
- {
- Object value = GetValue(key);
- if(value == null)
- {
- return null;
- }
- CheckValueType(value, typeof(string));
- return (string) value;
- }
+ public string GetString(string key)
+ {
+ Object value = GetValue(key);
+ if (value == null)
+ {
+ return null;
+ }
- public void SetString(string key, string value)
- {
- SetValue(key, value);
- }
+ CheckValueType(value, typeof(string));
+ return (string) value;
+ }
- public bool GetBool(String key)
- {
- Object value = GetValue(key);
- CheckValueType(value, typeof(bool));
- return (bool) value;
- }
+ public void SetString(string key, string value)
+ {
+ SetValue(key, value);
+ }
- public void SetBool(String key, bool value)
- {
- SetValue(key, value);
- }
+ public bool GetBool(String key)
+ {
+ Object value = GetValue(key);
+ CheckValueType(value, typeof(bool));
+ return (bool) value;
+ }
- public byte GetByte(String key)
- {
- Object value = GetValue(key);
- CheckValueType(value, typeof(byte));
- return (byte) value;
- }
+ public void SetBool(String key, bool value)
+ {
+ SetValue(key, value);
+ }
- public void SetByte(String key, byte value)
- {
- SetValue(key, value);
- }
+ public byte GetByte(String key)
+ {
+ Object value = GetValue(key);
+ CheckValueType(value, typeof(byte));
+ return (byte) value;
+ }
- public char GetChar(String key)
- {
- Object value = GetValue(key);
- CheckValueType(value, typeof(char));
- return (char) value;
- }
+ public void SetByte(String key, byte value)
+ {
+ SetValue(key, value);
+ }
- public void SetChar(String key, char value)
- {
- SetValue(key, value);
- }
+ public char GetChar(String key)
+ {
+ Object value = GetValue(key);
+ CheckValueType(value, typeof(char));
+ return (char) value;
+ }
- public short GetShort(String key)
- {
- Object value = GetValue(key);
- CheckValueType(value, typeof(short));
- return (short) value;
- }
+ public void SetChar(String key, char value)
+ {
+ SetValue(key, value);
+ }
- public void SetShort(String key, short value)
- {
- SetValue(key, value);
- }
+ public short GetShort(String key)
+ {
+ Object value = GetValue(key);
+ CheckValueType(value, typeof(short));
+ return (short) value;
+ }
- public int GetInt(String key)
- {
- Object value = GetValue(key);
- CheckValueType(value, typeof(int));
- return (int) value;
- }
+ public void SetShort(String key, short value)
+ {
+ SetValue(key, value);
+ }
- public void SetInt(String key, int value)
- {
- SetValue(key, value);
- }
+ public int GetInt(String key)
+ {
+ Object value = GetValue(key);
+ CheckValueType(value, typeof(int));
+ return (int) value;
+ }
- public long GetLong(String key)
- {
- Object value = GetValue(key);
- CheckValueType(value, typeof(long));
- return (long) value;
- }
+ public void SetInt(String key, int value)
+ {
+ SetValue(key, value);
+ }
- public void SetLong(String key, long value)
- {
- SetValue(key, value);
- }
+ public long GetLong(String key)
+ {
+ Object value = GetValue(key);
+ CheckValueType(value, typeof(long));
+ return (long) value;
+ }
- public float GetFloat(String key)
- {
- Object value = GetValue(key);
- CheckValueType(value, typeof(float));
- return (float) value;
- }
+ public void SetLong(String key, long value)
+ {
+ SetValue(key, value);
+ }
- public void SetFloat(String key, float value)
- {
- SetValue(key, value);
- }
+ public float GetFloat(String key)
+ {
+ Object value = GetValue(key);
+ CheckValueType(value, typeof(float));
+ return (float) value;
+ }
- public double GetDouble(String key)
- {
- Object value = GetValue(key);
- CheckValueType(value, typeof(double));
- return (double) value;
- }
+ public void SetFloat(String key, float value)
+ {
+ SetValue(key, value);
+ }
- public void SetDouble(String key, double value)
- {
- SetValue(key, value);
- }
+ public double GetDouble(String key)
+ {
+ Object value = GetValue(key);
+ CheckValueType(value, typeof(double));
+ return (double) value;
+ }
- public IList GetList(String key)
- {
- Object value = GetValue(key);
- if(value != null && !(value is IList))
- {
- throw new NMSException("Property: " + key + " is not an IList but is: " + value);
- }
- return (IList) value;
- }
-
- public void SetList(String key, IList value)
- {
- SetValue(key, value);
- }
+ public void SetDouble(String key, double value)
+ {
+ SetValue(key, value);
+ }
- public void SetBytes(String key, byte[] value)
- {
- this.SetBytes(key, value, 0, value.Length);
- }
-
- public void SetBytes(String key, byte[] value, int offset, int length)
- {
- byte[] copy = new byte[length];
- Array.Copy(value, offset, copy, 0, length);
- SetValue(key, copy);
- }
-
- public byte[] GetBytes(string key)
- {
- Object value = GetValue(key);
- if(value != null && !(value is Byte[]))
- {
- throw new NMSException("Property: " + key + " is not an byte[] but is: " + value);
- }
- return (byte[]) value;
- }
-
- public IDictionary GetDictionary(String key)
- {
- Object value = GetValue(key);
- if(value != null && !(value is IDictionary))
- {
- throw new NMSException("Property: " + key + " is not an IDictionary but is: " + value);
- }
- return (IDictionary) value;
- }
+ public IList GetList(String key)
+ {
+ Object value = GetValue(key);
+ if (value != null && !(value is IList))
+ {
+ throw new NMSException("Property: " + key + " is not an IList but is: " + value);
+ }
- public void SetDictionary(String key, IDictionary value)
- {
- SetValue(key, value);
- }
+ return (IList) value;
+ }
- protected virtual void SetValue(String key, Object value)
- {
- dictionary[key] = value;
- }
+ public void SetList(String key, IList value)
+ {
+ SetValue(key, value);
+ }
- protected virtual Object GetValue(String key)
- {
- return dictionary[key];
- }
+ public void SetBytes(String key, byte[] value)
+ {
+ this.SetBytes(key, value, 0, value.Length);
+ }
- protected virtual void CheckValueType(Object value, Type type)
- {
- if(!type.IsInstanceOfType(value))
- {
- throw new NMSException("Expected type: " + type.Name + " but was: " + value);
- }
- }
+ public void SetBytes(String key, byte[] value, int offset, int length)
+ {
+ byte[] copy = new byte[length];
+ Array.Copy(value, offset, copy, 0, length);
+ SetValue(key, copy);
+ }
- protected virtual void CheckValidType(Object value)
- {
- if(value != null && !(value is IList) && !(value is IDictionary))
- {
- Type type = value.GetType();
+ public byte[] GetBytes(string key)
+ {
+ Object value = GetValue(key);
+ if (value != null && !(value is Byte[]))
+ {
+ throw new NMSException("Property: " + key + " is not an byte[] but is: " + value);
+ }
- if(type.IsInstanceOfType(typeof(Object)) ||
- (!type.IsPrimitive && !type.IsValueType && !type.IsAssignableFrom(typeof(string))))
- {
- throw new NMSException("Invalid type: " + type.Name + " for value: " + value);
- }
- }
- }
+ return (byte[]) value;
+ }
- /// <summary>
- /// Method ToString
- /// </summary>
- /// <returns>A string</returns>
- public override String ToString()
- {
- String s = "{";
- bool first = true;
- lock(dictionary.SyncRoot)
- {
- foreach(DictionaryEntry entry in dictionary)
- {
- if(!first)
- {
- s += ", ";
- }
- first = false;
- String name = (String) entry.Key;
- Object value = entry.Value;
- s += name + "=" + value;
- }
- }
- s += "}";
- return s;
- }
+ public IDictionary GetDictionary(String key)
+ {
+ Object value = GetValue(key);
+ if (value != null && !(value is IDictionary))
+ {
+ throw new NMSException("Property: " + key + " is not an IDictionary but is: " + value);
+ }
- /// <summary>
- /// Unmarshalls the map from the given data or if the data is null just
- /// return an empty map
- /// </summary>
- public static PrimitiveMap Unmarshal(byte[] data)
- {
- PrimitiveMap answer = new PrimitiveMap();
- answer.dictionary = UnmarshalPrimitiveMap(data);
- return answer;
- }
+ return (IDictionary) value;
+ }
- /// <summary>
- /// Unmarshals a PrimitiveMap directly from a Stream object. This
- /// allows for clients to read PrimitiveMaps from Compressed or other
- /// wise encoded streams without this class needing to know about it.
- /// </summary>
- /// <param name="source">
- /// A <see cref="Stream"/>
- /// </param>
- /// <returns>
- /// A <see cref="PrimitiveMap"/>
- /// </returns>
- public static PrimitiveMap Unmarshal(Stream source)
- {
- PrimitiveMap answer = new PrimitiveMap();
- answer.dictionary = UnmarshalPrimitiveMap(source);
- return answer;
- }
+ public void SetDictionary(String key, IDictionary value)
+ {
+ SetValue(key, value);
+ }
- public byte[] Marshal()
- {
- lock(dictionary.SyncRoot)
- {
- return MarshalPrimitiveMap(dictionary);
- }
- }
+ protected virtual void SetValue(String key, Object value)
+ {
+ dictionary[key] = value;
+ }
- /// <summary>
- /// Marshals a PrimitiveMap directly to a Stream object. This
- /// allows a client to write a PrimitiveMap in a compressed or
- /// otherwise encoded form without this class needing to know
- /// about it.
- /// </summary>
- /// <param name="destination">
- /// A <see cref="Stream"/>
- /// </param>
- public void Marshal(Stream destination)
- {
- lock(dictionary.SyncRoot)
- {
- MarshalPrimitiveMap(dictionary, destination);
- }
- }
-
- /// <summary>
- /// Marshals the primitive type map to a byte array
- /// </summary>
- public static byte[] MarshalPrimitiveMap(IDictionary map)
- {
- if(map == null)
- {
- return null;
- }
+ protected virtual Object GetValue(String key)
+ {
+ return dictionary[key];
+ }
- MemoryStream memoryStream = new MemoryStream();
- lock(map.SyncRoot)
- {
- MarshalPrimitiveMap(map, new EndianBinaryWriter(memoryStream));
- }
+ protected virtual void CheckValueType(Object value, Type type)
+ {
+ if (!type.IsInstanceOfType(value))
+ {
+ throw new NMSException("Expected type: " + type.Name + " but was: " + value);
+ }
+ }
- return memoryStream.ToArray();
- }
+ protected virtual void CheckValidType(Object value)
+ {
+ if (value != null && !(value is IList) && !(value is IDictionary))
+ {
+ Type type = value.GetType();
- public static void MarshalPrimitiveMap(IDictionary map, Stream stream)
- {
- if(map != null)
- {
- lock(map.SyncRoot)
- {
- MarshalPrimitiveMap(map, new EndianBinaryWriter(stream));
- }
- }
- }
-
- public static void MarshalPrimitiveMap(IDictionary map, BinaryWriter dataOut)
- {
- if(map == null)
- {
- dataOut.Write((int) -1);
- }
- else
- {
- lock(map.SyncRoot)
- {
- dataOut.Write(map.Count);
- foreach(DictionaryEntry entry in map)
- {
- String name = (String) entry.Key;
- dataOut.Write(name);
- Object value = entry.Value;
- MarshalPrimitive(dataOut, value);
- }
- }
- }
- }
+ if (type.IsInstanceOfType(typeof(Object)) ||
+ (!type.IsPrimitive && !type.IsValueType && !type.IsAssignableFrom(typeof(string))))
+ {
+ throw new NMSException("Invalid type: " + type.Name + " for value: " + value);
+ }
+ }
+ }
- /// <summary>
- /// Unmarshals the primitive type map from the given byte array
- /// </summary>
- public static IDictionary UnmarshalPrimitiveMap(byte[] data)
- {
- if(data == null)
- {
- return new Hashtable();
- }
- else
- {
- return UnmarshalPrimitiveMap(new EndianBinaryReader(new MemoryStream(data)));
- }
- }
-
- public static IDictionary UnmarshalPrimitiveMap(Stream source)
- {
- return UnmarshalPrimitiveMap(new EndianBinaryReader(source));
- }
+ /// <summary>
+ /// Method ToString
+ /// </summary>
+ /// <returns>A string</returns>
+ public override String ToString()
+ {
+ String s = "{";
+ bool first = true;
+ lock (dictionary.SyncRoot)
+ {
+ foreach (DictionaryEntry entry in dictionary)
+ {
+ if (!first)
+ {
+ s += ", ";
+ }
- public static IDictionary UnmarshalPrimitiveMap(BinaryReader dataIn)
- {
- int size = dataIn.ReadInt32();
- if(size < 0)
- {
- return null;
- }
+ first = false;
+ String name = (String) entry.Key;
+ Object value = entry.Value;
+ s += name + "=" + value;
+ }
+ }
- IDictionary answer = new Hashtable(size);
- for(int i = 0; i < size; i++)
- {
- String name = dataIn.ReadString();
- answer[name] = UnmarshalPrimitive(dataIn);
- }
+ s += "}";
+ return s;
+ }
- return answer;
- }
+ /// <summary>
+ /// Unmarshalls the map from the given data or if the data is null just
+ /// return an empty map
+ /// </summary>
+ public static PrimitiveMap Unmarshal(byte[] data)
+ {
+ PrimitiveMap answer = new PrimitiveMap();
+ answer.dictionary = UnmarshalPrimitiveMap(data);
+ return answer;
+ }
- public static void MarshalPrimitiveList(IList list, BinaryWriter dataOut)
- {
- dataOut.Write((int) list.Count);
- foreach(Object element in list)
- {
- MarshalPrimitive(dataOut, element);
- }
- }
+ /// <summary>
+ /// Unmarshals a PrimitiveMap directly from a Stream object. This
+ /// allows for clients to read PrimitiveMaps from Compressed or other
+ /// wise encoded streams without this class needing to know about it.
+ /// </summary>
+ /// <param name="source">
+ /// A <see cref="Stream"/>
+ /// </param>
+ /// <returns>
+ /// A <see cref="PrimitiveMap"/>
+ /// </returns>
+ public static PrimitiveMap Unmarshal(Stream source)
+ {
+ PrimitiveMap answer = new PrimitiveMap();
+ answer.dictionary = UnmarshalPrimitiveMap(source);
+ return answer;
+ }
- public static IList UnmarshalPrimitiveList(BinaryReader dataIn)
- {
- int size = dataIn.ReadInt32();
- IList answer = new ArrayList(size);
- while(size-- > 0)
- {
- answer.Add(UnmarshalPrimitive(dataIn));
- }
+ public byte[] Marshal()
+ {
+ lock (dictionary.SyncRoot)
+ {
+ return MarshalPrimitiveMap(dictionary);
+ }
+ }
- return answer;
- }
+ /// <summary>
+ /// Marshals a PrimitiveMap directly to a Stream object. This
+ /// allows a client to write a PrimitiveMap in a compressed or
+ /// otherwise encoded form without this class needing to know
+ /// about it.
+ /// </summary>
+ /// <param name="destination">
+ /// A <see cref="Stream"/>
+ /// </param>
+ public void Marshal(Stream destination)
+ {
+ lock (dictionary.SyncRoot)
+ {
+ MarshalPrimitiveMap(dictionary, destination);
+ }
+ }
- public static void MarshalPrimitive(BinaryWriter dataOut, Object value)
- {
- if(value == null)
- {
- dataOut.Write(NULL);
- }
- else if(value is bool)
- {
- dataOut.Write(BOOLEAN_TYPE);
- dataOut.Write((bool) value);
- }
- else if(value is byte)
- {
- dataOut.Write(BYTE_TYPE);
- dataOut.Write(((byte) value));
- }
- else if(value is char)
- {
- dataOut.Write(CHAR_TYPE);
- dataOut.Write((char) value);
- }
- else if(value is short)
- {
- dataOut.Write(SHORT_TYPE);
- dataOut.Write((short) value);
- }
- else if(value is int)
- {
- dataOut.Write(INTEGER_TYPE);
- dataOut.Write((int) value);
- }
- else if(value is long)
- {
- dataOut.Write(LONG_TYPE);
- dataOut.Write((long) value);
- }
- else if(value is float)
- {
- dataOut.Write(FLOAT_TYPE);
- dataOut.Write((float) value);
- }
- else if(value is double)
- {
- dataOut.Write(DOUBLE_TYPE);
- dataOut.Write((double) value);
- }
- else if(value is byte[])
- {
- byte[] data = (byte[]) value;
- dataOut.Write(BYTE_ARRAY_TYPE);
- dataOut.Write(data.Length);
- dataOut.Write(data);
- }
- else if(value is string)
- {
- string s = (string) value;
- // is the string big??
- if(s.Length > 8191)
- {
- dataOut.Write(BIG_STRING_TYPE);
- ((EndianBinaryWriter) dataOut).WriteString32(s);
- }
- else
- {
- dataOut.Write(STRING_TYPE);
- ((EndianBinaryWriter) dataOut).WriteString16(s);
- }
- }
- else if(value is IDictionary)
- {
- dataOut.Write(MAP_TYPE);
- MarshalPrimitiveMap((IDictionary) value, dataOut);
- }
- else if(value is IList)
- {
- dataOut.Write(LIST_TYPE);
- MarshalPrimitiveList((IList) value, dataOut);
- }
- else
- {
- throw new IOException("Object is not a primitive: " + value);
- }
- }
+ /// <summary>
+ /// Marshals the primitive type map to a byte array
+ /// </summary>
+ public static byte[] MarshalPrimitiveMap(IDictionary map)
+ {
+ if (map == null)
+ {
+ return null;
+ }
- public static Object UnmarshalPrimitive(BinaryReader dataIn)
- {
- Object value = null;
- byte type = dataIn.ReadByte();
- switch(type)
- {
- case NULL:
- value = null;
- break;
- case BYTE_TYPE:
- value = dataIn.ReadByte();
- break;
- case BOOLEAN_TYPE:
- value = dataIn.ReadBoolean();
- break;
- case CHAR_TYPE:
- value = dataIn.ReadChar();
- break;
- case SHORT_TYPE:
- value = dataIn.ReadInt16();
- break;
- case INTEGER_TYPE:
- value = dataIn.ReadInt32();
- break;
- case LONG_TYPE:
- value = dataIn.ReadInt64();
- break;
- case FLOAT_TYPE:
- value = dataIn.ReadSingle();
- break;
- case DOUBLE_TYPE:
- value = dataIn.ReadDouble();
- break;
- case BYTE_ARRAY_TYPE:
- int size = dataIn.ReadInt32();
- byte[] data = new byte[size];
- dataIn.Read(data, 0, size);
- value = data;
- break;
- case STRING_TYPE:
- value = ((EndianBinaryReader) dataIn).ReadString16();
- break;
- case BIG_STRING_TYPE:
- value = ((EndianBinaryReader) dataIn).ReadString32();
- break;
- case MAP_TYPE:
- value = UnmarshalPrimitiveMap(dataIn);
- break;
- case LIST_TYPE:
- value = UnmarshalPrimitiveList(dataIn);
- break;
+ MemoryStream memoryStream = new MemoryStream();
+ lock (map.SyncRoot)
+ {
+ MarshalPrimitiveMap(map, new EndianBinaryWriter(memoryStream));
+ }
- default:
- throw new Exception("Unsupported data type: " + type);
- }
- return value;
- }
- }
-}
+ return memoryStream.ToArray();
+ }
+
+ public static void MarshalPrimitiveMap(IDictionary map, Stream stream)
+ {
+ if (map != null)
+ {
+ lock (map.SyncRoot)
+ {
+ MarshalPrimitiveMap(map, new EndianBinaryWriter(stream));
+ }
+ }
+ }
+
+ public static void MarshalPrimitiveMap(IDictionary map, BinaryWriter dataOut)
+ {
+ if (map == null)
+ {
+ dataOut.Write((int) -1);
+ }
+ else
+ {
+ lock (map.SyncRoot)
+ {
+ dataOut.Write(map.Count);
+ foreach (DictionaryEntry entry in map)
+ {
+ String name = (String) entry.Key;
+ dataOut.Write(name);
+ Object value = entry.Value;
+ MarshalPrimitive(dataOut, value);
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Unmarshals the primitive type map from the given byte array
+ /// </summary>
+ public static IDictionary UnmarshalPrimitiveMap(byte[] data)
+ {
+ if (data == null)
+ {
+ return new Hashtable();
+ }
+ else
+ {
+ return UnmarshalPrimitiveMap(new EndianBinaryReader(new MemoryStream(data)));
+ }
+ }
+
+ public static IDictionary UnmarshalPrimitiveMap(Stream source)
+ {
+ return UnmarshalPrimitiveMap(new EndianBinaryReader(source));
+ }
+
+ public static IDictionary UnmarshalPrimitiveMap(BinaryReader dataIn)
+ {
+ int size = dataIn.ReadInt32();
+ if (size < 0)
+ {
+ return null;
+ }
+
+ IDictionary answer = new Hashtable(size);
+ for (int i = 0; i < size; i++)
+ {
+ String name = dataIn.ReadString();
+ answer[name] = UnmarshalPrimitive(dataIn);
+ }
+
+ return answer;
+ }
+
+ public static void MarshalPrimitiveList(IList list, BinaryWriter dataOut)
+ {
+ dataOut.Write((int) list.Count);
+ foreach (Object element in list)
+ {
+ MarshalPrimitive(dataOut, element);
+ }
+ }
+
+ public static IList UnmarshalPrimitiveList(BinaryReader dataIn)
+ {
+ int size = dataIn.ReadInt32();
+ IList answer = new ArrayList(size);
+ while (size-- > 0)
+ {
+ answer.Add(UnmarshalPrimitive(dataIn));
+ }
+
+ return answer;
+ }
+
+ public static void MarshalPrimitive(BinaryWriter dataOut, Object value)
+ {
+ if (value == null)
+ {
+ dataOut.Write(NULL);
+ }
+ else if (value is bool)
+ {
+ dataOut.Write(BOOLEAN_TYPE);
+ dataOut.Write((bool) value);
+ }
+ else if (value is byte)
+ {
+ dataOut.Write(BYTE_TYPE);
+ dataOut.Write(((byte) value));
+ }
+ else if (value is char)
+ {
+ dataOut.Write(CHAR_TYPE);
+ dataOut.Write((char) value);
+ }
+ else if (value is short)
+ {
+ dataOut.Write(SHORT_TYPE);
+ dataOut.Write((short) value);
+ }
+ else if (value is int)
+ {
+ dataOut.Write(INTEGER_TYPE);
+ dataOut.Write((int) value);
+ }
+ else if (value is long)
+ {
+ dataOut.Write(LONG_TYPE);
+ dataOut.Write((long) value);
+ }
+ else if (value is float)
+ {
+ dataOut.Write(FLOAT_TYPE);
+ dataOut.Write((float) value);
+ }
+ else if (value is double)
+ {
+ dataOut.Write(DOUBLE_TYPE);
+ dataOut.Write((double) value);
+ }
+ else if (value is byte[])
+ {
+ byte[] data = (byte[]) value;
+ dataOut.Write(BYTE_ARRAY_TYPE);
+ dataOut.Write(data.Length);
+ dataOut.Write(data);
+ }
+ else if (value is string)
+ {
+ string s = (string) value;
+ // is the string big??
+ if (s.Length > 8191)
+ {
+ dataOut.Write(BIG_STRING_TYPE);
+ ((EndianBinaryWriter) dataOut).WriteString32(s);
+ }
+ else
+ {
+ dataOut.Write(STRING_TYPE);
+ ((EndianBinaryWriter) dataOut).WriteString16(s);
+ }
+ }
+ else if (value is IDictionary)
+ {
+ dataOut.Write(MAP_TYPE);
+ MarshalPrimitiveMap((IDictionary) value, dataOut);
+ }
+ else if (value is IList)
+ {
+ dataOut.Write(LIST_TYPE);
+ MarshalPrimitiveList((IList) value, dataOut);
+ }
+ else
+ {
+ throw new IOException("Object is not a primitive: " + value);
+ }
+ }
+
+ public static Object UnmarshalPrimitive(BinaryReader dataIn)
+ {
+ Object value = null;
+ byte type = dataIn.ReadByte();
+ switch (type)
+ {
+ case NULL:
+ value = null;
+ break;
+ case BYTE_TYPE:
+ value = dataIn.ReadByte();
+ break;
+ case BOOLEAN_TYPE:
+ value = dataIn.ReadBoolean();
+ break;
+ case CHAR_TYPE:
+ value = dataIn.ReadChar();
+ break;
+ case SHORT_TYPE:
+ value = dataIn.ReadInt16();
+ break;
+ case INTEGER_TYPE:
+ value = dataIn.ReadInt32();
+ break;
+ case LONG_TYPE:
+ value = dataIn.ReadInt64();
+ break;
+ case FLOAT_TYPE:
+ value = dataIn.ReadSingle();
+ break;
+ case DOUBLE_TYPE:
+ value = dataIn.ReadDouble();
+ break;
+ case BYTE_ARRAY_TYPE:
+ int size = dataIn.ReadInt32();
+ byte[] data = new byte[size];
+ dataIn.Read(data, 0, size);
+ value = data;
+ break;
+ case STRING_TYPE:
+ value = ((EndianBinaryReader) dataIn).ReadString16();
+ break;
+ case BIG_STRING_TYPE:
+ value = ((EndianBinaryReader) dataIn).ReadString32();
+ break;
+ case MAP_TYPE:
+ value = UnmarshalPrimitiveMap(dataIn);
+ break;
+ case LIST_TYPE:
+ value = UnmarshalPrimitiveList(dataIn);
+ break;
+
+ default:
+ throw new Exception("Unsupported data type: " + type);
+ }
+
+ return value;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/PrimitiveMapInterceptor.cs b/src/nms-api/Util/PrimitiveMapInterceptor.cs
index 689765b..279e92a 100644
--- a/src/nms-api/Util/PrimitiveMapInterceptor.cs
+++ b/src/nms-api/Util/PrimitiveMapInterceptor.cs
@@ -49,7 +49,7 @@
protected IMessage message;
protected IPrimitiveMap properties;
private bool readOnly = false;
- private bool allowByteArrays = true;
+ private bool allowByteArrays = true;
public PrimitiveMapInterceptor(IMessage message, IPrimitiveMap properties)
{
@@ -63,15 +63,15 @@
this.properties = properties;
this.readOnly = readOnly;
}
-
+
public PrimitiveMapInterceptor(IMessage message, IPrimitiveMap properties, bool readOnly, bool allowByteArrays)
{
this.message = message;
this.properties = properties;
this.readOnly = readOnly;
- this.allowByteArrays = allowByteArrays;
+ this.allowByteArrays = allowByteArrays;
}
-
+
protected virtual object GetObjectProperty(string name)
{
return this.properties[name];
@@ -83,14 +83,14 @@
try
{
- if(!this.allowByteArrays && (value is byte[]))
- {
- throw new NotSupportedException("Byte Arrays not allowed in this PrimitiveMap");
- }
-
+ if (!this.allowByteArrays && (value is byte[]))
+ {
+ throw new NotSupportedException("Byte Arrays not allowed in this PrimitiveMap");
+ }
+
this.properties[name] = value;
}
- catch(Exception ex)
+ catch (Exception ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -139,12 +139,12 @@
public string GetString(string key)
{
Object value = GetObjectProperty(key);
-
- if(value == null)
+
+ if (value == null)
{
return null;
}
- else if((value is IList) || (value is IDictionary))
+ else if ((value is IList) || (value is IDictionary))
{
throw new MessageFormatException(" cannot read a boolean from " + value.GetType().Name);
}
@@ -163,11 +163,11 @@
try
{
- if(value is Boolean)
+ if (value is Boolean)
{
return (bool) value;
}
- else if(value is String)
+ else if (value is String)
{
return ((string) value).ToLower() == "true";
}
@@ -176,7 +176,7 @@
throw new MessageFormatException(" cannot read a boolean from " + value.GetType().Name);
}
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -193,11 +193,11 @@
try
{
- if(value is Byte)
+ if (value is Byte)
{
return (byte) value;
}
- else if(value is String)
+ else if (value is String)
{
return Convert.ToByte(value);
}
@@ -206,7 +206,7 @@
throw new MessageFormatException(" cannot read a byte from " + value.GetType().Name);
}
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -223,25 +223,25 @@
try
{
- if(value is Char)
+ if (value is Char)
{
return (char) value;
}
- else if(value is String)
- {
- string svalue = value as string;
- if(svalue.Length == 1)
- {
- return svalue.ToCharArray()[0];
- }
- }
+ else if (value is String)
+ {
+ string svalue = value as string;
+ if (svalue.Length == 1)
+ {
+ return svalue.ToCharArray()[0];
+ }
+ }
- throw new MessageFormatException(" cannot read a char from " + value.GetType().Name);
+ throw new MessageFormatException(" cannot read a char from " + value.GetType().Name);
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
- }
+ }
}
public void SetChar(string key, char value)
@@ -255,11 +255,11 @@
try
{
- if(value is Int16)
+ if (value is Int16)
{
return (short) value;
}
- else if(value is Byte || value is String)
+ else if (value is Byte || value is String)
{
return Convert.ToInt16(value);
}
@@ -268,7 +268,7 @@
throw new MessageFormatException(" cannot read a short from " + value.GetType().Name);
}
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -285,11 +285,11 @@
try
{
- if(value is Int32)
+ if (value is Int32)
{
return (int) value;
}
- else if(value is Int16 || value is Byte || value is String)
+ else if (value is Int16 || value is Byte || value is String)
{
return Convert.ToInt32(value);
}
@@ -298,7 +298,7 @@
throw new MessageFormatException(" cannot read a int from " + value.GetType().Name);
}
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -315,11 +315,11 @@
try
{
- if(value is Int64)
+ if (value is Int64)
{
return (long) value;
}
- else if(value is Int32 || value is Int16 || value is Byte || value is String)
+ else if (value is Int32 || value is Int16 || value is Byte || value is String)
{
return Convert.ToInt64(value);
}
@@ -328,7 +328,7 @@
throw new MessageFormatException(" cannot read a long from " + value.GetType().Name);
}
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -345,11 +345,11 @@
try
{
- if(value is Single)
+ if (value is Single)
{
return (float) value;
}
- else if(value is String)
+ else if (value is String)
{
return Convert.ToSingle(value);
}
@@ -358,7 +358,7 @@
throw new MessageFormatException(" cannot read a float from " + value.GetType().Name);
}
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -375,11 +375,11 @@
try
{
- if(value is Double)
+ if (value is Double)
{
return (double) value;
}
- else if(value is Single || value is String)
+ else if (value is Single || value is String)
{
return Convert.ToDouble(value);
}
@@ -388,7 +388,7 @@
throw new MessageFormatException(" cannot read a double from " + value.GetType().Name);
}
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -399,25 +399,25 @@
SetObjectProperty(key, value);
}
- public void SetBytes(String key, byte[] value)
- {
- this.SetBytes(key, value, 0, value.Length);
- }
-
- public void SetBytes(String key, byte[] value, int offset, int length)
- {
- byte[] copy = new byte[length];
- Array.Copy(value, offset, copy, 0, length);
+ public void SetBytes(String key, byte[] value)
+ {
+ this.SetBytes(key, value, 0, value.Length);
+ }
+
+ public void SetBytes(String key, byte[] value, int offset, int length)
+ {
+ byte[] copy = new byte[length];
+ Array.Copy(value, offset, copy, 0, length);
SetObjectProperty(key, value);
- }
-
- public byte[] GetBytes(string key)
- {
+ }
+
+ public byte[] GetBytes(string key)
+ {
Object value = GetObjectProperty(key);
-
+
try
{
- if(value is Byte[])
+ if (value is Byte[])
{
return (byte[]) value;
}
@@ -426,12 +426,12 @@
throw new MessageFormatException(" cannot read a byte[] from " + value.GetType().Name);
}
}
- catch(FormatException ex)
+ catch (FormatException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
- }
-
+ }
+
public System.Collections.IList GetList(string key)
{
return (System.Collections.IList) GetObjectProperty(key);
@@ -456,22 +456,22 @@
public bool ReadOnly
{
- get{ return this.readOnly; }
- set{ this.readOnly = value; }
+ get { return this.readOnly; }
+ set { this.readOnly = value; }
}
public bool AllowByteArrays
{
- get{ return this.allowByteArrays; }
- set{ this.allowByteArrays = value; }
+ get { return this.allowByteArrays; }
+ set { this.allowByteArrays = value; }
}
-
+
protected virtual void FailIfReadOnly()
{
- if(this.ReadOnly == true)
+ if (this.ReadOnly == true)
{
throw new MessageNotWriteableException("Properties are in Read-Only mode.");
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/SessionUtils.cs b/src/nms-api/Util/SessionUtils.cs
index fbdff80..70b8604 100644
--- a/src/nms-api/Util/SessionUtils.cs
+++ b/src/nms-api/Util/SessionUtils.cs
@@ -14,176 +14,180 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS.Util
{
- /// <summary>
- /// Class to provide support for working with Session objects.
- /// </summary>
- public class SessionUtil
- {
- private const string QueuePrefix = "queue://";
- private const string TopicPrefix = "topic://";
- private const string TempQueuePrefix = "temp-queue://";
- private const string TempTopicPrefix = "temp-topic://";
+ /// <summary>
+ /// Class to provide support for working with Session objects.
+ /// </summary>
+ public class SessionUtil
+ {
+ private const string QueuePrefix = "queue://";
+ private const string TopicPrefix = "topic://";
+ private const string TempQueuePrefix = "temp-queue://";
+ private const string TempTopicPrefix = "temp-topic://";
- /// <summary>
- /// Get the destination by parsing the embedded type prefix. Default is Queue if no prefix is
- /// embedded in the destinationName.
- /// </summary>
- /// <param name="session">Session object to use to get the destination.</param>
- /// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
- /// <list type="bullet">
- /// <item>queue://</item>
- /// <item>topic://</item>
- /// <item>temp-queue://</item>
- /// <item>temp-topic://</item>
- /// </list>
- /// </param>
- /// <returns></returns>
- public static IDestination GetDestination(ISession session, string destinationName)
- {
- return SessionUtil.GetDestination(session, destinationName, DestinationType.Queue);
- }
+ /// <summary>
+ /// Get the destination by parsing the embedded type prefix. Default is Queue if no prefix is
+ /// embedded in the destinationName.
+ /// </summary>
+ /// <param name="session">Session object to use to get the destination.</param>
+ /// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
+ /// <list type="bullet">
+ /// <item>queue://</item>
+ /// <item>topic://</item>
+ /// <item>temp-queue://</item>
+ /// <item>temp-topic://</item>
+ /// </list>
+ /// </param>
+ /// <returns></returns>
+ public static IDestination GetDestination(ISession session, string destinationName)
+ {
+ return SessionUtil.GetDestination(session, destinationName, DestinationType.Queue);
+ }
- /// <summary>
- /// Get the destination by parsing the embedded type prefix.
- /// </summary>
- /// <param name="session">Session object to use to get the destination.</param>
- /// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
- /// <list type="bullet">
- /// <item>queue://</item>
- /// <item>topic://</item>
- /// <item>temp-queue://</item>
- /// <item>temp-topic://</item>
- /// </list>
- /// </param>
- /// <param name="defaultType">Default type if no embedded prefix is specified.</param>
- /// <returns></returns>
- public static IDestination GetDestination(ISession session, string destinationName, DestinationType defaultType)
- {
- IDestination destination = null;
- DestinationType destinationType = defaultType;
+ /// <summary>
+ /// Get the destination by parsing the embedded type prefix.
+ /// </summary>
+ /// <param name="session">Session object to use to get the destination.</param>
+ /// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
+ /// <list type="bullet">
+ /// <item>queue://</item>
+ /// <item>topic://</item>
+ /// <item>temp-queue://</item>
+ /// <item>temp-topic://</item>
+ /// </list>
+ /// </param>
+ /// <param name="defaultType">Default type if no embedded prefix is specified.</param>
+ /// <returns></returns>
+ public static IDestination GetDestination(ISession session, string destinationName, DestinationType defaultType)
+ {
+ IDestination destination = null;
+ DestinationType destinationType = defaultType;
- if(null != destinationName)
- {
- if(destinationName.Length > QueuePrefix.Length
- && 0 == String.Compare(destinationName.Substring(0, QueuePrefix.Length), QueuePrefix, false))
- {
- destinationType = DestinationType.Queue;
- destinationName = destinationName.Substring(QueuePrefix.Length);
- }
- else if(destinationName.Length > TopicPrefix.Length
- && 0 == String.Compare(destinationName.Substring(0, TopicPrefix.Length), TopicPrefix, false))
- {
- destinationType = DestinationType.Topic;
- destinationName = destinationName.Substring(TopicPrefix.Length);
- }
- else if(destinationName.Length > TempQueuePrefix.Length
- && 0 == String.Compare(destinationName.Substring(0, TempQueuePrefix.Length), TempQueuePrefix, false))
- {
- destinationType = DestinationType.TemporaryQueue;
- destinationName = destinationName.Substring(TempQueuePrefix.Length);
- }
- else if(destinationName.Length > TempTopicPrefix.Length
- && 0 == String.Compare(destinationName.Substring(0, TempTopicPrefix.Length), TempTopicPrefix, false))
- {
- destinationType = DestinationType.TemporaryTopic;
- destinationName = destinationName.Substring(TempTopicPrefix.Length);
- }
- }
+ if (null != destinationName)
+ {
+ if (destinationName.Length > QueuePrefix.Length
+ && 0 == String.Compare(destinationName.Substring(0, QueuePrefix.Length), QueuePrefix, false))
+ {
+ destinationType = DestinationType.Queue;
+ destinationName = destinationName.Substring(QueuePrefix.Length);
+ }
+ else if (destinationName.Length > TopicPrefix.Length
+ && 0 == String.Compare(destinationName.Substring(0, TopicPrefix.Length), TopicPrefix, false))
+ {
+ destinationType = DestinationType.Topic;
+ destinationName = destinationName.Substring(TopicPrefix.Length);
+ }
+ else if (destinationName.Length > TempQueuePrefix.Length
+ && 0 == String.Compare(destinationName.Substring(0, TempQueuePrefix.Length), TempQueuePrefix,
+ false))
+ {
+ destinationType = DestinationType.TemporaryQueue;
+ destinationName = destinationName.Substring(TempQueuePrefix.Length);
+ }
+ else if (destinationName.Length > TempTopicPrefix.Length
+ && 0 == String.Compare(destinationName.Substring(0, TempTopicPrefix.Length), TempTopicPrefix,
+ false))
+ {
+ destinationType = DestinationType.TemporaryTopic;
+ destinationName = destinationName.Substring(TempTopicPrefix.Length);
+ }
+ }
- switch(destinationType)
- {
- case DestinationType.Queue:
- if(null != destinationName)
- {
- destination = session.GetQueue(destinationName);
- }
- break;
+ switch (destinationType)
+ {
+ case DestinationType.Queue:
+ if (null != destinationName)
+ {
+ destination = session.GetQueue(destinationName);
+ }
- case DestinationType.Topic:
- if(null != destinationName)
- {
- destination = session.GetTopic(destinationName);
- }
- break;
+ break;
- case DestinationType.TemporaryQueue:
- destination = session.CreateTemporaryQueue();
- break;
+ case DestinationType.Topic:
+ if (null != destinationName)
+ {
+ destination = session.GetTopic(destinationName);
+ }
- case DestinationType.TemporaryTopic:
- destination = session.CreateTemporaryTopic();
- break;
- }
+ break;
- return destination;
- }
+ case DestinationType.TemporaryQueue:
+ destination = session.CreateTemporaryQueue();
+ break;
- public static IQueue GetQueue(ISession session, string queueName)
- {
- return GetDestination(session, queueName, DestinationType.Queue) as IQueue;
- }
+ case DestinationType.TemporaryTopic:
+ destination = session.CreateTemporaryTopic();
+ break;
+ }
- public static ITopic GetTopic(ISession session, string topicName)
- {
- return GetDestination(session, topicName, DestinationType.Topic) as ITopic;
- }
+ return destination;
+ }
- /// <summary>
- /// Delete the named destination by parsing the embedded type prefix. Default is Queue if no prefix is
- /// embedded in the destinationName.
- /// </summary>
- /// <param name="session">Session object to use to get the destination.</param>
- /// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
- /// <list type="bullet">
- /// <item>queue://</item>
- /// <item>topic://</item>
- /// <item>temp-queue://</item>
- /// <item>temp-topic://</item>
- /// </list>
- /// </param>
- /// <returns></returns>
- public static void DeleteDestination(ISession session, string destinationName)
- {
- SessionUtil.DeleteDestination(session, destinationName, DestinationType.Queue);
- }
+ public static IQueue GetQueue(ISession session, string queueName)
+ {
+ return GetDestination(session, queueName, DestinationType.Queue) as IQueue;
+ }
- /// <summary>
- /// Delete the named destination by parsing the embedded type prefix.
- /// </summary>
- /// <param name="session">Session object to use to get the destination.</param>
- /// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
- /// <list type="bullet">
- /// <item>queue://</item>
- /// <item>topic://</item>
- /// <item>temp-queue://</item>
- /// <item>temp-topic://</item>
- /// </list>
- /// </param>
- /// <param name="defaultType">Default type if no embedded prefix is specified.</param>
- /// <returns></returns>
- public static void DeleteDestination(ISession session, string destinationName, DestinationType defaultType)
- {
- IDestination destination = SessionUtil.GetDestination(session, destinationName, defaultType);
+ public static ITopic GetTopic(ISession session, string topicName)
+ {
+ return GetDestination(session, topicName, DestinationType.Topic) as ITopic;
+ }
- if(null != destination)
- {
- session.DeleteDestination(destination);
- }
- }
+ /// <summary>
+ /// Delete the named destination by parsing the embedded type prefix. Default is Queue if no prefix is
+ /// embedded in the destinationName.
+ /// </summary>
+ /// <param name="session">Session object to use to get the destination.</param>
+ /// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
+ /// <list type="bullet">
+ /// <item>queue://</item>
+ /// <item>topic://</item>
+ /// <item>temp-queue://</item>
+ /// <item>temp-topic://</item>
+ /// </list>
+ /// </param>
+ /// <returns></returns>
+ public static void DeleteDestination(ISession session, string destinationName)
+ {
+ SessionUtil.DeleteDestination(session, destinationName, DestinationType.Queue);
+ }
- public static void DeleteQueue(ISession session, string queueName)
- {
- DeleteDestination(session, queueName, DestinationType.Queue);
- }
+ /// <summary>
+ /// Delete the named destination by parsing the embedded type prefix.
+ /// </summary>
+ /// <param name="session">Session object to use to get the destination.</param>
+ /// <param name="destinationName">Name of destination with embedded prefix. The embedded prefix can be one of the following:
+ /// <list type="bullet">
+ /// <item>queue://</item>
+ /// <item>topic://</item>
+ /// <item>temp-queue://</item>
+ /// <item>temp-topic://</item>
+ /// </list>
+ /// </param>
+ /// <param name="defaultType">Default type if no embedded prefix is specified.</param>
+ /// <returns></returns>
+ public static void DeleteDestination(ISession session, string destinationName, DestinationType defaultType)
+ {
+ IDestination destination = SessionUtil.GetDestination(session, destinationName, defaultType);
- public static void DeleteTopic(ISession session, string topicName)
- {
- DeleteDestination(session, topicName, DestinationType.Topic);
- }
- }
-}
+ if (null != destination)
+ {
+ session.DeleteDestination(destination);
+ }
+ }
+ public static void DeleteQueue(ISession session, string queueName)
+ {
+ DeleteDestination(session, queueName, DestinationType.Queue);
+ }
+
+ public static void DeleteTopic(ISession session, string topicName)
+ {
+ DeleteDestination(session, topicName, DestinationType.Topic);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/URISupport.cs b/src/nms-api/Util/URISupport.cs
index 5a3d686..eca905f 100644
--- a/src/nms-api/Util/URISupport.cs
+++ b/src/nms-api/Util/URISupport.cs
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.Collections;
using System.Collections.Generic;
@@ -23,616 +24,625 @@
using System.Text;
#if !NETCF
using System.Web;
+
#endif
namespace Apache.NMS.Util
{
- /// <summary>
- /// Class to provide support for Uri query parameters which uses .Net reflection
- /// to identify and set properties.
- /// </summary>
- public class URISupport
- {
- /// <summary>
- /// Given a string that could be a Composite Uri that uses syntax not compatible
- /// with the .NET Uri class such as an ActiveMQ failover Uri formatted as
- /// "failover://(tcp://localhost:61616)", the initial '://' must be changed
- /// to ':(' so that the Uri class doesn't attempt to parse the '(tcp:' as
- /// the Uri's Authority as that is not a valid host name.
- /// </summary>
- /// <param name="uriString">
- /// A string that could be a Composite Uri that uses syntax not compatible
- /// with the .NET Uri class
- /// </param>
- public static Uri CreateCompatibleUri(string uriString)
- {
- string sanitized = uriString.Replace("://(", ":(");
- return new Uri(sanitized);
- }
+ /// <summary>
+ /// Class to provide support for Uri query parameters which uses .Net reflection
+ /// to identify and set properties.
+ /// </summary>
+ public class URISupport
+ {
+ /// <summary>
+ /// Given a string that could be a Composite Uri that uses syntax not compatible
+ /// with the .NET Uri class such as an ActiveMQ failover Uri formatted as
+ /// "failover://(tcp://localhost:61616)", the initial '://' must be changed
+ /// to ':(' so that the Uri class doesn't attempt to parse the '(tcp:' as
+ /// the Uri's Authority as that is not a valid host name.
+ /// </summary>
+ /// <param name="uriString">
+ /// A string that could be a Composite Uri that uses syntax not compatible
+ /// with the .NET Uri class
+ /// </param>
+ public static Uri CreateCompatibleUri(string uriString)
+ {
+ string sanitized = uriString.Replace("://(", ":(");
+ return new Uri(sanitized);
+ }
- /// <summary>
- /// Parse a Uri query string of the form ?x=y&z=0
- /// into a map of name/value pairs.
- /// </summary>
- /// <param name="query">The query string to parse. This string should not contain
- /// Uri escape characters.</param>
- public static StringDictionary ParseQuery(String query)
- {
- StringDictionary map = new StringDictionary();
+ /// <summary>
+ /// Parse a Uri query string of the form ?x=y&z=0
+ /// into a map of name/value pairs.
+ /// </summary>
+ /// <param name="query">The query string to parse. This string should not contain
+ /// Uri escape characters.</param>
+ public static StringDictionary ParseQuery(String query)
+ {
+ StringDictionary map = new StringDictionary();
- if(String.IsNullOrEmpty(query))
- {
- return EmptyMap;
- }
+ if (String.IsNullOrEmpty(query))
+ {
+ return EmptyMap;
+ }
- // strip the initial "?"
- if(query.StartsWith("?"))
- {
- query = query.Substring(1);
- }
+ // strip the initial "?"
+ if (query.StartsWith("?"))
+ {
+ query = query.Substring(1);
+ }
- // split the query into parameters
- string[] parameters = query.Split('&');
- foreach(string pair in parameters)
- {
- if(pair.Length > 0)
- {
- string[] nameValue = pair.Split('=');
+ // split the query into parameters
+ string[] parameters = query.Split('&');
+ foreach (string pair in parameters)
+ {
+ if (pair.Length > 0)
+ {
+ string[] nameValue = pair.Split('=');
- if(nameValue.Length != 2)
- {
- throw new NMSException(string.Format("Invalid Uri parameter: {0}", query));
- }
+ if (nameValue.Length != 2)
+ {
+ throw new NMSException(string.Format("Invalid Uri parameter: {0}", query));
+ }
- map[UrlDecode(nameValue[0])] = UrlDecode(nameValue[1]);
- }
- }
+ map[UrlDecode(nameValue[0])] = UrlDecode(nameValue[1]);
+ }
+ }
- return map;
- }
+ return map;
+ }
- public static StringDictionary ParseParameters(Uri uri)
- {
- return (uri.Query == null
- ? EmptyMap
- : ParseQuery(StripPrefix(uri.Query, "?")));
- }
+ public static StringDictionary ParseParameters(Uri uri)
+ {
+ return (uri.Query == null
+ ? EmptyMap
+ : ParseQuery(StripPrefix(uri.Query, "?")));
+ }
- /// <summary>
- /// Sets the public properties of a target object using a string map.
- /// This method uses .Net reflection to identify public properties of
- /// the target object matching the keys from the passed map.
- /// </summary>
- /// <param name="target">The object whose properties will be set.</param>
- /// <param name="map">Map of key/value pairs.</param>
- public static void SetProperties(object target, StringDictionary map)
- {
- Type type = target.GetType();
+ /// <summary>
+ /// Sets the public properties of a target object using a string map.
+ /// This method uses .Net reflection to identify public properties of
+ /// the target object matching the keys from the passed map.
+ /// </summary>
+ /// <param name="target">The object whose properties will be set.</param>
+ /// <param name="map">Map of key/value pairs.</param>
+ public static void SetProperties(object target, StringDictionary map)
+ {
+ Type type = target.GetType();
- foreach(string key in map.Keys)
- {
- PropertyInfo prop = type.GetProperty(key,
- BindingFlags.FlattenHierarchy
- | BindingFlags.Public
- | BindingFlags.Instance
- | BindingFlags.IgnoreCase);
+ foreach (string key in map.Keys)
+ {
+ PropertyInfo prop = type.GetProperty(key,
+ BindingFlags.FlattenHierarchy
+ | BindingFlags.Public
+ | BindingFlags.Instance
+ | BindingFlags.IgnoreCase);
- if(null != prop)
- {
- prop.SetValue(target, Convert.ChangeType(map[key], prop.PropertyType, CultureInfo.InvariantCulture), null);
- }
- else
- {
- FieldInfo field = type.GetField(key,
- BindingFlags.FlattenHierarchy
- | BindingFlags.Public
- | BindingFlags.Instance
- | BindingFlags.IgnoreCase);
- if(null != field)
- {
- field.SetValue(target, Convert.ChangeType(map[key], field.FieldType, CultureInfo.InvariantCulture));
- }
- else
- {
- throw new NMSException(string.Format("No such property or field: {0} on class: {1}", key, target.GetType().Name));
- }
- }
- }
- }
+ if (null != prop)
+ {
+ prop.SetValue(target, Convert.ChangeType(map[key], prop.PropertyType, CultureInfo.InvariantCulture),
+ null);
+ }
+ else
+ {
+ FieldInfo field = type.GetField(key,
+ BindingFlags.FlattenHierarchy
+ | BindingFlags.Public
+ | BindingFlags.Instance
+ | BindingFlags.IgnoreCase);
+ if (null != field)
+ {
+ field.SetValue(target,
+ Convert.ChangeType(map[key], field.FieldType, CultureInfo.InvariantCulture));
+ }
+ else
+ {
+ throw new NMSException(string.Format("No such property or field: {0} on class: {1}", key,
+ target.GetType().Name));
+ }
+ }
+ }
+ }
- /// <summary>
- /// Sets the public properties of a target object using a string map.
- /// This method uses .Net reflection to identify public properties of
- /// the target object matching the keys from the passed map.
- /// </summary>
- /// <param name="target">The object whose properties will be set.</param>
- /// <param name="map">Map of key/value pairs.</param>
- /// <param name="prefix">Key value prefix. This is prepended to the property name
- /// before searching for a matching key value.</param>
- public static void SetProperties(object target, StringDictionary map, string prefix)
- {
- Type type = target.GetType();
+ /// <summary>
+ /// Sets the public properties of a target object using a string map.
+ /// This method uses .Net reflection to identify public properties of
+ /// the target object matching the keys from the passed map.
+ /// </summary>
+ /// <param name="target">The object whose properties will be set.</param>
+ /// <param name="map">Map of key/value pairs.</param>
+ /// <param name="prefix">Key value prefix. This is prepended to the property name
+ /// before searching for a matching key value.</param>
+ public static void SetProperties(object target, StringDictionary map, string prefix)
+ {
+ Type type = target.GetType();
- List<String> matches = new List<String>();
+ List<String> matches = new List<String>();
- foreach(string key in map.Keys)
- {
- if(key.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
- {
- string bareKey = key.Substring(prefix.Length);
- PropertyInfo prop = type.GetProperty(bareKey,
- BindingFlags.FlattenHierarchy
- | BindingFlags.Public
- | BindingFlags.Instance
- | BindingFlags.IgnoreCase);
+ foreach (string key in map.Keys)
+ {
+ if (key.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
+ {
+ string bareKey = key.Substring(prefix.Length);
+ PropertyInfo prop = type.GetProperty(bareKey,
+ BindingFlags.FlattenHierarchy
+ | BindingFlags.Public
+ | BindingFlags.Instance
+ | BindingFlags.IgnoreCase);
- if(null != prop)
- {
- prop.SetValue(target, Convert.ChangeType(map[key], prop.PropertyType, CultureInfo.InvariantCulture), null);
- }
- else
- {
- FieldInfo field = type.GetField(bareKey,
- BindingFlags.FlattenHierarchy
- | BindingFlags.Public
- | BindingFlags.Instance
- | BindingFlags.IgnoreCase);
- if(null != field)
- {
- field.SetValue(target, Convert.ChangeType(map[key], field.FieldType, CultureInfo.InvariantCulture));
- }
- else
- {
- throw new NMSException(string.Format("No such property or field: {0} on class: {1}", bareKey, target.GetType().Name));
- }
- }
+ if (null != prop)
+ {
+ prop.SetValue(target,
+ Convert.ChangeType(map[key], prop.PropertyType, CultureInfo.InvariantCulture), null);
+ }
+ else
+ {
+ FieldInfo field = type.GetField(bareKey,
+ BindingFlags.FlattenHierarchy
+ | BindingFlags.Public
+ | BindingFlags.Instance
+ | BindingFlags.IgnoreCase);
+ if (null != field)
+ {
+ field.SetValue(target,
+ Convert.ChangeType(map[key], field.FieldType, CultureInfo.InvariantCulture));
+ }
+ else
+ {
+ throw new NMSException(string.Format("No such property or field: {0} on class: {1}",
+ bareKey, target.GetType().Name));
+ }
+ }
- // store for later removal.
- matches.Add(key);
- }
- }
+ // store for later removal.
+ matches.Add(key);
+ }
+ }
- // Remove all the properties we set so they are used again later.
- foreach(string match in matches)
- {
- map.Remove(match);
- }
- }
+ // Remove all the properties we set so they are used again later.
+ foreach (string match in matches)
+ {
+ map.Remove(match);
+ }
+ }
- public static StringDictionary GetProperties(StringDictionary props, string prefix)
- {
- if(props == null)
- {
- throw new Exception("Properties Object was null");
- }
+ public static StringDictionary GetProperties(StringDictionary props, string prefix)
+ {
+ if (props == null)
+ {
+ throw new Exception("Properties Object was null");
+ }
- StringDictionary result = new StringDictionary();
+ StringDictionary result = new StringDictionary();
- foreach(string key in props.Keys)
- {
- if(key.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
- {
- string bareKey = key.Substring(prefix.Length);
- String value = props[key];
- result[bareKey] = value;
- }
- }
+ foreach (string key in props.Keys)
+ {
+ if (key.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
+ {
+ string bareKey = key.Substring(prefix.Length);
+ String value = props[key];
+ result[bareKey] = value;
+ }
+ }
- return result;
- }
+ return result;
+ }
- public static StringDictionary ExtractProperties(StringDictionary props, string prefix)
- {
+ public static StringDictionary ExtractProperties(StringDictionary props, string prefix)
+ {
+ if (props == null)
+ {
+ throw new Exception("Properties Object was null");
+ }
- if(props == null)
- {
- throw new Exception("Properties Object was null");
- }
+ StringDictionary result = new StringDictionary();
+ List<String> matches = new List<String>();
- StringDictionary result = new StringDictionary();
- List<String> matches = new List<String>();
+ foreach (string key in props.Keys)
+ {
+ if (key.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
+ {
+ String value = props[key];
+ result[key] = value;
+ matches.Add(key);
+ }
+ }
- foreach(string key in props.Keys)
- {
- if(key.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
- {
- String value = props[key];
- result[key] = value;
- matches.Add(key);
- }
- }
+ foreach (string match in matches)
+ {
+ props.Remove(match);
+ }
- foreach(string match in matches)
- {
- props.Remove(match);
- }
+ return result;
+ }
- return result;
- }
-
- public static String UrlDecode(String s)
- {
+ public static String UrlDecode(String s)
+ {
#if !NETCF
- return HttpUtility.UrlDecode(s);
+ return HttpUtility.UrlDecode(s);
#else
return Uri.UnescapeDataString(s);
#endif
- }
+ }
- public static String UrlEncode(String s)
- {
+ public static String UrlEncode(String s)
+ {
#if !NETCF
- return HttpUtility.UrlEncode(s);
+ return HttpUtility.UrlEncode(s);
#else
return Uri.EscapeUriString(s);
#endif
- }
+ }
- public static String CreateQueryString(StringDictionary options)
- {
- if(options != null && options.Count > 0)
- {
- StringBuilder rc = new StringBuilder();
- bool first = true;
+ public static String CreateQueryString(StringDictionary options)
+ {
+ if (options != null && options.Count > 0)
+ {
+ StringBuilder rc = new StringBuilder();
+ bool first = true;
- foreach(String key in options.Keys)
- {
- string value = options[key];
+ foreach (String key in options.Keys)
+ {
+ string value = options[key];
- if(first)
- {
- first = false;
- }
- else
- {
- rc.Append("&");
- }
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ rc.Append("&");
+ }
- rc.Append(UrlEncode(key));
- rc.Append("=");
- rc.Append(UrlEncode(value));
- }
+ rc.Append(UrlEncode(key));
+ rc.Append("=");
+ rc.Append(UrlEncode(value));
+ }
- return rc.ToString();
- }
- else
- {
- return "";
- }
- }
+ return rc.ToString();
+ }
+ else
+ {
+ return "";
+ }
+ }
- public static Uri CreateRemainingUri(Uri originalUri, StringDictionary parameters)
- {
- string s = CreateQueryString(parameters);
+ public static Uri CreateRemainingUri(Uri originalUri, StringDictionary parameters)
+ {
+ string s = CreateQueryString(parameters);
- if(String.IsNullOrEmpty(s))
- {
- s = null;
- }
+ if (String.IsNullOrEmpty(s))
+ {
+ s = null;
+ }
- return CreateUriWithQuery(originalUri, s);
- }
+ return CreateUriWithQuery(originalUri, s);
+ }
- public class CompositeData
- {
- private String host;
- private String scheme;
- private String path;
- private Uri[] components;
- private StringDictionary parameters;
- private String fragment;
+ public class CompositeData
+ {
+ private String host;
+ private String scheme;
+ private String path;
+ private Uri[] components;
+ private StringDictionary parameters;
+ private String fragment;
- public Uri[] Components
- {
- get { return components; }
- set { components = value; }
- }
+ public Uri[] Components
+ {
+ get { return components; }
+ set { components = value; }
+ }
- public String Fragment
- {
- get { return fragment; }
- set { fragment = value; }
- }
+ public String Fragment
+ {
+ get { return fragment; }
+ set { fragment = value; }
+ }
- public StringDictionary Parameters
- {
- get { return parameters; }
- set { parameters = value; }
- }
+ public StringDictionary Parameters
+ {
+ get { return parameters; }
+ set { parameters = value; }
+ }
- public String Scheme
- {
- get { return scheme; }
- set { scheme = value; }
- }
+ public String Scheme
+ {
+ get { return scheme; }
+ set { scheme = value; }
+ }
- public String Path
- {
- get { return path; }
- set { path = value; }
- }
+ public String Path
+ {
+ get { return path; }
+ set { path = value; }
+ }
- public String Host
- {
- get { return host; }
- set { host = value; }
- }
+ public String Host
+ {
+ get { return host; }
+ set { host = value; }
+ }
- public Uri toUri()
- {
- StringBuilder sb = new StringBuilder();
- if(scheme != null)
- {
- sb.Append(scheme);
- sb.Append(':');
- }
+ public Uri toUri()
+ {
+ StringBuilder sb = new StringBuilder();
+ if (scheme != null)
+ {
+ sb.Append(scheme);
+ sb.Append(':');
+ }
- if(!string.IsNullOrEmpty(host))
- {
- sb.Append(host);
- }
- else
- {
- sb.Append('(');
- for(int i = 0; i < components.Length; i++)
- {
- if(i != 0)
- {
- sb.Append(',');
- }
- sb.Append(components[i].ToString());
- }
- sb.Append(')');
- }
+ if (!string.IsNullOrEmpty(host))
+ {
+ sb.Append(host);
+ }
+ else
+ {
+ sb.Append('(');
+ for (int i = 0; i < components.Length; i++)
+ {
+ if (i != 0)
+ {
+ sb.Append(',');
+ }
- if(path != null)
- {
- sb.Append('/');
- sb.Append(path);
- }
+ sb.Append(components[i].ToString());
+ }
- if(parameters.Count != 0)
- {
- sb.Append("?");
- sb.Append(CreateQueryString(parameters));
- }
+ sb.Append(')');
+ }
- if(fragment != null)
- {
- sb.Append("#");
- sb.Append(fragment);
- }
+ if (path != null)
+ {
+ sb.Append('/');
+ sb.Append(path);
+ }
- return new Uri(sb.ToString());
- }
- }
+ if (parameters.Count != 0)
+ {
+ sb.Append("?");
+ sb.Append(CreateQueryString(parameters));
+ }
- public static String StripPrefix(String value, String prefix)
- {
- if(value.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
- {
- return value.Substring(prefix.Length);
- }
+ if (fragment != null)
+ {
+ sb.Append("#");
+ sb.Append(fragment);
+ }
- return value;
- }
+ return new Uri(sb.ToString());
+ }
+ }
- public static Uri CreateUriWithQuery(Uri uri, string query)
- {
- if(!String.IsNullOrEmpty(query) && !query.StartsWith("?"))
- {
- query = "?" + query;
- }
+ public static String StripPrefix(String value, String prefix)
+ {
+ if (value.StartsWith(prefix, StringComparison.InvariantCultureIgnoreCase))
+ {
+ return value.Substring(prefix.Length);
+ }
- if(String.IsNullOrEmpty(uri.Query))
- {
- return new Uri(uri.OriginalString + query);
- }
- else
- {
- string originalUri = uri.OriginalString;
+ return value;
+ }
- int queryDelimPos = originalUri.LastIndexOf('?');
- int compositeDelimPos = originalUri.LastIndexOf(')');
+ public static Uri CreateUriWithQuery(Uri uri, string query)
+ {
+ if (!String.IsNullOrEmpty(query) && !query.StartsWith("?"))
+ {
+ query = "?" + query;
+ }
- if(queryDelimPos <= compositeDelimPos)
- {
- // No Query or the Query is part of an inner Composite.
- return new Uri(originalUri + query);
- }
- else
- {
- // Outer Uri has a Query or not a Composite Uri with a Query
- string strippedUri = originalUri.Substring(0, queryDelimPos);
- return new Uri(strippedUri + query);
- }
- }
- }
+ if (String.IsNullOrEmpty(uri.Query))
+ {
+ return new Uri(uri.OriginalString + query);
+ }
+ else
+ {
+ string originalUri = uri.OriginalString;
- public static Uri RemoveQuery(Uri original)
- {
- return CreateUriWithQuery(original, null);
- }
+ int queryDelimPos = originalUri.LastIndexOf('?');
+ int compositeDelimPos = originalUri.LastIndexOf(')');
- public static CompositeData ParseComposite(Uri uri)
- {
- CompositeData rc = new CompositeData();
- rc.Scheme = uri.Scheme;
+ if (queryDelimPos <= compositeDelimPos)
+ {
+ // No Query or the Query is part of an inner Composite.
+ return new Uri(originalUri + query);
+ }
+ else
+ {
+ // Outer Uri has a Query or not a Composite Uri with a Query
+ string strippedUri = originalUri.Substring(0, queryDelimPos);
+ return new Uri(strippedUri + query);
+ }
+ }
+ }
- // Start with original URI
- //String ssp = uri.Authority + uri.PathAndQuery;
- String ssp = uri.OriginalString;
+ public static Uri RemoveQuery(Uri original)
+ {
+ return CreateUriWithQuery(original, null);
+ }
- ssp = StripPrefix(ssp, rc.Scheme + ":");
- ssp = StripPrefix(ssp, "//");
+ public static CompositeData ParseComposite(Uri uri)
+ {
+ CompositeData rc = new CompositeData();
+ rc.Scheme = uri.Scheme;
- int lastPoundPos = ssp.LastIndexOf("#");
- int lastParendPos = ssp.LastIndexOf(")");
+ // Start with original URI
+ //String ssp = uri.Authority + uri.PathAndQuery;
+ String ssp = uri.OriginalString;
- // Only include a Fragment that's outside any Composte sections.
- if(lastPoundPos > lastParendPos)
- {
- rc.Fragment = ssp.Substring(lastPoundPos);
- ssp = ssp.Substring(0, lastPoundPos);
- }
+ ssp = StripPrefix(ssp, rc.Scheme + ":");
+ ssp = StripPrefix(ssp, "//");
- // Ensure any embedded URIs don't have malformed authority's by changing
- // them from '://(' which would cause the .NET Uri class to attempt to validate
- // the authority as a hostname with, ':(' which is valid.
- ssp = ssp.Replace("://(", ":(");
+ int lastPoundPos = ssp.LastIndexOf("#");
+ int lastParendPos = ssp.LastIndexOf(")");
- // Handle the composite components
- ParseComposite(uri, rc, ssp);
- return rc;
- }
+ // Only include a Fragment that's outside any Composte sections.
+ if (lastPoundPos > lastParendPos)
+ {
+ rc.Fragment = ssp.Substring(lastPoundPos);
+ ssp = ssp.Substring(0, lastPoundPos);
+ }
- /// <summary>
- /// </summary>
- /// <param name="uri"></param>
- /// <param name="rc"></param>
- /// <param name="ssp"></param>
- private static void ParseComposite(Uri uri, CompositeData rc, String ssp)
- {
- String componentString;
- String parms;
+ // Ensure any embedded URIs don't have malformed authority's by changing
+ // them from '://(' which would cause the .NET Uri class to attempt to validate
+ // the authority as a hostname with, ':(' which is valid.
+ ssp = ssp.Replace("://(", ":(");
- if(!CheckParenthesis(ssp))
- {
- throw new NMSException(uri.ToString() + ": Not a matching number of '(' and ')' parenthesis");
- }
+ // Handle the composite components
+ ParseComposite(uri, rc, ssp);
+ return rc;
+ }
- int p;
- int intialParen = ssp.IndexOf("(");
+ /// <summary>
+ /// </summary>
+ /// <param name="uri"></param>
+ /// <param name="rc"></param>
+ /// <param name="ssp"></param>
+ private static void ParseComposite(Uri uri, CompositeData rc, String ssp)
+ {
+ String componentString;
+ String parms;
- if(intialParen >= 0)
- {
- rc.Host = ssp.Substring(0, intialParen);
- p = rc.Host.IndexOf("/");
- if(p >= 0)
- {
- rc.Path = rc.Host.Substring(p);
- rc.Host = rc.Host.Substring(0, p);
- }
+ if (!CheckParenthesis(ssp))
+ {
+ throw new NMSException(uri.ToString() + ": Not a matching number of '(' and ')' parenthesis");
+ }
- p = ssp.LastIndexOf(")");
- int start = intialParen + 1;
- int len = p - start;
- componentString = ssp.Substring(start, len);
- parms = ssp.Substring(p + 1).Trim();
- }
- else
- {
- componentString = ssp;
- parms = "";
- }
+ int p;
+ int intialParen = ssp.IndexOf("(");
- String[] components = SplitComponents(componentString);
- rc.Components = new Uri[components.Length];
- for(int i = 0; i < components.Length; i++)
- {
- rc.Components[i] = new Uri(components[i].Trim());
- }
+ if (intialParen >= 0)
+ {
+ rc.Host = ssp.Substring(0, intialParen);
+ p = rc.Host.IndexOf("/");
+ if (p >= 0)
+ {
+ rc.Path = rc.Host.Substring(p);
+ rc.Host = rc.Host.Substring(0, p);
+ }
- p = parms.IndexOf("?");
- if(p >= 0)
- {
- if(p > 0)
- {
- rc.Path = StripPrefix(parms.Substring(0, p), "/");
- }
+ p = ssp.LastIndexOf(")");
+ int start = intialParen + 1;
+ int len = p - start;
+ componentString = ssp.Substring(start, len);
+ parms = ssp.Substring(p + 1).Trim();
+ }
+ else
+ {
+ componentString = ssp;
+ parms = "";
+ }
- rc.Parameters = ParseQuery(parms.Substring(p + 1));
- }
- else
- {
- if(parms.Length > 0)
- {
- rc.Path = StripPrefix(parms, "/");
- }
+ String[] components = SplitComponents(componentString);
+ rc.Components = new Uri[components.Length];
+ for (int i = 0; i < components.Length; i++)
+ {
+ rc.Components[i] = new Uri(components[i].Trim());
+ }
- rc.Parameters = EmptyMap;
- }
- }
+ p = parms.IndexOf("?");
+ if (p >= 0)
+ {
+ if (p > 0)
+ {
+ rc.Path = StripPrefix(parms.Substring(0, p), "/");
+ }
- private static StringDictionary EmptyMap
- {
- get { return new StringDictionary(); }
- }
+ rc.Parameters = ParseQuery(parms.Substring(p + 1));
+ }
+ else
+ {
+ if (parms.Length > 0)
+ {
+ rc.Path = StripPrefix(parms, "/");
+ }
- /// <summary>
- /// </summary>
- /// <param name="componentString"></param>
- private static String[] SplitComponents(String componentString)
- {
- ArrayList l = new ArrayList();
+ rc.Parameters = EmptyMap;
+ }
+ }
- int last = 0;
- int depth = 0;
- char[] chars = componentString.ToCharArray();
- for(int i = 0; i < chars.Length; i++)
- {
- switch(chars[i])
- {
- case '(':
- depth++;
- break;
+ private static StringDictionary EmptyMap
+ {
+ get { return new StringDictionary(); }
+ }
- case ')':
- depth--;
- break;
+ /// <summary>
+ /// </summary>
+ /// <param name="componentString"></param>
+ private static String[] SplitComponents(String componentString)
+ {
+ ArrayList l = new ArrayList();
- case ',':
- if(depth == 0)
- {
- String s = componentString.Substring(last, i - last);
- l.Add(s);
- last = i + 1;
- }
- break;
+ int last = 0;
+ int depth = 0;
+ char[] chars = componentString.ToCharArray();
+ for (int i = 0; i < chars.Length; i++)
+ {
+ switch (chars[i])
+ {
+ case '(':
+ depth++;
+ break;
- default:
- break;
- }
- }
+ case ')':
+ depth--;
+ break;
- String ending = componentString.Substring(last);
- if(ending.Length != 0)
- {
- l.Add(ending);
- }
+ case ',':
+ if (depth == 0)
+ {
+ String s = componentString.Substring(last, i - last);
+ l.Add(s);
+ last = i + 1;
+ }
- String[] rc = new String[l.Count];
- l.CopyTo(rc);
- return rc;
- }
+ break;
- public static bool CheckParenthesis(String str)
- {
- bool result = true;
+ default:
+ break;
+ }
+ }
- if(str != null)
- {
- int open = 0;
- int closed = 0;
+ String ending = componentString.Substring(last);
+ if (ending.Length != 0)
+ {
+ l.Add(ending);
+ }
- int i = 0;
- while((i = str.IndexOf('(', i)) >= 0)
- {
- i++;
- open++;
- }
+ String[] rc = new String[l.Count];
+ l.CopyTo(rc);
+ return rc;
+ }
- i = 0;
- while((i = str.IndexOf(')', i)) >= 0)
- {
- i++;
- closed++;
- }
+ public static bool CheckParenthesis(String str)
+ {
+ bool result = true;
- result = (open == closed);
- }
+ if (str != null)
+ {
+ int open = 0;
+ int closed = 0;
- return result;
- }
- }
-}
+ int i = 0;
+ while ((i = str.IndexOf('(', i)) >= 0)
+ {
+ i++;
+ open++;
+ }
+
+ i = 0;
+ while ((i = str.IndexOf(')', i)) >= 0)
+ {
+ i++;
+ closed++;
+ }
+
+ result = (open == closed);
+ }
+
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/Util/XmlUtils.cs b/src/nms-api/Util/XmlUtils.cs
index 5223d38..a1f1267 100644
--- a/src/nms-api/Util/XmlUtils.cs
+++ b/src/nms-api/Util/XmlUtils.cs
@@ -24,111 +24,112 @@
namespace Apache.NMS.Util
{
- /// <summary>
- /// Class to provide support for working with Xml objects.
- /// </summary>
- public class XmlUtil
- {
- private static readonly XmlWriterSettings xmlWriterSettings;
+ /// <summary>
+ /// Class to provide support for working with Xml objects.
+ /// </summary>
+ public class XmlUtil
+ {
+ private static readonly XmlWriterSettings xmlWriterSettings;
- /// <summary>
- /// Static class constructor.
- /// </summary>
- static XmlUtil()
- {
- xmlWriterSettings = new XmlWriterSettings();
- xmlWriterSettings.Encoding = new UTF8Encoding(false, false);
- }
+ /// <summary>
+ /// Static class constructor.
+ /// </summary>
+ static XmlUtil()
+ {
+ xmlWriterSettings = new XmlWriterSettings();
+ xmlWriterSettings.Encoding = new UTF8Encoding(false, false);
+ }
- /// <summary>
- /// Serialize the object to XML format. The XML encoding will be UTF-8. A Byte Order Mark (BOM)
- /// will NOT be placed at the beginning of the string.
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static string Serialize(object obj)
- {
- try
- {
- byte[] encodedBytes;
+ /// <summary>
+ /// Serialize the object to XML format. The XML encoding will be UTF-8. A Byte Order Mark (BOM)
+ /// will NOT be placed at the beginning of the string.
+ /// </summary>
+ /// <param name="obj"></param>
+ /// <returns></returns>
+ public static string Serialize(object obj)
+ {
+ try
+ {
+ byte[] encodedBytes;
- using(MemoryStream outputStream = new MemoryStream())
- using(XmlWriter xmlWriter = XmlWriter.Create(outputStream, xmlWriterSettings))
- {
- XmlSerializer serializer = new XmlSerializer(obj.GetType());
+ using (MemoryStream outputStream = new MemoryStream())
+ using (XmlWriter xmlWriter = XmlWriter.Create(outputStream, xmlWriterSettings))
+ {
+ XmlSerializer serializer = new XmlSerializer(obj.GetType());
- // Set the error handlers.
- serializer.UnknownNode += serializer_UnknownNode;
- serializer.UnknownElement += serializer_UnknownElement;
- serializer.UnknownAttribute += serializer_UnknownAttribute;
- serializer.Serialize(xmlWriter, obj);
- encodedBytes = outputStream.ToArray();
- }
+ // Set the error handlers.
+ serializer.UnknownNode += serializer_UnknownNode;
+ serializer.UnknownElement += serializer_UnknownElement;
+ serializer.UnknownAttribute += serializer_UnknownAttribute;
+ serializer.Serialize(xmlWriter, obj);
+ encodedBytes = outputStream.ToArray();
+ }
- return xmlWriterSettings.Encoding.GetString(encodedBytes, 0, encodedBytes.Length);
- }
- catch(Exception ex)
- {
- Tracer.ErrorFormat("Error serializing object: {0}", ex.Message);
- return null;
- }
- }
+ return xmlWriterSettings.Encoding.GetString(encodedBytes, 0, encodedBytes.Length);
+ }
+ catch (Exception ex)
+ {
+ Tracer.ErrorFormat("Error serializing object: {0}", ex.Message);
+ return null;
+ }
+ }
- public static object Deserialize(Type objType, string text)
- {
- if(null == text)
- {
- return null;
- }
+ public static object Deserialize(Type objType, string text)
+ {
+ if (null == text)
+ {
+ return null;
+ }
- try
- {
- XmlSerializer serializer = new XmlSerializer(objType);
+ try
+ {
+ XmlSerializer serializer = new XmlSerializer(objType);
- // Set the error handlers.
- serializer.UnknownNode += serializer_UnknownNode;
- serializer.UnknownElement += serializer_UnknownElement;
- serializer.UnknownAttribute += serializer_UnknownAttribute;
- return serializer.Deserialize(new StringReader(text));
- }
- catch(Exception ex)
- {
- Tracer.ErrorFormat("Error deserializing object: {0}", ex.Message);
- return null;
- }
- }
+ // Set the error handlers.
+ serializer.UnknownNode += serializer_UnknownNode;
+ serializer.UnknownElement += serializer_UnknownElement;
+ serializer.UnknownAttribute += serializer_UnknownAttribute;
+ return serializer.Deserialize(new StringReader(text));
+ }
+ catch (Exception ex)
+ {
+ Tracer.ErrorFormat("Error deserializing object: {0}", ex.Message);
+ return null;
+ }
+ }
- /// <summary>
- /// From xml spec valid chars:
- /// #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
- /// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
- /// </summary>
- private const string invalidXMLMatch = @"[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]";
- private static readonly Regex regexInvalidXMLChars = new Regex(invalidXMLMatch);
+ /// <summary>
+ /// From xml spec valid chars:
+ /// #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
+ /// any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.
+ /// </summary>
+ private const string invalidXMLMatch = @"[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]";
- /// <summary>
- /// This removes characters that are invalid for xml encoding
- /// </summary>
- /// <param name="text">Text to be encoded.</param>
- /// <returns>Text with invalid xml characters removed.</returns>
- public static string CleanInvalidXmlChars(string text)
- {
- return regexInvalidXMLChars.Replace(text, "");
- }
+ private static readonly Regex regexInvalidXMLChars = new Regex(invalidXMLMatch);
- private static void serializer_UnknownNode(object sender, XmlNodeEventArgs e)
- {
- Tracer.ErrorFormat("Unknown Node: {0}\t{1}", e.Name, e.Text);
- }
+ /// <summary>
+ /// This removes characters that are invalid for xml encoding
+ /// </summary>
+ /// <param name="text">Text to be encoded.</param>
+ /// <returns>Text with invalid xml characters removed.</returns>
+ public static string CleanInvalidXmlChars(string text)
+ {
+ return regexInvalidXMLChars.Replace(text, "");
+ }
- private static void serializer_UnknownElement(object sender, XmlElementEventArgs e)
- {
- Tracer.ErrorFormat("Unknown Element: {0}\t{1}", e.Element.Name, e.Element.Value);
- }
+ private static void serializer_UnknownNode(object sender, XmlNodeEventArgs e)
+ {
+ Tracer.ErrorFormat("Unknown Node: {0}\t{1}", e.Name, e.Text);
+ }
- private static void serializer_UnknownAttribute(object sender, XmlAttributeEventArgs e)
- {
- Tracer.ErrorFormat("Unknown attribute: {0}='{1}'", e.Attr.Name, e.Attr.Value);
- }
- }
-}
+ private static void serializer_UnknownElement(object sender, XmlElementEventArgs e)
+ {
+ Tracer.ErrorFormat("Unknown Element: {0}\t{1}", e.Element.Name, e.Element.Value);
+ }
+
+ private static void serializer_UnknownAttribute(object sender, XmlAttributeEventArgs e)
+ {
+ Tracer.ErrorFormat("Unknown attribute: {0}='{1}'", e.Attr.Name, e.Attr.Value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/nms-api/nms-api.csproj b/src/nms-api/nms-api.csproj
index d27adbd..e38f984 100644
--- a/src/nms-api/nms-api.csproj
+++ b/src/nms-api/nms-api.csproj
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
+
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -16,63 +17,63 @@
under the License.
-->
<Project Sdk="Microsoft.NET.Sdk">
- <PropertyGroup>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <OutputType>Library</OutputType>
- <TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
- <RootNamespace>Apache.NMS</RootNamespace>
- <AssemblyName>Apache.NMS</AssemblyName>
- </PropertyGroup>
+ <PropertyGroup>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <OutputType>Library</OutputType>
+ <TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
+ <RootNamespace>Apache.NMS</RootNamespace>
+ <AssemblyName>Apache.NMS</AssemblyName>
+ </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)'=='Release'">
- <OutputPath>..\..\build\</OutputPath>
- <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
- </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)'=='Release'">
+ <OutputPath>..\..\build\</OutputPath>
+ <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
+ </PropertyGroup>
- <PropertyGroup>
- <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
- <PackageId>Apache.NMS</PackageId>
- <Version>1.8.1</Version>
- <Authors>Apache ActiveMQ</Authors>
- <Company>Apache Software Foundation</Company>
- <Product>Apache NMS API</Product>
- <Description>Apache NMS (.Net Standard Messaging Library): An abstract interface to Message Oriented Middleware (MOM) providers</Description>
- <Copyright>Copyright (C) 2005-2019 Apache Software Foundation</Copyright>
- <PackageProjectUrl>https://activemq.apache.org/components/nms/</PackageProjectUrl>
- <PackageLicense>https://github.com/apache/activemq-nms-api/blob/master/LICENSE.txt</PackageLicense>
- <PackageIconUrl>https://activemq.apache.org/assets/img/activemq_logo_icon.png</PackageIconUrl>
- <RepositoryUrl>https://github.com/apache/activemq-nms-api</RepositoryUrl>
- <RepositoryType>git</RepositoryType>
- <PackageTags>apache;activemq;nms;api;net;messaging</PackageTags>
- <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
- </PropertyGroup>
+ <PropertyGroup>
+ <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
+ <PackageId>Apache.NMS</PackageId>
+ <Version>1.8.1</Version>
+ <Authors>Apache ActiveMQ</Authors>
+ <Company>Apache Software Foundation</Company>
+ <Product>Apache NMS API</Product>
+ <Description>Apache NMS (.Net Standard Messaging Library): An abstract interface to Message Oriented Middleware (MOM) providers</Description>
+ <Copyright>Copyright (C) 2005-2019 Apache Software Foundation</Copyright>
+ <PackageProjectUrl>https://activemq.apache.org/components/nms/</PackageProjectUrl>
+ <PackageLicense>https://github.com/apache/activemq-nms-api/blob/master/LICENSE.txt</PackageLicense>
+ <PackageIconUrl>https://activemq.apache.org/assets/img/activemq_logo_icon.png</PackageIconUrl>
+ <RepositoryUrl>https://github.com/apache/activemq-nms-api</RepositoryUrl>
+ <RepositoryType>git</RepositoryType>
+ <PackageTags>apache;activemq;nms;api;net;messaging</PackageTags>
+ <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
+ </PropertyGroup>
- <!-- SourceLink Start -->
- <PropertyGroup>
- <!-- Embed source files that are not tracked by the source control manager in the PDB -->
- <EmbedUntrackedSources>true</EmbedUntrackedSources>
- <!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
- <IncludeSymbols>true</IncludeSymbols>
- <SymbolPackageFormat>snupkg</SymbolPackageFormat>
- </PropertyGroup>
- <ItemGroup>
- <!-- Add PackageReference specific for your source control provider (see below) -->
- <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
- </ItemGroup>
- <!-- SourceLink End -->
+ <!-- SourceLink Start -->
+ <PropertyGroup>
+ <!-- Embed source files that are not tracked by the source control manager in the PDB -->
+ <EmbedUntrackedSources>true</EmbedUntrackedSources>
+ <!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
+ <IncludeSymbols>true</IncludeSymbols>
+ <SymbolPackageFormat>snupkg</SymbolPackageFormat>
+ </PropertyGroup>
+ <ItemGroup>
+ <!-- Add PackageReference specific for your source control provider (see below) -->
+ <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
+ </ItemGroup>
+ <!-- SourceLink End -->
- <ItemGroup>
- <None Include="..\..\LICENSE.txt" Pack="true" PackagePath="LICENSE.txt"/>
- <None Include="..\..\NOTICE.txt" Pack="true" PackagePath="NOTICE.txt"/>
- </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\LICENSE.txt" Pack="true" PackagePath="LICENSE.txt" />
+ <None Include="..\..\NOTICE.txt" Pack="true" PackagePath="NOTICE.txt" />
+ </ItemGroup>
- <ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
- <Reference Include="System.Transactions" />
- <Reference Include="System.Web" />
- </ItemGroup>
+ <ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
+ <Reference Include="System.Transactions" />
+ <Reference Include="System.Web" />
+ </ItemGroup>
- <PropertyGroup>
- <SignAssembly>true</SignAssembly>
- <AssemblyOriginatorKeyFile>..\..\keyfile\NMSKey.snk</AssemblyOriginatorKeyFile>
- </PropertyGroup>
-</Project>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>..\..\keyfile\NMSKey.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/src/nms-api/policies/RedeliveryPolicy.cs b/src/nms-api/policies/RedeliveryPolicy.cs
index 30cff90..3d917d4 100644
--- a/src/nms-api/policies/RedeliveryPolicy.cs
+++ b/src/nms-api/policies/RedeliveryPolicy.cs
@@ -66,13 +66,13 @@
{
int delay = 0;
- if(redeliveredCounter == 0)
+ if (redeliveredCounter == 0)
{
// The first time through there is no delay, the Rollback should be immediate.
return 0;
}
- if(UseExponentialBackOff && BackOffMultiplier > 1)
+ if (UseExponentialBackOff && BackOffMultiplier > 1)
{
delay = initialRedeliveryDelay * Convert.ToInt32(Math.Pow(BackOffMultiplier, redeliveredCounter - 1));
}
@@ -81,10 +81,11 @@
delay = InitialRedeliveryDelay;
}
- if(UseCollisionAvoidance)
+ if (UseCollisionAvoidance)
{
Random random = RandomNumberGenerator;
- double variance = (NextBool ? collisionAvoidanceFactor : collisionAvoidanceFactor *= -1) * random.NextDouble();
+ double variance = (NextBool ? collisionAvoidanceFactor : collisionAvoidanceFactor *= -1) *
+ random.NextDouble();
delay += Convert.ToInt32(Convert.ToDouble(delay) * variance);
}
@@ -113,11 +114,11 @@
{
get
{
- if(randomNumberGenerator == null)
+ if (randomNumberGenerator == null)
{
- lock(syncObject)
+ lock (syncObject)
{
- if(randomNumberGenerator == null)
+ if (randomNumberGenerator == null)
{
randomNumberGenerator = new Random(DateTime.Now.Second);
}
@@ -136,7 +137,7 @@
{
get
{
- lock(syncObject)
+ lock (syncObject)
{
nextBool = !nextBool;
return nextBool;
@@ -155,6 +156,5 @@
// this method is an override.
return this.MemberwiseClone();
}
-
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/AsyncConsumeTest.cs b/test/nms-api-test/AsyncConsumeTest.cs
index be49561..15a4291 100644
--- a/test/nms-api-test/AsyncConsumeTest.cs
+++ b/test/nms-api-test/AsyncConsumeTest.cs
@@ -20,194 +20,196 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class AsyncConsumeTest : NMSTestSupport
- {
- protected string RESPONSE_CLIENT_ID;
- protected AutoResetEvent semaphore;
- protected bool received;
- protected IMessage receivedMsg;
+ [TestFixture]
+ public class AsyncConsumeTest : NMSTestSupport
+ {
+ protected string RESPONSE_CLIENT_ID;
+ protected AutoResetEvent semaphore;
+ protected bool received;
+ protected IMessage receivedMsg;
- [SetUp]
- public override void SetUp()
- {
- base.SetUp();
- semaphore = new AutoResetEvent(false);
- received = false;
- receivedMsg = null;
+ [SetUp]
+ public override void SetUp()
+ {
+ base.SetUp();
+ semaphore = new AutoResetEvent(false);
+ received = false;
+ receivedMsg = null;
- RESPONSE_CLIENT_ID = GetTestClientId() + ":RESPONSE";
- }
+ RESPONSE_CLIENT_ID = GetTestClientId() + ":RESPONSE";
+ }
- [TearDown]
- public override void TearDown()
- {
- receivedMsg = null;
- base.TearDown();
- }
+ [TearDown]
+ public override void TearDown()
+ {
+ receivedMsg = null;
+ base.TearDown();
+ }
- [Test]
- public void TestAsynchronousConsume(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnectionAndStart(GetTestClientId()))
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- using(IDestination destination = CreateDestination(session, DestinationType.Queue))
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
- consumer.Listener += new MessageListener(OnMessage);
+ [Test]
+ public void TestAsynchronousConsume(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnectionAndStart(GetTestClientId()))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (IDestination destination = CreateDestination(session, DestinationType.Queue))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
+ consumer.Listener += new MessageListener(OnMessage);
- IMessage request = session.CreateMessage();
- request.NMSCorrelationID = "AsyncConsume";
- request.NMSType = "Test";
- producer.Send(request);
+ IMessage request = session.CreateMessage();
+ request.NMSCorrelationID = "AsyncConsume";
+ request.NMSType = "Test";
+ producer.Send(request);
- WaitForMessageToArrive();
- Assert.AreEqual(request.NMSCorrelationID, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
- }
- }
+ WaitForMessageToArrive();
+ Assert.AreEqual(request.NMSCorrelationID, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
+ }
+ }
- [Test]
- public void TestCreateConsumerAfterSend(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnectionAndStart(GetTestClientId()))
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- using(IDestination destination = CreateDestination(session, DestinationType.Queue))
- {
- string correlationId = "AsyncConsumeAfterSend";
+ [Test]
+ public void TestCreateConsumerAfterSend(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnectionAndStart(GetTestClientId()))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (IDestination destination = CreateDestination(session, DestinationType.Queue))
+ {
+ string correlationId = "AsyncConsumeAfterSend";
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
- IMessage request = session.CreateMessage();
- request.NMSCorrelationID = correlationId;
- request.NMSType = "Test";
- producer.Send(request);
- }
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
+ IMessage request = session.CreateMessage();
+ request.NMSCorrelationID = correlationId;
+ request.NMSType = "Test";
+ producer.Send(request);
+ }
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- {
- consumer.Listener += new MessageListener(OnMessage);
- WaitForMessageToArrive();
- Assert.AreEqual(correlationId, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
- }
- }
- }
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ {
+ consumer.Listener += new MessageListener(OnMessage);
+ WaitForMessageToArrive();
+ Assert.AreEqual(correlationId, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
+ }
+ }
+ }
- [Test]
- public void TestCreateConsumerBeforeSendAddListenerAfterSend(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnectionAndStart(GetTestClientId()))
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- using(IDestination destination = CreateDestination(session, DestinationType.Queue))
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
+ [Test]
+ public void TestCreateConsumerBeforeSendAddListenerAfterSend(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnectionAndStart(GetTestClientId()))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (IDestination destination = CreateDestination(session, DestinationType.Queue))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
- IMessage request = session.CreateMessage();
- request.NMSCorrelationID = "AsyncConsumeAfterSendLateListener";
- request.NMSType = "Test";
- producer.Send(request);
+ IMessage request = session.CreateMessage();
+ request.NMSCorrelationID = "AsyncConsumeAfterSendLateListener";
+ request.NMSType = "Test";
+ producer.Send(request);
- // now lets add the listener
- consumer.Listener += new MessageListener(OnMessage);
- WaitForMessageToArrive();
- Assert.AreEqual(request.NMSCorrelationID, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
- }
- }
+ // now lets add the listener
+ consumer.Listener += new MessageListener(OnMessage);
+ WaitForMessageToArrive();
+ Assert.AreEqual(request.NMSCorrelationID, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
+ }
+ }
- [Test]
- public void TestAsynchronousTextMessageConsume(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnectionAndStart(GetTestClientId()))
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- using(IDestination destination = CreateDestination(session, DestinationType.Queue))
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- consumer.Listener += new MessageListener(OnMessage);
- producer.DeliveryMode = deliveryMode;
+ [Test]
+ public void TestAsynchronousTextMessageConsume(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnectionAndStart(GetTestClientId()))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (IDestination destination = CreateDestination(session, DestinationType.Queue))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ consumer.Listener += new MessageListener(OnMessage);
+ producer.DeliveryMode = deliveryMode;
- ITextMessage request = session.CreateTextMessage("Hello, World!");
- request.NMSCorrelationID = "AsyncConsumeTextMessage";
- request.Properties["NMSXGroupID"] = "cheese";
- request.Properties["myHeader"] = "James";
+ ITextMessage request = session.CreateTextMessage("Hello, World!");
+ request.NMSCorrelationID = "AsyncConsumeTextMessage";
+ request.Properties["NMSXGroupID"] = "cheese";
+ request.Properties["myHeader"] = "James";
- producer.Send(request);
+ producer.Send(request);
- WaitForMessageToArrive();
- Assert.AreEqual(request.NMSCorrelationID, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
- Assert.AreEqual(request.Properties["NMSXGroupID"], receivedMsg.Properties["NMSXGroupID"], "Invalid NMSXGroupID.");
- Assert.AreEqual(request.Properties["myHeader"], receivedMsg.Properties["myHeader"], "Invalid myHeader.");
- Assert.AreEqual(request.Text, ((ITextMessage) receivedMsg).Text, "Invalid text body.");
- }
- }
+ WaitForMessageToArrive();
+ Assert.AreEqual(request.NMSCorrelationID, receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
+ Assert.AreEqual(request.Properties["NMSXGroupID"], receivedMsg.Properties["NMSXGroupID"],
+ "Invalid NMSXGroupID.");
+ Assert.AreEqual(request.Properties["myHeader"], receivedMsg.Properties["myHeader"],
+ "Invalid myHeader.");
+ Assert.AreEqual(request.Text, ((ITextMessage) receivedMsg).Text, "Invalid text body.");
+ }
+ }
- [Test]
- public void TestTemporaryQueueAsynchronousConsume(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnectionAndStart(GetTestClientId()))
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- using(ITemporaryQueue tempReplyDestination = session.CreateTemporaryQueue())
- using(IDestination destination = CreateDestination(session, DestinationType.Queue))
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageConsumer tempConsumer = session.CreateConsumer(tempReplyDestination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
- tempConsumer.Listener += new MessageListener(OnMessage);
- consumer.Listener += new MessageListener(OnQueueMessage);
+ [Test]
+ public void TestTemporaryQueueAsynchronousConsume(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnectionAndStart(GetTestClientId()))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ITemporaryQueue tempReplyDestination = session.CreateTemporaryQueue())
+ using (IDestination destination = CreateDestination(session, DestinationType.Queue))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageConsumer tempConsumer = session.CreateConsumer(tempReplyDestination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
+ tempConsumer.Listener += new MessageListener(OnMessage);
+ consumer.Listener += new MessageListener(OnQueueMessage);
- IMessage request = session.CreateMessage();
- request.NMSCorrelationID = "TemqQueueAsyncConsume";
- request.NMSType = "Test";
- request.NMSReplyTo = tempReplyDestination;
- producer.Send(request);
+ IMessage request = session.CreateMessage();
+ request.NMSCorrelationID = "TemqQueueAsyncConsume";
+ request.NMSType = "Test";
+ request.NMSReplyTo = tempReplyDestination;
+ producer.Send(request);
- WaitForMessageToArrive();
- Assert.AreEqual("TempQueueAsyncResponse", receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
- }
- }
+ WaitForMessageToArrive();
+ Assert.AreEqual("TempQueueAsyncResponse", receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
+ }
+ }
- protected void OnQueueMessage(IMessage message)
- {
- Assert.AreEqual("TemqQueueAsyncConsume", message.NMSCorrelationID, "Invalid correlation ID.");
- using(IConnection connection = CreateConnectionAndStart(RESPONSE_CLIENT_ID))
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- using(IMessageProducer producer = session.CreateProducer(message.NMSReplyTo))
- {
- producer.DeliveryMode = message.NMSDeliveryMode;
+ protected void OnQueueMessage(IMessage message)
+ {
+ Assert.AreEqual("TemqQueueAsyncConsume", message.NMSCorrelationID, "Invalid correlation ID.");
+ using (IConnection connection = CreateConnectionAndStart(RESPONSE_CLIENT_ID))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (IMessageProducer producer = session.CreateProducer(message.NMSReplyTo))
+ {
+ producer.DeliveryMode = message.NMSDeliveryMode;
- ITextMessage response = session.CreateTextMessage("Asynchronous Response Message Text");
- response.NMSCorrelationID = "TempQueueAsyncResponse";
- response.NMSType = message.NMSType;
- producer.Send(response);
- }
- }
+ ITextMessage response = session.CreateTextMessage("Asynchronous Response Message Text");
+ response.NMSCorrelationID = "TempQueueAsyncResponse";
+ response.NMSType = message.NMSType;
+ producer.Send(response);
+ }
+ }
- protected void OnMessage(IMessage message)
- {
- receivedMsg = message;
- received = true;
- semaphore.Set();
- }
+ protected void OnMessage(IMessage message)
+ {
+ receivedMsg = message;
+ received = true;
+ semaphore.Set();
+ }
- protected void WaitForMessageToArrive()
- {
- semaphore.WaitOne((int) receiveTimeout.TotalMilliseconds, true);
- Assert.IsTrue(received, "Should have received a message by now!");
- }
- }
-}
+ protected void WaitForMessageToArrive()
+ {
+ semaphore.WaitOne((int) receiveTimeout.TotalMilliseconds, true);
+ Assert.IsTrue(received, "Should have received a message by now!");
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/BadConsumeTest.cs b/test/nms-api-test/BadConsumeTest.cs
index a15bcf2..e7748de 100644
--- a/test/nms-api-test/BadConsumeTest.cs
+++ b/test/nms-api-test/BadConsumeTest.cs
@@ -14,45 +14,46 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using NUnit.Framework;
namespace Apache.NMS.Test
{
- [TestFixture]
- public class BadConsumeTest : NMSTestSupport
- {
- protected IConnection connection;
- protected ISession session;
+ [TestFixture]
+ public class BadConsumeTest : NMSTestSupport
+ {
+ protected IConnection connection;
+ protected ISession session;
- [SetUp]
- public override void SetUp()
- {
- connection = CreateConnection(GetTestClientId());
- connection.Start();
- session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
- }
+ [SetUp]
+ public override void SetUp()
+ {
+ connection = CreateConnection(GetTestClientId());
+ connection.Start();
+ session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+ }
- [TearDown]
- public override void TearDown()
- {
- if(null != session)
- {
- session.Dispose();
- session = null;
- }
+ [TearDown]
+ public override void TearDown()
+ {
+ if (null != session)
+ {
+ session.Dispose();
+ session = null;
+ }
- if(null != connection)
- {
- connection.Dispose();
- connection = null;
- }
- }
+ if (null != connection)
+ {
+ connection.Dispose();
+ connection = null;
+ }
+ }
- [Test]
- public void TestBadConsumerException()
- {
+ [Test]
+ public void TestBadConsumerException()
+ {
Assert.Throws<NMSException>(() => session.CreateConsumer(null));
}
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/BytesMessageTest.cs b/test/nms-api-test/BytesMessageTest.cs
index e5c282e..9f31ed3 100644
--- a/test/nms-api-test/BytesMessageTest.cs
+++ b/test/nms-api-test/BytesMessageTest.cs
@@ -21,56 +21,55 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class BytesMessageTest : NMSTestSupport
- {
- protected byte[] msgContent = {1, 2, 3, 4, 5, 6, 7, 8};
+ [TestFixture]
+ public class BytesMessageTest : NMSTestSupport
+ {
+ protected byte[] msgContent = {1, 2, 3, 4, 5, 6, 7, 8};
- [Test]
- public void SendReceiveBytesMessage(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnection(GetTestClientId()))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
- IMessage request = session.CreateBytesMessage(msgContent);
- producer.Send(request);
+ [Test]
+ public void SendReceiveBytesMessage(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
+ IMessage request = session.CreateBytesMessage(msgContent);
+ producer.Send(request);
- IMessage message = consumer.Receive(receiveTimeout);
+ IMessage message = consumer.Receive(receiveTimeout);
AssertMessageIsReadOnly(message);
- AssertBytesMessageEqual(request, message);
- Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
-
- }
- }
- }
- }
+ AssertBytesMessageEqual(request, message);
+ Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
+ }
+ }
+ }
+ }
[Test]
public void SendReceiveBytesMessageContent(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
IBytesMessage request = session.CreateBytesMessage();
-
+
request.WriteBoolean(true);
request.WriteByte((byte) 1);
request.WriteBytes(new byte[1]);
@@ -83,51 +82,50 @@
request.WriteObject("stringobj");
request.WriteInt16((short) 1);
request.WriteString("utfstring");
-
+
producer.Send(request);
IMessage message = consumer.Receive(receiveTimeout);
AssertMessageIsReadOnly(message);
AssertBytesMessageEqual(request, message);
Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
-
}
}
}
}
-
+
protected void AssertMessageIsReadOnly(IMessage message)
{
- Type writeableExceptionType = typeof(MessageNotWriteableException);
- IBytesMessage theMessage = message as IBytesMessage;
+ Type writeableExceptionType = typeof(MessageNotWriteableException);
+ IBytesMessage theMessage = message as IBytesMessage;
Assert.IsNotNull(theMessage);
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBoolean(true); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteByte((byte) 1); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBytes(new byte[1]); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteBytes(new byte[3], 0, 2); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteChar('a'); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteDouble(1.5); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteSingle((float) 1.5); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt32(1); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt64(1); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteObject("stringobj"); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteInt16((short) 1); });
- Assert.Throws(writeableExceptionType, delegate () { theMessage.WriteString("utfstring"); });
- }
-
- /// <summary>
- /// Assert that two messages are IBytesMessages and their contents are equal.
- /// </summary>
- /// <param name="expected"></param>
- /// <param name="actual"></param>
- protected void AssertBytesMessageEqual(IMessage expected, IMessage actual)
- {
- IBytesMessage expectedBytesMsg = expected as IBytesMessage;
- expectedBytesMsg.Reset();
- Assert.IsNotNull(expectedBytesMsg, "'expected' message not a bytes message");
- IBytesMessage actualBytesMsg = actual as IBytesMessage;
- Assert.IsNotNull(actualBytesMsg, "'actual' message not a bytes message");
- Assert.AreEqual(expectedBytesMsg.Content, actualBytesMsg.Content, "Bytes message contents do not match.");
- }
- }
-}
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteBoolean(true); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteByte((byte) 1); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteBytes(new byte[1]); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteBytes(new byte[3], 0, 2); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteChar('a'); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteDouble(1.5); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteSingle((float) 1.5); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteInt32(1); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteInt64(1); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteObject("stringobj"); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteInt16((short) 1); });
+ Assert.Throws(writeableExceptionType, delegate() { theMessage.WriteString("utfstring"); });
+ }
+
+ /// <summary>
+ /// Assert that two messages are IBytesMessages and their contents are equal.
+ /// </summary>
+ /// <param name="expected"></param>
+ /// <param name="actual"></param>
+ protected void AssertBytesMessageEqual(IMessage expected, IMessage actual)
+ {
+ IBytesMessage expectedBytesMsg = expected as IBytesMessage;
+ expectedBytesMsg.Reset();
+ Assert.IsNotNull(expectedBytesMsg, "'expected' message not a bytes message");
+ IBytesMessage actualBytesMsg = actual as IBytesMessage;
+ Assert.IsNotNull(actualBytesMsg, "'actual' message not a bytes message");
+ Assert.AreEqual(expectedBytesMsg.Content, actualBytesMsg.Content, "Bytes message contents do not match.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/BytesMessage.cs b/test/nms-api-test/Commands/BytesMessage.cs
index 02fb23d..00e9c13 100644
--- a/test/nms-api-test/Commands/BytesMessage.cs
+++ b/test/nms-api-test/Commands/BytesMessage.cs
@@ -61,24 +61,24 @@
{
return dataIn.ReadByte();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteByte( byte value )
+ public void WriteByte(byte value)
{
InitializeWriting();
try
{
- dataOut.Write( value );
+ dataOut.Write(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
@@ -91,24 +91,24 @@
{
return dataIn.ReadBoolean();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteBoolean( bool value )
+ public void WriteBoolean(bool value)
{
InitializeWriting();
try
{
- dataOut.Write( value );
+ dataOut.Write(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
@@ -121,24 +121,24 @@
{
return dataIn.ReadChar();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteChar( char value )
+ public void WriteChar(char value)
{
InitializeWriting();
try
{
- dataOut.Write( value );
+ dataOut.Write(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
@@ -151,24 +151,24 @@
{
return dataIn.ReadInt16();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteInt16( short value )
+ public void WriteInt16(short value)
{
InitializeWriting();
try
{
- dataOut.Write( value );
+ dataOut.Write(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
@@ -181,24 +181,24 @@
{
return dataIn.ReadInt32();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteInt32( int value )
+ public void WriteInt32(int value)
{
InitializeWriting();
try
{
- dataOut.Write( value );
+ dataOut.Write(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
@@ -211,24 +211,24 @@
{
return dataIn.ReadInt64();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteInt64( long value )
+ public void WriteInt64(long value)
{
InitializeWriting();
try
{
- dataOut.Write( value );
+ dataOut.Write(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
@@ -241,24 +241,24 @@
{
return dataIn.ReadSingle();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteSingle( float value )
+ public void WriteSingle(float value)
{
InitializeWriting();
try
{
- dataOut.Write( value );
+ dataOut.Write(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
@@ -271,84 +271,84 @@
{
return dataIn.ReadDouble();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteDouble( double value )
+ public void WriteDouble(double value)
{
InitializeWriting();
try
{
- dataOut.Write( value );
+ dataOut.Write(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
}
- public int ReadBytes( byte[] value )
+ public int ReadBytes(byte[] value)
{
InitializeReading();
try
{
- return dataIn.Read( value, 0, value.Length );
+ return dataIn.Read(value, 0, value.Length);
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public int ReadBytes( byte[] value, int length )
+ public int ReadBytes(byte[] value, int length)
{
InitializeReading();
try
{
- return dataIn.Read( value, 0, length );
+ return dataIn.Read(value, 0, length);
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteBytes( byte[] value )
+ public void WriteBytes(byte[] value)
{
InitializeWriting();
try
{
- dataOut.Write( value, 0, value.Length );
+ dataOut.Write(value, 0, value.Length);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
}
- public void WriteBytes( byte[] value, int offset, int length )
+ public void WriteBytes(byte[] value, int offset, int length)
{
InitializeWriting();
try
{
- dataOut.Write( value, offset, length );
+ dataOut.Write(value, offset, length);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
@@ -362,17 +362,17 @@
// JMS, CMS and NMS all encode the String using a 16 bit size header.
return dataIn.ReadString16();
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- public void WriteString( string value )
+ public void WriteString(string value)
{
InitializeWriting();
try
@@ -380,54 +380,54 @@
// JMS, CMS and NMS all encode the String using a 16 bit size header.
dataOut.WriteString16(value);
}
- catch(Exception e)
+ catch (Exception e)
{
throw NMSExceptionSupport.Create(e);
}
}
- public void WriteObject( System.Object value )
+ public void WriteObject(System.Object value)
{
InitializeWriting();
- if( value is System.Byte )
+ if (value is System.Byte)
{
- this.dataOut.Write( (byte) value );
+ this.dataOut.Write((byte) value);
}
- else if( value is Char )
+ else if (value is Char)
{
- this.dataOut.Write( (char) value );
+ this.dataOut.Write((char) value);
}
- else if( value is Boolean )
+ else if (value is Boolean)
{
- this.dataOut.Write( (bool) value );
+ this.dataOut.Write((bool) value);
}
- else if( value is Int16 )
+ else if (value is Int16)
{
- this.dataOut.Write( (short) value );
+ this.dataOut.Write((short) value);
}
- else if( value is Int32 )
+ else if (value is Int32)
{
- this.dataOut.Write( (int) value );
+ this.dataOut.Write((int) value);
}
- else if( value is Int64 )
+ else if (value is Int64)
{
- this.dataOut.Write( (long) value );
+ this.dataOut.Write((long) value);
}
- else if( value is Single )
+ else if (value is Single)
{
- this.dataOut.Write( (float) value );
+ this.dataOut.Write((float) value);
}
- else if( value is Double )
+ else if (value is Double)
{
- this.dataOut.Write( (double) value );
+ this.dataOut.Write((double) value);
}
- else if( value is byte[] )
+ else if (value is byte[])
{
- this.dataOut.Write( (byte[]) value );
+ this.dataOut.Write((byte[]) value);
}
- else if( value is String )
+ else if (value is String)
{
- this.dataOut.WriteString16( (string) value );
+ this.dataOut.WriteString16((string) value);
}
else
{
@@ -441,11 +441,12 @@
{
byte[] buffer = null;
InitializeReading();
- if(this.length != 0)
+ if (this.length != 0)
{
buffer = new byte[this.length];
this.dataIn.Read(buffer, 0, buffer.Length);
}
+
return buffer;
}
@@ -468,11 +469,11 @@
private void InitializeReading()
{
FailIfWriteOnlyBody();
- if(this.dataIn == null)
+ if (this.dataIn == null)
{
byte[] data = base.Content;
- if(base.Content == null)
+ if (base.Content == null)
{
data = new byte[0];
}
@@ -487,7 +488,7 @@
private void InitializeWriting()
{
FailIfReadOnlyBody();
- if(this.dataOut == null)
+ if (this.dataOut == null)
{
this.outputBuffer = new MemoryStream();
this.dataOut = new EndianBinaryWriter(this.outputBuffer);
@@ -496,7 +497,7 @@
private void StoreContent()
{
- if(this.dataOut != null)
+ if (this.dataOut != null)
{
this.dataOut.Close();
base.Content = outputBuffer.ToArray();
@@ -505,7 +506,5 @@
this.outputBuffer = null;
}
}
-
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/Destination.cs b/test/nms-api-test/Commands/Destination.cs
index 58c7749..f62956c 100644
--- a/test/nms-api-test/Commands/Destination.cs
+++ b/test/nms-api-test/Commands/Destination.cs
@@ -30,14 +30,17 @@
/// Topic Destination object
/// </summary>
public const int TOPIC = 1;
+
/// <summary>
/// Temporary Topic Destination object
/// </summary>
public const int TEMPORARY_TOPIC = 2;
+
/// <summary>
/// Queue Destination object
/// </summary>
public const int QUEUE = 3;
+
/// <summary>
/// Temporary Queue Destination object
/// </summary>
@@ -49,7 +52,7 @@
private String physicalName = "";
private StringDictionary options = null;
- private bool disposed = false;
+ private bool disposed = false;
/// <summary>
/// The Default Constructor
@@ -67,53 +70,53 @@
setPhysicalName(name);
}
- ~Destination()
- {
- Dispose(false);
- }
+ ~Destination()
+ {
+ Dispose(false);
+ }
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
- private void Dispose(bool disposing)
- {
- if(disposed)
- {
- return;
- }
+ private void Dispose(bool disposing)
+ {
+ if (disposed)
+ {
+ return;
+ }
- if(disposing)
- {
- try
- {
- OnDispose();
- }
- catch(Exception ex)
- {
- Tracer.ErrorFormat("Exception disposing Destination {0}: {1}", this.physicalName, ex.Message);
- }
- }
+ if (disposing)
+ {
+ try
+ {
+ OnDispose();
+ }
+ catch (Exception ex)
+ {
+ Tracer.ErrorFormat("Exception disposing Destination {0}: {1}", this.physicalName, ex.Message);
+ }
+ }
- disposed = true;
- }
+ disposed = true;
+ }
- /// <summary>
- /// Child classes can override this method to perform clean-up logic.
- /// </summary>
- protected virtual void OnDispose()
- {
- }
+ /// <summary>
+ /// Child classes can override this method to perform clean-up logic.
+ /// </summary>
+ protected virtual void OnDispose()
+ {
+ }
- public bool IsTopic
+ public bool IsTopic
{
get
{
int destinationType = GetDestinationType();
return TOPIC == destinationType
- || TEMPORARY_TOPIC == destinationType;
+ || TEMPORARY_TOPIC == destinationType;
}
}
@@ -123,7 +126,7 @@
{
int destinationType = GetDestinationType();
return QUEUE == destinationType
- || TEMPORARY_QUEUE == destinationType;
+ || TEMPORARY_QUEUE == destinationType;
}
}
@@ -133,7 +136,7 @@
{
int destinationType = GetDestinationType();
return TEMPORARY_QUEUE == destinationType
- || TEMPORARY_TOPIC == destinationType;
+ || TEMPORARY_TOPIC == destinationType;
}
}
@@ -152,7 +155,7 @@
this.physicalName = name;
int p = name.IndexOf('?');
- if(p >= 0)
+ if (p >= 0)
{
String optstring = physicalName.Substring(p + 1);
this.physicalName = name.Substring(0, p);
@@ -167,32 +170,33 @@
public static Destination Transform(IDestination destination)
{
Destination result = null;
- if(destination != null)
+ if (destination != null)
{
- if(destination is Destination)
+ if (destination is Destination)
{
result = (Destination) destination;
}
else
{
- if(destination is ITemporaryQueue)
+ if (destination is ITemporaryQueue)
{
result = new TempQueue(((IQueue) destination).QueueName);
}
- else if(destination is ITemporaryTopic)
+ else if (destination is ITemporaryTopic)
{
result = new TempTopic(((ITopic) destination).TopicName);
}
- else if(destination is IQueue)
+ else if (destination is IQueue)
{
result = new Queue(((IQueue) destination).QueueName);
}
- else if(destination is ITopic)
+ else if (destination is ITopic)
{
result = new Topic(((ITopic) destination).TopicName);
}
}
}
+
return result;
}
@@ -214,20 +218,21 @@
public static String GetClientId(Destination destination)
{
String answer = null;
- if(destination != null && destination.IsTemporary)
+ if (destination != null && destination.IsTemporary)
{
String name = destination.PhysicalName;
int start = name.IndexOf(TEMP_PREFIX);
- if(start >= 0)
+ if (start >= 0)
{
start += TEMP_PREFIX.Length;
int stop = name.LastIndexOf(TEMP_POSTFIX);
- if(stop > start && stop < name.Length)
+ if (stop > start && stop < name.Length)
{
answer = name.Substring(start, stop);
}
}
}
+
return answer;
}
@@ -237,10 +242,11 @@
/// <returns>1 if this is less than o else 0 if they are equal or -1 if this is less than o</returns>
public int CompareTo(Object o)
{
- if(o is Destination)
+ if (o is Destination)
{
return CompareTo((Destination) o);
}
+
return -1;
}
@@ -252,36 +258,38 @@
public int CompareTo(Destination that)
{
int answer = 0;
- if(physicalName != that.physicalName)
+ if (physicalName != that.physicalName)
{
- if(physicalName == null)
+ if (physicalName == null)
{
return -1;
}
- else if(that.physicalName == null)
+ else if (that.physicalName == null)
{
return 1;
}
+
answer = physicalName.CompareTo(that.physicalName);
}
- if(answer == 0)
+ if (answer == 0)
{
- if(IsTopic)
+ if (IsTopic)
{
- if(that.IsQueue)
+ if (that.IsQueue)
{
return 1;
}
}
else
{
- if(that.IsTopic)
+ if (that.IsTopic)
{
return -1;
}
}
}
+
return answer;
}
@@ -293,10 +301,7 @@
public String PhysicalName
{
get { return this.physicalName; }
- set
- {
- this.physicalName = value;
- }
+ set { this.physicalName = value; }
}
/// <summary>
@@ -304,19 +309,19 @@
/// <returns>string representation of this instance</returns>
public override String ToString()
{
- switch(DestinationType)
+ switch (DestinationType)
{
- case DestinationType.Topic:
- return "topic://" + PhysicalName;
+ case DestinationType.Topic:
+ return "topic://" + PhysicalName;
- case DestinationType.TemporaryTopic:
- return "temp-topic://" + PhysicalName;
+ case DestinationType.TemporaryTopic:
+ return "temp-topic://" + PhysicalName;
- case DestinationType.TemporaryQueue:
- return "temp-queue://" + PhysicalName;
+ case DestinationType.TemporaryQueue:
+ return "temp-queue://" + PhysicalName;
- default:
- return "queue://" + PhysicalName;
+ default:
+ return "queue://" + PhysicalName;
}
}
@@ -327,14 +332,16 @@
{
int answer = 37;
- if(this.physicalName != null)
+ if (this.physicalName != null)
{
answer = physicalName.GetHashCode();
}
- if(IsTopic)
+
+ if (IsTopic)
{
answer ^= 0xfabfab;
}
+
return answer;
}
@@ -346,12 +353,13 @@
public override bool Equals(Object obj)
{
bool result = this == obj;
- if(!result && obj != null && obj is Destination)
+ if (!result && obj != null && obj is Destination)
{
Destination other = (Destination) obj;
result = this.GetDestinationType() == other.GetDestinationType()
- && this.physicalName.Equals(other.physicalName);
+ && this.physicalName.Equals(other.physicalName);
}
+
return result;
}
@@ -362,10 +370,7 @@
/// <returns>the created Destination</returns>
public abstract Destination CreateDestination(String name);
- public abstract DestinationType DestinationType
- {
- get;
- }
+ public abstract DestinationType DestinationType { get; }
public virtual Object Clone()
{
@@ -376,5 +381,4 @@
return this.MemberwiseClone();
}
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/MapMessage.cs b/test/nms-api-test/Commands/MapMessage.cs
index 34de7aa..f057906 100644
--- a/test/nms-api-test/Commands/MapMessage.cs
+++ b/test/nms-api-test/Commands/MapMessage.cs
@@ -50,7 +50,7 @@
set
{
- if(this.typeConverter != null)
+ if (this.typeConverter != null)
{
this.typeConverter.ReadOnly = true;
}
@@ -64,7 +64,7 @@
{
get
{
- if(this.body == null)
+ if (this.body == null)
{
this.body = new PrimitiveMap();
this.typeConverter = new PrimitiveMapInterceptor(this, this.body);
@@ -76,7 +76,7 @@
set
{
this.body = value as PrimitiveMap;
- if(value != null)
+ if (value != null)
{
this.typeConverter = new PrimitiveMapInterceptor(this, value);
}
@@ -87,4 +87,4 @@
}
}
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/Message.cs b/test/nms-api-test/Commands/Message.cs
index dcb38d6..50b0442 100644
--- a/test/nms-api-test/Commands/Message.cs
+++ b/test/nms-api-test/Commands/Message.cs
@@ -17,7 +17,6 @@
using System;
using System.Collections;
-
using Apache.NMS.Util;
namespace Apache.NMS.Commands
@@ -28,7 +27,7 @@
private string transactionId;
private string messageId;
private string groupID;
- private int groupSequence;
+ private int groupSequence;
private string correlationId;
private bool persistent;
private long expiration;
@@ -57,13 +56,13 @@
// if we had any.
Message o = (Message) this.MemberwiseClone();
- if(this.messageId != null)
+ if (this.messageId != null)
{
o.NMSMessageId = (string) this.messageId.Clone();
}
-
- return o;
- }
+
+ return o;
+ }
///
/// <summery>
@@ -74,38 +73,38 @@
public override string ToString()
{
return GetType().Name + "[" +
- "Destination=" + destination + ", " +
- "TransactionId=" + transactionId + ", " +
- "MessageId=" + messageId + ", " +
- "GroupID=" + groupID + ", " +
- "GroupSequence=" + groupSequence + ", " +
- "CorrelationId=" + correlationId + ", " +
- "Expiration=" + expiration + ", " +
- "Priority=" + priority + ", " +
- "ReplyTo=" + replyTo + ", " +
- "Timestamp=" + timestamp + ", " +
- "Type=" + type + ", " +
- "Redelivered=" + redelivered +
- "]";
+ "Destination=" + destination + ", " +
+ "TransactionId=" + transactionId + ", " +
+ "MessageId=" + messageId + ", " +
+ "GroupID=" + groupID + ", " +
+ "GroupSequence=" + groupSequence + ", " +
+ "CorrelationId=" + correlationId + ", " +
+ "Expiration=" + expiration + ", " +
+ "Priority=" + priority + ", " +
+ "ReplyTo=" + replyTo + ", " +
+ "Timestamp=" + timestamp + ", " +
+ "Type=" + type + ", " +
+ "Redelivered=" + redelivered +
+ "]";
}
public void Acknowledge()
{
}
-
+
public virtual void ClearBody()
{
- this.content = null;
+ this.content = null;
}
public virtual void ClearProperties()
{
this.properties.Clear();
}
-
+
protected void FailIfReadOnlyBody()
{
- if(ReadOnlyBody == true)
+ if (ReadOnlyBody == true)
{
throw new MessageNotWriteableException("Message is in Read-Only mode.");
}
@@ -113,26 +112,26 @@
protected void FailIfWriteOnlyBody()
{
- if(ReadOnlyBody == false)
+ if (ReadOnlyBody == false)
{
throw new MessageNotReadableException("Message is in Write-Only mode.");
}
}
-
+
#region Properties
-
- public string TransactionId
- {
- get { return this.transactionId; }
- set { this.transactionId = value; }
- }
+
+ public string TransactionId
+ {
+ get { return this.transactionId; }
+ set { this.transactionId = value; }
+ }
public byte[] Content
{
get { return content; }
set { this.content = value; }
}
-
+
public virtual bool ReadOnlyProperties
{
get { return this.readOnlyMsgProperties; }
@@ -144,12 +143,12 @@
get { return this.readOnlyMsgBody; }
set { this.readOnlyMsgBody = value; }
}
-
+
public IPrimitiveMap Properties
{
get
{
- if(null == properties)
+ if (null == properties)
{
properties = new PrimitiveMap();
propertyHelper = new MessagePropertyIntercepter(this, properties, this.ReadOnlyProperties);
@@ -179,6 +178,7 @@
}
private TimeSpan timeToLive = TimeSpan.FromMilliseconds(0);
+
/// <summary>
/// The time in milliseconds that this message should expire in
/// </summary>
@@ -189,11 +189,11 @@
set
{
timeToLive = value;
- if(timeToLive.TotalMilliseconds > 0)
+ if (timeToLive.TotalMilliseconds > 0)
{
long timeStamp = timestamp;
- if(timeStamp == 0)
+ if (timeStamp == 0)
{
timeStamp = DateUtils.ToJavaTimeUtc(DateTime.UtcNow);
}
@@ -216,7 +216,7 @@
set
{
timestamp = DateUtils.ToJavaTimeUtc(value);
- if(timeToLive.TotalMilliseconds > 0)
+ if (timeToLive.TotalMilliseconds > 0)
{
expiration = timestamp + (long) timeToLive.TotalMilliseconds;
}
@@ -297,6 +297,7 @@
get { return groupID; }
set { groupID = value; }
}
+
/// <summary>
/// The Message Group Sequence counter to indicate the position in a group
/// </summary>
@@ -313,7 +314,7 @@
{
get
{
- if(null != transactionId)
+ if (null != transactionId)
{
return transactionId;
}
@@ -323,7 +324,5 @@
}
#endregion
-
};
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/ObjectMessage.cs b/test/nms-api-test/Commands/ObjectMessage.cs
index 4db9de6..056014d 100644
--- a/test/nms-api-test/Commands/ObjectMessage.cs
+++ b/test/nms-api-test/Commands/ObjectMessage.cs
@@ -18,7 +18,6 @@
using System;
using System.Collections;
using System.IO;
-
using Apache.NMS;
namespace Apache.NMS.Commands
@@ -27,9 +26,10 @@
{
private object body;
- public override string ToString() {
+ public override string ToString()
+ {
return GetType().Name + "["
- + " ]";
+ + " ]";
}
// Properties
@@ -39,6 +39,5 @@
get { return body; }
set { body = value; }
}
-
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/Queue.cs b/test/nms-api-test/Commands/Queue.cs
index 342156f..2c39021 100644
--- a/test/nms-api-test/Commands/Queue.cs
+++ b/test/nms-api-test/Commands/Queue.cs
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS.Commands
@@ -35,10 +36,7 @@
override public DestinationType DestinationType
{
- get
- {
- return DestinationType.Queue;
- }
+ get { return DestinationType.Queue; }
}
public String QueueName
@@ -71,5 +69,4 @@
return o;
}
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/StreamMessage.cs b/test/nms-api-test/Commands/StreamMessage.cs
index 86e4e28..ab81aff 100644
--- a/test/nms-api-test/Commands/StreamMessage.cs
+++ b/test/nms-api-test/Commands/StreamMessage.cs
@@ -18,7 +18,6 @@
using System;
using System.IO;
using System.Collections;
-
using Apache.NMS;
using Apache.NMS.Util;
@@ -42,15 +41,15 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.BOOLEAN_TYPE)
+ if (type == PrimitiveMap.BOOLEAN_TYPE)
{
return this.dataIn.ReadBoolean();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return Boolean.Parse(this.dataIn.ReadString16());
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new NMSException("Cannot convert Null type to a bool");
@@ -61,17 +60,17 @@
throw new MessageFormatException("Value is not a Boolean type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -88,15 +87,15 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.BYTE_TYPE)
+ if (type == PrimitiveMap.BYTE_TYPE)
{
return this.dataIn.ReadByte();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return Byte.Parse(this.dataIn.ReadString16());
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new NMSException("Cannot convert Null type to a byte");
@@ -107,17 +106,17 @@
throw new MessageFormatException("Value is not a Byte type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -134,11 +133,11 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.CHAR_TYPE)
+ if (type == PrimitiveMap.CHAR_TYPE)
{
return this.dataIn.ReadChar();
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new NMSException("Cannot convert Null type to a char");
@@ -149,17 +148,17 @@
throw new MessageFormatException("Value is not a Char type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -176,19 +175,19 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.SHORT_TYPE)
+ if (type == PrimitiveMap.SHORT_TYPE)
{
return this.dataIn.ReadInt16();
}
- else if(type == PrimitiveMap.BYTE_TYPE)
+ else if (type == PrimitiveMap.BYTE_TYPE)
{
return this.dataIn.ReadByte();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return Int16.Parse(this.dataIn.ReadString16());
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new NMSException("Cannot convert Null type to a short");
@@ -199,17 +198,17 @@
throw new MessageFormatException("Value is not a Int16 type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -226,23 +225,23 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.INTEGER_TYPE)
+ if (type == PrimitiveMap.INTEGER_TYPE)
{
return this.dataIn.ReadInt32();
}
- else if(type == PrimitiveMap.SHORT_TYPE)
+ else if (type == PrimitiveMap.SHORT_TYPE)
{
return this.dataIn.ReadInt16();
}
- else if(type == PrimitiveMap.BYTE_TYPE)
+ else if (type == PrimitiveMap.BYTE_TYPE)
{
return this.dataIn.ReadByte();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return Int32.Parse(this.dataIn.ReadString16());
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new NMSException("Cannot convert Null type to a int");
@@ -253,17 +252,17 @@
throw new MessageFormatException("Value is not a Int32 type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -280,27 +279,27 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.LONG_TYPE)
+ if (type == PrimitiveMap.LONG_TYPE)
{
return this.dataIn.ReadInt64();
}
- else if(type == PrimitiveMap.INTEGER_TYPE)
+ else if (type == PrimitiveMap.INTEGER_TYPE)
{
return this.dataIn.ReadInt32();
}
- else if(type == PrimitiveMap.SHORT_TYPE)
+ else if (type == PrimitiveMap.SHORT_TYPE)
{
return this.dataIn.ReadInt16();
}
- else if(type == PrimitiveMap.BYTE_TYPE)
+ else if (type == PrimitiveMap.BYTE_TYPE)
{
return this.dataIn.ReadByte();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return Int64.Parse(this.dataIn.ReadString16());
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new NMSException("Cannot convert Null type to a long");
@@ -311,17 +310,17 @@
throw new MessageFormatException("Value is not a Int64 type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -338,15 +337,15 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.FLOAT_TYPE)
+ if (type == PrimitiveMap.FLOAT_TYPE)
{
return this.dataIn.ReadSingle();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return Single.Parse(this.dataIn.ReadString16());
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new NMSException("Cannot convert Null type to a float");
@@ -357,17 +356,17 @@
throw new MessageFormatException("Value is not a Single type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -384,19 +383,19 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.DOUBLE_TYPE)
+ if (type == PrimitiveMap.DOUBLE_TYPE)
{
return this.dataIn.ReadDouble();
}
- else if(type == PrimitiveMap.FLOAT_TYPE)
+ else if (type == PrimitiveMap.FLOAT_TYPE)
{
return this.dataIn.ReadSingle();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return Single.Parse(this.dataIn.ReadString16());
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new NMSException("Cannot convert Null type to a double");
@@ -407,17 +406,17 @@
throw new MessageFormatException("Value is not a Double type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -433,47 +432,47 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.BIG_STRING_TYPE)
+ if (type == PrimitiveMap.BIG_STRING_TYPE)
{
return this.dataIn.ReadString32();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return this.dataIn.ReadString16();
}
- else if(type == PrimitiveMap.LONG_TYPE)
+ else if (type == PrimitiveMap.LONG_TYPE)
{
return this.dataIn.ReadInt64().ToString();
}
- else if(type == PrimitiveMap.INTEGER_TYPE)
+ else if (type == PrimitiveMap.INTEGER_TYPE)
{
return this.dataIn.ReadInt32().ToString();
}
- else if(type == PrimitiveMap.SHORT_TYPE)
+ else if (type == PrimitiveMap.SHORT_TYPE)
{
return this.dataIn.ReadInt16().ToString();
}
- else if(type == PrimitiveMap.FLOAT_TYPE)
+ else if (type == PrimitiveMap.FLOAT_TYPE)
{
return this.dataIn.ReadSingle().ToString();
}
- else if(type == PrimitiveMap.DOUBLE_TYPE)
+ else if (type == PrimitiveMap.DOUBLE_TYPE)
{
return this.dataIn.ReadDouble().ToString();
}
- else if(type == PrimitiveMap.CHAR_TYPE)
+ else if (type == PrimitiveMap.CHAR_TYPE)
{
return this.dataIn.ReadChar().ToString();
}
- else if(type == PrimitiveMap.BYTE_TYPE)
+ else if (type == PrimitiveMap.BYTE_TYPE)
{
return this.dataIn.ReadByte().ToString();
}
- else if(type == PrimitiveMap.BOOLEAN_TYPE)
+ else if (type == PrimitiveMap.BOOLEAN_TYPE)
{
return this.dataIn.ReadBoolean().ToString();
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
return null;
}
@@ -483,16 +482,16 @@
throw new MessageFormatException("Value is not a known type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -502,19 +501,19 @@
{
InitializeReading();
- if(value == null)
+ if (value == null)
{
throw new NullReferenceException("Passed Byte Array is null");
}
try
{
- if(this.bytesRemaining == -1)
+ if (this.bytesRemaining == -1)
{
long startingPos = this.byteBuffer.Position;
byte type = this.dataIn.ReadByte();
- if(type != PrimitiveMap.BYTE_ARRAY_TYPE)
+ if (type != PrimitiveMap.BYTE_ARRAY_TYPE)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw new MessageFormatException("Not a byte array");
@@ -522,13 +521,13 @@
this.bytesRemaining = this.dataIn.ReadInt32();
}
- else if(this.bytesRemaining == 0)
+ else if (this.bytesRemaining == 0)
{
this.bytesRemaining = -1;
return -1;
}
- if(value.Length <= this.bytesRemaining)
+ if (value.Length <= this.bytesRemaining)
{
// small buffer
this.bytesRemaining -= value.Length;
@@ -543,11 +542,11 @@
return rc;
}
}
- catch(EndOfStreamException ex)
+ catch (EndOfStreamException ex)
{
throw NMSExceptionSupport.CreateMessageEOFException(ex);
}
- catch(IOException ex)
+ catch (IOException ex)
{
throw NMSExceptionSupport.CreateMessageFormatException(ex);
}
@@ -563,54 +562,54 @@
{
int type = this.dataIn.ReadByte();
- if(type == PrimitiveMap.BIG_STRING_TYPE)
+ if (type == PrimitiveMap.BIG_STRING_TYPE)
{
return this.dataIn.ReadString32();
}
- else if(type == PrimitiveMap.STRING_TYPE)
+ else if (type == PrimitiveMap.STRING_TYPE)
{
return this.dataIn.ReadString16();
}
- else if(type == PrimitiveMap.LONG_TYPE)
+ else if (type == PrimitiveMap.LONG_TYPE)
{
return this.dataIn.ReadInt64();
}
- else if(type == PrimitiveMap.INTEGER_TYPE)
+ else if (type == PrimitiveMap.INTEGER_TYPE)
{
return this.dataIn.ReadInt32();
}
- else if(type == PrimitiveMap.SHORT_TYPE)
+ else if (type == PrimitiveMap.SHORT_TYPE)
{
return this.dataIn.ReadInt16();
}
- else if(type == PrimitiveMap.FLOAT_TYPE)
+ else if (type == PrimitiveMap.FLOAT_TYPE)
{
return this.dataIn.ReadSingle();
}
- else if(type == PrimitiveMap.DOUBLE_TYPE)
+ else if (type == PrimitiveMap.DOUBLE_TYPE)
{
return this.dataIn.ReadDouble();
}
- else if(type == PrimitiveMap.CHAR_TYPE)
+ else if (type == PrimitiveMap.CHAR_TYPE)
{
return this.dataIn.ReadChar();
}
- else if(type == PrimitiveMap.BYTE_TYPE)
+ else if (type == PrimitiveMap.BYTE_TYPE)
{
return this.dataIn.ReadByte();
}
- else if(type == PrimitiveMap.BOOLEAN_TYPE)
+ else if (type == PrimitiveMap.BOOLEAN_TYPE)
{
return this.dataIn.ReadBoolean();
}
- else if(type == PrimitiveMap.BYTE_ARRAY_TYPE)
+ else if (type == PrimitiveMap.BYTE_ARRAY_TYPE)
{
int length = this.dataIn.ReadInt32();
byte[] data = new byte[length];
this.dataIn.Read(data, 0, length);
return data;
}
- else if(type == PrimitiveMap.NULL)
+ else if (type == PrimitiveMap.NULL)
{
return null;
}
@@ -620,16 +619,16 @@
throw new MessageFormatException("Value is not a known type.");
}
}
- catch(FormatException e)
+ catch (FormatException e)
{
this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
- catch(EndOfStreamException e)
+ catch (EndOfStreamException e)
{
throw NMSExceptionSupport.CreateMessageEOFException(e);
}
- catch(IOException e)
+ catch (IOException e)
{
throw NMSExceptionSupport.CreateMessageFormatException(e);
}
@@ -643,7 +642,7 @@
this.dataOut.Write(PrimitiveMap.BOOLEAN_TYPE);
this.dataOut.Write(value);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -657,7 +656,7 @@
this.dataOut.Write(PrimitiveMap.BYTE_TYPE);
this.dataOut.Write(value);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -678,7 +677,7 @@
this.dataOut.Write((int) length);
this.dataOut.Write(value, offset, length);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -692,7 +691,7 @@
this.dataOut.Write(PrimitiveMap.CHAR_TYPE);
this.dataOut.Write(value);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -706,7 +705,7 @@
this.dataOut.Write(PrimitiveMap.SHORT_TYPE);
this.dataOut.Write(value);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -720,7 +719,7 @@
this.dataOut.Write(PrimitiveMap.INTEGER_TYPE);
this.dataOut.Write(value);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -734,7 +733,7 @@
this.dataOut.Write(PrimitiveMap.LONG_TYPE);
this.dataOut.Write(value);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -748,7 +747,7 @@
this.dataOut.Write(PrimitiveMap.FLOAT_TYPE);
this.dataOut.Write(value);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -762,7 +761,7 @@
this.dataOut.Write(PrimitiveMap.DOUBLE_TYPE);
this.dataOut.Write(value);
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -773,7 +772,7 @@
InitializeWriting();
try
{
- if( value.Length > 8192 )
+ if (value.Length > 8192)
{
this.dataOut.Write(PrimitiveMap.BIG_STRING_TYPE);
this.dataOut.WriteString32(value);
@@ -784,7 +783,7 @@
this.dataOut.WriteString16(value);
}
}
- catch(IOException e)
+ catch (IOException e)
{
NMSExceptionSupport.Create(e);
}
@@ -793,45 +792,45 @@
public void WriteObject(Object value)
{
InitializeWriting();
- if( value is System.Byte )
+ if (value is System.Byte)
{
- this.WriteByte( (byte) value );
+ this.WriteByte((byte) value);
}
- else if( value is Char )
+ else if (value is Char)
{
- this.WriteChar( (char) value );
+ this.WriteChar((char) value);
}
- else if( value is Boolean )
+ else if (value is Boolean)
{
- this.WriteBoolean( (bool) value );
+ this.WriteBoolean((bool) value);
}
- else if( value is Int16 )
+ else if (value is Int16)
{
- this.WriteInt16( (short) value );
+ this.WriteInt16((short) value);
}
- else if( value is Int32 )
+ else if (value is Int32)
{
- this.WriteInt32( (int) value );
+ this.WriteInt32((int) value);
}
- else if( value is Int64 )
+ else if (value is Int64)
{
- this.WriteInt64( (long) value );
+ this.WriteInt64((long) value);
}
- else if( value is Single )
+ else if (value is Single)
{
- this.WriteSingle( (float) value );
+ this.WriteSingle((float) value);
}
- else if( value is Double )
+ else if (value is Double)
{
- this.WriteDouble( (double) value );
+ this.WriteDouble((double) value);
}
- else if( value is byte[] )
+ else if (value is byte[])
{
- this.WriteBytes( (byte[]) value );
+ this.WriteBytes((byte[]) value);
}
- else if( value is String )
+ else if (value is String)
{
- this.WriteString( (string) value );
+ this.WriteString((string) value);
}
else
{
@@ -867,7 +866,7 @@
private void InitializeReading()
{
FailIfWriteOnlyBody();
- if(this.dataIn == null)
+ if (this.dataIn == null)
{
this.byteBuffer = new MemoryStream(this.Content, false);
this.dataIn = new EndianBinaryReader(this.byteBuffer);
@@ -877,7 +876,7 @@
private void InitializeWriting()
{
FailIfReadOnlyBody();
- if(this.dataOut == null)
+ if (this.dataOut == null)
{
this.byteBuffer = new MemoryStream();
this.dataOut = new EndianBinaryWriter(this.byteBuffer);
@@ -886,7 +885,7 @@
private void StoreContent()
{
- if( dataOut != null)
+ if (dataOut != null)
{
dataOut.Close();
@@ -895,7 +894,5 @@
this.byteBuffer = null;
}
}
-
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/TempDestination.cs b/test/nms-api-test/Commands/TempDestination.cs
index 1e085c9..2d829b4 100644
--- a/test/nms-api-test/Commands/TempDestination.cs
+++ b/test/nms-api-test/Commands/TempDestination.cs
@@ -31,10 +31,7 @@
return null;
}
- abstract override public DestinationType DestinationType
- {
- get;
- }
+ abstract override public DestinationType DestinationType { get; }
public TempDestination()
: base()
@@ -66,5 +63,4 @@
throw new NotSupportedException("Stomp Cannot Delete Temporary Destinations");
}
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/TempQueue.cs b/test/nms-api-test/Commands/TempQueue.cs
index b8ee277..af84912 100644
--- a/test/nms-api-test/Commands/TempQueue.cs
+++ b/test/nms-api-test/Commands/TempQueue.cs
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS.Commands
@@ -35,10 +36,7 @@
override public DestinationType DestinationType
{
- get
- {
- return DestinationType.TemporaryQueue;
- }
+ get { return DestinationType.TemporaryQueue; }
}
public String QueueName
@@ -75,7 +73,5 @@
return o;
}
-
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/TempTopic.cs b/test/nms-api-test/Commands/TempTopic.cs
index 2ba499e..5d9461e 100644
--- a/test/nms-api-test/Commands/TempTopic.cs
+++ b/test/nms-api-test/Commands/TempTopic.cs
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS.Commands
{
-
/// <summary>
/// A Temporary Topic
/// </summary>
@@ -71,7 +71,5 @@
return o;
}
-
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/TextMessage.cs b/test/nms-api-test/Commands/TextMessage.cs
index b36f4ba..f8a8cf1 100644
--- a/test/nms-api-test/Commands/TextMessage.cs
+++ b/test/nms-api-test/Commands/TextMessage.cs
@@ -17,7 +17,6 @@
using System;
using System.IO;
-
using Apache.NMS;
using Apache.NMS.Util;
@@ -40,10 +39,11 @@
{
string text = this.Text;
- if(text != null && text.Length > 63)
+ if (text != null && text.Length > 63)
{
text = text.Substring(0, 45) + "..." + text.Substring(text.Length - 12);
}
+
return base.ToString() + " Text = " + (text ?? "null");
}
@@ -66,5 +66,4 @@
}
}
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/Commands/Topic.cs b/test/nms-api-test/Commands/Topic.cs
index bbab902..56761ad 100644
--- a/test/nms-api-test/Commands/Topic.cs
+++ b/test/nms-api-test/Commands/Topic.cs
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
namespace Apache.NMS.Commands
{
-
/// <summary>
/// Summary description for Topic.
/// </summary>
@@ -34,10 +34,7 @@
override public DestinationType DestinationType
{
- get
- {
- return DestinationType.Topic;
- }
+ get { return DestinationType.Topic; }
}
public String TopicName
@@ -70,5 +67,4 @@
return o;
}
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/ConnectionTest.cs b/test/nms-api-test/ConnectionTest.cs
index 1be3e05..0c39fd6 100644
--- a/test/nms-api-test/ConnectionTest.cs
+++ b/test/nms-api-test/ConnectionTest.cs
@@ -20,17 +20,17 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class ConnectionTest : NMSTestSupport
- {
+ [TestFixture]
+ public class ConnectionTest : NMSTestSupport
+ {
IConnection startedConnection = null;
IConnection stoppedConnection = null;
-
+
[SetUp]
public override void SetUp()
{
base.SetUp();
-
+
startedConnection = CreateConnection(null);
startedConnection.Start();
stoppedConnection = CreateConnection(null);
@@ -41,100 +41,98 @@
{
startedConnection.Close();
stoppedConnection.Close();
-
- base.TearDown();
+
+ base.TearDown();
}
-
- /// <summary>
- /// Verify that it is possible to create multiple connections to the broker.
- /// There was a bug in the connection factory which set the clientId member which made
- /// it impossible to create an additional connection.
- /// </summary>
- [Test]
- public void TwoConnections()
- {
- using(IConnection connection1 = CreateConnection(null))
- {
- connection1.Start();
- using(IConnection connection2 = CreateConnection(null))
- {
- // with the bug present we'll get an exception in connection2.start()
- connection2.Start();
- }
- }
- }
- [Test]
- public void CreateAndDisposeWithConsumer(
- [Values(true, false)]
- bool disposeConsumer)
- {
- using(IConnection connection = CreateConnection("DisposalTestConnection"))
- {
- connection.Start();
+ /// <summary>
+ /// Verify that it is possible to create multiple connections to the broker.
+ /// There was a bug in the connection factory which set the clientId member which made
+ /// it impossible to create an additional connection.
+ /// </summary>
+ [Test]
+ public void TwoConnections()
+ {
+ using (IConnection connection1 = CreateConnection(null))
+ {
+ connection1.Start();
+ using (IConnection connection2 = CreateConnection(null))
+ {
+ // with the bug present we'll get an exception in connection2.start()
+ connection2.Start();
+ }
+ }
+ }
- using(ISession session = connection.CreateSession())
- {
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- IMessageConsumer consumer = session.CreateConsumer(destination);
+ [Test]
+ public void CreateAndDisposeWithConsumer(
+ [Values(true, false)] bool disposeConsumer)
+ {
+ using (IConnection connection = CreateConnection("DisposalTestConnection"))
+ {
+ connection.Start();
- connection.Stop();
- if(disposeConsumer)
- {
- consumer.Dispose();
- }
- }
- }
- }
+ using (ISession session = connection.CreateSession())
+ {
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IMessageConsumer consumer = session.CreateConsumer(destination);
- [Test]
- public void CreateAndDisposeWithProducer(
- [Values(true, false)]
- bool disposeProducer)
- {
- using(IConnection connection = CreateConnection("DisposalTestConnection"))
- {
- connection.Start();
+ connection.Stop();
+ if (disposeConsumer)
+ {
+ consumer.Dispose();
+ }
+ }
+ }
+ }
- using(ISession session = connection.CreateSession())
- {
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- IMessageProducer producer = session.CreateProducer(destination);
+ [Test]
+ public void CreateAndDisposeWithProducer(
+ [Values(true, false)] bool disposeProducer)
+ {
+ using (IConnection connection = CreateConnection("DisposalTestConnection"))
+ {
+ connection.Start();
- connection.Stop();
- if(disposeProducer)
- {
- producer.Dispose();
- }
- }
- }
- }
+ using (ISession session = connection.CreateSession())
+ {
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IMessageProducer producer = session.CreateProducer(destination);
+
+ connection.Stop();
+ if (disposeProducer)
+ {
+ producer.Dispose();
+ }
+ }
+ }
+ }
[Test]
public void TestStartAfterSend(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode,
- [Values(DestinationType.Queue, DestinationType.Topic)]
- DestinationType destinationType)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode,
+ [Values(DestinationType.Queue, DestinationType.Topic)]
+ DestinationType destinationType)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
- {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
+ {
ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
IDestination destination = CreateDestination(session, destinationType);
IMessageConsumer consumer = session.CreateConsumer(destination);
-
+
// Send the messages
SendMessages(session, destination, deliveryMode, 1);
-
+
// Start the conncection after the message was sent.
connection.Start();
-
+
// Make sure only 1 message was delivered.
Assert.IsNotNull(consumer.Receive(TimeSpan.FromMilliseconds(1000)));
Assert.IsNull(consumer.ReceiveNoWait());
}
}
-
+
/// <summary>
/// Tests if the consumer receives the messages that were sent before the
/// connection was started.
@@ -144,32 +142,32 @@
{
ISession startedSession = startedConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
ISession stoppedSession = stoppedConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
-
+
// Setup the consumers.
IDestination topic = CreateDestination(startedSession, DestinationType.Topic);
IMessageConsumer startedConsumer = startedSession.CreateConsumer(topic);
IMessageConsumer stoppedConsumer = stoppedSession.CreateConsumer(topic);
-
+
// Send the message.
IMessageProducer producer = startedSession.CreateProducer(topic);
ITextMessage message = startedSession.CreateTextMessage("Hello");
producer.Send(message);
-
+
// Test the assertions.
IMessage m = startedConsumer.Receive(TimeSpan.FromMilliseconds(1000));
Assert.IsNotNull(m);
-
+
m = stoppedConsumer.Receive(TimeSpan.FromMilliseconds(1000));
Assert.IsNull(m);
-
+
stoppedConnection.Start();
m = stoppedConsumer.Receive(TimeSpan.FromMilliseconds(5000));
Assert.IsNotNull(m);
-
+
startedSession.Close();
stoppedSession.Close();
}
-
+
/// <summary>
/// Tests if the consumer is able to receive messages eveb when the
/// connecction restarts multiple times.
@@ -182,6 +180,6 @@
TestStoppedConsumerHoldsMessagesTillStarted();
stoppedConnection.Stop();
TestStoppedConsumerHoldsMessagesTillStarted();
- }
- }
-}
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/ConsumerTest.cs b/test/nms-api-test/ConsumerTest.cs
index 72fa929..ee36cdf 100644
--- a/test/nms-api-test/ConsumerTest.cs
+++ b/test/nms-api-test/ConsumerTest.cs
@@ -40,16 +40,16 @@
// Launch a thread to perform IMessageConsumer.Receive().
// If it doesn't fail in less than three seconds, no exception was thrown.
Thread receiveThread = new Thread(new ThreadStart(TimeoutConsumerThreadProc));
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
+ using (ISession session = connection.CreateSession(ackMode))
{
ITemporaryQueue queue = session.CreateTemporaryQueue();
- using(this.timeoutConsumer = session.CreateConsumer(queue))
+ using (this.timeoutConsumer = session.CreateConsumer(queue))
{
receiveThread.Start();
- if(receiveThread.Join(3000))
+ if (receiveThread.Join(3000))
{
Assert.Fail("IMessageConsumer.Receive() returned without blocking. Test failed.");
}
@@ -71,16 +71,16 @@
{
timeoutConsumer.Receive();
}
- catch(ArgumentOutOfRangeException e)
+ catch (ArgumentOutOfRangeException e)
{
// The test failed. We will know because the timeout will expire inside TestNoTimeoutConsumer().
Assert.Fail("Test failed with exception: " + e.Message);
}
- catch(ThreadInterruptedException)
+ catch (ThreadInterruptedException)
{
// The test succeeded! We were still blocked when we were interrupted.
}
- catch(Exception e)
+ catch (Exception e)
{
// Some other exception occurred.
Assert.Fail("Test failed with exception: " + e.Message);
@@ -118,7 +118,8 @@
{
// Kill the thread - otherwise it'll sit in Receive() until a message arrives.
receiveThread.Interrupt();
- Assert.Fail("IMessageConsumer.Receive() thread is still alive, Close should have killed it.");
+ Assert.Fail(
+ "IMessageConsumer.Receive() thread is still alive, Close should have killed it.");
}
}
}
@@ -139,9 +140,9 @@
{
ThreadArg args = arg as ThreadArg;
- using(ISession session = args.connection.CreateSession())
+ using (ISession session = args.connection.CreateSession())
{
- using(IMessageProducer producer = session.CreateProducer(args.destination))
+ using (IMessageProducer producer = session.CreateProducer(args.destination))
{
// Give the consumer time to enter the receive.
Thread.Sleep(5000);
@@ -150,7 +151,7 @@
}
}
}
- catch(Exception e)
+ catch (Exception e)
{
// Some other exception occurred.
Assert.Fail("Test failed with exception: " + e.Message);
@@ -162,52 +163,51 @@
[Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
AcknowledgementMode ackMode,
- [Values(true, false)] bool doClear)
+ [Values(true, false)] bool doClear)
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
+ using (ISession session = connection.CreateSession(ackMode))
{
ITemporaryQueue queue = session.CreateTemporaryQueue();
- using(IMessageConsumer consumer = session.CreateConsumer(queue))
+ using (IMessageConsumer consumer = session.CreateConsumer(queue))
{
IMessageProducer producer = session.CreateProducer(queue);
ITextMessage message = session.CreateTextMessage();
string prefix = "ConsumerTest - TestDoChangeSentMessage: ";
- for(int i = 0; i < COUNT; i++)
+ for (int i = 0; i < COUNT; i++)
{
message.Properties[VALUE_NAME] = i;
message.Text = prefix + Convert.ToString(i);
producer.Send(message);
- if(doClear)
- {
- message.ClearBody();
- message.ClearProperties();
- }
+ if (doClear)
+ {
+ message.ClearBody();
+ message.ClearProperties();
+ }
}
- if(ackMode == AcknowledgementMode.Transactional)
+ if (ackMode == AcknowledgementMode.Transactional)
{
session.Commit();
}
- for(int i = 0; i < COUNT; i++)
+ for (int i = 0; i < COUNT; i++)
{
ITextMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(2000)) as ITextMessage;
Assert.AreEqual(msg.Text, prefix + Convert.ToString(i));
Assert.AreEqual(msg.Properties.GetInt(VALUE_NAME), i);
}
- if(ackMode == AcknowledgementMode.Transactional)
+ if (ackMode == AcknowledgementMode.Transactional)
{
session.Commit();
}
-
}
}
}
@@ -221,13 +221,13 @@
{
// Launch a thread to perform a delayed send.
Thread sendThread = new Thread(DelayedProducerThreadProc);
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
+ using (ISession session = connection.CreateSession(ackMode))
{
ITemporaryQueue queue = session.CreateTemporaryQueue();
- using(IMessageConsumer consumer = session.CreateConsumer(queue))
+ using (IMessageConsumer consumer = session.CreateConsumer(queue))
{
ThreadArg arg = new ThreadArg();
@@ -248,9 +248,9 @@
[Values(MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode,
[Values(DestinationType.Queue, DestinationType.Topic)]
- DestinationType destinationType )
+ DestinationType destinationType)
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
ISession session = connection.CreateSession();
IDestination destination = CreateDestination(session, destinationType);
@@ -268,10 +268,11 @@
public void TestSendReceiveTransacted(
[Values(MsgDeliveryMode.NonPersistent, MsgDeliveryMode.Persistent)]
MsgDeliveryMode deliveryMode,
- [Values(DestinationType.Queue, DestinationType.Topic, DestinationType.TemporaryQueue, DestinationType.TemporaryTopic)]
+ [Values(DestinationType.Queue, DestinationType.Topic, DestinationType.TemporaryQueue,
+ DestinationType.TemporaryTopic)]
DestinationType destinationType)
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
// Send a message to the broker.
connection.Start();
@@ -313,11 +314,11 @@
[Test]
public void TestAckedMessageAreConsumed()
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
ISession session = connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
- IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
IMessageProducer producer = session.CreateProducer(destination);
producer.Send(session.CreateTextMessage("Hello"));
@@ -343,11 +344,11 @@
[Test]
public void TestLastMessageAcked()
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
ISession session = connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
- IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
IMessageProducer producer = session.CreateProducer(destination);
producer.Send(session.CreateTextMessage("Hello"));
producer.Send(session.CreateTextMessage("Hello2"));
@@ -379,11 +380,11 @@
[Test]
public void TestUnAckedMessageAreNotConsumedOnSessionClose()
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
ISession session = connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
- IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
IMessageProducer producer = session.CreateProducer(destination);
producer.Send(session.CreateTextMessage("Hello"));
@@ -410,11 +411,11 @@
[Test]
public void TestAsyncAckedMessageAreConsumed()
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
ISession session = connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
- IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
IMessageProducer producer = session.CreateProducer(destination);
producer.Send(session.CreateTextMessage("Hello"));
@@ -441,13 +442,13 @@
[Test]
public void TestAsyncUnAckedMessageAreNotConsumedOnSessionClose()
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
// don't aknowledge message on onMessage() call
dontAck = true;
ISession session = connection.CreateSession(AcknowledgementMode.ClientAcknowledge);
- IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
IMessageProducer producer = session.CreateProducer(destination);
producer.Send(session.CreateTextMessage("Hello"));
@@ -475,7 +476,7 @@
[Test]
public void TestAddRemoveAsnycMessageListener()
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
@@ -495,13 +496,13 @@
{
Assert.IsNotNull(message);
- if(!dontAck)
+ if (!dontAck)
{
try
{
message.Acknowledge();
}
- catch(Exception)
+ catch (Exception)
{
}
}
@@ -515,50 +516,49 @@
[Values(MsgDeliveryMode.NonPersistent, MsgDeliveryMode.Persistent)]
MsgDeliveryMode deliveryMode)
{
- const int RETRIES = 20;
+ const int RETRIES = 20;
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
+ using (ISession session = connection.CreateSession(ackMode))
{
IDestination destination = session.CreateTemporaryQueue();
- using(IMessageProducer producer = session.CreateProducer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
- producer.DeliveryMode = deliveryMode;
- ITextMessage message = session.CreateTextMessage("TEST");
- producer.Send(message);
+ producer.DeliveryMode = deliveryMode;
+ ITextMessage message = session.CreateTextMessage("TEST");
+ producer.Send(message);
- if(AcknowledgementMode.Transactional == ackMode)
+ if (AcknowledgementMode.Transactional == ackMode)
{
session.Commit();
- }
- }
-
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- {
- IMessage message = null;
+ }
+ }
- for(int i = 0; i < RETRIES && message == null; ++i)
- {
- message = consumer.ReceiveNoWait();
- Thread.Sleep(100);
- }
-
- Assert.IsNotNull(message);
- message.Acknowledge();
-
- if(AcknowledgementMode.Transactional == ackMode)
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ {
+ IMessage message = null;
+
+ for (int i = 0; i < RETRIES && message == null; ++i)
+ {
+ message = consumer.ReceiveNoWait();
+ Thread.Sleep(100);
+ }
+
+ Assert.IsNotNull(message);
+ message.Acknowledge();
+
+ if (AcknowledgementMode.Transactional == ackMode)
{
session.Commit();
- }
- }
- }
- }
- }
-
+ }
+ }
+ }
+ }
+ }
+
#endif
-
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/DurableTest.cs b/test/nms-api-test/DurableTest.cs
index c9910ab..9e49778 100644
--- a/test/nms-api-test/DurableTest.cs
+++ b/test/nms-api-test/DurableTest.cs
@@ -22,245 +22,253 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class DurableTest : NMSTestSupport
- {
- protected static string DURABLE_TOPIC = "topic://TEST.DurableConsumerTopic";
- protected static string DURABLE_SELECTOR = "2 > 1";
+ [TestFixture]
+ public class DurableTest : NMSTestSupport
+ {
+ protected static string DURABLE_TOPIC = "topic://TEST.DurableConsumerTopic";
+ protected static string DURABLE_SELECTOR = "2 > 1";
- protected string TEST_CLIENT_AND_CONSUMER_ID;
- protected string SEND_CLIENT_ID;
-
- [SetUp]
- public override void SetUp()
- {
- base.SetUp();
-
- TEST_CLIENT_AND_CONSUMER_ID = GetTestClientId();
- SEND_CLIENT_ID = GetTestClientId();
- }
+ protected string TEST_CLIENT_AND_CONSUMER_ID;
+ protected string SEND_CLIENT_ID;
- [Test]
- public void TestSendWhileClosed(
- [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
- AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
- AcknowledgementMode ackMode)
- {
- try
- {
- using(IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
- {
- connection.Start();
-
- using(ISession session = connection.CreateSession(ackMode))
- {
- ITopic topic = (ITopic) CreateDestination(session, DestinationType.Topic);
- IMessageProducer producer = session.CreateProducer(topic);
+ [SetUp]
+ public override void SetUp()
+ {
+ base.SetUp();
- producer.DeliveryMode = MsgDeliveryMode.Persistent;
-
- ISession consumeSession = connection.CreateSession(ackMode);
- IMessageConsumer consumer = consumeSession.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, null, false);
- Thread.Sleep(1000);
- consumer.Dispose();
- consumer = null;
-
- ITextMessage message = session.CreateTextMessage("DurableTest-TestSendWhileClosed");
- message.Properties.SetString("test", "test");
- message.NMSType = "test";
- producer.Send(message);
- if(AcknowledgementMode.Transactional == ackMode)
- {
- session.Commit();
- }
-
- Thread.Sleep(1000);
- consumer = consumeSession.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, null, false);
- ITextMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
- msg.Acknowledge();
- if(AcknowledgementMode.Transactional == ackMode)
- {
- consumeSession.Commit();
- }
-
- Assert.IsNotNull(msg);
- Assert.AreEqual(msg.Text, "DurableTest-TestSendWhileClosed");
- Assert.AreEqual(msg.NMSType, "test");
- Assert.AreEqual(msg.Properties.GetString("test"), "test");
- }
- }
- }
- catch(Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
- // Pause to allow Stomp to unregister at the broker.
- Thread.Sleep(500);
+ TEST_CLIENT_AND_CONSUMER_ID = GetTestClientId();
+ SEND_CLIENT_ID = GetTestClientId();
+ }
- UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
- }
- }
-
- [Test]
- public void TestDurableConsumerSelectorChange(
- [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
- AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
- AcknowledgementMode ackMode)
- {
- try
- {
- using(IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
- {
- ITopic topic = (ITopic) CreateDestination(session, DestinationType.Topic);
- IMessageProducer producer = session.CreateProducer(topic);
- IMessageConsumer consumer = session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, "color='red'", false);
+ [Test]
+ public void TestSendWhileClosed(
+ [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
+ AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
+ AcknowledgementMode ackMode)
+ {
+ try
+ {
+ using (IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
+ {
+ connection.Start();
- producer.DeliveryMode = MsgDeliveryMode.Persistent;
+ using (ISession session = connection.CreateSession(ackMode))
+ {
+ ITopic topic = (ITopic) CreateDestination(session, DestinationType.Topic);
+ IMessageProducer producer = session.CreateProducer(topic);
- // Send the messages
- ITextMessage sendMessage = session.CreateTextMessage("1st");
- sendMessage.Properties["color"] = "red";
- producer.Send(sendMessage);
- if(AcknowledgementMode.Transactional == ackMode)
- {
- session.Commit();
- }
+ producer.DeliveryMode = MsgDeliveryMode.Persistent;
- ITextMessage receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage;
- Assert.IsNotNull(receiveMsg, "Failed to retrieve 1st durable message.");
- Assert.AreEqual("1st", receiveMsg.Text);
- Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not match");
- receiveMsg.Acknowledge();
- if(AcknowledgementMode.Transactional == ackMode)
- {
- session.Commit();
- }
-
- // Change the subscription, allowing some time for the Broker to purge the
- // consumers resources.
- consumer.Dispose();
+ ISession consumeSession = connection.CreateSession(ackMode);
+ IMessageConsumer consumer =
+ consumeSession.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, null, false);
Thread.Sleep(1000);
-
- consumer = session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, "color='blue'", false);
+ consumer.Dispose();
+ consumer = null;
- sendMessage = session.CreateTextMessage("2nd");
- sendMessage.Properties["color"] = "red";
- producer.Send(sendMessage);
- sendMessage = session.CreateTextMessage("3rd");
- sendMessage.Properties["color"] = "blue";
- producer.Send(sendMessage);
- if(AcknowledgementMode.Transactional == ackMode)
- {
- session.Commit();
- }
+ ITextMessage message = session.CreateTextMessage("DurableTest-TestSendWhileClosed");
+ message.Properties.SetString("test", "test");
+ message.NMSType = "test";
+ producer.Send(message);
+ if (AcknowledgementMode.Transactional == ackMode)
+ {
+ session.Commit();
+ }
- // Selector should skip the 2nd message.
- receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage;
- Assert.IsNotNull(receiveMsg, "Failed to retrieve durable message.");
- Assert.AreEqual("3rd", receiveMsg.Text, "Retrieved the wrong durable message.");
- Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode, "NMSDeliveryMode does not match");
- receiveMsg.Acknowledge();
- if(AcknowledgementMode.Transactional == ackMode)
- {
- session.Commit();
- }
+ Thread.Sleep(1000);
+ consumer = consumeSession.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, null,
+ false);
+ ITextMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(1000)) as ITextMessage;
+ msg.Acknowledge();
+ if (AcknowledgementMode.Transactional == ackMode)
+ {
+ consumeSession.Commit();
+ }
- // Make sure there are no pending messages.
- Assert.IsNull(consumer.ReceiveNoWait(), "Wrong number of messages in durable subscription.");
- }
- }
- }
- catch(Exception ex)
- {
- Assert.Fail(ex.Message);
- }
- finally
- {
+ Assert.IsNotNull(msg);
+ Assert.AreEqual(msg.Text, "DurableTest-TestSendWhileClosed");
+ Assert.AreEqual(msg.NMSType, "test");
+ Assert.AreEqual(msg.Properties.GetString("test"), "test");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
// Pause to allow Stomp to unregister at the broker.
Thread.Sleep(500);
- UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
- }
- }
+ UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
+ }
+ }
- [Test]
- public void TestDurableConsumer(
- [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
- AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
- AcknowledgementMode ackMode)
- {
- string TEST_DURABLE_TOPIC = DURABLE_TOPIC + ":TestDurableConsumer";
+ [Test]
+ public void TestDurableConsumerSelectorChange(
+ [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
+ AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
+ AcknowledgementMode ackMode)
+ {
+ try
+ {
+ using (IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(ackMode))
+ {
+ ITopic topic = (ITopic) CreateDestination(session, DestinationType.Topic);
+ IMessageProducer producer = session.CreateProducer(topic);
+ IMessageConsumer consumer = session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID,
+ "color='red'", false);
- try
- {
- RegisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_DURABLE_TOPIC, TEST_CLIENT_AND_CONSUMER_ID, null, false);
- RunTestDurableConsumer(TEST_DURABLE_TOPIC, ackMode);
- if(AcknowledgementMode.Transactional == ackMode)
- {
- RunTestDurableConsumer(TEST_DURABLE_TOPIC, ackMode);
- }
- }
- finally
- {
+ producer.DeliveryMode = MsgDeliveryMode.Persistent;
+
+ // Send the messages
+ ITextMessage sendMessage = session.CreateTextMessage("1st");
+ sendMessage.Properties["color"] = "red";
+ producer.Send(sendMessage);
+ if (AcknowledgementMode.Transactional == ackMode)
+ {
+ session.Commit();
+ }
+
+ ITextMessage receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage;
+ Assert.IsNotNull(receiveMsg, "Failed to retrieve 1st durable message.");
+ Assert.AreEqual("1st", receiveMsg.Text);
+ Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode,
+ "NMSDeliveryMode does not match");
+ receiveMsg.Acknowledge();
+ if (AcknowledgementMode.Transactional == ackMode)
+ {
+ session.Commit();
+ }
+
+ // Change the subscription, allowing some time for the Broker to purge the
+ // consumers resources.
+ consumer.Dispose();
+ Thread.Sleep(1000);
+
+ consumer = session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, "color='blue'",
+ false);
+
+ sendMessage = session.CreateTextMessage("2nd");
+ sendMessage.Properties["color"] = "red";
+ producer.Send(sendMessage);
+ sendMessage = session.CreateTextMessage("3rd");
+ sendMessage.Properties["color"] = "blue";
+ producer.Send(sendMessage);
+ if (AcknowledgementMode.Transactional == ackMode)
+ {
+ session.Commit();
+ }
+
+ // Selector should skip the 2nd message.
+ receiveMsg = consumer.Receive(receiveTimeout) as ITextMessage;
+ Assert.IsNotNull(receiveMsg, "Failed to retrieve durable message.");
+ Assert.AreEqual("3rd", receiveMsg.Text, "Retrieved the wrong durable message.");
+ Assert.AreEqual(MsgDeliveryMode.Persistent, receiveMsg.NMSDeliveryMode,
+ "NMSDeliveryMode does not match");
+ receiveMsg.Acknowledge();
+ if (AcknowledgementMode.Transactional == ackMode)
+ {
+ session.Commit();
+ }
+
+ // Make sure there are no pending messages.
+ Assert.IsNull(consumer.ReceiveNoWait(), "Wrong number of messages in durable subscription.");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Assert.Fail(ex.Message);
+ }
+ finally
+ {
// Pause to allow Stomp to unregister at the broker.
Thread.Sleep(500);
-
- UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
- }
- }
- protected void RunTestDurableConsumer(string topicName, AcknowledgementMode ackMode)
- {
- SendDurableMessage(topicName);
- SendDurableMessage(topicName);
+ UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
+ }
+ }
- using(IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
- {
- ITopic topic = SessionUtil.GetTopic(session, topicName);
- using(IMessageConsumer consumer = session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, null, false))
- {
- IMessage msg = consumer.Receive(receiveTimeout);
- Assert.IsNotNull(msg, "Did not receive first durable message.");
- msg.Acknowledge();
+ [Test]
+ public void TestDurableConsumer(
+ [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge,
+ AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)]
+ AcknowledgementMode ackMode)
+ {
+ string TEST_DURABLE_TOPIC = DURABLE_TOPIC + ":TestDurableConsumer";
- msg = consumer.Receive(receiveTimeout);
- Assert.IsNotNull(msg, "Did not receive second durable message.");
- msg.Acknowledge();
+ try
+ {
+ RegisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_DURABLE_TOPIC, TEST_CLIENT_AND_CONSUMER_ID,
+ null, false);
+ RunTestDurableConsumer(TEST_DURABLE_TOPIC, ackMode);
+ if (AcknowledgementMode.Transactional == ackMode)
+ {
+ RunTestDurableConsumer(TEST_DURABLE_TOPIC, ackMode);
+ }
+ }
+ finally
+ {
+ // Pause to allow Stomp to unregister at the broker.
+ Thread.Sleep(500);
- if(AcknowledgementMode.Transactional == ackMode)
- {
- session.Commit();
- }
- }
- }
- }
- }
+ UnregisterDurableConsumer(TEST_CLIENT_AND_CONSUMER_ID, TEST_CLIENT_AND_CONSUMER_ID);
+ }
+ }
- protected void SendDurableMessage(string topicName)
- {
- using(IConnection connection = CreateConnection(SEND_CLIENT_ID))
- {
- connection.Start();
- using(ISession session = connection.CreateSession())
- {
- ITopic topic = SessionUtil.GetTopic(session, topicName);
- using(IMessageProducer producer = session.CreateProducer(topic))
- {
- ITextMessage message = session.CreateTextMessage("Durable Hello");
+ protected void RunTestDurableConsumer(string topicName, AcknowledgementMode ackMode)
+ {
+ SendDurableMessage(topicName);
+ SendDurableMessage(topicName);
- producer.DeliveryMode = MsgDeliveryMode.Persistent;
- producer.Send(message);
- }
- }
- }
- }
- }
-}
+ using (IConnection connection = CreateConnection(TEST_CLIENT_AND_CONSUMER_ID))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(ackMode))
+ {
+ ITopic topic = SessionUtil.GetTopic(session, topicName);
+ using (IMessageConsumer consumer =
+ session.CreateDurableConsumer(topic, TEST_CLIENT_AND_CONSUMER_ID, null, false))
+ {
+ IMessage msg = consumer.Receive(receiveTimeout);
+ Assert.IsNotNull(msg, "Did not receive first durable message.");
+ msg.Acknowledge();
+
+ msg = consumer.Receive(receiveTimeout);
+ Assert.IsNotNull(msg, "Did not receive second durable message.");
+ msg.Acknowledge();
+
+ if (AcknowledgementMode.Transactional == ackMode)
+ {
+ session.Commit();
+ }
+ }
+ }
+ }
+ }
+
+ protected void SendDurableMessage(string topicName)
+ {
+ using (IConnection connection = CreateConnection(SEND_CLIENT_ID))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession())
+ {
+ ITopic topic = SessionUtil.GetTopic(session, topicName);
+ using (IMessageProducer producer = session.CreateProducer(topic))
+ {
+ ITextMessage message = session.CreateTextMessage("Durable Hello");
+
+ producer.DeliveryMode = MsgDeliveryMode.Persistent;
+ producer.Send(message);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/EndianBinaryReaderTest.cs b/test/nms-api-test/EndianBinaryReaderTest.cs
index 5a90ce0..db99b4c 100644
--- a/test/nms-api-test/EndianBinaryReaderTest.cs
+++ b/test/nms-api-test/EndianBinaryReaderTest.cs
@@ -21,50 +21,55 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class EndianBinaryReaderTest
- {
- public void readString16Helper(byte[] input, char[] expect)
- {
- MemoryStream stream = new MemoryStream(input);
- EndianBinaryReader reader = new EndianBinaryReader(stream);
+ [TestFixture]
+ public class EndianBinaryReaderTest
+ {
+ public void readString16Helper(byte[] input, char[] expect)
+ {
+ MemoryStream stream = new MemoryStream(input);
+ EndianBinaryReader reader = new EndianBinaryReader(stream);
- char[] result = reader.ReadString16().ToCharArray();
+ char[] result = reader.ReadString16().ToCharArray();
- for(int i = 0; i < expect.Length; ++i)
- {
- Assert.AreEqual(expect[i], result[i]);
- }
- }
+ for (int i = 0; i < expect.Length; ++i)
+ {
+ Assert.AreEqual(expect[i], result[i]);
+ }
+ }
- [Test]
- public void testReadString16_1byteUTF8encoding()
- {
- // Test data with 1-byte UTF8 encoding.
- char[] expect = { '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F', '\u0072', '\u006C', '\u0064' };
- byte[] input = { 0x00, 0x0E, 0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 };
+ [Test]
+ public void testReadString16_1byteUTF8encoding()
+ {
+ // Test data with 1-byte UTF8 encoding.
+ char[] expect =
+ {
+ '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F',
+ '\u0072', '\u006C', '\u0064'
+ };
+ byte[] input =
+ {0x00, 0x0E, 0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64};
- readString16Helper(input, expect);
- }
+ readString16Helper(input, expect);
+ }
- [Test]
- public void testReadString16_2byteUTF8encoding()
- {
- // Test data with 2-byte UT8 encoding.
- char[] expect = { '\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6' };
- byte[] input = { 0x00, 0x0A, 0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6 };
- readString16Helper(input, expect);
- }
+ [Test]
+ public void testReadString16_2byteUTF8encoding()
+ {
+ // Test data with 2-byte UT8 encoding.
+ char[] expect = {'\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6'};
+ byte[] input = {0x00, 0x0A, 0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6};
+ readString16Helper(input, expect);
+ }
- [Test]
- public void testReadString16_1byteAnd2byteEmbeddedNULLs()
- {
- // Test data with 1-byte and 2-byte encoding with embedded NULL's.
- char[] expect = { '\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6' };
- byte[] input = { 0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 };
+ [Test]
+ public void testReadString16_1byteAnd2byteEmbeddedNULLs()
+ {
+ // Test data with 1-byte and 2-byte encoding with embedded NULL's.
+ char[] expect = {'\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6'};
+ byte[] input = {0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6};
- readString16Helper(input, expect);
- }
+ readString16Helper(input, expect);
+ }
[Test]
public void testReadString16_UTF8Missing2ndByte()
@@ -73,74 +78,83 @@
}
private void _testReadString16_UTF8Missing2ndByte()
- {
- // Test with bad UTF-8 encoding, missing 2nd byte of two byte value
- byte[] input = { 0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xC2, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 };
+ {
+ // Test with bad UTF-8 encoding, missing 2nd byte of two byte value
+ byte[] input = {0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xC2, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6};
- MemoryStream stream = new MemoryStream(input);
- EndianBinaryReader reader = new EndianBinaryReader(stream);
+ MemoryStream stream = new MemoryStream(input);
+ EndianBinaryReader reader = new EndianBinaryReader(stream);
- reader.ReadString16();
- }
+ reader.ReadString16();
+ }
- [Test]
+ [Test]
public void testReadString16_3byteEncodingMissingLastByte()
{
Assert.Throws<IOException>(_testReadString16_3byteEncodingMissingLastByte);
}
private void _testReadString16_3byteEncodingMissingLastByte()
- {
- // Test with three byte encode that's missing a last byte.
- byte[] input = { 0x00, 0x02, 0xE8, 0xA8 };
+ {
+ // Test with three byte encode that's missing a last byte.
+ byte[] input = {0x00, 0x02, 0xE8, 0xA8};
- MemoryStream stream = new MemoryStream(input);
- EndianBinaryReader reader = new EndianBinaryReader(stream);
+ MemoryStream stream = new MemoryStream(input);
+ EndianBinaryReader reader = new EndianBinaryReader(stream);
- reader.ReadString16();
- }
+ reader.ReadString16();
+ }
- public void readString32Helper(byte[] input, char[] expect)
- {
- MemoryStream stream = new MemoryStream(input);
- EndianBinaryReader reader = new EndianBinaryReader(stream);
+ public void readString32Helper(byte[] input, char[] expect)
+ {
+ MemoryStream stream = new MemoryStream(input);
+ EndianBinaryReader reader = new EndianBinaryReader(stream);
- char[] result = reader.ReadString32().ToCharArray();
+ char[] result = reader.ReadString32().ToCharArray();
- for(int i = 0; i < expect.Length; ++i)
- {
- Assert.AreEqual(expect[i], result[i]);
- }
- }
+ for (int i = 0; i < expect.Length; ++i)
+ {
+ Assert.AreEqual(expect[i], result[i]);
+ }
+ }
- [Test]
- public void testReadString32_1byteUTF8encoding()
- {
- // Test data with 1-byte UTF8 encoding.
- char[] expect = { '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F', '\u0072', '\u006C', '\u0064' };
- byte[] input = { 0x00, 0x00, 0x00, 0x0E, 0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 };
+ [Test]
+ public void testReadString32_1byteUTF8encoding()
+ {
+ // Test data with 1-byte UTF8 encoding.
+ char[] expect =
+ {
+ '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F',
+ '\u0072', '\u006C', '\u0064'
+ };
+ byte[] input =
+ {
+ 0x00, 0x00, 0x00, 0x0E, 0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C,
+ 0x64
+ };
- readString32Helper(input, expect);
- }
+ readString32Helper(input, expect);
+ }
- [Test]
- public void testReadString32_2byteUTF8encoding()
- {
- // Test data with 2-byte UT8 encoding.
- char[] expect = { '\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6' };
- byte[] input = { 0x00, 0x00, 0x00, 0x0A, 0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6 };
- readString32Helper(input, expect);
- }
+ [Test]
+ public void testReadString32_2byteUTF8encoding()
+ {
+ // Test data with 2-byte UT8 encoding.
+ char[] expect = {'\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6'};
+ byte[] input = {0x00, 0x00, 0x00, 0x0A, 0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6};
+ readString32Helper(input, expect);
+ }
- [Test]
- public void testReadString32_1byteAnd2byteEmbeddedNULLs()
- {
- // Test data with 1-byte and 2-byte encoding with embedded NULL's.
- char[] expect = { '\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6' };
- byte[] input = { 0x00, 0x00, 0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 };
+ [Test]
+ public void testReadString32_1byteAnd2byteEmbeddedNULLs()
+ {
+ // Test data with 1-byte and 2-byte encoding with embedded NULL's.
+ char[] expect = {'\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6'};
+ byte[] input =
+ {0x00, 0x00, 0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6};
- readString32Helper(input, expect);
- }
+ readString32Helper(input, expect);
+ }
[Test]
public void testReadString32_UTF8Missing2ndByte()
@@ -149,32 +163,32 @@
}
private void _testReadString32_UTF8Missing2ndByte()
- {
-
+ {
// Test with bad UTF-8 encoding, missing 2nd byte of two byte value
- byte[] input = { 0x00, 0x00, 0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xC2, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 };
+ byte[] input =
+ {0x00, 0x00, 0x00, 0x0D, 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xC2, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6};
- MemoryStream stream = new MemoryStream(input);
- EndianBinaryReader reader = new EndianBinaryReader(stream);
+ MemoryStream stream = new MemoryStream(input);
+ EndianBinaryReader reader = new EndianBinaryReader(stream);
- reader.ReadString32();
- }
+ reader.ReadString32();
+ }
- [Test]
+ [Test]
public void testReadString32_3byteEncodingMissingLastByte()
{
Assert.Throws<IOException>(_testReadString32_3byteEncodingMissingLastByte);
}
private void _testReadString32_3byteEncodingMissingLastByte()
- {
- // Test with three byte encode that's missing a last byte.
- byte[] input = { 0x00, 0x00, 0x00, 0x02, 0xE8, 0xA8 };
+ {
+ // Test with three byte encode that's missing a last byte.
+ byte[] input = {0x00, 0x00, 0x00, 0x02, 0xE8, 0xA8};
- MemoryStream stream = new MemoryStream(input);
- EndianBinaryReader reader = new EndianBinaryReader(stream);
+ MemoryStream stream = new MemoryStream(input);
+ EndianBinaryReader reader = new EndianBinaryReader(stream);
- reader.ReadString32();
- }
- }
-}
+ reader.ReadString32();
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/EndianBinaryWriterTest.cs b/test/nms-api-test/EndianBinaryWriterTest.cs
index 3508962..04e3620 100644
--- a/test/nms-api-test/EndianBinaryWriterTest.cs
+++ b/test/nms-api-test/EndianBinaryWriterTest.cs
@@ -22,189 +22,197 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class EndianBinaryWriterTest
- {
- void writeString16TestHelper(char[] input, byte[] expect)
- {
- MemoryStream stream = new MemoryStream();
- EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+ [TestFixture]
+ public class EndianBinaryWriterTest
+ {
+ void writeString16TestHelper(char[] input, byte[] expect)
+ {
+ MemoryStream stream = new MemoryStream();
+ EndianBinaryWriter writer = new EndianBinaryWriter(stream);
- String str = new String(input);
+ String str = new String(input);
- writer.WriteString16(str);
+ writer.WriteString16(str);
- byte[] result = stream.GetBuffer();
+ byte[] result = stream.GetBuffer();
- Assert.AreEqual(result[0], 0x00);
- Assert.AreEqual(result[1], expect.Length);
+ Assert.AreEqual(result[0], 0x00);
+ Assert.AreEqual(result[1], expect.Length);
- for(int i = 4; i < expect.Length; ++i)
- {
- Assert.AreEqual(result[i], expect[i - 2]);
- }
- }
+ for (int i = 4; i < expect.Length; ++i)
+ {
+ Assert.AreEqual(result[i], expect[i - 2]);
+ }
+ }
- [Test]
- public void testWriteString16_1byteUTF8encoding()
- {
- // Test data with 1-byte UTF8 encoding.
- char[] input = { '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F', '\u0072', '\u006C', '\u0064' };
- byte[] expect = { 0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 };
+ [Test]
+ public void testWriteString16_1byteUTF8encoding()
+ {
+ // Test data with 1-byte UTF8 encoding.
+ char[] input =
+ {
+ '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F',
+ '\u0072', '\u006C', '\u0064'
+ };
+ byte[] expect = {0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64};
- writeString16TestHelper(input, expect);
- }
+ writeString16TestHelper(input, expect);
+ }
- [Test]
- public void testWriteString16_2byteUTF8encoding()
- {
- // Test data with 2-byte UT8 encoding.
- char[] input = { '\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6' };
- byte[] expect = { 0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6 };
+ [Test]
+ public void testWriteString16_2byteUTF8encoding()
+ {
+ // Test data with 2-byte UT8 encoding.
+ char[] input = {'\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6'};
+ byte[] expect = {0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6};
- writeString16TestHelper(input, expect);
- }
+ writeString16TestHelper(input, expect);
+ }
- [Test]
- public void testWriteString16_1byteAnd2byteEmbeddedNULLs()
- {
- // Test data with 1-byte and 2-byte encoding with embedded NULL's.
- char[] input = { '\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6' };
- byte[] expect = { 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 };
+ [Test]
+ public void testWriteString16_1byteAnd2byteEmbeddedNULLs()
+ {
+ // Test data with 1-byte and 2-byte encoding with embedded NULL's.
+ char[] input = {'\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6'};
+ byte[] expect = {0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6};
- writeString16TestHelper(input, expect);
- }
+ writeString16TestHelper(input, expect);
+ }
- [Test]
- public void testWriteString16_nullstring()
- {
- // test that a null string writes no output.
- MemoryStream stream = new MemoryStream();
- EndianBinaryWriter writer = new EndianBinaryWriter(stream);
- writer.WriteString16(null);
- Assert.AreEqual(0, stream.Length);
- }
+ [Test]
+ public void testWriteString16_nullstring()
+ {
+ // test that a null string writes no output.
+ MemoryStream stream = new MemoryStream();
+ EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+ writer.WriteString16(null);
+ Assert.AreEqual(0, stream.Length);
+ }
- [Test]
- public void testWriteString16_emptystring()
- {
- // test that a null string writes no output.
- MemoryStream stream = new MemoryStream();
- EndianBinaryWriter writer = new EndianBinaryWriter(stream);
- writer.WriteString16("");
+ [Test]
+ public void testWriteString16_emptystring()
+ {
+ // test that a null string writes no output.
+ MemoryStream stream = new MemoryStream();
+ EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+ writer.WriteString16("");
- stream.Seek(0, SeekOrigin.Begin);
- EndianBinaryReader reader = new EndianBinaryReader(stream);
- Assert.AreEqual(0, reader.ReadInt16());
- }
+ stream.Seek(0, SeekOrigin.Begin);
+ EndianBinaryReader reader = new EndianBinaryReader(stream);
+ Assert.AreEqual(0, reader.ReadInt16());
+ }
- [Test]
+ [Test]
public void testWriteString16_stringTooLong()
{
Assert.Throws<IOException>(_testWriteString16_stringTooLong);
}
private void _testWriteString16_stringTooLong()
- {
- // String of length 65536 of Null Characters.
- MemoryStream stream = new MemoryStream();
- EndianBinaryWriter writer = new EndianBinaryWriter(stream);
- String testStr = new String('a', 65536);
- writer.Write(testStr);
- }
+ {
+ // String of length 65536 of Null Characters.
+ MemoryStream stream = new MemoryStream();
+ EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+ String testStr = new String('a', 65536);
+ writer.Write(testStr);
+ }
- [Test]
- public void testWriteString16_maxStringLength()
- {
- // String of length 65535 of non Null Characters since Null encodes as UTF-8.
- MemoryStream stream = new MemoryStream();
- EndianBinaryWriter writer = new EndianBinaryWriter(stream);
- String testStr = new String('a', 65535);
- writer.Write(testStr);
- }
+ [Test]
+ public void testWriteString16_maxStringLength()
+ {
+ // String of length 65535 of non Null Characters since Null encodes as UTF-8.
+ MemoryStream stream = new MemoryStream();
+ EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+ String testStr = new String('a', 65535);
+ writer.Write(testStr);
+ }
- [Test]
+ [Test]
public void testWriteString16_invalidEncodingHeader()
{
Assert.Throws<IOException>(_testWriteString16_invalidEncodingHeader);
}
private void _testWriteString16_invalidEncodingHeader()
- {
- // Set one of the 65535 bytes to a value that will result in a 2 byte UTF8 encoded sequence.
- // This will cause the string of length 65535 to have a utf length of 65536.
- MemoryStream stream = new MemoryStream();
- EndianBinaryWriter writer = new EndianBinaryWriter(stream);
- String testStr = new String('a', 65535);
- char[] array = testStr.ToCharArray();
- array[0] = '\u0000';
- testStr = new String(array);
- writer.Write(testStr);
- }
+ {
+ // Set one of the 65535 bytes to a value that will result in a 2 byte UTF8 encoded sequence.
+ // This will cause the string of length 65535 to have a utf length of 65536.
+ MemoryStream stream = new MemoryStream();
+ EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+ String testStr = new String('a', 65535);
+ char[] array = testStr.ToCharArray();
+ array[0] = '\u0000';
+ testStr = new String(array);
+ writer.Write(testStr);
+ }
- void writeString32TestHelper(char[] input, byte[] expect)
- {
- MemoryStream stream = new MemoryStream();
- EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+ void writeString32TestHelper(char[] input, byte[] expect)
+ {
+ MemoryStream stream = new MemoryStream();
+ EndianBinaryWriter writer = new EndianBinaryWriter(stream);
- String str = new String(input);
+ String str = new String(input);
- writer.WriteString32(str);
+ writer.WriteString32(str);
- byte[] result = stream.GetBuffer();
+ byte[] result = stream.GetBuffer();
- Assert.AreEqual(result[0], 0x00);
- Assert.AreEqual(result[1], 0x00);
- Assert.AreEqual(result[2], 0x00);
- Assert.AreEqual(result[3], expect.Length);
+ Assert.AreEqual(result[0], 0x00);
+ Assert.AreEqual(result[1], 0x00);
+ Assert.AreEqual(result[2], 0x00);
+ Assert.AreEqual(result[3], expect.Length);
- for(int i = 4; i < expect.Length; ++i)
- {
- Assert.AreEqual(result[i], expect[i - 4]);
- }
- }
+ for (int i = 4; i < expect.Length; ++i)
+ {
+ Assert.AreEqual(result[i], expect[i - 4]);
+ }
+ }
- [Test]
- public void testWriteString32_1byteUTF8encoding()
- {
- // Test data with 1-byte UTF8 encoding.
- char[] input = { '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F', '\u0072', '\u006C', '\u0064' };
- byte[] expect = { 0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 };
+ [Test]
+ public void testWriteString32_1byteUTF8encoding()
+ {
+ // Test data with 1-byte UTF8 encoding.
+ char[] input =
+ {
+ '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F',
+ '\u0072', '\u006C', '\u0064'
+ };
+ byte[] expect = {0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64};
- writeString32TestHelper(input, expect);
- }
+ writeString32TestHelper(input, expect);
+ }
- [Test]
- public void testWriteString32_2byteUTF8encoding()
- {
- // Test data with 2-byte UT8 encoding.
- char[] input = { '\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6' };
- byte[] expect = { 0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6 };
+ [Test]
+ public void testWriteString32_2byteUTF8encoding()
+ {
+ // Test data with 2-byte UT8 encoding.
+ char[] input = {'\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6'};
+ byte[] expect = {0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6};
- writeString32TestHelper(input, expect);
- }
+ writeString32TestHelper(input, expect);
+ }
- [Test]
- public void testWriteString32_1byteAnd2byteEmbeddedNULLs()
- {
- // Test data with 1-byte and 2-byte encoding with embedded NULL's.
- char[] input = { '\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6' };
- byte[] expect = { 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 };
+ [Test]
+ public void testWriteString32_1byteAnd2byteEmbeddedNULLs()
+ {
+ // Test data with 1-byte and 2-byte encoding with embedded NULL's.
+ char[] input = {'\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6'};
+ byte[] expect = {0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6};
- writeString32TestHelper(input, expect);
- }
+ writeString32TestHelper(input, expect);
+ }
- [Test]
- public void testWriteString32_nullstring()
- {
- // test that a null strings writes a -1
- MemoryStream stream = new MemoryStream();
- EndianBinaryWriter writer = new EndianBinaryWriter(stream);
- writer.WriteString32(null);
+ [Test]
+ public void testWriteString32_nullstring()
+ {
+ // test that a null strings writes a -1
+ MemoryStream stream = new MemoryStream();
+ EndianBinaryWriter writer = new EndianBinaryWriter(stream);
+ writer.WriteString32(null);
- stream.Seek(0, SeekOrigin.Begin);
- EndianBinaryReader reader = new EndianBinaryReader(stream);
- Assert.AreEqual(-1, reader.ReadInt32());
- }
- }
-}
+ stream.Seek(0, SeekOrigin.Begin);
+ EndianBinaryReader reader = new EndianBinaryReader(stream);
+ Assert.AreEqual(-1, reader.ReadInt32());
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/EndianTest.cs b/test/nms-api-test/EndianTest.cs
index ad9ce08..abd138a 100644
--- a/test/nms-api-test/EndianTest.cs
+++ b/test/nms-api-test/EndianTest.cs
@@ -21,111 +21,108 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class EndianTest
- {
- [Test]
- public void TestLongEndian()
- {
- long value = 0x0102030405060708L;
- long newValue = EndianSupport.SwitchEndian(value);
- Assert.AreEqual(0x0807060504030201L, newValue);
- long actual = EndianSupport.SwitchEndian(newValue);
- Assert.AreEqual(value, actual);
- }
+ [TestFixture]
+ public class EndianTest
+ {
+ [Test]
+ public void TestLongEndian()
+ {
+ long value = 0x0102030405060708L;
+ long newValue = EndianSupport.SwitchEndian(value);
+ Assert.AreEqual(0x0807060504030201L, newValue);
+ long actual = EndianSupport.SwitchEndian(newValue);
+ Assert.AreEqual(value, actual);
+ }
- [Test]
- public void TestIntEndian()
- {
- int value = 0x12345678;
- int newValue = EndianSupport.SwitchEndian(value);
- Assert.AreEqual(0x78563412, newValue);
- int actual = EndianSupport.SwitchEndian(newValue);
- Assert.AreEqual(value, actual);
- }
+ [Test]
+ public void TestIntEndian()
+ {
+ int value = 0x12345678;
+ int newValue = EndianSupport.SwitchEndian(value);
+ Assert.AreEqual(0x78563412, newValue);
+ int actual = EndianSupport.SwitchEndian(newValue);
+ Assert.AreEqual(value, actual);
+ }
- [Test]
- public void TestCharEndian()
- {
- char value = 'J';
- char newValue = EndianSupport.SwitchEndian(value);
- char actual = EndianSupport.SwitchEndian(newValue);
- Assert.AreEqual(value, actual);
- }
+ [Test]
+ public void TestCharEndian()
+ {
+ char value = 'J';
+ char newValue = EndianSupport.SwitchEndian(value);
+ char actual = EndianSupport.SwitchEndian(newValue);
+ Assert.AreEqual(value, actual);
+ }
- [Test]
- public void TestShortEndian()
- {
- short value = 0x1234;
- short newValue = EndianSupport.SwitchEndian(value);
- Assert.AreEqual(0x3412, newValue);
- short actual = EndianSupport.SwitchEndian(newValue);
- Assert.AreEqual(value, actual);
- }
+ [Test]
+ public void TestShortEndian()
+ {
+ short value = 0x1234;
+ short newValue = EndianSupport.SwitchEndian(value);
+ Assert.AreEqual(0x3412, newValue);
+ short actual = EndianSupport.SwitchEndian(newValue);
+ Assert.AreEqual(value, actual);
+ }
- [Test]
- public void TestNegativeLongEndian()
- {
- long value = -0x0102030405060708L;
- long newValue = EndianSupport.SwitchEndian(value);
- long actual = EndianSupport.SwitchEndian(newValue);
- Assert.AreEqual(value, actual);
- }
+ [Test]
+ public void TestNegativeLongEndian()
+ {
+ long value = -0x0102030405060708L;
+ long newValue = EndianSupport.SwitchEndian(value);
+ long actual = EndianSupport.SwitchEndian(newValue);
+ Assert.AreEqual(value, actual);
+ }
- [Test]
- public void TestNegativeIntEndian()
- {
- int value = -0x12345678;
- int newValue = EndianSupport.SwitchEndian(value);
- int actual = EndianSupport.SwitchEndian(newValue);
- Assert.AreEqual(value, actual);
- }
+ [Test]
+ public void TestNegativeIntEndian()
+ {
+ int value = -0x12345678;
+ int newValue = EndianSupport.SwitchEndian(value);
+ int actual = EndianSupport.SwitchEndian(newValue);
+ Assert.AreEqual(value, actual);
+ }
- [Test]
- public void TestNegativeShortEndian()
- {
- short value = -0x1234;
- short newValue = EndianSupport.SwitchEndian(value);
- short actual = EndianSupport.SwitchEndian(newValue);
- Assert.AreEqual(value, actual);
- }
+ [Test]
+ public void TestNegativeShortEndian()
+ {
+ short value = -0x1234;
+ short newValue = EndianSupport.SwitchEndian(value);
+ short actual = EndianSupport.SwitchEndian(newValue);
+ Assert.AreEqual(value, actual);
+ }
- [Test]
- public void TestFloatDontNeedEndianSwitch()
- {
- float value = -1.223F;
+ [Test]
+ public void TestFloatDontNeedEndianSwitch()
+ {
+ float value = -1.223F;
- // Convert to int so we can compare to Java version.
- MemoryStream ms = new MemoryStream(4);
- BinaryWriter bw = new BinaryWriter(ms);
- bw.Write(value);
- bw.Close();
- ms = new MemoryStream(ms.ToArray());
- BinaryReader br = new BinaryReader(ms);
+ // Convert to int so we can compare to Java version.
+ MemoryStream ms = new MemoryStream(4);
+ BinaryWriter bw = new BinaryWriter(ms);
+ bw.Write(value);
+ bw.Close();
+ ms = new MemoryStream(ms.ToArray());
+ BinaryReader br = new BinaryReader(ms);
- // System.out.println(Integer.toString(Float.floatToIntBits(-1.223F), 16));
- Assert.AreEqual(-0x406374bc, br.ReadInt32());
- }
+ // System.out.println(Integer.toString(Float.floatToIntBits(-1.223F), 16));
+ Assert.AreEqual(-0x406374bc, br.ReadInt32());
+ }
- [Test]
- public void TestDoublDontNeedEndianSwitch()
- {
- double value = -1.223D;
+ [Test]
+ public void TestDoublDontNeedEndianSwitch()
+ {
+ double value = -1.223D;
- // Convert to int so we can compare to Java version.
- MemoryStream ms = new MemoryStream(4);
- BinaryWriter bw = new BinaryWriter(ms);
- bw.Write(value);
- bw.Close();
- ms = new MemoryStream(ms.ToArray());
- BinaryReader br = new BinaryReader(ms);
- long longVersion = br.ReadInt64();
+ // Convert to int so we can compare to Java version.
+ MemoryStream ms = new MemoryStream(4);
+ BinaryWriter bw = new BinaryWriter(ms);
+ bw.Write(value);
+ bw.Close();
+ ms = new MemoryStream(ms.ToArray());
+ BinaryReader br = new BinaryReader(ms);
+ long longVersion = br.ReadInt64();
- // System.out.println(Long.toString(Double.doubleToLongBits(-1.223D), 16));
- Assert.AreEqual(-0x400c6e978d4fdf3b, longVersion);
- }
- }
-}
-
-
-
+ // System.out.println(Long.toString(Double.doubleToLongBits(-1.223D), 16));
+ Assert.AreEqual(-0x400c6e978d4fdf3b, longVersion);
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/ForgeinMessageTransformationTest.cs b/test/nms-api-test/ForgeinMessageTransformationTest.cs
index ff88ecf..7f19ac5 100644
--- a/test/nms-api-test/ForgeinMessageTransformationTest.cs
+++ b/test/nms-api-test/ForgeinMessageTransformationTest.cs
@@ -16,9 +16,7 @@
*/
using System;
-
using NUnit.Framework;
-
using Apache.NMS.Util;
using Apache.NMS.Commands;
@@ -54,14 +52,14 @@
[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Topic);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Topic);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
try
{
@@ -73,16 +71,19 @@
IMessage message = consumer.Receive(receiveTimeout);
Assert.IsNotNull(message, "No message returned!");
- Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties.");
+ Assert.AreEqual(request.Properties.Count, message.Properties.Count,
+ "Invalid number of properties.");
Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
// use generic API to access entries
- Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties[propertyName],
+ "generic map entry: " + propertyName);
// use type safe APIs
- Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName),
+ "map entry: " + propertyName);
}
- catch(NotSupportedException)
+ catch (NotSupportedException)
{
}
}
@@ -95,14 +96,14 @@
[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Topic);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Topic);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
try
{
@@ -115,19 +116,22 @@
ITextMessage message = consumer.Receive(receiveTimeout) as ITextMessage;
Assert.IsNotNull(message, "No message returned!");
- Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties.");
+ Assert.AreEqual(request.Properties.Count, message.Properties.Count,
+ "Invalid number of properties.");
Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
// Check the body
Assert.AreEqual(textBody, message.Text, "TextMessage body was wrong.");
// use generic API to access entries
- Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties[propertyName],
+ "generic map entry: " + propertyName);
// use type safe APIs
- Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName),
+ "map entry: " + propertyName);
}
- catch(NotSupportedException)
+ catch (NotSupportedException)
{
}
}
@@ -140,14 +144,14 @@
[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Topic);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Topic);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
try
{
@@ -160,7 +164,8 @@
IBytesMessage message = consumer.Receive(receiveTimeout) as IBytesMessage;
Assert.IsNotNull(message, "No message returned!");
- Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties.");
+ Assert.AreEqual(request.Properties.Count, message.Properties.Count,
+ "Invalid number of properties.");
Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
// Check the body
@@ -169,12 +174,14 @@
Assert.AreEqual(bytesContent, content, "BytesMessage body was wrong.");
// use generic API to access entries
- Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties[propertyName],
+ "generic map entry: " + propertyName);
// use type safe APIs
- Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName),
+ "map entry: " + propertyName);
}
- catch(NotSupportedException)
+ catch (NotSupportedException)
{
}
}
@@ -187,14 +194,14 @@
[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Topic);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Topic);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
try
{
@@ -207,20 +214,24 @@
IMapMessage message = consumer.Receive(receiveTimeout) as IMapMessage;
Assert.IsNotNull(message, "No message returned!");
- Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties.");
+ Assert.AreEqual(request.Properties.Count, message.Properties.Count,
+ "Invalid number of properties.");
Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
// Check the body
Assert.AreEqual(request.Body.Count, message.Body.Count);
- Assert.AreEqual(mapElementValue, message.Body[mapElementName], "MapMessage body was wrong.");
+ Assert.AreEqual(mapElementValue, message.Body[mapElementName],
+ "MapMessage body was wrong.");
// use generic API to access entries
- Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties[propertyName],
+ "generic map entry: " + propertyName);
// use type safe APIs
- Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName),
+ "map entry: " + propertyName);
}
- catch(NotSupportedException)
+ catch (NotSupportedException)
{
}
}
@@ -233,14 +244,14 @@
[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection())
+ using (IConnection connection = CreateConnection())
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Topic);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Topic);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
try
{
@@ -267,7 +278,8 @@
IStreamMessage message = consumer.Receive(receiveTimeout) as IStreamMessage;
Assert.IsNotNull(message, "No message returned!");
- Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties.");
+ Assert.AreEqual(request.Properties.Count, message.Properties.Count,
+ "Invalid number of properties.");
Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
// Check the body
@@ -287,19 +299,19 @@
Assert.AreEqual(n, message.ReadDouble(), "Stream Double Value: n");
// use generic API to access entries
- Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties[propertyName],
+ "generic map entry: " + propertyName);
// use type safe APIs
- Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName);
+ Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName),
+ "map entry: " + propertyName);
}
- catch(NotSupportedException)
+ catch (NotSupportedException)
{
}
}
}
}
}
-
}
-}
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/MapMessageTest.cs b/test/nms-api-test/MapMessageTest.cs
index 616872f..82e9330 100644
--- a/test/nms-api-test/MapMessageTest.cs
+++ b/test/nms-api-test/MapMessageTest.cs
@@ -40,20 +40,20 @@
protected float m = 2.1F;
protected double n = 2.3;
protected byte[] o = {1, 2, 3, 4, 5};
-
+
[Test]
public void SendReceiveMapMessage(
[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
IMapMessage request = session.CreateMapMessage();
@@ -123,14 +123,14 @@
[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
try
{
@@ -142,7 +142,7 @@
IDictionary grandChildMap = new Hashtable();
grandChildMap["x"] = "abc";
- grandChildMap["y"] = new ArrayList(new object[] { "a", "b", "c" });
+ grandChildMap["y"] = new ArrayList(new object[] {"a", "b", "c"});
IDictionary nestedMap = new Hashtable();
nestedMap["a"] = "foo";
@@ -151,7 +151,7 @@
nestedMap["d"] = grandChildMap;
request.Body.SetDictionary("mapField", nestedMap);
- request.Body.SetList("listField", new ArrayList(new Object[] { "a", "b", "c" }));
+ request.Body.SetList("listField", new ArrayList(new Object[] {"a", "b", "c"}));
producer.Send(request);
@@ -165,14 +165,16 @@
IDictionary nestedMapResponse = message.Body.GetDictionary("mapField");
Assert.IsNotNull(nestedMapResponse, "Nested map not returned.");
- Assert.AreEqual(nestedMap.Count, nestedMapResponse.Count, "nestedMap: Wrong number of elements");
+ Assert.AreEqual(nestedMap.Count, nestedMapResponse.Count,
+ "nestedMap: Wrong number of elements");
Assert.AreEqual("foo", nestedMapResponse["a"], "nestedMap: a");
Assert.AreEqual(23, nestedMapResponse["b"], "nestedMap: b");
Assert.AreEqual(45, nestedMapResponse["c"], "nestedMap: c");
IDictionary grandChildMapResponse = nestedMapResponse["d"] as IDictionary;
Assert.IsNotNull(grandChildMapResponse, "Grand child map not returned.");
- Assert.AreEqual(grandChildMap.Count, grandChildMapResponse.Count, "grandChildMap: Wrong number of elements");
+ Assert.AreEqual(grandChildMap.Count, grandChildMapResponse.Count,
+ "grandChildMap: Wrong number of elements");
Assert.AreEqual(grandChildMapResponse["x"], "abc", "grandChildMap: x");
IList grandChildList = grandChildMapResponse["y"] as IList;
@@ -184,21 +186,22 @@
IList listFieldResponse = message.Body.GetList("listField");
Assert.IsNotNull(listFieldResponse, "Nested list not returned.");
- Assert.AreEqual(3, listFieldResponse.Count, "listFieldResponse: Wrong number of list elements.");
+ Assert.AreEqual(3, listFieldResponse.Count,
+ "listFieldResponse: Wrong number of list elements.");
Assert.AreEqual("a", listFieldResponse[0], "listFieldResponse: a");
Assert.AreEqual("b", listFieldResponse[1], "listFieldResponse: b");
Assert.AreEqual("c", listFieldResponse[2], "listFieldResponse: c");
}
- catch(NotSupportedException)
- {
- }
- catch(NMSException e)
+ catch (NotSupportedException)
{
- Assert.IsTrue(e.InnerException.GetType() == typeof(NotSupportedException));
+ }
+ catch (NMSException e)
+ {
+ Assert.IsTrue(e.InnerException.GetType() == typeof(NotSupportedException));
}
}
}
}
}
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/MessageSelectorTest.cs b/test/nms-api-test/MessageSelectorTest.cs
index 4208fb4..1822473 100644
--- a/test/nms-api-test/MessageSelectorTest.cs
+++ b/test/nms-api-test/MessageSelectorTest.cs
@@ -22,162 +22,166 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- [Category("LongRunning")]
- public class MessageSelectorTest : NMSTestSupport
- {
- protected const string QUEUE_DESTINATION_NAME = "queue://TEST.MessageSelectorQueue";
- protected const string TOPIC_DESTINATION_NAME = "topic://TEST.MessageSelectorTopic";
+ [TestFixture]
+ [Category("LongRunning")]
+ public class MessageSelectorTest : NMSTestSupport
+ {
+ protected const string QUEUE_DESTINATION_NAME = "queue://TEST.MessageSelectorQueue";
+ protected const string TOPIC_DESTINATION_NAME = "topic://TEST.MessageSelectorTopic";
- private int receivedNonIgnoredMsgCount = 0;
- private int receivedIgnoredMsgCount = 0;
- private bool simulateSlowConsumer = false;
+ private int receivedNonIgnoredMsgCount = 0;
+ private int receivedIgnoredMsgCount = 0;
+ private bool simulateSlowConsumer = false;
- [Test]
- public void FilterIgnoredMessagesTest(
- [Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME)]
- string destinationName)
- {
- simulateSlowConsumer = false;
- RunFilterIgnoredMessagesTest(destinationName);
- }
+ [Test]
+ public void FilterIgnoredMessagesTest(
+ [Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME)]
+ string destinationName)
+ {
+ simulateSlowConsumer = false;
+ RunFilterIgnoredMessagesTest(destinationName);
+ }
- /// <summary>
- /// A slow consumer will trigger the producer flow control on the broker when the destination is
- /// a queue. It will also trigger the consumer flow control by slowing down the feed to all of the
- /// consumers on the queue to only send messages as fast as the slowest consumer can run.
- /// When sending to a topic, the producer will not be slowed down, and consumers will be allowed
- /// to run as fast as they can go.
- /// Since this test can take a long time to run, it is marked as explicit.
- /// </summary>
- /// <param name="destinationName"></param>
- [Test]
- public void FilterIgnoredMessagesSlowConsumerTest(
- [Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME)]
- string destinationName)
- {
- simulateSlowConsumer = true;
- RunFilterIgnoredMessagesTest(destinationName);
- }
+ /// <summary>
+ /// A slow consumer will trigger the producer flow control on the broker when the destination is
+ /// a queue. It will also trigger the consumer flow control by slowing down the feed to all of the
+ /// consumers on the queue to only send messages as fast as the slowest consumer can run.
+ /// When sending to a topic, the producer will not be slowed down, and consumers will be allowed
+ /// to run as fast as they can go.
+ /// Since this test can take a long time to run, it is marked as explicit.
+ /// </summary>
+ /// <param name="destinationName"></param>
+ [Test]
+ public void FilterIgnoredMessagesSlowConsumerTest(
+ [Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME)]
+ string destinationName)
+ {
+ simulateSlowConsumer = true;
+ RunFilterIgnoredMessagesTest(destinationName);
+ }
- public void RunFilterIgnoredMessagesTest(string destinationName)
- {
- TimeSpan ttl = TimeSpan.FromMinutes(30);
- const int MaxNumRequests = 100000;
+ public void RunFilterIgnoredMessagesTest(string destinationName)
+ {
+ TimeSpan ttl = TimeSpan.FromMinutes(30);
+ const int MaxNumRequests = 100000;
- using(IConnection connection1 = CreateConnection(GetTestClientId()))
- using(IConnection connection2 = CreateConnection(GetTestClientId()))
- using(IConnection connection3 = CreateConnection(GetTestClientId()))
- {
- connection1.Start();
- connection2.Start();
- connection3.Start();
- using(ISession session1 = connection1.CreateSession(AcknowledgementMode.AutoAcknowledge))
- using(ISession session2 = connection2.CreateSession(AcknowledgementMode.AutoAcknowledge))
- using(ISession session3 = connection3.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination1 = CreateDestination(session1, destinationName);
- IDestination destination2 = CreateDestination(session2, destinationName);
- IDestination destination3 = CreateDestination(session3, destinationName);
+ using (IConnection connection1 = CreateConnection(GetTestClientId()))
+ using (IConnection connection2 = CreateConnection(GetTestClientId()))
+ using (IConnection connection3 = CreateConnection(GetTestClientId()))
+ {
+ connection1.Start();
+ connection2.Start();
+ connection3.Start();
+ using (ISession session1 = connection1.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session2 = connection2.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session3 = connection3.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination1 = CreateDestination(session1, destinationName);
+ IDestination destination2 = CreateDestination(session2, destinationName);
+ IDestination destination3 = CreateDestination(session3, destinationName);
- using(IMessageProducer producer = session1.CreateProducer(destination1))
- using(IMessageConsumer consumer1 = session2.CreateConsumer(destination2, "JMSType NOT LIKE '%IGNORE'"))
- {
- int numNonIgnoredMsgsSent = 0;
- int numIgnoredMsgsSent = 0;
+ using (IMessageProducer producer = session1.CreateProducer(destination1))
+ using (IMessageConsumer consumer1 =
+ session2.CreateConsumer(destination2, "JMSType NOT LIKE '%IGNORE'"))
+ {
+ int numNonIgnoredMsgsSent = 0;
+ int numIgnoredMsgsSent = 0;
- producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
+ producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
- receivedNonIgnoredMsgCount = 0;
- receivedIgnoredMsgCount = 0;
- consumer1.Listener += new MessageListener(OnNonIgnoredMessage);
- IMessageConsumer consumer2 = null;
+ receivedNonIgnoredMsgCount = 0;
+ receivedIgnoredMsgCount = 0;
+ consumer1.Listener += new MessageListener(OnNonIgnoredMessage);
+ IMessageConsumer consumer2 = null;
- for(int index = 1; index <= MaxNumRequests; index++)
- {
- IMessage request = session1.CreateTextMessage(String.Format("Hello World! [{0} of {1}]", index, MaxNumRequests));
+ for (int index = 1; index <= MaxNumRequests; index++)
+ {
+ IMessage request = session1.CreateTextMessage(String.Format("Hello World! [{0} of {1}]",
+ index, MaxNumRequests));
- request.NMSTimeToLive = ttl;
- if(0 == (index % 2))
- {
- request.NMSType = "ACTIVE";
- numNonIgnoredMsgsSent++;
- }
- else
- {
- request.NMSType = "ACTIVE.IGNORE";
- numIgnoredMsgsSent++;
- }
+ request.NMSTimeToLive = ttl;
+ if (0 == (index % 2))
+ {
+ request.NMSType = "ACTIVE";
+ numNonIgnoredMsgsSent++;
+ }
+ else
+ {
+ request.NMSType = "ACTIVE.IGNORE";
+ numIgnoredMsgsSent++;
+ }
- producer.Send(request);
+ producer.Send(request);
- if(2000 == index)
- {
- // Start the second consumer
- if(destination3.IsTopic)
- {
- // Reset the ignored message sent count, since all previous messages
- // will not have been consumed on a topic.
- numIgnoredMsgsSent = 0;
- }
+ if (2000 == index)
+ {
+ // Start the second consumer
+ if (destination3.IsTopic)
+ {
+ // Reset the ignored message sent count, since all previous messages
+ // will not have been consumed on a topic.
+ numIgnoredMsgsSent = 0;
+ }
- consumer2 = session3.CreateConsumer(destination3, "JMSType LIKE '%IGNORE'");
- consumer2.Listener += new MessageListener(OnIgnoredMessage);
- }
- }
+ consumer2 = session3.CreateConsumer(destination3, "JMSType LIKE '%IGNORE'");
+ consumer2.Listener += new MessageListener(OnIgnoredMessage);
+ }
+ }
- // Create a waiting loop that will coordinate the end of the test. It checks
- // to see that all intended messages were received. It will continue to wait as
- // long as new messages are being received. If it stops receiving messages before
- // it receives everything it expects, it will eventually timeout and the test will fail.
- int waitCount = 0;
- int lastReceivedINongnoredMsgCount = receivedNonIgnoredMsgCount;
- int lastReceivedIgnoredMsgCount = receivedIgnoredMsgCount;
+ // Create a waiting loop that will coordinate the end of the test. It checks
+ // to see that all intended messages were received. It will continue to wait as
+ // long as new messages are being received. If it stops receiving messages before
+ // it receives everything it expects, it will eventually timeout and the test will fail.
+ int waitCount = 0;
+ int lastReceivedINongnoredMsgCount = receivedNonIgnoredMsgCount;
+ int lastReceivedIgnoredMsgCount = receivedIgnoredMsgCount;
- while(receivedNonIgnoredMsgCount < numNonIgnoredMsgsSent
- || receivedIgnoredMsgCount < numIgnoredMsgsSent)
- {
- if(lastReceivedINongnoredMsgCount != receivedNonIgnoredMsgCount
- || lastReceivedIgnoredMsgCount != receivedIgnoredMsgCount)
- {
- // Reset the wait count.
- waitCount = 0;
- }
- else
- {
- waitCount++;
- }
+ while (receivedNonIgnoredMsgCount < numNonIgnoredMsgsSent
+ || receivedIgnoredMsgCount < numIgnoredMsgsSent)
+ {
+ if (lastReceivedINongnoredMsgCount != receivedNonIgnoredMsgCount
+ || lastReceivedIgnoredMsgCount != receivedIgnoredMsgCount)
+ {
+ // Reset the wait count.
+ waitCount = 0;
+ }
+ else
+ {
+ waitCount++;
+ }
- lastReceivedINongnoredMsgCount = receivedNonIgnoredMsgCount;
- lastReceivedIgnoredMsgCount = receivedIgnoredMsgCount;
+ lastReceivedINongnoredMsgCount = receivedNonIgnoredMsgCount;
+ lastReceivedIgnoredMsgCount = receivedIgnoredMsgCount;
- Assert.IsTrue(waitCount <= 30, String.Format("Timeout waiting for all messages to be delivered. Only {0} of {1} non-ignored messages delivered. Only {2} of {3} ignored messages delivered.",
- receivedNonIgnoredMsgCount, numNonIgnoredMsgsSent, receivedIgnoredMsgCount, numIgnoredMsgsSent));
- Thread.Sleep(1000);
- }
+ Assert.IsTrue(waitCount <= 30, String.Format(
+ "Timeout waiting for all messages to be delivered. Only {0} of {1} non-ignored messages delivered. Only {2} of {3} ignored messages delivered.",
+ receivedNonIgnoredMsgCount, numNonIgnoredMsgsSent, receivedIgnoredMsgCount,
+ numIgnoredMsgsSent));
+ Thread.Sleep(1000);
+ }
- consumer2.Dispose();
- }
- }
- }
- }
+ consumer2.Dispose();
+ }
+ }
+ }
+ }
- protected void OnNonIgnoredMessage(IMessage message)
- {
- receivedNonIgnoredMsgCount++;
- Assert.AreEqual(message.NMSType, "ACTIVE");
- }
+ protected void OnNonIgnoredMessage(IMessage message)
+ {
+ receivedNonIgnoredMsgCount++;
+ Assert.AreEqual(message.NMSType, "ACTIVE");
+ }
- protected void OnIgnoredMessage(IMessage message)
- {
- receivedIgnoredMsgCount++;
- Assert.AreEqual(message.NMSType, "ACTIVE.IGNORE");
- if(simulateSlowConsumer)
- {
- // Simulate a slow consumer It doesn't have to be too slow in a high speed environment
- // in order to trigger producer flow control.
- Thread.Sleep(10);
- }
- }
- }
-}
+ protected void OnIgnoredMessage(IMessage message)
+ {
+ receivedIgnoredMsgCount++;
+ Assert.AreEqual(message.NMSType, "ACTIVE.IGNORE");
+ if (simulateSlowConsumer)
+ {
+ // Simulate a slow consumer It doesn't have to be too slow in a high speed environment
+ // in order to trigger producer flow control.
+ Thread.Sleep(10);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/MessageTest.cs b/test/nms-api-test/MessageTest.cs
index 7c76eff..26a1493 100644
--- a/test/nms-api-test/MessageTest.cs
+++ b/test/nms-api-test/MessageTest.cs
@@ -16,130 +16,128 @@
*/
using System;
-
using Apache.NMS.Util;
-
using NUnit.Framework;
namespace Apache.NMS.Test
{
- [TestFixture]
- public class MessageTest : NMSTestSupport
- {
- protected bool a = true;
- protected byte b = 123;
- protected char c = 'c';
- protected short d = 0x1234;
- protected int e = 0x12345678;
- protected long f = 0x1234567812345678;
- protected string g = "Hello World!";
- protected bool h = false;
- protected byte i = 0xFF;
- protected short j = -0x1234;
- protected int k = -0x12345678;
- protected long l = -0x1234567812345678;
- protected float m = 2.1F;
- protected double n = 2.3;
- protected byte[] o = {1, 2, 3, 4, 5};
+ [TestFixture]
+ public class MessageTest : NMSTestSupport
+ {
+ protected bool a = true;
+ protected byte b = 123;
+ protected char c = 'c';
+ protected short d = 0x1234;
+ protected int e = 0x12345678;
+ protected long f = 0x1234567812345678;
+ protected string g = "Hello World!";
+ protected bool h = false;
+ protected byte i = 0xFF;
+ protected short j = -0x1234;
+ protected int k = -0x12345678;
+ protected long l = -0x1234567812345678;
+ protected float m = 2.1F;
+ protected double n = 2.3;
+ protected byte[] o = {1, 2, 3, 4, 5};
- [Test]
- public void SendReceiveMessageProperties(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnection(GetTestClientId()))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
- IMessage request = session.CreateMessage();
- request.Properties["a"] = a;
- request.Properties["b"] = b;
- request.Properties["c"] = c;
- request.Properties["d"] = d;
- request.Properties["e"] = e;
- request.Properties["f"] = f;
- request.Properties["g"] = g;
- request.Properties["h"] = h;
- request.Properties["i"] = i;
- request.Properties["j"] = j;
- request.Properties["k"] = k;
- request.Properties["l"] = l;
- request.Properties["m"] = m;
- request.Properties["n"] = n;
-
- try
- {
- request.Properties["o"] = o;
- Assert.Fail("Should not be able to add a Byte[] to the Properties of a Message.");
- }
- catch
- {
- // Expected
- }
-
- try
- {
- request.Properties.SetBytes("o", o);
- Assert.Fail("Should not be able to add a Byte[] to the Properties of a Message.");
- }
- catch
- {
- // Expected
- }
-
- producer.Send(request);
+ [Test]
+ public void SendReceiveMessageProperties(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
+ IMessage request = session.CreateMessage();
+ request.Properties["a"] = a;
+ request.Properties["b"] = b;
+ request.Properties["c"] = c;
+ request.Properties["d"] = d;
+ request.Properties["e"] = e;
+ request.Properties["f"] = f;
+ request.Properties["g"] = g;
+ request.Properties["h"] = h;
+ request.Properties["i"] = i;
+ request.Properties["j"] = j;
+ request.Properties["k"] = k;
+ request.Properties["l"] = l;
+ request.Properties["m"] = m;
+ request.Properties["n"] = n;
- IMessage message = consumer.Receive(receiveTimeout);
- Assert.IsNotNull(message, "No message returned!");
- Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties.");
- Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
- Assert.AreEqual(ToHex(f), ToHex(message.Properties.GetLong("f")), "map entry: f as hex");
+ try
+ {
+ request.Properties["o"] = o;
+ Assert.Fail("Should not be able to add a Byte[] to the Properties of a Message.");
+ }
+ catch
+ {
+ // Expected
+ }
- // use generic API to access entries
- // Perform a string only comparison here since some NMS providers are type limited and
- // may return only a string instance from the generic [] accessor. Each provider should
- // further test this functionality to determine that the correct type is returned if
- // it is capable of doing so.
- Assert.AreEqual(a.ToString(), message.Properties["a"].ToString(), "generic map entry: a");
- Assert.AreEqual(b.ToString(), message.Properties["b"].ToString(), "generic map entry: b");
- Assert.AreEqual(c.ToString(), message.Properties["c"].ToString(), "generic map entry: c");
- Assert.AreEqual(d.ToString(), message.Properties["d"].ToString(), "generic map entry: d");
- Assert.AreEqual(e.ToString(), message.Properties["e"].ToString(), "generic map entry: e");
- Assert.AreEqual(f.ToString(), message.Properties["f"].ToString(), "generic map entry: f");
- Assert.AreEqual(g.ToString(), message.Properties["g"].ToString(), "generic map entry: g");
- Assert.AreEqual(h.ToString(), message.Properties["h"].ToString(), "generic map entry: h");
- Assert.AreEqual(i.ToString(), message.Properties["i"].ToString(), "generic map entry: i");
- Assert.AreEqual(j.ToString(), message.Properties["j"].ToString(), "generic map entry: j");
- Assert.AreEqual(k.ToString(), message.Properties["k"].ToString(), "generic map entry: k");
- Assert.AreEqual(l.ToString(), message.Properties["l"].ToString(), "generic map entry: l");
- Assert.AreEqual(m.ToString(), message.Properties["m"].ToString(), "generic map entry: m");
- Assert.AreEqual(n.ToString(), message.Properties["n"].ToString(), "generic map entry: n");
+ try
+ {
+ request.Properties.SetBytes("o", o);
+ Assert.Fail("Should not be able to add a Byte[] to the Properties of a Message.");
+ }
+ catch
+ {
+ // Expected
+ }
- // use type safe APIs
- Assert.AreEqual(a, message.Properties.GetBool("a"), "map entry: a");
- Assert.AreEqual(b, message.Properties.GetByte("b"), "map entry: b");
- Assert.AreEqual(c, message.Properties.GetChar("c"), "map entry: c");
- Assert.AreEqual(d, message.Properties.GetShort("d"), "map entry: d");
- Assert.AreEqual(e, message.Properties.GetInt("e"), "map entry: e");
- Assert.AreEqual(f, message.Properties.GetLong("f"), "map entry: f");
- Assert.AreEqual(g, message.Properties.GetString("g"), "map entry: g");
- Assert.AreEqual(h, message.Properties.GetBool("h"), "map entry: h");
- Assert.AreEqual(i, message.Properties.GetByte("i"), "map entry: i");
- Assert.AreEqual(j, message.Properties.GetShort("j"), "map entry: j");
- Assert.AreEqual(k, message.Properties.GetInt("k"), "map entry: k");
- Assert.AreEqual(l, message.Properties.GetLong("l"), "map entry: l");
- Assert.AreEqual(m, message.Properties.GetFloat("m"), "map entry: m");
- Assert.AreEqual(n, message.Properties.GetDouble("n"), "map entry: n");
- }
- }
- }
- }
- }
-}
+ producer.Send(request);
+ IMessage message = consumer.Receive(receiveTimeout);
+ Assert.IsNotNull(message, "No message returned!");
+ Assert.AreEqual(request.Properties.Count, message.Properties.Count,
+ "Invalid number of properties.");
+ Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
+ Assert.AreEqual(ToHex(f), ToHex(message.Properties.GetLong("f")), "map entry: f as hex");
+
+ // use generic API to access entries
+ // Perform a string only comparison here since some NMS providers are type limited and
+ // may return only a string instance from the generic [] accessor. Each provider should
+ // further test this functionality to determine that the correct type is returned if
+ // it is capable of doing so.
+ Assert.AreEqual(a.ToString(), message.Properties["a"].ToString(), "generic map entry: a");
+ Assert.AreEqual(b.ToString(), message.Properties["b"].ToString(), "generic map entry: b");
+ Assert.AreEqual(c.ToString(), message.Properties["c"].ToString(), "generic map entry: c");
+ Assert.AreEqual(d.ToString(), message.Properties["d"].ToString(), "generic map entry: d");
+ Assert.AreEqual(e.ToString(), message.Properties["e"].ToString(), "generic map entry: e");
+ Assert.AreEqual(f.ToString(), message.Properties["f"].ToString(), "generic map entry: f");
+ Assert.AreEqual(g.ToString(), message.Properties["g"].ToString(), "generic map entry: g");
+ Assert.AreEqual(h.ToString(), message.Properties["h"].ToString(), "generic map entry: h");
+ Assert.AreEqual(i.ToString(), message.Properties["i"].ToString(), "generic map entry: i");
+ Assert.AreEqual(j.ToString(), message.Properties["j"].ToString(), "generic map entry: j");
+ Assert.AreEqual(k.ToString(), message.Properties["k"].ToString(), "generic map entry: k");
+ Assert.AreEqual(l.ToString(), message.Properties["l"].ToString(), "generic map entry: l");
+ Assert.AreEqual(m.ToString(), message.Properties["m"].ToString(), "generic map entry: m");
+ Assert.AreEqual(n.ToString(), message.Properties["n"].ToString(), "generic map entry: n");
+
+ // use type safe APIs
+ Assert.AreEqual(a, message.Properties.GetBool("a"), "map entry: a");
+ Assert.AreEqual(b, message.Properties.GetByte("b"), "map entry: b");
+ Assert.AreEqual(c, message.Properties.GetChar("c"), "map entry: c");
+ Assert.AreEqual(d, message.Properties.GetShort("d"), "map entry: d");
+ Assert.AreEqual(e, message.Properties.GetInt("e"), "map entry: e");
+ Assert.AreEqual(f, message.Properties.GetLong("f"), "map entry: f");
+ Assert.AreEqual(g, message.Properties.GetString("g"), "map entry: g");
+ Assert.AreEqual(h, message.Properties.GetBool("h"), "map entry: h");
+ Assert.AreEqual(i, message.Properties.GetByte("i"), "map entry: i");
+ Assert.AreEqual(j, message.Properties.GetShort("j"), "map entry: j");
+ Assert.AreEqual(k, message.Properties.GetInt("k"), "map entry: k");
+ Assert.AreEqual(l, message.Properties.GetLong("l"), "map entry: l");
+ Assert.AreEqual(m, message.Properties.GetFloat("m"), "map entry: m");
+ Assert.AreEqual(n, message.Properties.GetDouble("n"), "map entry: n");
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/MessageTransformerTest.cs b/test/nms-api-test/MessageTransformerTest.cs
index 992fdc3..5b0f6e0 100644
--- a/test/nms-api-test/MessageTransformerTest.cs
+++ b/test/nms-api-test/MessageTransformerTest.cs
@@ -16,35 +16,33 @@
*/
using System;
-
using Apache.NMS.Util;
-
using NUnit.Framework;
namespace Apache.NMS.Test
{
- [TestFixture]
- public class MessageTransformerTest : NMSTestSupport
- {
- private string propertyName = "ADDITIONAL-PROPERTY";
- private string propertyValue = "ADDITIONAL-PROPERTY-VALUE";
-
- [Test]
- public void TestProducerTransformer(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnection())
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination = session.CreateTemporaryTopic();
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
- producer.ProducerTransformer = DoProducerTransform;
+ [TestFixture]
+ public class MessageTransformerTest : NMSTestSupport
+ {
+ private string propertyName = "ADDITIONAL-PROPERTY";
+ private string propertyValue = "ADDITIONAL-PROPERTY-VALUE";
+
+ [Test]
+ public void TestProducerTransformer(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnection())
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = session.CreateTemporaryTopic();
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
+ producer.ProducerTransformer = DoProducerTransform;
IMessage message = session.CreateMessage();
@@ -59,28 +57,28 @@
Assert.AreEqual("Value", message.Properties["Test"]);
Assert.AreEqual(propertyValue, message.Properties[propertyName]);
- }
- }
- }
- }
-
- [Test]
- public void TestConsumerTransformer(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnection())
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination = session.CreateTemporaryTopic();
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
+ }
+ }
+ }
+ }
- consumer.ConsumerTransformer = DoConsumerTransform;
+ [Test]
+ public void TestConsumerTransformer(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnection())
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = session.CreateTemporaryTopic();
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
+
+ consumer.ConsumerTransformer = DoConsumerTransform;
IMessage message = session.CreateMessage();
@@ -96,27 +94,26 @@
Assert.AreEqual("Value", message.Properties["Test"], "Propert 'Value' was incorrect");
Assert.AreEqual(propertyValue, message.Properties[propertyName], "Property not inserted");
}
- }
- }
- }
-
- private IMessage DoProducerTransform(ISession session, IMessageProducer producer, IMessage message)
- {
- message.Properties[propertyName] = propertyValue;
-
- return message;
- }
+ }
+ }
+ }
- private IMessage DoConsumerTransform(ISession session, IMessageConsumer consumer, IMessage message)
- {
+ private IMessage DoProducerTransform(ISession session, IMessageProducer producer, IMessage message)
+ {
+ message.Properties[propertyName] = propertyValue;
+
+ return message;
+ }
+
+ private IMessage DoConsumerTransform(ISession session, IMessageConsumer consumer, IMessage message)
+ {
IMessage newMessage = session.CreateMessage();
MessageTransformation.CopyNMSMessageProperties(message, newMessage);
- newMessage.Properties[propertyName] = propertyValue;
+ newMessage.Properties[propertyName] = propertyValue;
- return newMessage;
- }
- }
-}
-
+ return newMessage;
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/NMSPropertyTest.cs b/test/nms-api-test/NMSPropertyTest.cs
index ef22756..20085cd 100644
--- a/test/nms-api-test/NMSPropertyTest.cs
+++ b/test/nms-api-test/NMSPropertyTest.cs
@@ -21,58 +21,58 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class NMSPropertyTest : NMSTestSupport
- {
- // standard NMS properties
- protected string expectedText = "Hey this works!";
- protected string correlationID = "FooBar";
- protected MsgPriority priority = MsgPriority.Normal;
- protected String type = "FooType";
- protected String groupID = "BarGroup";
- protected int groupSeq = 1;
+ [TestFixture]
+ public class NMSPropertyTest : NMSTestSupport
+ {
+ // standard NMS properties
+ protected string expectedText = "Hey this works!";
+ protected string correlationID = "FooBar";
+ protected MsgPriority priority = MsgPriority.Normal;
+ protected String type = "FooType";
+ protected String groupID = "BarGroup";
+ protected int groupSeq = 1;
- [Test]
- public void SendReceiveNMSProperties(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnection(GetTestClientId()))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.Priority = priority;
- producer.DeliveryMode = deliveryMode;
- ITextMessage request = session.CreateTextMessage(expectedText);
+ [Test]
+ public void SendReceiveNMSProperties(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.Priority = priority;
+ producer.DeliveryMode = deliveryMode;
+ ITextMessage request = session.CreateTextMessage(expectedText);
- // Set the headers
- request.NMSCorrelationID = correlationID;
- request.NMSType = type;
- request.Properties["NMSXGroupID"] = groupID;
- request.Properties["NMSXGroupSeq"] = groupSeq;
+ // Set the headers
+ request.NMSCorrelationID = correlationID;
+ request.NMSType = type;
+ request.Properties["NMSXGroupID"] = groupID;
+ request.Properties["NMSXGroupSeq"] = groupSeq;
- producer.Send(request);
+ producer.Send(request);
- ITextMessage message = consumer.Receive(receiveTimeout) as ITextMessage;
+ ITextMessage message = consumer.Receive(receiveTimeout) as ITextMessage;
- Assert.IsNotNull(message, "Did not receive an ITextMessage!");
- Assert.AreEqual(expectedText, message.Text, "Message text does not match.");
+ Assert.IsNotNull(message, "Did not receive an ITextMessage!");
+ Assert.AreEqual(expectedText, message.Text, "Message text does not match.");
- // compare standard NMS headers
- Assert.AreEqual(correlationID, message.NMSCorrelationID, "NMSCorrelationID does not match");
- Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
- Assert.AreEqual(priority, message.NMSPriority, "NMSPriority does not match");
- Assert.AreEqual(type, message.NMSType, "NMSType does not match");
- Assert.AreEqual(groupID, message.Properties["NMSXGroupID"], "NMSXGroupID does not match");
- Assert.AreEqual(groupSeq, message.Properties["NMSXGroupSeq"], "NMSXGroupSeq does not match");
- }
- }
- }
- }
- }
-}
+ // compare standard NMS headers
+ Assert.AreEqual(correlationID, message.NMSCorrelationID, "NMSCorrelationID does not match");
+ Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
+ Assert.AreEqual(priority, message.NMSPriority, "NMSPriority does not match");
+ Assert.AreEqual(type, message.NMSType, "NMSType does not match");
+ Assert.AreEqual(groupID, message.Properties["NMSXGroupID"], "NMSXGroupID does not match");
+ Assert.AreEqual(groupSeq, message.Properties["NMSXGroupSeq"], "NMSXGroupSeq does not match");
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/NMSTestSupport.cs b/test/nms-api-test/NMSTestSupport.cs
index bd1749c..52ca9f4 100644
--- a/test/nms-api-test/NMSTestSupport.cs
+++ b/test/nms-api-test/NMSTestSupport.cs
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
using System;
using System.Collections;
using System.IO;
@@ -25,595 +26,610 @@
namespace Apache.NMS.Test
{
- /// <summary>
- /// useful base class for test cases
- /// </summary>
- public abstract class NMSTestSupport
- {
- private NMSConnectionFactory NMSFactory;
- protected TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(15000);
- protected string clientId;
- protected string passWord;
- protected string userName;
- protected int testRun;
- protected int idCounter;
+ /// <summary>
+ /// useful base class for test cases
+ /// </summary>
+ public abstract class NMSTestSupport
+ {
+ private NMSConnectionFactory NMSFactory;
+ protected TimeSpan receiveTimeout = TimeSpan.FromMilliseconds(15000);
+ protected string clientId;
+ protected string passWord;
+ protected string userName;
+ protected int testRun;
+ protected int idCounter;
- static NMSTestSupport()
- {
- Apache.NMS.Tracer.Trace = new NmsTracer();
- }
+ static NMSTestSupport()
+ {
+ Apache.NMS.Tracer.Trace = new NmsTracer();
+ }
- public NMSTestSupport()
- {
- }
+ public NMSTestSupport()
+ {
+ }
- [SetUp]
- public virtual void SetUp()
- {
- this.testRun++;
- }
+ [SetUp]
+ public virtual void SetUp()
+ {
+ this.testRun++;
+ }
- [TearDown]
- public virtual void TearDown()
- {
- }
+ [TearDown]
+ public virtual void TearDown()
+ {
+ }
- // Properties
+ // Properties
- /// <summary>
- /// The connection factory interface property.
- /// </summary>
- public IConnectionFactory Factory
- {
- get
- {
- if(null == NMSFactory)
- {
- Assert.IsTrue(CreateNMSFactory(), "Error creating factory.");
- }
+ /// <summary>
+ /// The connection factory interface property.
+ /// </summary>
+ public IConnectionFactory Factory
+ {
+ get
+ {
+ if (null == NMSFactory)
+ {
+ Assert.IsTrue(CreateNMSFactory(), "Error creating factory.");
+ }
- return NMSFactory.ConnectionFactory;
- }
- }
+ return NMSFactory.ConnectionFactory;
+ }
+ }
- /// <summary>
- /// Name of the connection configuration filename.
- /// </summary>
- /// <returns></returns>
- protected virtual string GetConnectionConfigFileName() { return "nmsprovider-test.config"; }
+ /// <summary>
+ /// Name of the connection configuration filename.
+ /// </summary>
+ /// <returns></returns>
+ protected virtual string GetConnectionConfigFileName()
+ {
+ return "nmsprovider-test.config";
+ }
- /// <summary>
- /// The name of the connection configuration that CreateNMSFactory() will load.
- /// </summary>
- /// <returns></returns>
- protected virtual string GetNameTestURI() { return "defaultURI"; }
+ /// <summary>
+ /// The name of the connection configuration that CreateNMSFactory() will load.
+ /// </summary>
+ /// <returns></returns>
+ protected virtual string GetNameTestURI()
+ {
+ return "defaultURI";
+ }
- /// <summary>
- /// Create the NMS Factory that can create NMS Connections.
- /// </summary>
- /// <returns></returns>
- protected bool CreateNMSFactory()
- {
- return CreateNMSFactory(GetNameTestURI());
- }
+ /// <summary>
+ /// Create the NMS Factory that can create NMS Connections.
+ /// </summary>
+ /// <returns></returns>
+ protected bool CreateNMSFactory()
+ {
+ return CreateNMSFactory(GetNameTestURI());
+ }
- /// <summary>
- /// Return the configured URI String. This function loads the connection
- /// settings from the configuration file.
- /// </summary>
- /// <returns></returns>
- protected string GetConfiguredConnectionURI()
- {
- Uri brokerUri = null;
- string[] paths = GetConfigSearchPaths();
- string connectionConfigFileName = GetConnectionConfigFileName();
- bool configFound = false;
+ /// <summary>
+ /// Return the configured URI String. This function loads the connection
+ /// settings from the configuration file.
+ /// </summary>
+ /// <returns></returns>
+ protected string GetConfiguredConnectionURI()
+ {
+ Uri brokerUri = null;
+ string[] paths = GetConfigSearchPaths();
+ string connectionConfigFileName = GetConnectionConfigFileName();
+ bool configFound = false;
- foreach(string path in paths)
- {
- string fullpath = Path.Combine(path, connectionConfigFileName);
- Tracer.Debug("\tScanning folder: " + path);
+ foreach (string path in paths)
+ {
+ string fullpath = Path.Combine(path, connectionConfigFileName);
+ Tracer.Debug("\tScanning folder: " + path);
- if(File.Exists(fullpath))
- {
- Tracer.Debug("\tAssembly found!");
- connectionConfigFileName = fullpath;
- configFound = true;
- break;
- }
- }
+ if (File.Exists(fullpath))
+ {
+ Tracer.Debug("\tAssembly found!");
+ connectionConfigFileName = fullpath;
+ configFound = true;
+ break;
+ }
+ }
- Assert.IsTrue(configFound, "Connection configuration file does not exist.");
- XmlDocument configDoc = new XmlDocument();
+ Assert.IsTrue(configFound, "Connection configuration file does not exist.");
+ XmlDocument configDoc = new XmlDocument();
- configDoc.Load(connectionConfigFileName);
- XmlElement uriNode = (XmlElement) configDoc.SelectSingleNode(String.Format("/configuration/{0}", GetNameTestURI()));
+ configDoc.Load(connectionConfigFileName);
+ XmlElement uriNode =
+ (XmlElement) configDoc.SelectSingleNode(String.Format("/configuration/{0}", GetNameTestURI()));
- if(null != uriNode)
- {
- // Replace any environment variables embedded inside the string.
- brokerUri = new Uri(ReplaceEnvVar(uriNode.GetAttribute("value")));
- }
+ if (null != uriNode)
+ {
+ // Replace any environment variables embedded inside the string.
+ brokerUri = new Uri(ReplaceEnvVar(uriNode.GetAttribute("value")));
+ }
- return brokerUri.ToString();
- }
+ return brokerUri.ToString();
+ }
- /// <summary>
- /// Create the NMS Factory that can create NMS Connections. This function loads the
- /// connection settings from the configuration file.
- /// </summary>
- /// <param name="nameTestURI">The named connection configuration.</param>
- /// <returns></returns>
- protected bool CreateNMSFactory(string nameTestURI)
- {
- Uri brokerUri = null;
- string[] paths = GetConfigSearchPaths();
- object[] factoryParams = null;
- string connectionConfigFileName = GetConnectionConfigFileName();
- bool configFound = false;
+ /// <summary>
+ /// Create the NMS Factory that can create NMS Connections. This function loads the
+ /// connection settings from the configuration file.
+ /// </summary>
+ /// <param name="nameTestURI">The named connection configuration.</param>
+ /// <returns></returns>
+ protected bool CreateNMSFactory(string nameTestURI)
+ {
+ Uri brokerUri = null;
+ string[] paths = GetConfigSearchPaths();
+ object[] factoryParams = null;
+ string connectionConfigFileName = GetConnectionConfigFileName();
+ bool configFound = false;
- foreach(string path in paths)
- {
- string fullpath = Path.Combine(path, connectionConfigFileName);
- Tracer.Debug("\tScanning folder: " + path);
+ foreach (string path in paths)
+ {
+ string fullpath = Path.Combine(path, connectionConfigFileName);
+ Tracer.Debug("\tScanning folder: " + path);
- if(File.Exists(fullpath))
- {
- Tracer.Debug("\tAssembly found!");
- connectionConfigFileName = fullpath;
- configFound = true;
- break;
- }
- }
+ if (File.Exists(fullpath))
+ {
+ Tracer.Debug("\tAssembly found!");
+ connectionConfigFileName = fullpath;
+ configFound = true;
+ break;
+ }
+ }
- Assert.IsTrue(configFound, "Connection configuration file does not exist.");
- XmlDocument configDoc = new XmlDocument();
+ Assert.IsTrue(configFound, "Connection configuration file does not exist.");
+ XmlDocument configDoc = new XmlDocument();
- configDoc.Load(connectionConfigFileName);
- XmlElement uriNode = (XmlElement) configDoc.SelectSingleNode(String.Format("/configuration/{0}", nameTestURI));
+ configDoc.Load(connectionConfigFileName);
+ XmlElement uriNode =
+ (XmlElement) configDoc.SelectSingleNode(String.Format("/configuration/{0}", nameTestURI));
- if(null != uriNode)
- {
- // Replace any environment variables embedded inside the string.
- brokerUri = new Uri(ReplaceEnvVar(uriNode.GetAttribute("value")));
- factoryParams = GetFactoryParams(uriNode);
- clientId = ReplaceEnvVar(GetNodeValueAttribute(uriNode, "clientId", "NMSTestClientId"));
- userName = ReplaceEnvVar(GetNodeValueAttribute(uriNode, "userName", "guest"));
- passWord = ReplaceEnvVar(GetNodeValueAttribute(uriNode, "passWord", "guest"));
- }
+ if (null != uriNode)
+ {
+ // Replace any environment variables embedded inside the string.
+ brokerUri = new Uri(ReplaceEnvVar(uriNode.GetAttribute("value")));
+ factoryParams = GetFactoryParams(uriNode);
+ clientId = ReplaceEnvVar(GetNodeValueAttribute(uriNode, "clientId", "NMSTestClientId"));
+ userName = ReplaceEnvVar(GetNodeValueAttribute(uriNode, "userName", "guest"));
+ passWord = ReplaceEnvVar(GetNodeValueAttribute(uriNode, "passWord", "guest"));
+ }
- if(null == factoryParams)
- {
- NMSFactory = new Apache.NMS.NMSConnectionFactory(brokerUri);
- }
- else
- {
- NMSFactory = new Apache.NMS.NMSConnectionFactory(brokerUri, factoryParams);
- }
+ if (null == factoryParams)
+ {
+ NMSFactory = new Apache.NMS.NMSConnectionFactory(brokerUri);
+ }
+ else
+ {
+ NMSFactory = new Apache.NMS.NMSConnectionFactory(brokerUri, factoryParams);
+ }
- return (null != NMSFactory);
- }
+ return (null != NMSFactory);
+ }
- private static string[] GetConfigSearchPaths()
- {
- ArrayList pathList = new ArrayList();
+ private static string[] GetConfigSearchPaths()
+ {
+ ArrayList pathList = new ArrayList();
- // Check the current folder first.
- pathList.Add("");
+ // Check the current folder first.
+ pathList.Add("");
#if !NETCF
- AppDomain currentDomain = AppDomain.CurrentDomain;
+ AppDomain currentDomain = AppDomain.CurrentDomain;
- // Check the folder the assembly is located in.
- pathList.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
- if(null != currentDomain.BaseDirectory)
- {
- pathList.Add(currentDomain.BaseDirectory);
- }
+ // Check the folder the assembly is located in.
+ pathList.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
+ if (null != currentDomain.BaseDirectory)
+ {
+ pathList.Add(currentDomain.BaseDirectory);
+ }
- if(null != currentDomain.RelativeSearchPath)
- {
- pathList.Add(currentDomain.RelativeSearchPath);
- }
+ if (null != currentDomain.RelativeSearchPath)
+ {
+ pathList.Add(currentDomain.RelativeSearchPath);
+ }
#endif
- return (string[]) pathList.ToArray(typeof(string));
- }
+ return (string[]) pathList.ToArray(typeof(string));
+ }
- /// <summary>
- /// Get the parameters for the ConnectionFactory from the configuration file.
- /// </summary>
- /// <param name="uriNode">Parent node of the factoryParams node.</param>
- /// <returns>Object array of parameter objects to be passsed to provider factory object. Null if no parameters are specified in configuration file.</returns>
- protected object[] GetFactoryParams(XmlElement uriNode)
- {
- ArrayList factoryParams = new ArrayList();
- XmlElement factoryParamsNode = (XmlElement) uriNode.SelectSingleNode("factoryParams");
+ /// <summary>
+ /// Get the parameters for the ConnectionFactory from the configuration file.
+ /// </summary>
+ /// <param name="uriNode">Parent node of the factoryParams node.</param>
+ /// <returns>Object array of parameter objects to be passsed to provider factory object. Null if no parameters are specified in configuration file.</returns>
+ protected object[] GetFactoryParams(XmlElement uriNode)
+ {
+ ArrayList factoryParams = new ArrayList();
+ XmlElement factoryParamsNode = (XmlElement) uriNode.SelectSingleNode("factoryParams");
- if(null != factoryParamsNode)
- {
- XmlNodeList nodeList = factoryParamsNode.SelectNodes("param");
+ if (null != factoryParamsNode)
+ {
+ XmlNodeList nodeList = factoryParamsNode.SelectNodes("param");
- if(null != nodeList)
- {
- foreach(XmlElement paramNode in nodeList)
- {
- string paramType = paramNode.GetAttribute("type");
- string paramValue = ReplaceEnvVar(paramNode.GetAttribute("value"));
+ if (null != nodeList)
+ {
+ foreach (XmlElement paramNode in nodeList)
+ {
+ string paramType = paramNode.GetAttribute("type");
+ string paramValue = ReplaceEnvVar(paramNode.GetAttribute("value"));
- switch(paramType)
- {
- case "string":
- factoryParams.Add(paramValue);
- break;
+ switch (paramType)
+ {
+ case "string":
+ factoryParams.Add(paramValue);
+ break;
- case "int":
- factoryParams.Add(int.Parse(paramValue));
- break;
+ case "int":
+ factoryParams.Add(int.Parse(paramValue));
+ break;
- // TODO: Add more parameter types
- }
- }
- }
- }
+ // TODO: Add more parameter types
+ }
+ }
+ }
+ }
- if(factoryParams.Count > 0)
- {
- return factoryParams.ToArray();
- }
+ if (factoryParams.Count > 0)
+ {
+ return factoryParams.ToArray();
+ }
- return null;
- }
+ return null;
+ }
- /// <summary>
- ///
- /// </summary>
- /// <param name="parentNode"></param>
- /// <param name="nodeName"></param>
- /// <param name="dflt"></param>
- /// <returns></returns>
- protected static string GetNodeValueAttribute(XmlElement parentNode, string nodeName, string dflt)
- {
- XmlElement node = (XmlElement) parentNode.SelectSingleNode(nodeName);
- string val;
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="parentNode"></param>
+ /// <param name="nodeName"></param>
+ /// <param name="dflt"></param>
+ /// <returns></returns>
+ protected static string GetNodeValueAttribute(XmlElement parentNode, string nodeName, string dflt)
+ {
+ XmlElement node = (XmlElement) parentNode.SelectSingleNode(nodeName);
+ string val;
- if(null != node)
- {
- val = node.GetAttribute("value");
- }
- else
- {
- val = dflt;
- }
+ if (null != node)
+ {
+ val = node.GetAttribute("value");
+ }
+ else
+ {
+ val = dflt;
+ }
- return val;
- }
+ return val;
+ }
- /// <summary>
- /// Replace embedded variable markups with environment variable values.
- /// Variable markups are of the following form:
- /// ${varname}
- /// </summary>
- /// <param name="srcText"></param>
- /// <returns></returns>
- public static string ReplaceEnvVar(string srcText)
- {
- // NOTE: Might be able to refactor to be more generic and support full variable
- // names that can be pulled from the environment. Currently, we only support limited
- // hard-coded variable names.
+ /// <summary>
+ /// Replace embedded variable markups with environment variable values.
+ /// Variable markups are of the following form:
+ /// ${varname}
+ /// </summary>
+ /// <param name="srcText"></param>
+ /// <returns></returns>
+ public static string ReplaceEnvVar(string srcText)
+ {
+ // NOTE: Might be able to refactor to be more generic and support full variable
+ // names that can be pulled from the environment. Currently, we only support limited
+ // hard-coded variable names.
- string defaultBroker = GetEnvVar("NMSTestBroker", "activemqhost");
+ string defaultBroker = GetEnvVar("NMSTestBroker", "activemqhost");
- srcText = ReplaceEnvVar(srcText, "ActiveMQHost", defaultBroker);
- srcText = ReplaceEnvVar(srcText, "ActiveMQBackupHost", defaultBroker);
+ srcText = ReplaceEnvVar(srcText, "ActiveMQHost", defaultBroker);
+ srcText = ReplaceEnvVar(srcText, "ActiveMQBackupHost", defaultBroker);
- srcText = ReplaceEnvVar(srcText, "TIBCOHost", defaultBroker);
- srcText = ReplaceEnvVar(srcText, "TIBCOBackupHost", defaultBroker);
+ srcText = ReplaceEnvVar(srcText, "TIBCOHost", defaultBroker);
+ srcText = ReplaceEnvVar(srcText, "TIBCOBackupHost", defaultBroker);
- srcText = ReplaceEnvVar(srcText, "MSMQHost", defaultBroker);
- srcText = ReplaceEnvVar(srcText, "MSMQBackupHost", defaultBroker);
- return srcText;
- }
+ srcText = ReplaceEnvVar(srcText, "MSMQHost", defaultBroker);
+ srcText = ReplaceEnvVar(srcText, "MSMQBackupHost", defaultBroker);
+ return srcText;
+ }
- /// <summary>
- /// Replace the variable with environment variable.
- /// </summary>
- /// <param name="srcText"></param>
- /// <param name="varName"></param>
- /// <param name="defaultValue"></param>
- /// <returns></returns>
- public static string ReplaceEnvVar(string srcText, string varName, string defaultValue)
- {
- string replacementValue = GetEnvVar(varName, defaultValue);
- return Regex.Replace(srcText, "\\${" + varName + "}", replacementValue, RegexOptions.IgnoreCase);
- }
+ /// <summary>
+ /// Replace the variable with environment variable.
+ /// </summary>
+ /// <param name="srcText"></param>
+ /// <param name="varName"></param>
+ /// <param name="defaultValue"></param>
+ /// <returns></returns>
+ public static string ReplaceEnvVar(string srcText, string varName, string defaultValue)
+ {
+ string replacementValue = GetEnvVar(varName, defaultValue);
+ return Regex.Replace(srcText, "\\${" + varName + "}", replacementValue, RegexOptions.IgnoreCase);
+ }
- /// <summary>
- /// Get environment variable value.
- /// </summary>
- /// <param name="varName"></param>
- /// <param name="defaultValue"></param>
- /// <returns></returns>
- public static string GetEnvVar(string varName, string defaultValue)
- {
+ /// <summary>
+ /// Get environment variable value.
+ /// </summary>
+ /// <param name="varName"></param>
+ /// <param name="defaultValue"></param>
+ /// <returns></returns>
+ public static string GetEnvVar(string varName, string defaultValue)
+ {
#if (PocketPC||NETCF||NETCF_2_0)
string varValue = null;
#else
- string varValue = Environment.GetEnvironmentVariable(varName);
+ string varValue = Environment.GetEnvironmentVariable(varName);
#endif
- if(null == varValue)
- {
- varValue = defaultValue;
- }
+ if (null == varValue)
+ {
+ varValue = defaultValue;
+ }
- return varValue;
- }
+ return varValue;
+ }
- public virtual string GetTestClientId()
- {
+ public virtual string GetTestClientId()
+ {
+ System.Text.StringBuilder id = new System.Text.StringBuilder();
- System.Text.StringBuilder id = new System.Text.StringBuilder();
+ id.Append("ID:");
+ id.Append(this.GetType().Name);
+ id.Append(":");
+ id.Append(this.testRun);
+ id.Append(":");
+ id.Append(++idCounter);
- id.Append("ID:");
- id.Append(this.GetType().Name);
- id.Append(":");
- id.Append(this.testRun);
- id.Append(":");
- id.Append(++idCounter);
+ return id.ToString();
+ }
- return id.ToString();
- }
+ /// <summary>
+ /// Create a new connection to the broker.
+ /// </summary>
+ /// <returns></returns>
+ public virtual IConnection CreateConnection()
+ {
+ return CreateConnection(null);
+ }
- /// <summary>
- /// Create a new connection to the broker.
- /// </summary>
- /// <returns></returns>
- public virtual IConnection CreateConnection()
- {
- return CreateConnection(null);
- }
+ /// <summary>
+ /// Create a new connection to the broker.
+ /// </summary>
+ /// <param name="newClientId">Client ID of the new connection.</param>
+ /// <returns></returns>
+ public virtual IConnection CreateConnection(string newClientId)
+ {
+ IConnection newConnection = Factory.CreateConnection(userName, passWord);
+ Assert.IsNotNull(newConnection, "connection not created");
+ if (newClientId != null)
+ {
+ newConnection.ClientId = newClientId;
+ }
- /// <summary>
- /// Create a new connection to the broker.
- /// </summary>
- /// <param name="newClientId">Client ID of the new connection.</param>
- /// <returns></returns>
- public virtual IConnection CreateConnection(string newClientId)
- {
- IConnection newConnection = Factory.CreateConnection(userName, passWord);
- Assert.IsNotNull(newConnection, "connection not created");
- if(newClientId != null)
- {
- newConnection.ClientId = newClientId;
- }
+ return newConnection;
+ }
- return newConnection;
- }
+ /// <summary>
+ /// Create a new connection to the broker, and start it.
+ /// </summary>
+ /// <returns></returns>
+ public virtual IConnection CreateConnectionAndStart()
+ {
+ return CreateConnectionAndStart(null);
+ }
- /// <summary>
- /// Create a new connection to the broker, and start it.
- /// </summary>
- /// <returns></returns>
- public virtual IConnection CreateConnectionAndStart()
- {
- return CreateConnectionAndStart(null);
- }
+ /// <summary>
+ /// Create a new connection to the broker, and start it.
+ /// </summary>
+ /// <param name="newClientId">Client ID of the new connection.</param>
+ /// <returns></returns>
+ public virtual IConnection CreateConnectionAndStart(string newClientId)
+ {
+ IConnection newConnection = CreateConnection(newClientId);
+ newConnection.Start();
+ return newConnection;
+ }
- /// <summary>
- /// Create a new connection to the broker, and start it.
- /// </summary>
- /// <param name="newClientId">Client ID of the new connection.</param>
- /// <returns></returns>
- public virtual IConnection CreateConnectionAndStart(string newClientId)
- {
- IConnection newConnection = CreateConnection(newClientId);
- newConnection.Start();
- return newConnection;
- }
+ public IDestination CreateDestination(ISession session, DestinationType type)
+ {
+ return CreateDestination(session, type, "");
+ }
- public IDestination CreateDestination(ISession session, DestinationType type)
- {
- return CreateDestination(session, type, "");
- }
+ public IDestination CreateDestination(ISession session, DestinationType type, string name)
+ {
+ switch (type)
+ {
+ case DestinationType.Queue:
+ if (string.IsNullOrEmpty(name))
+ {
+ name = "queue://TEST." + this.GetType().Name + "." + Guid.NewGuid().ToString();
+ }
- public IDestination CreateDestination(ISession session, DestinationType type, string name)
- {
- switch(type)
- {
- case DestinationType.Queue:
- if(string.IsNullOrEmpty(name))
- {
- name = "queue://TEST." + this.GetType().Name + "." + Guid.NewGuid().ToString();
- }
- break;
+ break;
- case DestinationType.Topic:
- if(string.IsNullOrEmpty(name))
- {
- name = "topic://TEST." + this.GetType().Name + "." + Guid.NewGuid().ToString();
- }
- break;
+ case DestinationType.Topic:
+ if (string.IsNullOrEmpty(name))
+ {
+ name = "topic://TEST." + this.GetType().Name + "." + Guid.NewGuid().ToString();
+ }
- case DestinationType.TemporaryQueue:
- if(string.IsNullOrEmpty(name))
- {
- name = "temp-queue://TEST." + this.GetType().Name + "." + Guid.NewGuid().ToString();
- }
- break;
+ break;
- case DestinationType.TemporaryTopic:
- if(string.IsNullOrEmpty(name))
- {
- name = "temp-topic://TEST." + this.GetType().Name + "." + Guid.NewGuid().ToString();
- }
- break;
+ case DestinationType.TemporaryQueue:
+ if (string.IsNullOrEmpty(name))
+ {
+ name = "temp-queue://TEST." + this.GetType().Name + "." + Guid.NewGuid().ToString();
+ }
- default:
- throw new ArgumentException("type: " + type);
- }
+ break;
- return CreateDestination(session, name);
- }
+ case DestinationType.TemporaryTopic:
+ if (string.IsNullOrEmpty(name))
+ {
+ name = "temp-topic://TEST." + this.GetType().Name + "." + Guid.NewGuid().ToString();
+ }
- /// <summary>
- /// Create a destination. This will delete an existing destination and re-create it.
- /// </summary>
- /// <param name="session"></param>
- /// <param name="destinationName"></param>
- /// <returns></returns>
- public virtual IDestination CreateDestination(ISession session, string destinationName)
- {
- try
- {
- SessionUtil.DeleteDestination(session, destinationName);
- }
- catch(Exception)
- {
- // Can't delete it, so lets try and purge it.
- IDestination destination = SessionUtil.GetDestination(session, destinationName);
+ break;
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- {
- while(consumer.Receive(TimeSpan.FromMilliseconds(750)) != null)
- {
- }
- }
- }
+ default:
+ throw new ArgumentException("type: " + type);
+ }
- return SessionUtil.GetDestination(session, destinationName);
- }
+ return CreateDestination(session, name);
+ }
- /// <summary>
- /// Register a durable consumer
- /// </summary>
- /// <param name="connectionID">Connection ID of the consumer.</param>
- /// <param name="destination">Destination name to register. Supports embedded prefix names.</param>
- /// <param name="consumerID">Name of the durable consumer.</param>
- /// <param name="selector">Selector parameters for consumer.</param>
- /// <param name="noLocal"></param>
- protected void RegisterDurableConsumer(string connectionID, string destination, string consumerID, string selector, bool noLocal)
- {
- using(IConnection connection = CreateConnection(connectionID))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge))
- {
- ITopic destinationTopic = (ITopic) SessionUtil.GetDestination(session, destination);
- Assert.IsNotNull(destinationTopic, "Could not get destination topic.");
- using(IMessageConsumer consumer = session.CreateDurableConsumer(destinationTopic, consumerID, selector, noLocal))
- {
- Assert.IsNotNull(consumer, "Could not create durable consumer.");
- }
- }
- }
- }
+ /// <summary>
+ /// Create a destination. This will delete an existing destination and re-create it.
+ /// </summary>
+ /// <param name="session"></param>
+ /// <param name="destinationName"></param>
+ /// <returns></returns>
+ public virtual IDestination CreateDestination(ISession session, string destinationName)
+ {
+ try
+ {
+ SessionUtil.DeleteDestination(session, destinationName);
+ }
+ catch (Exception)
+ {
+ // Can't delete it, so lets try and purge it.
+ IDestination destination = SessionUtil.GetDestination(session, destinationName);
- /// <summary>
- /// Unregister a durable consumer for the given connection ID.
- /// </summary>
- /// <param name="connectionID">Connection ID of the consumer.</param>
- /// <param name="consumerID">Name of the durable consumer.</param>
- protected void UnregisterDurableConsumer(string connectionID, string consumerID)
- {
- using(IConnection connection = CreateConnection(connectionID))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge))
- {
- session.DeleteDurableConsumer(consumerID);
- }
- }
- }
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ {
+ while (consumer.Receive(TimeSpan.FromMilliseconds(750)) != null)
+ {
+ }
+ }
+ }
- public static string ToHex(long value)
- {
- return String.Format("{0:x}", value);
- }
+ return SessionUtil.GetDestination(session, destinationName);
+ }
- public void SendMessages(IDestination destination, MsgDeliveryMode deliveryMode, int count)
- {
- IConnection connection = CreateConnection();
- connection.Start();
- SendMessages(connection, destination, deliveryMode, count);
- connection.Close();
- }
+ /// <summary>
+ /// Register a durable consumer
+ /// </summary>
+ /// <param name="connectionID">Connection ID of the consumer.</param>
+ /// <param name="destination">Destination name to register. Supports embedded prefix names.</param>
+ /// <param name="consumerID">Name of the durable consumer.</param>
+ /// <param name="selector">Selector parameters for consumer.</param>
+ /// <param name="noLocal"></param>
+ protected void RegisterDurableConsumer(string connectionID, string destination, string consumerID,
+ string selector, bool noLocal)
+ {
+ using (IConnection connection = CreateConnection(connectionID))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge))
+ {
+ ITopic destinationTopic = (ITopic) SessionUtil.GetDestination(session, destination);
+ Assert.IsNotNull(destinationTopic, "Could not get destination topic.");
+ using (IMessageConsumer consumer =
+ session.CreateDurableConsumer(destinationTopic, consumerID, selector, noLocal))
+ {
+ Assert.IsNotNull(consumer, "Could not create durable consumer.");
+ }
+ }
+ }
+ }
- public void SendMessages(IConnection connection, IDestination destination, MsgDeliveryMode deliveryMode, int count)
- {
- ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
- SendMessages(session, destination, deliveryMode, count);
- session.Close();
- }
+ /// <summary>
+ /// Unregister a durable consumer for the given connection ID.
+ /// </summary>
+ /// <param name="connectionID">Connection ID of the consumer.</param>
+ /// <param name="consumerID">Name of the durable consumer.</param>
+ protected void UnregisterDurableConsumer(string connectionID, string consumerID)
+ {
+ using (IConnection connection = CreateConnection(connectionID))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.DupsOkAcknowledge))
+ {
+ session.DeleteDurableConsumer(consumerID);
+ }
+ }
+ }
- public void SendMessages(ISession session, IDestination destination, MsgDeliveryMode deliveryMode, int count)
- {
- IMessageProducer producer = session.CreateProducer(destination);
- producer.DeliveryMode = deliveryMode;
- for(int i = 0; i < count; i++)
- {
- producer.Send(session.CreateTextMessage("" + i));
- }
- producer.Close();
- }
+ public static string ToHex(long value)
+ {
+ return String.Format("{0:x}", value);
+ }
- protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet)
- {
- AssertTextMessagesEqual(firstSet, secondSet, "");
- }
+ public void SendMessages(IDestination destination, MsgDeliveryMode deliveryMode, int count)
+ {
+ IConnection connection = CreateConnection();
+ connection.Start();
+ SendMessages(connection, destination, deliveryMode, count);
+ connection.Close();
+ }
- protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet, string messsage)
- {
- Assert.AreEqual(firstSet.Length, secondSet.Length, "Message count does not match: " + messsage);
+ public void SendMessages(IConnection connection, IDestination destination, MsgDeliveryMode deliveryMode,
+ int count)
+ {
+ ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+ SendMessages(session, destination, deliveryMode, count);
+ session.Close();
+ }
- for(int i = 0; i < secondSet.Length; i++)
- {
- ITextMessage m1 = firstSet[i] as ITextMessage;
- ITextMessage m2 = secondSet[i] as ITextMessage;
+ public void SendMessages(ISession session, IDestination destination, MsgDeliveryMode deliveryMode, int count)
+ {
+ IMessageProducer producer = session.CreateProducer(destination);
+ producer.DeliveryMode = deliveryMode;
+ for (int i = 0; i < count; i++)
+ {
+ producer.Send(session.CreateTextMessage("" + i));
+ }
- AssertTextMessageEqual(m1, m2, "Message " + (i + 1) + " did not match : ");
- }
- }
+ producer.Close();
+ }
- protected void AssertEquals(ITextMessage m1, ITextMessage m2)
- {
- AssertEquals(m1, m2, "");
- }
+ protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet)
+ {
+ AssertTextMessagesEqual(firstSet, secondSet, "");
+ }
- protected void AssertTextMessageEqual(ITextMessage m1, ITextMessage m2, string message)
- {
- Assert.IsFalse(m1 == null ^ m2 == null, message + ": expected {" + m1 + "}, but was {" + m2 + "}");
+ protected void AssertTextMessagesEqual(IMessage[] firstSet, IMessage[] secondSet, string messsage)
+ {
+ Assert.AreEqual(firstSet.Length, secondSet.Length, "Message count does not match: " + messsage);
- if(m1 == null)
- {
- return;
- }
+ for (int i = 0; i < secondSet.Length; i++)
+ {
+ ITextMessage m1 = firstSet[i] as ITextMessage;
+ ITextMessage m2 = secondSet[i] as ITextMessage;
- Assert.AreEqual(m1.Text, m2.Text, message);
- }
+ AssertTextMessageEqual(m1, m2, "Message " + (i + 1) + " did not match : ");
+ }
+ }
- protected void AssertEquals(IMessage m1, IMessage m2)
- {
- AssertEquals(m1, m2, "");
- }
+ protected void AssertEquals(ITextMessage m1, ITextMessage m2)
+ {
+ AssertEquals(m1, m2, "");
+ }
- protected void AssertEquals(IMessage m1, IMessage m2, string message)
- {
- Assert.IsFalse(m1 == null ^ m2 == null, message + ": expected {" + m1 + "}, but was {" + m2 + "}");
+ protected void AssertTextMessageEqual(ITextMessage m1, ITextMessage m2, string message)
+ {
+ Assert.IsFalse(m1 == null ^ m2 == null, message + ": expected {" + m1 + "}, but was {" + m2 + "}");
- if(m1 == null)
- {
- return;
- }
+ if (m1 == null)
+ {
+ return;
+ }
- Assert.IsTrue(m1.GetType() == m2.GetType(), message + ": expected {" + m1 + "}, but was {" + m2 + "}");
+ Assert.AreEqual(m1.Text, m2.Text, message);
+ }
- if(m1 is ITextMessage)
- {
- AssertTextMessageEqual((ITextMessage) m1, (ITextMessage) m2, message);
- }
- else
- {
- Assert.AreEqual(m1, m2, message);
- }
- }
- }
-}
+ protected void AssertEquals(IMessage m1, IMessage m2)
+ {
+ AssertEquals(m1, m2, "");
+ }
+
+ protected void AssertEquals(IMessage m1, IMessage m2, string message)
+ {
+ Assert.IsFalse(m1 == null ^ m2 == null, message + ": expected {" + m1 + "}, but was {" + m2 + "}");
+
+ if (m1 == null)
+ {
+ return;
+ }
+
+ Assert.IsTrue(m1.GetType() == m2.GetType(), message + ": expected {" + m1 + "}, but was {" + m2 + "}");
+
+ if (m1 is ITextMessage)
+ {
+ AssertTextMessageEqual((ITextMessage) m1, (ITextMessage) m2, message);
+ }
+ else
+ {
+ Assert.AreEqual(m1, m2, message);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/NmsTracer.cs b/test/nms-api-test/NmsTracer.cs
index ee370fa..f7c8404 100644
--- a/test/nms-api-test/NmsTracer.cs
+++ b/test/nms-api-test/NmsTracer.cs
@@ -15,73 +15,74 @@
* limitations under the License.
*/
-#define TRACE // Force tracing to be enabled for this class
+#define TRACE // Force tracing to be enabled for this class
namespace Apache.NMS.Test
{
- public class NmsTracer : Apache.NMS.ITrace
- {
- #region ITrace Members
- public void Debug(string message)
- {
+ public class NmsTracer : Apache.NMS.ITrace
+ {
+ #region ITrace Members
+
+ public void Debug(string message)
+ {
#if !NETCF
- System.Diagnostics.Trace.WriteLine(string.Format("DEBUG: {0}", message));
+ System.Diagnostics.Trace.WriteLine(string.Format("DEBUG: {0}", message));
#endif
- }
+ }
- public void Error(string message)
- {
+ public void Error(string message)
+ {
#if !NETCF
- System.Diagnostics.Trace.WriteLine(string.Format("ERROR: {0}", message));
+ System.Diagnostics.Trace.WriteLine(string.Format("ERROR: {0}", message));
#endif
- }
+ }
- public void Fatal(string message)
- {
+ public void Fatal(string message)
+ {
#if !NETCF
- System.Diagnostics.Trace.WriteLine(string.Format("FATAL: {0}", message));
+ System.Diagnostics.Trace.WriteLine(string.Format("FATAL: {0}", message));
#endif
- }
+ }
- public void Info(string message)
- {
+ public void Info(string message)
+ {
#if !NETCF
- System.Diagnostics.Trace.WriteLine(string.Format("INFO: {0}", message));
+ System.Diagnostics.Trace.WriteLine(string.Format("INFO: {0}", message));
#endif
- }
+ }
- public void Warn(string message)
- {
+ public void Warn(string message)
+ {
#if !NETCF
- System.Diagnostics.Trace.WriteLine(string.Format("WARN: {0}", message));
+ System.Diagnostics.Trace.WriteLine(string.Format("WARN: {0}", message));
#endif
- }
+ }
- public bool IsDebugEnabled
- {
- get { return true; }
- }
+ public bool IsDebugEnabled
+ {
+ get { return true; }
+ }
- public bool IsErrorEnabled
- {
- get { return true; }
- }
+ public bool IsErrorEnabled
+ {
+ get { return true; }
+ }
- public bool IsFatalEnabled
- {
- get { return true; }
- }
+ public bool IsFatalEnabled
+ {
+ get { return true; }
+ }
- public bool IsInfoEnabled
- {
- get { return true; }
- }
+ public bool IsInfoEnabled
+ {
+ get { return true; }
+ }
- public bool IsWarnEnabled
- {
- get { return true; }
- }
+ public bool IsWarnEnabled
+ {
+ get { return true; }
+ }
- #endregion
- }
-}
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/PrimitiveMapTest.cs b/test/nms-api-test/PrimitiveMapTest.cs
index 3e20892..c085aea 100644
--- a/test/nms-api-test/PrimitiveMapTest.cs
+++ b/test/nms-api-test/PrimitiveMapTest.cs
@@ -22,149 +22,148 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class PrimitiveMapTest
- {
+ [TestFixture]
+ public class PrimitiveMapTest
+ {
+ bool a = true;
+ byte b = 123;
+ char c = 'c';
+ short d = 0x1234;
+ int e = 0x12345678;
+ long f = 0x1234567812345678;
+ string g = "Hello World!";
+ bool h = false;
+ byte i = 0xFF;
+ short j = -0x1234;
+ int k = -0x12345678;
+ long l = -0x1234567812345678;
+ IList m = CreateList();
+ IDictionary n = CreateDictionary();
- bool a = true;
- byte b = 123;
- char c = 'c';
- short d = 0x1234;
- int e = 0x12345678;
- long f = 0x1234567812345678;
- string g = "Hello World!";
- bool h = false;
- byte i = 0xFF;
- short j = -0x1234;
- int k = -0x12345678;
- long l = -0x1234567812345678;
- IList m = CreateList();
- IDictionary n = CreateDictionary();
+ [Test]
+ public void TestNotMarshalled()
+ {
+ PrimitiveMap map = CreatePrimitiveMap();
+ AssertPrimitiveMap(map);
+ }
- [Test]
- public void TestNotMarshalled()
- {
- PrimitiveMap map = CreatePrimitiveMap();
- AssertPrimitiveMap(map);
- }
+ [Test]
+ public void TestMarshalled()
+ {
+ PrimitiveMap map = CreatePrimitiveMap();
+ byte[] data = map.Marshal();
+ map = PrimitiveMap.Unmarshal(data);
+ AssertPrimitiveMap(map);
+ }
- [Test]
- public void TestMarshalled()
- {
- PrimitiveMap map = CreatePrimitiveMap();
- byte[] data = map.Marshal();
- map = PrimitiveMap.Unmarshal(data);
- AssertPrimitiveMap(map);
- }
+ [Test]
+ public void TestMarshalledWithBigString()
+ {
+ PrimitiveMap map = CreatePrimitiveMap();
+ String test = new String('a', 65538);
+ map.SetString("BIG_STRING", test);
+ byte[] data = map.Marshal();
+ map = PrimitiveMap.Unmarshal(data);
+ AssertPrimitiveMap(map);
+ Assert.AreEqual(test, map.GetString("BIG_STRING"));
+ }
- [Test]
- public void TestMarshalledWithBigString()
- {
- PrimitiveMap map = CreatePrimitiveMap();
- String test = new String('a', 65538);
- map.SetString("BIG_STRING", test);
- byte[] data = map.Marshal();
- map = PrimitiveMap.Unmarshal(data);
- AssertPrimitiveMap(map);
- Assert.AreEqual(test, map.GetString("BIG_STRING"));
- }
+ protected PrimitiveMap CreatePrimitiveMap()
+ {
+ PrimitiveMap map = new PrimitiveMap();
- protected PrimitiveMap CreatePrimitiveMap()
- {
- PrimitiveMap map = new PrimitiveMap();
+ map["a"] = a;
+ map["b"] = b;
+ map["c"] = c;
+ map["d"] = d;
+ map["e"] = e;
+ map["f"] = f;
+ map["g"] = g;
+ map["h"] = h;
+ map["i"] = i;
+ map["j"] = j;
+ map["k"] = k;
+ map["l"] = l;
+ map["m"] = m;
+ map["n"] = n;
- map["a"] = a;
- map["b"] = b;
- map["c"] = c;
- map["d"] = d;
- map["e"] = e;
- map["f"] = f;
- map["g"] = g;
- map["h"] = h;
- map["i"] = i;
- map["j"] = j;
- map["k"] = k;
- map["l"] = l;
- map["m"] = m;
- map["n"] = n;
+ return map;
+ }
- return map;
- }
+ protected void AssertPrimitiveMap(PrimitiveMap map)
+ {
+ // use generic API to access entries
+ Assert.AreEqual(a, map["a"], "generic map entry: a");
+ Assert.AreEqual(b, map["b"], "generic map entry: b");
+ Assert.AreEqual(c, map["c"], "generic map entry: c");
+ Assert.AreEqual(d, map["d"], "generic map entry: d");
+ Assert.AreEqual(e, map["e"], "generic map entry: e");
+ Assert.AreEqual(f, map["f"], "generic map entry: f");
+ Assert.AreEqual(g, map["g"], "generic map entry: g");
+ Assert.AreEqual(h, map["h"], "generic map entry: h");
+ Assert.AreEqual(i, map["i"], "generic map entry: i");
+ Assert.AreEqual(j, map["j"], "generic map entry: j");
+ Assert.AreEqual(k, map["k"], "generic map entry: k");
+ Assert.AreEqual(l, map["l"], "generic map entry: l");
+ //Assert.AreEqual(m, map["m"], "generic map entry: m");
+ //Assert.AreEqual(n, map["n"], "generic map entry: n");
- protected void AssertPrimitiveMap(PrimitiveMap map)
- {
- // use generic API to access entries
- Assert.AreEqual(a, map["a"], "generic map entry: a");
- Assert.AreEqual(b, map["b"], "generic map entry: b");
- Assert.AreEqual(c, map["c"], "generic map entry: c");
- Assert.AreEqual(d, map["d"], "generic map entry: d");
- Assert.AreEqual(e, map["e"], "generic map entry: e");
- Assert.AreEqual(f, map["f"], "generic map entry: f");
- Assert.AreEqual(g, map["g"], "generic map entry: g");
- Assert.AreEqual(h, map["h"], "generic map entry: h");
- Assert.AreEqual(i, map["i"], "generic map entry: i");
- Assert.AreEqual(j, map["j"], "generic map entry: j");
- Assert.AreEqual(k, map["k"], "generic map entry: k");
- Assert.AreEqual(l, map["l"], "generic map entry: l");
- //Assert.AreEqual(m, map["m"], "generic map entry: m");
- //Assert.AreEqual(n, map["n"], "generic map entry: n");
+ // use type safe APIs
+ Assert.AreEqual(a, map.GetBool("a"), "map entry: a");
+ Assert.AreEqual(b, map.GetByte("b"), "map entry: b");
+ Assert.AreEqual(c, map.GetChar("c"), "map entry: c");
+ Assert.AreEqual(d, map.GetShort("d"), "map entry: d");
+ Assert.AreEqual(e, map.GetInt("e"), "map entry: e");
+ Assert.AreEqual(f, map.GetLong("f"), "map entry: f");
+ Assert.AreEqual(g, map.GetString("g"), "map entry: g");
+ Assert.AreEqual(h, map.GetBool("h"), "map entry: h");
+ Assert.AreEqual(i, map.GetByte("i"), "map entry: i");
+ Assert.AreEqual(j, map.GetShort("j"), "map entry: j");
+ Assert.AreEqual(k, map.GetInt("k"), "map entry: k");
+ Assert.AreEqual(l, map.GetLong("l"), "map entry: l");
+ //Assert.AreEqual(m, map.GetList("m"), "map entry: m");
+ //Assert.AreEqual(n, map.GetDictionary("n"), "map entry: n");
- // use type safe APIs
- Assert.AreEqual(a, map.GetBool("a"), "map entry: a");
- Assert.AreEqual(b, map.GetByte("b"), "map entry: b");
- Assert.AreEqual(c, map.GetChar("c"), "map entry: c");
- Assert.AreEqual(d, map.GetShort("d"), "map entry: d");
- Assert.AreEqual(e, map.GetInt("e"), "map entry: e");
- Assert.AreEqual(f, map.GetLong("f"), "map entry: f");
- Assert.AreEqual(g, map.GetString("g"), "map entry: g");
- Assert.AreEqual(h, map.GetBool("h"), "map entry: h");
- Assert.AreEqual(i, map.GetByte("i"), "map entry: i");
- Assert.AreEqual(j, map.GetShort("j"), "map entry: j");
- Assert.AreEqual(k, map.GetInt("k"), "map entry: k");
- Assert.AreEqual(l, map.GetLong("l"), "map entry: l");
- //Assert.AreEqual(m, map.GetList("m"), "map entry: m");
- //Assert.AreEqual(n, map.GetDictionary("n"), "map entry: n");
+ IList list = map.GetList("m");
+ Assert.AreEqual(2, list.Count, "list size");
+ Assert.IsTrue(list.Contains("Item1"));
+ Assert.IsTrue(list.Contains("Item2"));
- IList list = map.GetList("m");
- Assert.AreEqual(2, list.Count, "list size");
- Assert.IsTrue(list.Contains("Item1"));
- Assert.IsTrue(list.Contains("Item2"));
+ IDictionary dictionary = map.GetDictionary("n");
+ Assert.AreEqual(5, dictionary.Count, "dictionary size");
- IDictionary dictionary = map.GetDictionary("n");
- Assert.AreEqual(5, dictionary.Count, "dictionary size");
+ IDictionary childMap = (IDictionary) dictionary["childMap"];
+ Assert.IsNotNull(childMap);
+ Assert.AreEqual("childMap", childMap["name"], "childMap[name]");
- IDictionary childMap = (IDictionary) dictionary["childMap"];
- Assert.IsNotNull(childMap);
- Assert.AreEqual("childMap", childMap["name"], "childMap[name]");
+ IList childList = (IList) dictionary["childList"];
+ Assert.IsNotNull(childList);
+ Assert.IsTrue(childList.Contains("childListElement1"));
+ }
- IList childList = (IList) dictionary["childList"];
- Assert.IsNotNull(childList);
- Assert.IsTrue(childList.Contains("childListElement1"));
- }
+ protected static IList CreateList()
+ {
+ ArrayList answer = new ArrayList();
+ answer.Add("Item1");
+ answer.Add("Item2");
+ return answer;
+ }
- protected static IList CreateList()
- {
- ArrayList answer = new ArrayList();
- answer.Add("Item1");
- answer.Add("Item2");
- return answer;
- }
+ protected static IDictionary CreateDictionary()
+ {
+ Hashtable answer = new Hashtable();
+ answer.Add("Name", "James");
+ answer.Add("Location", "London");
+ answer.Add("Company", "LogicBlaze");
- protected static IDictionary CreateDictionary()
- {
- Hashtable answer = new Hashtable();
- answer.Add("Name", "James");
- answer.Add("Location", "London");
- answer.Add("Company", "LogicBlaze");
+ Hashtable childMap = new Hashtable();
+ childMap.Add("name", "childMap");
+ answer.Add("childMap", childMap);
- Hashtable childMap = new Hashtable();
- childMap.Add("name", "childMap");
- answer.Add("childMap", childMap);
-
- ArrayList childList = new ArrayList();
- childList.Add("childListElement1");
- answer.Add("childList", childList);
- return answer;
- }
- }
-}
+ ArrayList childList = new ArrayList();
+ childList.Add("childListElement1");
+ answer.Add("childList", childList);
+ return answer;
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/ProducerTest.cs b/test/nms-api-test/ProducerTest.cs
index df50727..3d6dc70 100644
--- a/test/nms-api-test/ProducerTest.cs
+++ b/test/nms-api-test/ProducerTest.cs
@@ -20,16 +20,16 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class ProducerTest : NMSTestSupport
- {
+ [TestFixture]
+ public class ProducerTest : NMSTestSupport
+ {
[Test]
public void TestProducerSendToNullDestinationWithoutDefault()
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession())
+ using (ISession session = connection.CreateSession())
{
IMessageProducer producer = session.CreateProducer(null);
@@ -38,10 +38,10 @@
producer.Send(null, session.CreateTextMessage("Message"));
Assert.Fail("Producer should have thrown an NotSupportedException");
}
- catch(NotSupportedException)
+ catch (NotSupportedException)
{
}
- catch(Exception ex)
+ catch (Exception ex)
{
Assert.Fail("Wrong Exception Type Thrown: " + ex.GetType().Name);
}
@@ -52,10 +52,10 @@
[Test]
public void TestProducerSendToNullDestinationWithDefault()
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession())
+ using (ISession session = connection.CreateSession())
{
IDestination unusedDest = session.CreateTemporaryQueue();
@@ -66,10 +66,10 @@
producer.Send(null, session.CreateTextMessage("Message"));
Assert.Fail("Producer should have thrown an InvalidDestinationException");
}
- catch(InvalidDestinationException)
+ catch (InvalidDestinationException)
{
}
- catch(Exception ex)
+ catch (Exception ex)
{
Assert.Fail("Wrong Exception Type Thrown: " + ex.GetType().Name);
}
@@ -77,33 +77,33 @@
}
}
- [Test]
- public void TestProducerSendToNonDefaultDestination()
- {
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ [Test]
+ public void TestProducerSendToNonDefaultDestination()
+ {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession())
+ using (ISession session = connection.CreateSession())
{
- IDestination unusedDest = session.CreateTemporaryQueue();
- IDestination usedDest = session.CreateTemporaryQueue();
+ IDestination unusedDest = session.CreateTemporaryQueue();
+ IDestination usedDest = session.CreateTemporaryQueue();
- IMessageProducer producer = session.CreateProducer(unusedDest);
+ IMessageProducer producer = session.CreateProducer(unusedDest);
try
{
- producer.Send(usedDest, session.CreateTextMessage("Message"));
+ producer.Send(usedDest, session.CreateTextMessage("Message"));
Assert.Fail("Producer should have thrown an NotSupportedException");
}
- catch(NotSupportedException)
+ catch (NotSupportedException)
{
}
- catch(Exception ex)
+ catch (Exception ex)
{
Assert.Fail("Wrong Exception Type Thrown: " + ex.GetType().Name);
}
- }
- }
+ }
+ }
}
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/RedeliveryPolicyTest.cs b/test/nms-api-test/RedeliveryPolicyTest.cs
index 49d31d0..48dcdb8 100644
--- a/test/nms-api-test/RedeliveryPolicyTest.cs
+++ b/test/nms-api-test/RedeliveryPolicyTest.cs
@@ -41,8 +41,10 @@
Assert.IsTrue(policy.RedeliveryDelay(5) == 80, "redelivery delay not 160 is " + policy.RedeliveryDelay(5));
Assert.IsTrue(policy.RedeliveryDelay(6) == 160, "redelivery delay not 320 is " + policy.RedeliveryDelay(6));
Assert.IsTrue(policy.RedeliveryDelay(7) == 320, "redelivery delay not 640 is " + policy.RedeliveryDelay(7));
- Assert.IsTrue(policy.RedeliveryDelay(8) == 640, "redelivery delay not 1280 is " + policy.RedeliveryDelay(8));
- Assert.IsTrue(policy.RedeliveryDelay(9) == 1280, "redelivery delay not 2560 is " + policy.RedeliveryDelay(9));
+ Assert.IsTrue(policy.RedeliveryDelay(8) == 640,
+ "redelivery delay not 1280 is " + policy.RedeliveryDelay(8));
+ Assert.IsTrue(policy.RedeliveryDelay(9) == 1280,
+ "redelivery delay not 2560 is " + policy.RedeliveryDelay(9));
}
[Test]
@@ -62,9 +64,12 @@
Assert.IsTrue(policy.RedeliveryDelay(4) == 81, "redelivery delay not 80 is " + policy.RedeliveryDelay(4));
Assert.IsTrue(policy.RedeliveryDelay(5) == 243, "redelivery delay not 160 is " + policy.RedeliveryDelay(5));
Assert.IsTrue(policy.RedeliveryDelay(6) == 729, "redelivery delay not 320 is " + policy.RedeliveryDelay(6));
- Assert.IsTrue(policy.RedeliveryDelay(7) == 2187, "redelivery delay not 640 is " + policy.RedeliveryDelay(7));
- Assert.IsTrue(policy.RedeliveryDelay(8) == 6561, "redelivery delay not 1280 is " + policy.RedeliveryDelay(8));
- Assert.IsTrue(policy.RedeliveryDelay(9) == 19683, "redelivery delay not 2560 is " + policy.RedeliveryDelay(9));
+ Assert.IsTrue(policy.RedeliveryDelay(7) == 2187,
+ "redelivery delay not 640 is " + policy.RedeliveryDelay(7));
+ Assert.IsTrue(policy.RedeliveryDelay(8) == 6561,
+ "redelivery delay not 1280 is " + policy.RedeliveryDelay(8));
+ Assert.IsTrue(policy.RedeliveryDelay(9) == 19683,
+ "redelivery delay not 2560 is " + policy.RedeliveryDelay(9));
}
[Test]
@@ -112,7 +117,8 @@
int delay = policy.RedeliveryDelay(0);
Assert.IsTrue(delay == 0, "not zero is " + policy.RedeliveryDelay(0));
delay = policy.RedeliveryDelay(1);
- Assert.IsTrue(delay >= 4.5 && delay <= 5.5, "not delay >= 4.5 && delay <= 5.5 is " + policy.RedeliveryDelay(1));
+ Assert.IsTrue(delay >= 4.5 && delay <= 5.5,
+ "not delay >= 4.5 && delay <= 5.5 is " + policy.RedeliveryDelay(1));
delay = policy.RedeliveryDelay(2);
Assert.IsTrue(delay >= 9 && delay <= 11, "not delay >= 9 && delay <= 11 is " + policy.RedeliveryDelay(2));
delay = policy.RedeliveryDelay(3);
@@ -122,15 +128,20 @@
delay = policy.RedeliveryDelay(5);
Assert.IsTrue(delay >= 72 && delay <= 88, "not delay >= 72 && delay <= 88 is " + policy.RedeliveryDelay(5));
delay = policy.RedeliveryDelay(6);
- Assert.IsTrue(delay >= 144 && delay <= 176, "not delay >= 144 && delay <= 176 is " + policy.RedeliveryDelay(6));
+ Assert.IsTrue(delay >= 144 && delay <= 176,
+ "not delay >= 144 && delay <= 176 is " + policy.RedeliveryDelay(6));
delay = policy.RedeliveryDelay(7);
- Assert.IsTrue(delay >= 288 && delay <= 352, "not delay >= 288 && delay <= 352 is " + policy.RedeliveryDelay(7));
+ Assert.IsTrue(delay >= 288 && delay <= 352,
+ "not delay >= 288 && delay <= 352 is " + policy.RedeliveryDelay(7));
delay = policy.RedeliveryDelay(8);
- Assert.IsTrue(delay >= 576 && delay <= 704, "not delay >= 576 && delay <= 704 is " + policy.RedeliveryDelay(8));
+ Assert.IsTrue(delay >= 576 && delay <= 704,
+ "not delay >= 576 && delay <= 704 is " + policy.RedeliveryDelay(8));
delay = policy.RedeliveryDelay(9);
- Assert.IsTrue(delay >= 1152 && delay <= 1408, "not delay >= 1152 && delay <= 1408 is " + policy.RedeliveryDelay(9));
+ Assert.IsTrue(delay >= 1152 && delay <= 1408,
+ "not delay >= 1152 && delay <= 1408 is " + policy.RedeliveryDelay(9));
delay = policy.RedeliveryDelay(10);
- Assert.IsTrue(delay >= 2304 && delay <= 2816, "not delay >= 2304 && delay <= 2816 is " + policy.RedeliveryDelay(10));
+ Assert.IsTrue(delay >= 2304 && delay <= 2816,
+ "not delay >= 2304 && delay <= 2816 is " + policy.RedeliveryDelay(10));
}
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/RequestResponseTest.cs b/test/nms-api-test/RequestResponseTest.cs
index e2ebedb..d3733c2 100644
--- a/test/nms-api-test/RequestResponseTest.cs
+++ b/test/nms-api-test/RequestResponseTest.cs
@@ -16,57 +16,54 @@
*/
using System;
-
using Apache.NMS.Util;
-
using NUnit.Framework;
namespace Apache.NMS.Test
{
- [TestFixture]
- public class RequestResponseTest : NMSTestSupport
- {
- [Test]
- [Category("RequestResponse")]
- public void TestRequestResponseMessaging()
- {
- using(IConnection connection = CreateConnection())
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- ITemporaryQueue replyTo = session.CreateTemporaryQueue();
+ [TestFixture]
+ public class RequestResponseTest : NMSTestSupport
+ {
+ [Test]
+ [Category("RequestResponse")]
+ public void TestRequestResponseMessaging()
+ {
+ using (IConnection connection = CreateConnection())
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ ITemporaryQueue replyTo = session.CreateTemporaryQueue();
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- IMessage request = session.CreateMessage();
-
- request.NMSReplyTo = replyTo;
-
- producer.Send(request);
-
- request = consumer.Receive(TimeSpan.FromMilliseconds(3000));
- Assert.IsNotNull(request);
- Assert.IsNotNull(request.NMSReplyTo);
-
- using(IMessageProducer responder = session.CreateProducer(request.NMSReplyTo))
- {
- IMessage response = session.CreateTextMessage("RESPONSE");
- responder.Send(response);
- }
- }
-
- using(IMessageConsumer consumer = session.CreateConsumer(replyTo))
- {
- ITextMessage response = consumer.Receive(TimeSpan.FromMilliseconds(3000)) as ITextMessage;
- Assert.IsNotNull(response);
- Assert.AreEqual("RESPONSE", response.Text);
- }
- }
- }
- }
- }
-}
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ IMessage request = session.CreateMessage();
+ request.NMSReplyTo = replyTo;
+
+ producer.Send(request);
+
+ request = consumer.Receive(TimeSpan.FromMilliseconds(3000));
+ Assert.IsNotNull(request);
+ Assert.IsNotNull(request.NMSReplyTo);
+
+ using (IMessageProducer responder = session.CreateProducer(request.NMSReplyTo))
+ {
+ IMessage response = session.CreateTextMessage("RESPONSE");
+ responder.Send(response);
+ }
+ }
+
+ using (IMessageConsumer consumer = session.CreateConsumer(replyTo))
+ {
+ ITextMessage response = consumer.Receive(TimeSpan.FromMilliseconds(3000)) as ITextMessage;
+ Assert.IsNotNull(response);
+ Assert.AreEqual("RESPONSE", response.Text);
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/StreamMessageTest.cs b/test/nms-api-test/StreamMessageTest.cs
index 2a879de..6a15d59 100644
--- a/test/nms-api-test/StreamMessageTest.cs
+++ b/test/nms-api-test/StreamMessageTest.cs
@@ -20,7 +20,7 @@
namespace Apache.NMS.Test
{
- [TestFixture]
+ [TestFixture]
public class StreamMessageTest : NMSTestSupport
{
protected bool a = true;
@@ -40,30 +40,30 @@
[Test]
public void SendReceiveStreamMessage(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
{
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
- IStreamMessage request;
-
- try
- {
- request = session.CreateStreamMessage();
- }
- catch(System.NotSupportedException)
- {
- return;
- }
-
+ IStreamMessage request;
+
+ try
+ {
+ request = session.CreateStreamMessage();
+ }
+ catch (System.NotSupportedException)
+ {
+ return;
+ }
+
request.WriteBoolean(a);
request.WriteByte(b);
request.WriteChar(c);
@@ -103,6 +103,5 @@
}
}
}
-
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/TempDestinationDeletionTest.cs b/test/nms-api-test/TempDestinationDeletionTest.cs
index d9d2e78..bbb9134 100644
--- a/test/nms-api-test/TempDestinationDeletionTest.cs
+++ b/test/nms-api-test/TempDestinationDeletionTest.cs
@@ -21,61 +21,62 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class TempDestinationTests : NMSTestSupport
- {
- protected const string QUEUE_DESTINATION_NAME = "queue://TEST.AutoDeleteQueue";
- protected const string TOPIC_DESTINATION_NAME = "topic://TEST.AutoDeleteTopic";
- protected const string TEMP_QUEUE_DESTINATION_NAME = "temp-queue://TEST.AutoDeleteTempQueue";
- protected const string TEMP_TOPIC_DESTINATION_NAME = "temp-topic://TEST.AutoDeleteTempTopic";
+ [TestFixture]
+ public class TempDestinationTests : NMSTestSupport
+ {
+ protected const string QUEUE_DESTINATION_NAME = "queue://TEST.AutoDeleteQueue";
+ protected const string TOPIC_DESTINATION_NAME = "topic://TEST.AutoDeleteTopic";
+ protected const string TEMP_QUEUE_DESTINATION_NAME = "temp-queue://TEST.AutoDeleteTempQueue";
+ protected const string TEMP_TOPIC_DESTINATION_NAME = "temp-topic://TEST.AutoDeleteTempTopic";
- [Test]
- public void TempDestinationDeletionTest(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode,
- [Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME, TEMP_QUEUE_DESTINATION_NAME, TEMP_TOPIC_DESTINATION_NAME)]
- string destinationName)
- {
- using(IConnection connection1 = CreateConnection(GetTestClientId()))
- {
- connection1.Start();
- using(ISession session = connection1.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- const int MaxNumDestinations = 100;
+ [Test]
+ public void TempDestinationDeletionTest(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode,
+ [Values(QUEUE_DESTINATION_NAME, TOPIC_DESTINATION_NAME, TEMP_QUEUE_DESTINATION_NAME,
+ TEMP_TOPIC_DESTINATION_NAME)]
+ string destinationName)
+ {
+ using (IConnection connection1 = CreateConnection(GetTestClientId()))
+ {
+ connection1.Start();
+ using (ISession session = connection1.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ const int MaxNumDestinations = 100;
- for(int index = 1; index <= MaxNumDestinations; index++)
- {
- IDestination destination = CreateDestination(session, destinationName);
+ for (int index = 1; index <= MaxNumDestinations; index++)
+ {
+ IDestination destination = CreateDestination(session, destinationName);
- using(IMessageProducer producer = session.CreateProducer(destination))
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- {
- producer.DeliveryMode = deliveryMode;
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
- IMessage request = session.CreateTextMessage("Hello World, Just Passing Through!");
+ IMessage request = session.CreateTextMessage("Hello World, Just Passing Through!");
- request.NMSType = "TEMP_MSG";
- producer.Send(request);
- IMessage receivedMsg = consumer.Receive(TimeSpan.FromMilliseconds(5000));
- Assert.IsNotNull(receivedMsg);
- Assert.AreEqual(receivedMsg.NMSType, "TEMP_MSG");
-
- // Ensures that Consumer closes out its subscription
- consumer.Close();
- }
+ request.NMSType = "TEMP_MSG";
+ producer.Send(request);
+ IMessage receivedMsg = consumer.Receive(TimeSpan.FromMilliseconds(5000));
+ Assert.IsNotNull(receivedMsg);
+ Assert.AreEqual(receivedMsg.NMSType, "TEMP_MSG");
- try
- {
- session.DeleteDestination(destination);
- }
- catch(NotSupportedException)
- {
- // Might as well not try this again.
- break;
- }
- }
- }
- }
- }
- }
-}
+ // Ensures that Consumer closes out its subscription
+ consumer.Close();
+ }
+
+ try
+ {
+ session.DeleteDestination(destination);
+ }
+ catch (NotSupportedException)
+ {
+ // Might as well not try this again.
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/TempDestinationTest.cs b/test/nms-api-test/TempDestinationTest.cs
index e124476..f48f099 100644
--- a/test/nms-api-test/TempDestinationTest.cs
+++ b/test/nms-api-test/TempDestinationTest.cs
@@ -39,7 +39,7 @@
[TearDown]
public override void TearDown()
{
- foreach(IConnection conn in this.connections)
+ foreach (IConnection conn in this.connections)
{
try
{
@@ -98,7 +98,8 @@
IMessage message2 = consumer.Receive(TimeSpan.FromMilliseconds(1000));
Assert.IsNotNull(message2);
Assert.IsTrue(message2 is ITextMessage, "Expected message to be a ITextMessage");
- Assert.IsTrue(((ITextMessage)message2).Text == message.Text, "Expected message to be a '" + message.Text + "'");
+ Assert.IsTrue(((ITextMessage) message2).Text == message.Text,
+ "Expected message to be a '" + message.Text + "'");
}
[Test]
@@ -116,7 +117,8 @@
IMessage message2 = consumer.Receive(TimeSpan.FromMilliseconds(3000));
Assert.IsNotNull(message2);
Assert.IsTrue(message2 is ITextMessage, "Expected message to be a ITextMessage");
- Assert.IsTrue(((ITextMessage)message2).Text == message.Text, "Expected message to be a '" + message.Text + "'");
+ Assert.IsTrue(((ITextMessage) message2).Text == message.Text,
+ "Expected message to be a '" + message.Text + "'");
}
[Test]
@@ -141,7 +143,7 @@
srcdata[4] = (byte) 'O';
srcdata[5] = (byte) 'L';
srcdata[6] = (byte) 'F';
- for(int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
message = session.CreateBytesMessage();
message.WriteBytes(srcdata);
@@ -154,18 +156,18 @@
byte[] data = new byte[dataSize];
byte[] data2 = new byte[dataSize];
IMessageConsumer consumer = session.CreateConsumer(queue);
- for(int i = 0; i < count; i++)
+ for (int i = 0; i < count; i++)
{
message2 = consumer.Receive(TimeSpan.FromMilliseconds(2000)) as IBytesMessage;
Assert.IsNotNull(message2);
Assert.AreEqual(i, message2.Properties.GetInt("c"));
message = list[i] as IBytesMessage;
Assert.IsNotNull(message);
- message.Reset();
+ message.Reset();
message.ReadBytes(data);
message2.ReadBytes(data2);
Assert.AreEqual(data, data2);
}
}
}
-}
+}
\ No newline at end of file
diff --git a/test/nms-api-test/TextMessage.cs b/test/nms-api-test/TextMessage.cs
index 19873c4..704ed5d 100644
--- a/test/nms-api-test/TextMessage.cs
+++ b/test/nms-api-test/TextMessage.cs
@@ -20,47 +20,47 @@
namespace Apache.NMS.Test
{
- [TestFixture]
- public class TextMessageTest : NMSTestSupport
- {
- [Test]
- public void SendReceiveTextMessage(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnection(GetTestClientId()))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- producer.DeliveryMode = deliveryMode;
- IMessage request = session.CreateTextMessage("Hello World!");
- producer.Send(request);
+ [TestFixture]
+ public class TextMessageTest : NMSTestSupport
+ {
+ [Test]
+ public void SendReceiveTextMessage(
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.DeliveryMode = deliveryMode;
+ IMessage request = session.CreateTextMessage("Hello World!");
+ producer.Send(request);
- IMessage message = consumer.Receive(receiveTimeout);
- AssertTextMessageEqual(request, message);
- Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
- }
- }
- }
- }
+ IMessage message = consumer.Receive(receiveTimeout);
+ AssertTextMessageEqual(request, message);
+ Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match");
+ }
+ }
+ }
+ }
- /// <summary>
- /// Assert that two messages are ITextMessages and their text bodies are equal.
- /// </summary>
- /// <param name="expected"></param>
- /// <param name="actual"></param>
- protected void AssertTextMessageEqual(IMessage expected, IMessage actual)
- {
- ITextMessage expectedTextMsg = expected as ITextMessage;
- Assert.IsNotNull(expectedTextMsg, "'expected' message not a text message");
- ITextMessage actualTextMsg = actual as ITextMessage;
- Assert.IsNotNull(actualTextMsg, "'actual' message not a text message");
- Assert.AreEqual(expectedTextMsg.Text, actualTextMsg.Text, "Text message does not match.");
- }
- }
-}
+ /// <summary>
+ /// Assert that two messages are ITextMessages and their text bodies are equal.
+ /// </summary>
+ /// <param name="expected"></param>
+ /// <param name="actual"></param>
+ protected void AssertTextMessageEqual(IMessage expected, IMessage actual)
+ {
+ ITextMessage expectedTextMsg = expected as ITextMessage;
+ Assert.IsNotNull(expectedTextMsg, "'expected' message not a text message");
+ ITextMessage actualTextMsg = actual as ITextMessage;
+ Assert.IsNotNull(actualTextMsg, "'actual' message not a text message");
+ Assert.AreEqual(expectedTextMsg.Text, actualTextMsg.Text, "Text message does not match.");
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/TransactionTest.cs b/test/nms-api-test/TransactionTest.cs
index 0fead48..3e20ca3 100644
--- a/test/nms-api-test/TransactionTest.cs
+++ b/test/nms-api-test/TransactionTest.cs
@@ -28,17 +28,17 @@
[Test]
public void TestSendRollback(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
{
IDestination destination = CreateDestination(session, DESTINATION_NAME);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
ITextMessage firstMsgSend = session.CreateTextMessage("First Message");
@@ -70,50 +70,51 @@
[Test]
public void TestSendSessionClose(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
ITextMessage firstMsgSend;
ITextMessage secondMsgSend;
- using(IConnection connection1 = CreateConnection(GetTestClientId()))
+ using (IConnection connection1 = CreateConnection(GetTestClientId()))
{
connection1.Start();
- using(ISession session1 = connection1.CreateSession(AcknowledgementMode.Transactional))
+ using (ISession session1 = connection1.CreateSession(AcknowledgementMode.Transactional))
{
IDestination destination1 = CreateDestination(session1, DESTINATION_NAME);
- using(IMessageConsumer consumer = session1.CreateConsumer(destination1))
+ using (IMessageConsumer consumer = session1.CreateConsumer(destination1))
{
// First connection session that sends one message, and the
// second message is implicitly rolled back as the session is
// disposed before Commit() can be called.
- using(IConnection connection2 = CreateConnection(GetTestClientId()))
+ using (IConnection connection2 = CreateConnection(GetTestClientId()))
{
connection2.Start();
- using(ISession session2 = connection2.CreateSession(AcknowledgementMode.Transactional))
+ using (ISession session2 = connection2.CreateSession(AcknowledgementMode.Transactional))
{
IDestination destination2 = CreateDestination(session2, DESTINATION_NAME);
- using(IMessageProducer producer = session2.CreateProducer(destination2))
+ using (IMessageProducer producer = session2.CreateProducer(destination2))
{
producer.DeliveryMode = deliveryMode;
firstMsgSend = session2.CreateTextMessage("First Message");
producer.Send(firstMsgSend);
session2.Commit();
- ITextMessage rollbackMsg = session2.CreateTextMessage("I'm going to get rolled back.");
+ ITextMessage rollbackMsg =
+ session2.CreateTextMessage("I'm going to get rolled back.");
producer.Send(rollbackMsg);
}
}
}
// Second connection session that will send one message.
- using(IConnection connection2 = CreateConnection(GetTestClientId()))
+ using (IConnection connection2 = CreateConnection(GetTestClientId()))
{
connection2.Start();
- using(ISession session2 = connection2.CreateSession(AcknowledgementMode.Transactional))
+ using (ISession session2 = connection2.CreateSession(AcknowledgementMode.Transactional))
{
IDestination destination2 = CreateDestination(session2, DESTINATION_NAME);
- using(IMessageProducer producer = session2.CreateProducer(destination2))
+ using (IMessageProducer producer = session2.CreateProducer(destination2))
{
producer.DeliveryMode = deliveryMode;
secondMsgSend = session2.CreateTextMessage("Second Message");
@@ -139,17 +140,17 @@
[Test]
public void TestReceiveRollback(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
{
IDestination destination = CreateDestination(session, DESTINATION_NAME);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
// Send both messages
@@ -181,17 +182,17 @@
[Test]
public void TestReceiveTwoThenRollback(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
+ using (ISession session = connection.CreateSession(AcknowledgementMode.Transactional))
{
IDestination destination = CreateDestination(session, DESTINATION_NAME);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
// Send both messages
@@ -224,19 +225,19 @@
[Test]
public void TestSendCommitNonTransaction(
- [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)]
- AcknowledgementMode ackMode,
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)]
+ AcknowledgementMode ackMode,
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
+ using (ISession session = connection.CreateSession(ackMode))
{
IDestination destination = CreateDestination(session, DESTINATION_NAME);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
ITextMessage firstMsgSend = session.CreateTextMessage("SendCommitNonTransaction Message");
@@ -246,7 +247,7 @@
session.Commit();
Assert.Fail("Should have thrown an InvalidOperationException.");
}
- catch(InvalidOperationException)
+ catch (InvalidOperationException)
{
}
}
@@ -256,19 +257,19 @@
[Test]
public void TestReceiveCommitNonTransaction(
- [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)]
- AcknowledgementMode ackMode,
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)]
+ AcknowledgementMode ackMode,
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
+ using (ISession session = connection.CreateSession(ackMode))
{
IDestination destination = CreateDestination(session, DESTINATION_NAME);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
ITextMessage firstMsgSend = session.CreateTextMessage("ReceiveCommitNonTransaction Message");
@@ -278,7 +279,7 @@
IMessage message = consumer.Receive(receiveTimeout);
AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
- if(AcknowledgementMode.ClientAcknowledge == ackMode)
+ if (AcknowledgementMode.ClientAcknowledge == ackMode)
{
message.Acknowledge();
}
@@ -288,7 +289,7 @@
session.Commit();
Assert.Fail("Should have thrown an InvalidOperationException.");
}
- catch(InvalidOperationException)
+ catch (InvalidOperationException)
{
}
}
@@ -298,19 +299,19 @@
[Test]
public void TestReceiveRollbackNonTransaction(
- [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)]
- AcknowledgementMode ackMode,
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
- {
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)]
+ AcknowledgementMode ackMode,
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
+ {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
- using(ISession session = connection.CreateSession(ackMode))
+ using (ISession session = connection.CreateSession(ackMode))
{
IDestination destination = CreateDestination(session, DESTINATION_NAME);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
{
producer.DeliveryMode = deliveryMode;
ITextMessage firstMsgSend = session.CreateTextMessage("ReceiveCommitNonTransaction Message");
@@ -320,7 +321,7 @@
IMessage message = consumer.Receive(receiveTimeout);
AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
- if(AcknowledgementMode.ClientAcknowledge == ackMode)
+ if (AcknowledgementMode.ClientAcknowledge == ackMode)
{
message.Acknowledge();
}
@@ -330,7 +331,7 @@
session.Rollback();
Assert.Fail("Should have thrown an InvalidOperationException.");
}
- catch(InvalidOperationException)
+ catch (InvalidOperationException)
{
}
}
@@ -355,14 +356,14 @@
[Test]
public void TestRedispatchOfRolledbackTx(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
ISession session = connection.CreateSession(AcknowledgementMode.Transactional);
- IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
SendMessages(connection, destination, deliveryMode, 2);
@@ -394,14 +395,14 @@
[Test]
public void TestRedispatchOfUncommittedTx(
- [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
- MsgDeliveryMode deliveryMode)
+ [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)]
+ MsgDeliveryMode deliveryMode)
{
- using(IConnection connection = CreateConnection(GetTestClientId()))
+ using (IConnection connection = CreateConnection(GetTestClientId()))
{
connection.Start();
ISession session = connection.CreateSession(AcknowledgementMode.Transactional);
- IDestination destination = CreateDestination(session, DestinationType.Queue);
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
SendMessages(connection, destination, deliveryMode, 2);
@@ -432,6 +433,4 @@
}
}
}
-}
-
-
+}
\ No newline at end of file
diff --git a/test/nms-api-test/URISupportTest.cs b/test/nms-api-test/URISupportTest.cs
index 772ba0d..995fa06 100644
--- a/test/nms-api-test/URISupportTest.cs
+++ b/test/nms-api-test/URISupportTest.cs
@@ -21,265 +21,267 @@
using NUnit.Framework;
#if !NETCF
using System.Web;
+
#endif
namespace Apache.NMS.Test
{
- [TestFixture()]
- public class URISupportTest
- {
- protected void AssertMapKey(StringDictionary map, String key, Object expected)
- {
- Assert.AreEqual(expected, map[key], "Map key: " + key);
- }
+ [TestFixture()]
+ public class URISupportTest
+ {
+ protected void AssertMapKey(StringDictionary map, String key, Object expected)
+ {
+ Assert.AreEqual(expected, map[key], "Map key: " + key);
+ }
- [Test]
- public void TestCreateSupportedUriVariations(
- [Values("tcp://127.0.0.1:61616",
- "tcp:127.0.0.1:61616",
- "failover:tcp://127.0.0.1:61616",
- "failover:(tcp://127.0.0.1:61616)",
- "failover://(tcp://127.0.0.1:61616)",
- "failover://(tcp://127.0.0.1:61616,tcp:192.168.0.1:61616)",
- "activemq:failover:(tcp://localhost:61616)",
- "activemq:failover:(tcp://${activemqhost}:61616)")]
- string uriString)
- {
- Uri result = URISupport.CreateCompatibleUri(NMSTestSupport.ReplaceEnvVar(uriString));
+ [Test]
+ public void TestCreateSupportedUriVariations(
+ [Values("tcp://127.0.0.1:61616",
+ "tcp:127.0.0.1:61616",
+ "failover:tcp://127.0.0.1:61616",
+ "failover:(tcp://127.0.0.1:61616)",
+ "failover://(tcp://127.0.0.1:61616)",
+ "failover://(tcp://127.0.0.1:61616,tcp:192.168.0.1:61616)",
+ "activemq:failover:(tcp://localhost:61616)",
+ "activemq:failover:(tcp://${activemqhost}:61616)")]
+ string uriString)
+ {
+ Uri result = URISupport.CreateCompatibleUri(NMSTestSupport.ReplaceEnvVar(uriString));
- Assert.IsNotNull(result);
- }
+ Assert.IsNotNull(result);
+ }
- [Test]
- public void TestParseCompositeWithFragment()
- {
- string uriString =
- "failover:(tcp://localhost:61616,ssl://remotehost:61617?param=true#fragment)#fragment";
+ [Test]
+ public void TestParseCompositeWithFragment()
+ {
+ string uriString =
+ "failover:(tcp://localhost:61616,ssl://remotehost:61617?param=true#fragment)#fragment";
- URISupport.CompositeData rc = URISupport.ParseComposite(new Uri(uriString));
+ URISupport.CompositeData rc = URISupport.ParseComposite(new Uri(uriString));
- Assert.IsTrue(rc.Components.Length == 2);
- Assert.AreEqual("failover", rc.Scheme);
- Assert.AreEqual("#fragment", rc.Fragment);
+ Assert.IsTrue(rc.Components.Length == 2);
+ Assert.AreEqual("failover", rc.Scheme);
+ Assert.AreEqual("#fragment", rc.Fragment);
- Uri uri1 = rc.Components[0];
- Uri uri2 = rc.Components[1];
+ Uri uri1 = rc.Components[0];
+ Uri uri2 = rc.Components[1];
- Assert.AreEqual("tcp", uri1.Scheme);
- Assert.AreEqual("ssl", uri2.Scheme);
- Assert.AreEqual("localhost", uri1.Host);
- Assert.AreEqual("remotehost", uri2.Host);
- Assert.AreEqual(61616, uri1.Port);
- Assert.AreEqual(61617, uri2.Port);
- Assert.IsTrue(String.IsNullOrEmpty(uri1.Fragment));
- Assert.IsNotNull(uri2.Fragment);
- Assert.AreEqual("#fragment", uri2.Fragment);
- Assert.AreEqual("?param=true", uri2.Query);
- }
+ Assert.AreEqual("tcp", uri1.Scheme);
+ Assert.AreEqual("ssl", uri2.Scheme);
+ Assert.AreEqual("localhost", uri1.Host);
+ Assert.AreEqual("remotehost", uri2.Host);
+ Assert.AreEqual(61616, uri1.Port);
+ Assert.AreEqual(61617, uri2.Port);
+ Assert.IsTrue(String.IsNullOrEmpty(uri1.Fragment));
+ Assert.IsNotNull(uri2.Fragment);
+ Assert.AreEqual("#fragment", uri2.Fragment);
+ Assert.AreEqual("?param=true", uri2.Query);
+ }
- [Test]
- public void TestCreateRemainingUriNonComposite()
- {
- string uriStringNoParams = "tcp://localhost:61616";
- string uriStringWithParams1 = "tcp://localhost:61616?param1=true¶m2=false";
- string uriStringWithParams2 = "tcp://localhost:61616?param2=false¶m1=true";
+ [Test]
+ public void TestCreateRemainingUriNonComposite()
+ {
+ string uriStringNoParams = "tcp://localhost:61616";
+ string uriStringWithParams1 = "tcp://localhost:61616?param1=true¶m2=false";
+ string uriStringWithParams2 = "tcp://localhost:61616?param2=false¶m1=true";
- Uri uriNoParams = new Uri(uriStringNoParams);
- Uri uriWithParams1 = new Uri(uriStringWithParams1);
+ Uri uriNoParams = new Uri(uriStringNoParams);
+ Uri uriWithParams1 = new Uri(uriStringWithParams1);
- Uri result = URISupport.CreateRemainingUri(uriNoParams, null);
- Assert.AreEqual(uriStringNoParams, result.OriginalString);
+ Uri result = URISupport.CreateRemainingUri(uriNoParams, null);
+ Assert.AreEqual(uriStringNoParams, result.OriginalString);
- result = URISupport.CreateRemainingUri(uriWithParams1, null);
- Assert.AreEqual(uriStringNoParams, result.OriginalString);
+ result = URISupport.CreateRemainingUri(uriWithParams1, null);
+ Assert.AreEqual(uriStringNoParams, result.OriginalString);
- StringDictionary parameters = new StringDictionary();
- parameters.Add("param1", "true");
- parameters.Add("param2", "false");
+ StringDictionary parameters = new StringDictionary();
+ parameters.Add("param1", "true");
+ parameters.Add("param2", "false");
- result = URISupport.CreateRemainingUri(uriNoParams, parameters);
- // Have to test for reordering of parameters. The StringDictionary that is used internally
- // does not guarantee ordering of parameters. Out of order parameters are equivalent.
- // We just want to test that they were created successfully.
- bool isEqual = (0 == string.Compare(uriStringWithParams1, result.OriginalString)
- || 0 == string.Compare(uriStringWithParams2, result.OriginalString));
- Assert.IsTrue(isEqual, string.Format("Error creating remaining Uri: {0}", result.OriginalString));
- }
+ result = URISupport.CreateRemainingUri(uriNoParams, parameters);
+ // Have to test for reordering of parameters. The StringDictionary that is used internally
+ // does not guarantee ordering of parameters. Out of order parameters are equivalent.
+ // We just want to test that they were created successfully.
+ bool isEqual = (0 == string.Compare(uriStringWithParams1, result.OriginalString)
+ || 0 == string.Compare(uriStringWithParams2, result.OriginalString));
+ Assert.IsTrue(isEqual, string.Format("Error creating remaining Uri: {0}", result.OriginalString));
+ }
- [Test]
- public void TestCreateRemainingUriComposite()
- {
- string uriStringNoParams = "failover:tcp://localhost:61616";
- string uriStringWithParams1 = "failover:tcp://localhost:61616?param1=true¶m2=false";
- string uriStringWithParams2 = "failover:tcp://localhost:61616?param2=false¶m1=true";
+ [Test]
+ public void TestCreateRemainingUriComposite()
+ {
+ string uriStringNoParams = "failover:tcp://localhost:61616";
+ string uriStringWithParams1 = "failover:tcp://localhost:61616?param1=true¶m2=false";
+ string uriStringWithParams2 = "failover:tcp://localhost:61616?param2=false¶m1=true";
- Uri uriNoParams = new Uri(uriStringNoParams);
- Uri uriWithParams = new Uri(uriStringWithParams1);
+ Uri uriNoParams = new Uri(uriStringNoParams);
+ Uri uriWithParams = new Uri(uriStringWithParams1);
- Uri result = URISupport.CreateRemainingUri(uriNoParams, null);
- Assert.AreEqual(uriStringNoParams, result.OriginalString);
+ Uri result = URISupport.CreateRemainingUri(uriNoParams, null);
+ Assert.AreEqual(uriStringNoParams, result.OriginalString);
- result = URISupport.CreateRemainingUri(uriWithParams, null);
- Assert.AreEqual(uriStringNoParams, result.OriginalString);
+ result = URISupport.CreateRemainingUri(uriWithParams, null);
+ Assert.AreEqual(uriStringNoParams, result.OriginalString);
- StringDictionary parameters = new StringDictionary();
- parameters.Add("param1", "true");
- parameters.Add("param2", "false");
+ StringDictionary parameters = new StringDictionary();
+ parameters.Add("param1", "true");
+ parameters.Add("param2", "false");
- result = URISupport.CreateRemainingUri(uriNoParams, parameters);
- bool isEqual = (0 == string.Compare(uriStringWithParams1, result.OriginalString)
- || 0 == string.Compare(uriStringWithParams2, result.OriginalString));
- Assert.IsTrue(isEqual, string.Format("Error creating remaining Uri: {0}", result.OriginalString));
+ result = URISupport.CreateRemainingUri(uriNoParams, parameters);
+ bool isEqual = (0 == string.Compare(uriStringWithParams1, result.OriginalString)
+ || 0 == string.Compare(uriStringWithParams2, result.OriginalString));
+ Assert.IsTrue(isEqual, string.Format("Error creating remaining Uri: {0}", result.OriginalString));
- // Now test a Composite with parens.
+ // Now test a Composite with parens.
- uriStringNoParams = "failover:(tcp://localhost:61616)";
- uriStringWithParams1 = "failover:(tcp://localhost:61616)?param1=true¶m2=false";
- uriStringWithParams2 = "failover:(tcp://localhost:61616)?param2=false¶m1=true";
+ uriStringNoParams = "failover:(tcp://localhost:61616)";
+ uriStringWithParams1 = "failover:(tcp://localhost:61616)?param1=true¶m2=false";
+ uriStringWithParams2 = "failover:(tcp://localhost:61616)?param2=false¶m1=true";
- uriNoParams = new Uri(uriStringNoParams);
- uriWithParams = new Uri(uriStringWithParams1);
+ uriNoParams = new Uri(uriStringNoParams);
+ uriWithParams = new Uri(uriStringWithParams1);
- result = URISupport.CreateRemainingUri(uriNoParams, null);
- Assert.AreEqual(uriStringNoParams, result.OriginalString);
+ result = URISupport.CreateRemainingUri(uriNoParams, null);
+ Assert.AreEqual(uriStringNoParams, result.OriginalString);
- result = URISupport.CreateRemainingUri(uriWithParams, null);
- Assert.AreEqual(uriStringNoParams, result.OriginalString);
+ result = URISupport.CreateRemainingUri(uriWithParams, null);
+ Assert.AreEqual(uriStringNoParams, result.OriginalString);
- result = URISupport.CreateRemainingUri(uriNoParams, parameters);
- isEqual = (0 == string.Compare(uriStringWithParams1, result.OriginalString)
- || 0 == string.Compare(uriStringWithParams2, result.OriginalString));
- Assert.IsTrue(isEqual, string.Format("Error creating remaining Uri: {0}", result.OriginalString));
+ result = URISupport.CreateRemainingUri(uriNoParams, parameters);
+ isEqual = (0 == string.Compare(uriStringWithParams1, result.OriginalString)
+ || 0 == string.Compare(uriStringWithParams2, result.OriginalString));
+ Assert.IsTrue(isEqual, string.Format("Error creating remaining Uri: {0}", result.OriginalString));
- string queryString = URISupport.CreateQueryString(parameters);
- Assert.AreEqual(uriNoParams.OriginalString + "?" + queryString, result.OriginalString);
- }
+ string queryString = URISupport.CreateQueryString(parameters);
+ Assert.AreEqual(uriNoParams.OriginalString + "?" + queryString, result.OriginalString);
+ }
- [Test]
- public void TestEmptyCompositePath()
- {
- URISupport.CompositeData data = URISupport.ParseComposite(new Uri("broker:()/localhost?persistent=false"));
- Assert.AreEqual(0, data.Components.Length);
- }
+ [Test]
+ public void TestEmptyCompositePath()
+ {
+ URISupport.CompositeData data = URISupport.ParseComposite(new Uri("broker:()/localhost?persistent=false"));
+ Assert.AreEqual(0, data.Components.Length);
+ }
- [Test]
- public void TestCompositePath()
- {
- URISupport.CompositeData data = URISupport.ParseComposite(new Uri("test:(test:path)/path"));
- Assert.AreEqual("path", data.Path);
- data = URISupport.ParseComposite(new Uri("test:test:path"));
- Assert.IsNull(data.Path);
- }
+ [Test]
+ public void TestCompositePath()
+ {
+ URISupport.CompositeData data = URISupport.ParseComposite(new Uri("test:(test:path)/path"));
+ Assert.AreEqual("path", data.Path);
+ data = URISupport.ParseComposite(new Uri("test:test:path"));
+ Assert.IsNull(data.Path);
+ }
- [Test]
- public void TestSimpleComposite()
- {
- URISupport.CompositeData data = URISupport.ParseComposite(new Uri("test:tcp://part1"));
- Assert.AreEqual(1, data.Components.Length);
- }
+ [Test]
+ public void TestSimpleComposite()
+ {
+ URISupport.CompositeData data = URISupport.ParseComposite(new Uri("test:tcp://part1"));
+ Assert.AreEqual(1, data.Components.Length);
+ }
- [Test]
- public void TestComposite()
- {
- URISupport.CompositeData data = URISupport.ParseComposite(
- new Uri("test:(part1://host,part2://(sub1://part,sub2:part))"));
- Assert.AreEqual(2, data.Components.Length);
- }
+ [Test]
+ public void TestComposite()
+ {
+ URISupport.CompositeData data = URISupport.ParseComposite(
+ new Uri("test:(part1://host,part2://(sub1://part,sub2:part))"));
+ Assert.AreEqual(2, data.Components.Length);
+ }
- [Test]
- public void TestCompositeWithComponentParam()
- {
- URISupport.CompositeData data = URISupport.ParseComposite(new Uri("test:(part1://host?part1=true)?outside=true"));
- Assert.AreEqual(1, data.Components.Length);
- Assert.AreEqual(1, data.Parameters.Count);
- StringDictionary part1Params = URISupport.ParseParameters(data.Components[0]);
- Assert.AreEqual(1, part1Params.Count);
- Assert.IsTrue(part1Params.ContainsKey("part1"));
- }
+ [Test]
+ public void TestCompositeWithComponentParam()
+ {
+ URISupport.CompositeData data =
+ URISupport.ParseComposite(new Uri("test:(part1://host?part1=true)?outside=true"));
+ Assert.AreEqual(1, data.Components.Length);
+ Assert.AreEqual(1, data.Parameters.Count);
+ StringDictionary part1Params = URISupport.ParseParameters(data.Components[0]);
+ Assert.AreEqual(1, part1Params.Count);
+ Assert.IsTrue(part1Params.ContainsKey("part1"));
+ }
- [Test]
- public void TestParsingURI()
- {
- Uri source = new Uri("tcp://localhost:61626/foo/bar?cheese=Edam&x=123");
- StringDictionary map = URISupport.ParseParameters(source);
+ [Test]
+ public void TestParsingURI()
+ {
+ Uri source = new Uri("tcp://localhost:61626/foo/bar?cheese=Edam&x=123");
+ StringDictionary map = URISupport.ParseParameters(source);
- Assert.AreEqual(2, map.Count, "Size: " + map);
- AssertMapKey(map, "cheese", "Edam");
- AssertMapKey(map, "x", "123");
+ Assert.AreEqual(2, map.Count, "Size: " + map);
+ AssertMapKey(map, "cheese", "Edam");
+ AssertMapKey(map, "x", "123");
- Uri result = URISupport.RemoveQuery(source);
- Assert.AreEqual(new Uri("tcp://localhost:61626/foo/bar"), result);
- }
+ Uri result = URISupport.RemoveQuery(source);
+ Assert.AreEqual(new Uri("tcp://localhost:61626/foo/bar"), result);
+ }
- [Test]
- public void TestParsingCompositeURI()
- {
- URISupport.CompositeData data = URISupport.ParseComposite(
- URISupport.CreateCompatibleUri("failover://(tcp://localhost:61616)?name=foo"));
+ [Test]
+ public void TestParsingCompositeURI()
+ {
+ URISupport.CompositeData data = URISupport.ParseComposite(
+ URISupport.CreateCompatibleUri("failover://(tcp://localhost:61616)?name=foo"));
- Assert.AreEqual(1, data.Components.Length, "one component");
- Assert.AreEqual("localhost", data.Components[0].Host, "Component Host is incorrect");
- Assert.AreEqual(61616, data.Components[0].Port, "Component Port is incorrect");
- Assert.AreEqual(1, data.Parameters.Count, "Size: " + data.Parameters);
- }
+ Assert.AreEqual(1, data.Components.Length, "one component");
+ Assert.AreEqual("localhost", data.Components[0].Host, "Component Host is incorrect");
+ Assert.AreEqual(61616, data.Components[0].Port, "Component Port is incorrect");
+ Assert.AreEqual(1, data.Parameters.Count, "Size: " + data.Parameters);
+ }
- [Test]
- public void TestCheckParenthesis()
- {
- String str = "fred:(((ddd))";
- Assert.IsFalse(URISupport.CheckParenthesis(str));
- str += ")";
- Assert.IsTrue(URISupport.CheckParenthesis(str));
- }
+ [Test]
+ public void TestCheckParenthesis()
+ {
+ String str = "fred:(((ddd))";
+ Assert.IsFalse(URISupport.CheckParenthesis(str));
+ str += ")";
+ Assert.IsTrue(URISupport.CheckParenthesis(str));
+ }
- [Test]
- public void TestParseQueury()
- {
- String query1 = "?param1=false¶m2=true";
- String query2 = "param3=false¶m4=true¶m5=foo";
+ [Test]
+ public void TestParseQueury()
+ {
+ String query1 = "?param1=false¶m2=true";
+ String query2 = "param3=false¶m4=true¶m5=foo";
- StringDictionary results = URISupport.ParseQuery(query1);
+ StringDictionary results = URISupport.ParseQuery(query1);
- Assert.IsTrue(results.Count == 2);
- Assert.AreEqual("false", results["param1"]);
- Assert.AreEqual("true", results["param2"]);
+ Assert.IsTrue(results.Count == 2);
+ Assert.AreEqual("false", results["param1"]);
+ Assert.AreEqual("true", results["param2"]);
- results = URISupport.ParseQuery(query2);
+ results = URISupport.ParseQuery(query2);
- Assert.IsTrue(results.Count == 3);
- Assert.AreEqual("false", results["param3"]);
- Assert.AreEqual("true", results["param4"]);
- Assert.AreEqual("foo", results["param5"]);
+ Assert.IsTrue(results.Count == 3);
+ Assert.AreEqual("false", results["param3"]);
+ Assert.AreEqual("true", results["param4"]);
+ Assert.AreEqual("foo", results["param5"]);
- String query3 = "?param";
+ String query3 = "?param";
- try
- {
- URISupport.ParseQuery(query3);
- Assert.Fail("Should have thrown an Exception on invalid parameter.");
- }
- catch
- {
- }
- }
+ try
+ {
+ URISupport.ParseQuery(query3);
+ Assert.Fail("Should have thrown an Exception on invalid parameter.");
+ }
+ catch
+ {
+ }
+ }
- [Test]
- public void TestCreateWithQuery()
- {
- Uri source = new Uri("vm://localhost");
- Uri dest = URISupport.CreateUriWithQuery(source, "network=true&one=two");
+ [Test]
+ public void TestCreateWithQuery()
+ {
+ Uri source = new Uri("vm://localhost");
+ Uri dest = URISupport.CreateUriWithQuery(source, "network=true&one=two");
- Assert.AreEqual(2, URISupport.ParseParameters(dest).Count, "correct param count");
- Assert.AreEqual(source.Host, dest.Host, "same uri, host");
- Assert.AreEqual(source.Scheme, dest.Scheme, "same uri, scheme");
- Assert.IsFalse(dest.Query.Equals(source.Query), "same uri, ssp");
- }
+ Assert.AreEqual(2, URISupport.ParseParameters(dest).Count, "correct param count");
+ Assert.AreEqual(source.Host, dest.Host, "same uri, host");
+ Assert.AreEqual(source.Scheme, dest.Scheme, "same uri, scheme");
+ Assert.IsFalse(dest.Query.Equals(source.Query), "same uri, ssp");
+ }
#if !NETCF
- [Test]
- public void TestParseQueryEncoding() {
-
- String paramName = "name";
+ [Test]
+ public void TestParseQueryEncoding()
+ {
+ String paramName = "name";
String paramValue = "CN=Test, OU=bla, ..&%/§()%3q743847)/(&%/.. hjUIFHUFH";
String uriString = "http://someserver.com:1234/?";
@@ -296,6 +298,5 @@
NUnit.Framework.Assert.AreEqual(paramValue, value);
}
#endif
- }
-}
-
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/XmlMessageTest.cs b/test/nms-api-test/XmlMessageTest.cs
index 9d415fe..b25e6a4 100644
--- a/test/nms-api-test/XmlMessageTest.cs
+++ b/test/nms-api-test/XmlMessageTest.cs
@@ -21,53 +21,55 @@
namespace Apache.NMS.Test
{
- // For ease of cross-platform exchange of information, you might generate objects from
- // an XSD file using XSDObjectGen. However, C# has built-in support for serializing.
- // All of the XML attributes that are commented out are optional, but give you fine-grained
- // control over the serialized format if you need it.
+ // For ease of cross-platform exchange of information, you might generate objects from
+ // an XSD file using XSDObjectGen. However, C# has built-in support for serializing.
+ // All of the XML attributes that are commented out are optional, but give you fine-grained
+ // control over the serialized format if you need it.
- // [Serializable]
- public enum CheckType
- {
- // [XmlEnum(Name = "message")]
- message,
- // [XmlEnum(Name = "command")]
- command,
- // [XmlEnum(Name = "response")]
- response
- }
+ // [Serializable]
+ public enum CheckType
+ {
+ // [XmlEnum(Name = "message")]
+ message,
- // [XmlRoot(ElementName = "NMSTestXmlType1", IsNullable = false), Serializable]
- public class NMSTestXmlType1
- {
- // [XmlElement(ElementName = "crcCheck", IsNullable = false, DataType = "int")]
- public int crcCheck;
+ // [XmlEnum(Name = "command")]
+ command,
- // [XmlElement(Type = typeof(CheckType), ElementName = "checkType", IsNullable = false)]
- public CheckType checkType;
+ // [XmlEnum(Name = "response")]
+ response
+ }
- public NMSTestXmlType1()
- {
- crcCheck = 0;
- checkType = CheckType.message;
- }
- }
+ // [XmlRoot(ElementName = "NMSTestXmlType1", IsNullable = false), Serializable]
+ public class NMSTestXmlType1
+ {
+ // [XmlElement(ElementName = "crcCheck", IsNullable = false, DataType = "int")]
+ public int crcCheck;
- // [XmlRoot(ElementName = "NMSTestXmlType2", IsNullable = false), Serializable]
- public class NMSTestXmlType2
- {
- // [XmlElement(ElementName = "stringCheck", IsNullable = false, DataType = "string")]
- public string stringCheck;
+ // [XmlElement(Type = typeof(CheckType), ElementName = "checkType", IsNullable = false)]
+ public CheckType checkType;
- public NMSTestXmlType2()
- {
- stringCheck = String.Empty;
- }
- }
+ public NMSTestXmlType1()
+ {
+ crcCheck = 0;
+ checkType = CheckType.message;
+ }
+ }
- [TestFixture]
- public class XmlMessageTest : NMSTestSupport
- {
+ // [XmlRoot(ElementName = "NMSTestXmlType2", IsNullable = false), Serializable]
+ public class NMSTestXmlType2
+ {
+ // [XmlElement(ElementName = "stringCheck", IsNullable = false, DataType = "string")]
+ public string stringCheck;
+
+ public NMSTestXmlType2()
+ {
+ stringCheck = String.Empty;
+ }
+ }
+
+ [TestFixture]
+ public class XmlMessageTest : NMSTestSupport
+ {
#if NET_3_5 || MONO
[Test]
public void SendReceiveXmlMessage_Net35()
@@ -123,58 +125,59 @@
#else
- // Test the obsolete API versions until they are completely removed.
- [Test]
- public void SendReceiveXmlMessage()
- {
- using(IConnection connection = CreateConnection(GetTestClientId()))
- {
- connection.Start();
- using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
- {
- IDestination destination = CreateDestination(session, DestinationType.Queue);
- using(IMessageConsumer consumer = session.CreateConsumer(destination))
- using(IMessageProducer producer = session.CreateProducer(destination))
- {
- NMSTestXmlType1 srcIntObject = new NMSTestXmlType1();
- srcIntObject.crcCheck = 0xbadf00d;
- srcIntObject.checkType = CheckType.command;
- producer.Send(NMSConvert.ToXmlMessage(session, srcIntObject));
+ // Test the obsolete API versions until they are completely removed.
+ [Test]
+ public void SendReceiveXmlMessage()
+ {
+ using (IConnection connection = CreateConnection(GetTestClientId()))
+ {
+ connection.Start();
+ using (ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = CreateDestination(session, DestinationType.Queue);
+ using (IMessageConsumer consumer = session.CreateConsumer(destination))
+ using (IMessageProducer producer = session.CreateProducer(destination))
+ {
+ NMSTestXmlType1 srcIntObject = new NMSTestXmlType1();
+ srcIntObject.crcCheck = 0xbadf00d;
+ srcIntObject.checkType = CheckType.command;
+ producer.Send(NMSConvert.ToXmlMessage(session, srcIntObject));
- NMSTestXmlType2 srcStringObject = new NMSTestXmlType2();
- srcStringObject.stringCheck = "BadFood";
- producer.Send(NMSConvert.ToXmlMessage(session, srcStringObject));
+ NMSTestXmlType2 srcStringObject = new NMSTestXmlType2();
+ srcStringObject.stringCheck = "BadFood";
+ producer.Send(NMSConvert.ToXmlMessage(session, srcStringObject));
- // Demonstrate the ability to generically handle multiple object types
- // sent to the same consumer. If only one object type is ever sent to
- // the destination, then a simple inline cast is all that is necessary
- // when calling the NMSConvert.FromXmlMessage() function.
+ // Demonstrate the ability to generically handle multiple object types
+ // sent to the same consumer. If only one object type is ever sent to
+ // the destination, then a simple inline cast is all that is necessary
+ // when calling the NMSConvert.FromXmlMessage() function.
- for(int index = 0; index < 2; index++)
- {
- object receivedObject = NMSConvert.FromXmlMessage(consumer.Receive(receiveTimeout));
- Assert.IsNotNull(receivedObject, "Failed to retrieve XML message object.");
+ for (int index = 0; index < 2; index++)
+ {
+ object receivedObject = NMSConvert.FromXmlMessage(consumer.Receive(receiveTimeout));
+ Assert.IsNotNull(receivedObject, "Failed to retrieve XML message object.");
- if(receivedObject is NMSTestXmlType1)
- {
- NMSTestXmlType1 destObject = (NMSTestXmlType1) receivedObject;
- Assert.AreEqual(srcIntObject.crcCheck, destObject.crcCheck, "CRC integer mis-match.");
- Assert.AreEqual(srcIntObject.checkType, destObject.checkType, "Check type mis-match.");
- }
- else if(receivedObject is NMSTestXmlType2)
- {
- NMSTestXmlType2 destObject = (NMSTestXmlType2) receivedObject;
- Assert.AreEqual(srcStringObject.stringCheck, destObject.stringCheck, "CRC string mis-match.");
- }
- else
- {
- Assert.Fail("Invalid object type.");
- }
- }
- }
- }
- }
- }
+ if (receivedObject is NMSTestXmlType1)
+ {
+ NMSTestXmlType1 destObject = (NMSTestXmlType1) receivedObject;
+ Assert.AreEqual(srcIntObject.crcCheck, destObject.crcCheck, "CRC integer mis-match.");
+ Assert.AreEqual(srcIntObject.checkType, destObject.checkType, "Check type mis-match.");
+ }
+ else if (receivedObject is NMSTestXmlType2)
+ {
+ NMSTestXmlType2 destObject = (NMSTestXmlType2) receivedObject;
+ Assert.AreEqual(srcStringObject.stringCheck, destObject.stringCheck,
+ "CRC string mis-match.");
+ }
+ else
+ {
+ Assert.Fail("Invalid object type.");
+ }
+ }
+ }
+ }
+ }
+ }
#endif
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/test/nms-api-test/nms-api-test.csproj b/test/nms-api-test/nms-api-test.csproj
index ec7cd2c..d5a5900 100644
--- a/test/nms-api-test/nms-api-test.csproj
+++ b/test/nms-api-test/nms-api-test.csproj
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
+
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -16,62 +17,62 @@
under the License.
-->
<Project Sdk="Microsoft.NET.Sdk">
- <PropertyGroup>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <OutputType>Library</OutputType>
- <TargetFrameworks>net35;net40;netstandard2.0</TargetFrameworks>
- <RootNamespace>Apache.NMS.Test</RootNamespace>
- <AssemblyName>Apache.NMS.Test</AssemblyName>
- </PropertyGroup>
+ <PropertyGroup>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <OutputType>Library</OutputType>
+ <TargetFrameworks>net35;net40;netstandard2.0</TargetFrameworks>
+ <RootNamespace>Apache.NMS.Test</RootNamespace>
+ <AssemblyName>Apache.NMS.Test</AssemblyName>
+ </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)'=='Release'">
- <OutputPath>..\..\build\</OutputPath>
- <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
- </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)'=='Release'">
+ <OutputPath>..\..\build\</OutputPath>
+ <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
+ </PropertyGroup>
- <PropertyGroup>
- <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
- <PackageId>Apache.NMS.Test</PackageId>
- <Version>1.8.0</Version>
- <Authors>Apache ActiveMQ</Authors>
- <Company>Apache Software Foundation</Company>
- <Product>Apache NMS API</Product>
- <Description>Apache NMS (.Net Standard Messaging Library) Test Suite</Description>
- <Copyright>Copyright (C) 2005-2019 Apache Software Foundation</Copyright>
- <PackageProjectUrl>https://activemq.apache.org/components/nms/</PackageProjectUrl>
- <PackageLicense>https://github.com/apache/activemq-nms-api/blob/master/LICENSE.txt</PackageLicense>
- <PackageIconUrl>https://activemq.apache.org/assets/img/activemq_logo_icon.png</PackageIconUrl>
- <RepositoryUrl>https://github.com/apache/activemq-nms-api</RepositoryUrl>
- <RepositoryType>git</RepositoryType>
- <PackageTags>apache;activemq;nms;api;net;test;messaging</PackageTags>
- <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
- </PropertyGroup>
+ <PropertyGroup>
+ <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
+ <PackageId>Apache.NMS.Test</PackageId>
+ <Version>1.8.0</Version>
+ <Authors>Apache ActiveMQ</Authors>
+ <Company>Apache Software Foundation</Company>
+ <Product>Apache NMS API</Product>
+ <Description>Apache NMS (.Net Standard Messaging Library) Test Suite</Description>
+ <Copyright>Copyright (C) 2005-2019 Apache Software Foundation</Copyright>
+ <PackageProjectUrl>https://activemq.apache.org/components/nms/</PackageProjectUrl>
+ <PackageLicense>https://github.com/apache/activemq-nms-api/blob/master/LICENSE.txt</PackageLicense>
+ <PackageIconUrl>https://activemq.apache.org/assets/img/activemq_logo_icon.png</PackageIconUrl>
+ <RepositoryUrl>https://github.com/apache/activemq-nms-api</RepositoryUrl>
+ <RepositoryType>git</RepositoryType>
+ <PackageTags>apache;activemq;nms;api;net;test;messaging</PackageTags>
+ <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
+ </PropertyGroup>
- <ItemGroup>
- <None Include="..\..\LICENSE.txt" Pack="true" PackagePath="LICENSE.txt"/>
- <None Include="..\..\NOTICE.txt" Pack="true" PackagePath="NOTICE.txt"/>
- </ItemGroup>
+ <ItemGroup>
+ <None Include="..\..\LICENSE.txt" Pack="true" PackagePath="LICENSE.txt" />
+ <None Include="..\..\NOTICE.txt" Pack="true" PackagePath="NOTICE.txt" />
+ </ItemGroup>
- <PropertyGroup>
- <SignAssembly>true</SignAssembly>
- <AssemblyOriginatorKeyFile>..\..\keyfile\NMSKey.snk</AssemblyOriginatorKeyFile>
- </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>..\..\keyfile\NMSKey.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
- <ItemGroup>
- <PackageReference Include="NUnit" Version="3.12.0" />
- <PackageReference Include="NUnit.Console" Version="3.10.0" />
- <PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
- </ItemGroup>
+ <ItemGroup>
+ <PackageReference Include="NUnit" Version="3.12.0" />
+ <PackageReference Include="NUnit.Console" Version="3.10.0" />
+ <PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
+ </ItemGroup>
- <ItemGroup Condition=" '$(TargetFramework)' == 'net35'">
- <Reference Include="System.Web" />
- </ItemGroup>
+ <ItemGroup Condition=" '$(TargetFramework)' == 'net35'">
+ <Reference Include="System.Web" />
+ </ItemGroup>
- <ItemGroup Condition=" '$(TargetFramework)' == 'net40'">
- <Reference Include="System.Web" />
- </ItemGroup>
+ <ItemGroup Condition=" '$(TargetFramework)' == 'net40'">
+ <Reference Include="System.Web" />
+ </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\src\nms-api\nms-api.csproj" />
- </ItemGroup>
-</Project>
+ <ItemGroup>
+ <ProjectReference Include="..\..\src\nms-api\nms-api.csproj" />
+ </ItemGroup>
+</Project>
\ No newline at end of file