Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/NMSTestSupport.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/NMSTestSupport.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/NMSTestSupport.cs 
(added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/NMSTestSupport.cs 
Wed Jan  6 02:19:56 2016
@@ -0,0 +1,651 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using System.Collections;
+using System.IO;
+using System.Reflection;
+using System.Text.RegularExpressions;
+using System.Xml;
+using Apache.NMS.Util;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+       /// <summary>
+       /// Useful class for test cases support.
+       /// </summary>
+       public class NMSTestSupport
+       {
+               protected TimeSpan receiveTimeout = 
TimeSpan.FromMilliseconds(15000);
+               protected int testRun;
+               protected int idCounter;
+
+        protected Type testClassType;
+               public Type TestClassType
+               {
+                       get { return this.testClassType; }
+                       set { this.testClassType = value; }
+               }
+
+               #region Constructors
+
+               public NMSTestSupport()
+               {
+               }
+
+               #endregion
+
+               #region Set up and tear down
+
+               public virtual void SetUp()
+               {
+                       this.testRun++;
+               }
+
+               public virtual void TearDown()
+               {
+               }
+
+               #endregion
+
+               #region Configuration file
+
+               private XmlDocument configurationDocument = null;
+               /// <summary>
+               /// The configuration document.
+               /// </summary>
+               public XmlDocument ConfigurationDocument
+               {
+                       get
+                       {
+                               if(this.configurationDocument == null)
+                               {
+                                       this.configurationDocument = 
LoadConfigFile();
+                                       
Assert.IsTrue(this.configurationDocument != null,
+                                               "Error loading configuration.");
+                               }
+
+                               return this.configurationDocument;
+                       }
+               }
+
+               /// <summary>
+               /// Loads the configuration file.
+               /// </summary>
+               /// <returns>XmlDocument of the configuration file</returns>
+               public virtual XmlDocument LoadConfigFile()
+               {
+                       return LoadConfigFile(GetConfigFilePath());
+               }
+
+               /// <summary>
+               /// Loads the configuration file.
+               /// </summary>
+               /// <param name="configFilePath">Configuration file path</param>
+               /// <returns>XmlDocument of the configuration file</returns>
+               public virtual XmlDocument LoadConfigFile(string configFilePath)
+               {
+                       XmlDocument configDoc = new XmlDocument();
+
+                       configDoc.Load(configFilePath);
+
+                       return configDoc;
+               }
+
+               /// <summary>
+               /// Gets the path of the configuration filename.
+               /// </summary>
+               /// <returns>Path of the configuration filename</returns>
+               public virtual string GetConfigFilePath()
+               {
+                       // The full path may be specified by an environment 
variable
+                       string configFilePath = 
GetEnvVar(GetConfigEnvVarName(), "");
+                       bool configFound = 
(!string.IsNullOrEmpty(configFilePath)
+                               && File.Exists(configFilePath));
+
+                       // Else it may be found in well known locations
+                       if(!configFound)
+                       {
+                               string[] paths = GetConfigSearchPaths();
+                               string configFileName = 
GetDefaultConfigFileName();
+
+                               foreach(string path in paths)
+                               {
+                                       string fullpath = Path.Combine(path, 
configFileName);
+                                       Tracer.Debug("\tScanning folder: " + 
path);
+
+                                       if(File.Exists(fullpath))
+                                       {
+                                               Tracer.Debug("\tAssembly 
found!");
+                                               configFilePath = fullpath;
+                                               configFound = true;
+                                               break;
+                                       }
+                               }
+                       }
+
+                       Tracer.Debug("\tConfig file: " + configFilePath);
+                       Assert.IsTrue(configFound, "Connection configuration 
file does not exist.");
+                       return configFilePath;
+               }
+
+               /// <summary>
+               /// Gets the environment variable name for the configuration 
file path.
+               /// </summary>
+               /// <returns>Environment variable name</returns>
+               public virtual string GetConfigEnvVarName()
+               {
+                       return "NMSTESTCONFIGPATH";
+               }
+
+               /// <summary>
+               /// Gets the default name for the configuration filename.
+               /// </summary>
+               /// <returns>Default name of the configuration 
filename</returns>
+               public virtual string GetDefaultConfigFileName()
+               {
+                       return "nmsprovider-test.config";
+               }
+
+               /// <summary>
+               /// Gets an array of paths where the configuration file sould 
be found.
+               /// </summary>
+               /// <returns>Array of paths</returns>
+               private static string[] GetConfigSearchPaths()
+               {
+                       ArrayList pathList = new ArrayList();
+
+                       // Check the current folder first.
+                       pathList.Add("");
+#if !NETCF
+                       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);
+                       }
+
+                       if(null != currentDomain.RelativeSearchPath)
+                       {
+                               pathList.Add(currentDomain.RelativeSearchPath);
+                       }
+#endif
+
+                       return (string[]) pathList.ToArray(typeof(string));
+               }
+
+               /// <summary>
+               /// Gets the value of the "value" attribute of the specified 
node.
+               /// </summary>
+               /// <param name="parentNode">Parent node</param>
+               /// <param name="nodeName">Node name</param>
+               /// <param name="defaultVaue">Default value</param>
+               /// <returns></returns>
+               public string GetNodeValueAttribute(XmlElement parentNode,
+                       string nodeName, string defaultVaue)
+               {
+                       XmlElement node = 
(XmlElement)parentNode.SelectSingleNode(nodeName);
+
+                       return (node == null ? defaultVaue : 
node.GetAttribute("value"));
+               }
+
+               #endregion
+
+               #region URI node
+
+               /// <summary>
+               /// Gets the URI node for the default configuration.
+               /// </summary>
+               /// <returns>URI node for the default configuration 
name</returns>
+               public virtual XmlElement GetURINode()
+               {
+                       return GetURINode(GetNameTestURI());
+               }
+
+               /// <summary>
+               /// Gets the URI node for the default configuration.
+               /// </summary>
+               /// <param name="nameTestURI">Name of the default configuration 
node
+               /// </param>
+               /// <returns>URI node for the default configuration 
name</returns>
+               public virtual XmlElement GetURINode(string nameTestURI)
+               {
+                       return 
(XmlElement)ConfigurationDocument.SelectSingleNode(
+                               String.Format("/configuration/{0}", 
nameTestURI));
+               }
+
+               /// <summary>
+               /// Gets the name of the default connection configuration to be 
loaded.
+               /// </summary>
+               /// <returns>Default configuration name</returns>
+               public virtual string GetNameTestURI()
+               {
+                       return "testURI";
+               }
+
+               #endregion
+
+               #region Factory
+
+               private NMSConnectionFactory nmsFactory;
+               /// <summary>
+               /// The connection factory interface property.
+               /// </summary>
+               public IConnectionFactory Factory
+               {
+                       get
+                       {
+                               if(this.nmsFactory == null)
+                               {
+                                       this.nmsFactory = CreateNMSFactory();
+
+                                       Assert.IsNotNull(this.nmsFactory, 
"Error creating factory.");
+                               }
+
+                               return this.nmsFactory.ConnectionFactory;
+                       }
+               }
+
+               /// <summary>
+               /// Create the NMS Factory that can create NMS Connections.
+               /// </summary>
+               /// <returns>Connection factory</returns>
+               public NMSConnectionFactory CreateNMSFactory()
+               {
+                       return CreateNMSFactory(GetNameTestURI());
+               }
+
+               /// <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>Connection factory</returns>
+               public NMSConnectionFactory CreateNMSFactory(string nameTestURI)
+               {
+                       XmlElement uriNode = GetURINode(nameTestURI);
+
+                       Uri brokerUri = null;
+                       object[] factoryParams = null;
+                       if(uriNode != null)
+                       {
+                               // Replace any environment variables embedded 
inside the string.
+                               brokerUri = new 
Uri(uriNode.GetAttribute("value"));
+                               factoryParams = GetFactoryParams(uriNode);
+                               clientId = GetNodeValueAttribute(uriNode, 
"clientId", "NMSTestClientId");
+                               userName = GetNodeValueAttribute(uriNode, 
"userName", null);
+                               passWord = GetNodeValueAttribute(uriNode, 
"passWord", null);
+                       }
+
+                       if(factoryParams == null)
+                       {
+                               this.nmsFactory = new 
Apache.NMS.NMSConnectionFactory(brokerUri);
+                       }
+                       else
+                       {
+                               this.nmsFactory = new 
Apache.NMS.NMSConnectionFactory(brokerUri, factoryParams);
+                       }
+
+                       return this.nmsFactory;
+               }
+
+               /// <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>
+               public object[] GetFactoryParams(XmlElement uriNode)
+               {
+                       ArrayList factoryParams = new ArrayList();
+                       XmlElement factoryParamsNode = 
(XmlElement)uriNode.SelectSingleNode("factoryParams");
+
+                       if(factoryParamsNode != null)
+                       {
+                               XmlNodeList nodeList = 
factoryParamsNode.SelectNodes("param");
+
+                               if(nodeList != null)
+                               {
+                                       foreach(XmlElement paramNode in 
nodeList)
+                                       {
+                                               string paramType = 
paramNode.GetAttribute("type");
+                                               string paramValue = 
paramNode.GetAttribute("value");
+
+                                               switch(paramType)
+                                               {
+                                                       case "string":
+                                                               
factoryParams.Add(paramValue);
+                                                               break;
+
+                                                       case "int":
+                                                               
factoryParams.Add(int.Parse(paramValue));
+                                                               break;
+
+                                                       // TODO: Add more 
parameter types
+                                               }
+                                       }
+                               }
+                       }
+
+                       if(factoryParams.Count > 0)
+                       {
+                               return factoryParams.ToArray();
+                       }
+
+                       return null;
+               }
+
+               #endregion
+
+               #region Environment variables
+
+               /// <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);
+#endif
+                       if(null == varValue)
+                       {
+                               varValue = defaultValue;
+                       }
+
+                       return varValue;
+               }
+
+               #endregion
+
+               #region Client id and connection
+
+               protected string clientId;
+               /// <summary>
+               /// Client id.
+               /// </summary>
+               public string ClientId
+               {
+                       get { return this.clientId; }
+               }
+
+               /// <summary>
+               /// Gets a new client id.
+               /// </summary>
+               /// <returns>Client id</returns>
+               public virtual string GetTestClientId()
+               {
+                       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);
+
+                       return id.ToString();
+               }
+
+               protected string userName;
+               /// <summary>
+               /// User name.
+               /// </summary>
+               public string UserName
+               {
+                       get { return this.userName; }
+               }
+
+               protected string passWord;
+               /// <summary>
+               /// User pass word.
+               /// </summary>
+               public string PassWord
+               {
+                       get { return this.passWord; }
+               }
+
+               /// <summary>
+               /// Create a new connection to the broker.
+               /// </summary>
+               /// <returns>New connection</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>New connection</returns>
+               public virtual IConnection CreateConnection(string newClientId)
+               {
+                       IConnection newConnection;
+
+                       if(this.userName == null)
+                       {
+                               newConnection = Factory.CreateConnection();
+                       }
+                       else
+                       {
+                               newConnection = 
Factory.CreateConnection(userName, passWord);
+                       }
+
+                       Assert.IsNotNull(newConnection, "Connection not 
created");
+
+                       if(newClientId != null)
+                       {
+                               newConnection.ClientId = newClientId;
+                       }
+
+                       return newConnection;
+               }
+
+               /// <summary>
+               /// Create a new connection to the broker, and start it.
+               /// </summary>
+               /// <returns>Started connection</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>Started connection</returns>
+               public virtual IConnection CreateConnectionAndStart(string 
newClientId)
+               {
+                       IConnection newConnection = 
CreateConnection(newClientId);
+                       newConnection.Start();
+                       return newConnection;
+               }
+
+               #endregion
+
+               #region Destination
+
+               /// <summary>
+               /// Gets a clear destination.
+               /// </summary>
+               /// <param name="session">Session</param>
+               /// <param name="type">Destination type</param>
+               /// <param name="destinationRef">Configuration node name for the
+               /// destination URI</param>
+               /// <returns>Destination</returns>
+               public virtual IDestination GetClearDestination(ISession 
session,
+                       DestinationType type, string destinationRef)
+               {
+                       string uri = GetDestinationURI(type, destinationRef);
+
+                       return GetClearDestination(session, uri);
+               }
+
+               /// <summary>
+               /// Gets a clear destination. This will try to delete an 
existing
+               /// destination and re-create it.
+               /// </summary>
+               /// <param name="session">Session</param>
+               /// <param name="destinationURI">Destination URI</param>
+               /// <returns>Clear destination</returns>
+               public virtual IDestination GetClearDestination(ISession 
session,
+                       string destinationURI)
+               {
+                       IDestination destination;
+
+                       try
+                       {
+                               DeleteDestination(session, destinationURI);
+                               destination = CreateDestination(session, 
destinationURI);
+                       }
+                       catch(Exception)
+                       {
+                               // Can't delete it, so lets try and purge it.
+                               destination = 
SessionUtil.GetDestination(session, destinationURI);
+
+                               using(IMessageConsumer consumer = 
session.CreateConsumer(destination))
+                               {
+                                       
while(consumer.Receive(TimeSpan.FromMilliseconds(750)) != null)
+                                       {
+                                       }
+                               }
+                       }
+
+                       return destination;
+               }
+
+               /// <summary>
+               /// Deletes a destination.
+               /// </summary>
+               /// <param name="session">Session</param>
+               /// <param name="destinationURI">Destination URI</param>
+               protected virtual void DeleteDestination(ISession session,
+                       string destinationURI)
+               {
+                       // Only delete the destination if it can be recreated
+                       // SessionUtil.DeleteDestination(session, 
destinationURI, DestinationType.Queue)
+                       throw new NotSupportedException();
+               }
+
+               /// <summary>
+               /// Creates a destination.
+               /// </summary>
+               /// <param name="session">Session</param>
+               /// <param name="destinationURI">Destination URI</param>
+               protected virtual IDestination CreateDestination(ISession 
session,
+                       string destinationURI)
+               {
+                       throw new NotSupportedException();
+               }
+
+               /// <summary>
+               /// Gets an existing destination. Don't clear its contents.
+               /// </summary>
+               /// <param name="session">Session</param>
+               /// <param name="type">Destination type</param>
+               /// <param name="destinationRef">Configuration node name for the
+               /// destination URI</param>
+               /// <returns>Destination</returns>
+               public virtual IDestination GetDestination(ISession session,
+                       DestinationType type, string destinationRef)
+               {
+                       string uri = GetDestinationURI(type, destinationRef);
+
+                       IDestination destination = 
SessionUtil.GetDestination(session, uri);
+
+                       return destination;
+               }
+
+               /// <summary>
+               /// Gets a destination URI.
+               /// </summary>
+               /// <param name="type">Destination type</param>
+               /// <param name="destinationRef">Configuration node name for the
+               /// destination URI</param>
+               /// <returns>Destination URI</returns>
+               public virtual string GetDestinationURI(
+                       DestinationType type, string destinationRef)
+               {
+                       string uri = null;
+
+                       if(!string.IsNullOrEmpty(destinationRef))
+                       {
+                               XmlElement uriNode = GetURINode();
+
+                               if(uriNode != null)
+                               {
+                                       uri = GetNodeValueAttribute(uriNode, 
destinationRef, null);
+                               }
+                       }
+
+                       if(string.IsNullOrEmpty(uri))
+                       {
+                               uri = NewDestinationURI(type);
+                       }
+
+                       return uri;
+               }
+
+               /// <summary>
+               /// Gets a new destination URI.
+               /// </summary>
+               /// <param name="type">Destination type</param>
+               /// <returns>Destination URI</returns>
+               public virtual string NewDestinationURI(DestinationType type)
+               {
+                       string name = "TEST." + this.TestClassType.Name
+                                               + "." + 
Guid.NewGuid().ToString();
+                       string scheme;
+                       switch(type)
+                       {
+                               case DestinationType.Queue:
+                                       scheme = "queue://";
+                                       break;
+
+                               case DestinationType.Topic:
+                                       scheme = "topic://";
+                                       break;
+
+                               case DestinationType.TemporaryQueue:
+                                       scheme = "temp-queue://";
+                                       break;
+
+                               case DestinationType.TemporaryTopic:
+                                       scheme = "temp-topic://";
+                                       break;
+
+                               default:
+                                       throw new ArgumentException("type: " + 
type);
+                       }
+
+                       return scheme + name;
+               }
+
+               #endregion
+       }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/NMSTracer.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/NMSTracer.cs?rev=1723221&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/NMSTracer.cs 
(added)
+++ activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/NMSTracer.cs 
Wed Jan  6 02:19:56 2016
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#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)
+               {
+#if !NETCF
+                       
System.Diagnostics.Trace.WriteLine(string.Format("DEBUG: {0}", message));
+#endif
+               }
+
+               public void Error(string message)
+               {
+#if !NETCF
+                       
System.Diagnostics.Trace.WriteLine(string.Format("ERROR: {0}", message));
+#endif
+               }
+
+               public void Fatal(string message)
+               {
+#if !NETCF
+                       
System.Diagnostics.Trace.WriteLine(string.Format("FATAL: {0}", message));
+#endif
+               }
+
+               public void Info(string message)
+               {
+#if !NETCF
+                       System.Diagnostics.Trace.WriteLine(string.Format("INFO: 
{0}", message));
+#endif
+               }
+
+               public void Warn(string message)
+               {
+#if !NETCF
+                       System.Diagnostics.Trace.WriteLine(string.Format("WARN: 
{0}", message));
+#endif
+               }
+
+               public bool IsDebugEnabled
+               {
+                       get { return true; }
+               }
+
+               public bool IsErrorEnabled
+               {
+                       get { return true; }
+               }
+
+               public bool IsFatalEnabled
+               {
+                       get { return true; }
+               }
+
+               public bool IsInfoEnabled
+               {
+                       get { return true; }
+               }
+
+               public bool IsWarnEnabled
+               {
+                       get { return true; }
+               }
+
+               #endregion
+       }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/PrimitiveMapTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/PrimitiveMapTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/PrimitiveMapTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/PrimitiveMapTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections;
+using Apache.NMS.Util;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+       [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();
+
+               [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 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();
+
+                       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;
+               }
+
+               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");
+
+                       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 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"));
+               }
+
+               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");
+
+                       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;
+               }
+       }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/ProducerTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/ProducerTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/ProducerTest.cs 
(added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/ProducerTest.cs 
Wed Jan  6 02:19:56 2016
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+       //[TestFixture]
+       public class ProducerTest : NMSTest
+       {
+               protected ProducerTest(NMSTestSupport testSupport)
+                       : base(testSupport)
+               {
+               }
+
+        //[Test]
+        public virtual void TestProducerSendToNullDestinationWithoutDefault()
+        {
+            using(IConnection connection = CreateConnection(GetTestClientId()))
+            {
+                connection.Start();
+                using(ISession session = connection.CreateSession())
+                {
+                    IMessageProducer producer = session.CreateProducer(null);
+
+                    try
+                    {
+                        producer.Send(null, 
session.CreateTextMessage("Message"));
+                        Assert.Fail("Producer should have thrown an 
NotSupportedException");
+                    }
+                    catch(NotSupportedException)
+                    {
+                    }
+                    catch(Exception ex)
+                    {
+                        Assert.Fail("Wrong Exception Type Thrown: " + 
ex.GetType().Name);
+                    }
+                }
+            }
+        }
+
+        //[Test]
+        public virtual void TestProducerSendToNullDestinationWithDefault()
+        {
+            using(IConnection connection = CreateConnection(GetTestClientId()))
+            {
+                connection.Start();
+                using(ISession session = connection.CreateSession())
+                {
+                    IDestination unusedDest = session.CreateTemporaryQueue();
+
+                    IMessageProducer producer = 
session.CreateProducer(unusedDest);
+
+                    try
+                    {
+                        producer.Send(null, 
session.CreateTextMessage("Message"));
+                        Assert.Fail("Producer should have thrown an 
InvalidDestinationException");
+                    }
+                    catch(InvalidDestinationException)
+                    {
+                    }
+                    catch(Exception ex)
+                    {
+                        Assert.Fail("Wrong Exception Type Thrown: " + 
ex.GetType().Name);
+                    }
+                }
+            }
+        }
+
+               //[Test]
+               public virtual void TestProducerSendToNonDefaultDestination()
+               {
+            using(IConnection connection = CreateConnection(GetTestClientId()))
+            {
+                connection.Start();
+                using(ISession session = connection.CreateSession())
+                {
+                                       IDestination unusedDest = 
session.CreateTemporaryQueue();
+                                       IDestination usedDest = 
session.CreateTemporaryQueue();
+
+                                       IMessageProducer producer = 
session.CreateProducer(unusedDest);
+
+                    try
+                    {
+                                           producer.Send(usedDest, 
session.CreateTextMessage("Message"));
+                        Assert.Fail("Producer should have thrown an 
NotSupportedException");
+                    }
+                    catch(NotSupportedException)
+                    {
+                    }
+                    catch(Exception ex)
+                    {
+                        Assert.Fail("Wrong Exception Type Thrown: " + 
ex.GetType().Name);
+                    }
+                               }
+                       }
+        }
+       }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/RedeliveryPolicyTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/RedeliveryPolicyTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/RedeliveryPolicyTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/RedeliveryPolicyTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using Apache.NMS.Policies;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+    [TestFixture]
+    public class RedeliveryPolicyTest
+    {
+        [Test]
+        public void Executes_redelivery_policy_with_backoff_enabled_correctly()
+        {
+            RedeliveryPolicy policy = new RedeliveryPolicy();
+
+            policy.BackOffMultiplier = 2;
+            policy.InitialRedeliveryDelay = 5;
+            policy.UseExponentialBackOff = true;
+
+            // simulate a retry of 10 times
+            Assert.IsTrue(policy.RedeliveryDelay(0) == 0, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(0));
+            Assert.IsTrue(policy.RedeliveryDelay(1) == 5, "redelivery delay 
not 10 is " + policy.RedeliveryDelay(1));
+            Assert.IsTrue(policy.RedeliveryDelay(2) == 10, "redelivery delay 
not 20 is " + policy.RedeliveryDelay(2));
+            Assert.IsTrue(policy.RedeliveryDelay(3) == 20, "redelivery delay 
not 40 is " + policy.RedeliveryDelay(3));
+            Assert.IsTrue(policy.RedeliveryDelay(4) == 40, "redelivery delay 
not 80 is " + policy.RedeliveryDelay(4));
+            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));
+        }
+
+        [Test]
+        public void 
Executes_redelivery_policy_with_backoff_of_3_enabled_correctly()
+        {
+            RedeliveryPolicy policy = new RedeliveryPolicy();
+
+            policy.BackOffMultiplier = 3;
+            policy.InitialRedeliveryDelay = 3;
+            policy.UseExponentialBackOff = true;
+
+            // simulate a retry of 10 times
+            Assert.IsTrue(policy.RedeliveryDelay(0) == 0, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(0));
+            Assert.IsTrue(policy.RedeliveryDelay(1) == 3, "redelivery delay 
not 10 is " + policy.RedeliveryDelay(1));
+            Assert.IsTrue(policy.RedeliveryDelay(2) == 9, "redelivery delay 
not 20 is " + policy.RedeliveryDelay(2));
+            Assert.IsTrue(policy.RedeliveryDelay(3) == 27, "redelivery delay 
not 40 is " + policy.RedeliveryDelay(3));
+            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));
+        }
+
+        [Test]
+        public void 
Executes_redelivery_policy_without_backoff_enabled_correctly()
+        {
+            RedeliveryPolicy policy = new RedeliveryPolicy();
+
+            policy.InitialRedeliveryDelay = 5;
+
+            // simulate a retry of 10 times
+            Assert.IsTrue(policy.RedeliveryDelay(0) == 0, "redelivery delay 
not 0 is " + policy.RedeliveryDelay(0));
+            Assert.IsTrue(policy.RedeliveryDelay(1) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(1));
+            Assert.IsTrue(policy.RedeliveryDelay(2) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(2));
+            Assert.IsTrue(policy.RedeliveryDelay(3) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(3));
+            Assert.IsTrue(policy.RedeliveryDelay(4) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(4));
+            Assert.IsTrue(policy.RedeliveryDelay(5) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(5));
+            Assert.IsTrue(policy.RedeliveryDelay(6) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(6));
+            Assert.IsTrue(policy.RedeliveryDelay(7) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(7));
+            Assert.IsTrue(policy.RedeliveryDelay(8) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(8));
+            Assert.IsTrue(policy.RedeliveryDelay(9) == 5, "redelivery delay 
not 5 is " + policy.RedeliveryDelay(9));
+        }
+
+        [Test]
+        public void Should_get_collision_percent_correctly()
+        {
+            RedeliveryPolicy policy = new RedeliveryPolicy();
+
+            policy.CollisionAvoidancePercent = 45;
+
+            Assert.IsTrue(policy.CollisionAvoidancePercent == 45);
+        }
+
+        [Test]
+        public void 
Executes_redelivery_policy_with_collision_enabled_correctly()
+        {
+            RedeliveryPolicy policy = new RedeliveryPolicy();
+
+            policy.BackOffMultiplier = 2;
+            policy.InitialRedeliveryDelay = 5;
+            policy.UseExponentialBackOff = true;
+            policy.UseCollisionAvoidance = true;
+            policy.CollisionAvoidancePercent = 10;
+
+            // simulate a retry of 10 times
+            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));
+            delay = policy.RedeliveryDelay(2);
+            Assert.IsTrue(delay >= 9 && delay <= 11, "not delay >= 9 && delay 
<= 11 is " + policy.RedeliveryDelay(2));
+            delay = policy.RedeliveryDelay(3);
+            Assert.IsTrue(delay >= 18 && delay <= 22, "not delay >= 18 && 
delay <= 22 is " + policy.RedeliveryDelay(3));
+            delay = policy.RedeliveryDelay(4);
+            Assert.IsTrue(delay >= 36 && delay <= 44, "not delay >= 36 && 
delay <= 44 is " + policy.RedeliveryDelay(4));
+            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));
+            delay = 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));
+            delay = 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));
+        }
+    }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/RequestResponseTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/RequestResponseTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/RequestResponseTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/RequestResponseTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using Apache.NMS.Util;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+       //[TestFixture]
+       public class RequestResponseTest : NMSTest
+       {
+               protected RequestResponseTest(NMSTestSupport testSupport)
+                       : base(testSupport)
+               {
+               }
+
+               //[Test]
+               //[Category("RequestResponse")]         
+               public virtual void TestRequestResponseMessaging(string 
testQueueRef)
+               {
+                       using(IConnection connection = CreateConnection())
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       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);
+                                       }
+                               }
+                       }
+               }
+       }
+}
+

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/StreamMessageTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/StreamMessageTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/StreamMessageTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/StreamMessageTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using Apache.NMS.Util;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+       //[TestFixture]
+       public class StreamMessageTest : NMSTest
+       {
+               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 StreamMessageTest(NMSTestSupport testSupport)
+                       : base(testSupport)
+               {
+               }
+
+               //[Test]
+               public virtual void TestSendReceiveStreamMessage(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       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;
+                                               }
+
+                                               request.WriteBoolean(a);
+                                               request.WriteByte(b);
+                                               request.WriteChar(c);
+                                               request.WriteInt16(d);
+                                               request.WriteInt32(e);
+                                               request.WriteInt64(f);
+                                               request.WriteString(g);
+                                               request.WriteBoolean(h);
+                                               request.WriteByte(i);
+                                               request.WriteInt16(j);
+                                               request.WriteInt32(k);
+                                               request.WriteInt64(l);
+                                               request.WriteSingle(m);
+                                               request.WriteDouble(n);
+                                               producer.Send(request);
+
+                                               IStreamMessage message = 
consumer.Receive(receiveTimeout) as IStreamMessage;
+                                               Assert.IsNotNull(message, "No 
message returned!");
+                                               Assert.AreEqual(deliveryMode, 
message.NMSDeliveryMode, "NMSDeliveryMode does not match");
+
+                                               // use generic API to access 
entries
+                                               Assert.AreEqual(a, 
message.ReadBoolean(), "Stream Boolean Value: a");
+                                               Assert.AreEqual(b, 
message.ReadByte(), "Stream Byte Value: b");
+                                               Assert.AreEqual(c, 
message.ReadChar(), "Stream Char Value: c");
+                                               Assert.AreEqual(d, 
message.ReadInt16(), "Stream Int16 Value: d");
+                                               Assert.AreEqual(e, 
message.ReadInt32(), "Stream Int32 Value: e");
+                                               Assert.AreEqual(f, 
message.ReadInt64(), "Stream Int64 Value: f");
+                                               Assert.AreEqual(g, 
message.ReadString(), "Stream String Value: g");
+                                               Assert.AreEqual(h, 
message.ReadBoolean(), "Stream Boolean Value: h");
+                                               Assert.AreEqual(i, 
message.ReadByte(), "Stream Byte Value: i");
+                                               Assert.AreEqual(j, 
message.ReadInt16(), "Stream Int16 Value: j");
+                                               Assert.AreEqual(k, 
message.ReadInt32(), "Stream Int32 Value: k");
+                                               Assert.AreEqual(l, 
message.ReadInt64(), "Stream Int64 Value: l");
+                                               Assert.AreEqual(m, 
message.ReadSingle(), "Stream Single Value: m");
+                                               Assert.AreEqual(n, 
message.ReadDouble(), "Stream Double Value: n");
+                                       }
+                               }
+                       }
+               }
+       }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TempDestinationDeletionTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using Apache.NMS.Util;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+       //[TestFixture]
+       public class TempDestinationDeletionTest : NMSTest
+       {
+               protected TempDestinationDeletionTest(NMSTestSupport 
testSupport)
+                       : base(testSupport)
+               {
+               }
+
+               //[Test]
+               public virtual void TestTempDestinationDeletion(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode,
+                       //[Values(QUEUE_DESTINATION_NAME, 
TOPIC_DESTINATION_NAME, TEMP_QUEUE_DESTINATION_NAME, 
TEMP_TOPIC_DESTINATION_NAME)]
+                       string testDestinationURI)
+               {
+                       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 = 
GetClearDestination(session, testDestinationURI);
+
+                                               using(IMessageProducer producer 
= session.CreateProducer(destination))
+                                               using(IMessageConsumer consumer 
= session.CreateConsumer(destination))
+                                               {
+                                                       producer.DeliveryMode = 
deliveryMode;
+
+                                                       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();
+                                               }
+
+                                               try
+                                               {
+                                                       
session.DeleteDestination(destination);
+                                               }
+                                               catch(NotSupportedException)
+                                               {
+                                                       // Might as well not 
try this again.
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TempDestinationTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TempDestinationTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TempDestinationTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TempDestinationTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+    //[TestFixture]
+    public class TempDestinationTest : NMSTest
+    {
+        private IConnection connection;
+        private IList connections = ArrayList.Synchronized(new ArrayList());
+
+               protected TempDestinationTest(NMSTestSupport testSupport)
+                       : base(testSupport)
+               {
+               }
+
+        //[SetUp]
+        public override void SetUp()
+        {
+            base.SetUp();
+
+            this.connection = CreateConnection();
+            this.connections.Add(connection);
+        }
+
+        //[TearDown]
+        public override void TearDown()
+        {
+            foreach(IConnection conn in this.connections)
+            {
+                try
+                {
+                    conn.Close();
+                }
+                catch
+                {
+                }
+            }
+
+            connections.Clear();
+
+            base.TearDown();
+        }
+
+        //[Test]
+        public virtual void TestTempDestOnlyConsumedByLocalConn()
+        {
+            connection.Start();
+
+            ISession tempSession = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+            ITemporaryQueue queue = tempSession.CreateTemporaryQueue();
+            IMessageProducer producer = tempSession.CreateProducer(queue);
+            producer.DeliveryMode = (MsgDeliveryMode.NonPersistent);
+            ITextMessage message = tempSession.CreateTextMessage("First");
+            producer.Send(message);
+
+            // temp destination should not be consume when using another 
connection
+            IConnection otherConnection = CreateConnection();
+            connections.Add(otherConnection);
+            ISession otherSession = 
otherConnection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+            ITemporaryQueue otherQueue = otherSession.CreateTemporaryQueue();
+            IMessageConsumer consumer = 
otherSession.CreateConsumer(otherQueue);
+            IMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(3000));
+            Assert.IsNull(msg);
+
+            // should be able to consume temp destination from the same 
connection
+            consumer = tempSession.CreateConsumer(queue);
+            msg = consumer.Receive(TimeSpan.FromMilliseconds(3000));
+            Assert.IsNotNull(msg);
+        }
+
+        //[Test]
+        public virtual void TestTempQueueHoldsMessagesWithConsumers()
+        {
+            ISession session = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+            ITemporaryQueue queue = session.CreateTemporaryQueue();
+            IMessageConsumer consumer = session.CreateConsumer(queue);
+            connection.Start();
+
+            IMessageProducer producer = session.CreateProducer(queue);
+            producer.DeliveryMode = (MsgDeliveryMode.NonPersistent);
+            ITextMessage message = session.CreateTextMessage("Hello");
+            producer.Send(message);
+
+            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 + "'");
+        }
+
+        //[Test]
+        public virtual void TestTempQueueHoldsMessagesWithoutConsumers()
+        {
+            ISession session = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+            ITemporaryQueue queue = session.CreateTemporaryQueue();
+            IMessageProducer producer = session.CreateProducer(queue);
+            producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
+            ITextMessage message = session.CreateTextMessage("Hello");
+            producer.Send(message);
+
+            connection.Start();
+            IMessageConsumer consumer = session.CreateConsumer(queue);
+            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 + "'");
+        }
+
+        //[Test]
+        public virtual void TestTmpQueueWorksUnderLoad()
+        {
+            int count = 500;
+            int dataSize = 1024;
+
+            ArrayList list = new ArrayList(count);
+            ISession session = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
+            ITemporaryQueue queue = session.CreateTemporaryQueue();
+            IBytesMessage message;
+            IBytesMessage message2;
+            IMessageProducer producer = session.CreateProducer(queue);
+            producer.DeliveryMode = MsgDeliveryMode.NonPersistent;
+
+            byte[] srcdata = new byte[dataSize];
+            srcdata[0] = (byte) 'B';
+            srcdata[1] = (byte) 'A';
+            srcdata[2] = (byte) 'D';
+            srcdata[3] = (byte) 'W';
+            srcdata[4] = (byte) 'O';
+            srcdata[5] = (byte) 'L';
+            srcdata[6] = (byte) 'F';
+            for(int i = 0; i < count; i++)
+            {
+                message = session.CreateBytesMessage();
+                message.WriteBytes(srcdata);
+                message.Properties.SetInt("c", i);
+                producer.Send(message);
+                list.Add(message);
+            }
+
+            connection.Start();
+            byte[] data = new byte[dataSize];
+            byte[] data2 = new byte[dataSize];
+            IMessageConsumer consumer = session.CreateConsumer(queue);
+            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.ReadBytes(data);
+                message2.ReadBytes(data2);
+                Assert.AreEqual(data, data2);
+            }
+        }
+    }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TextMessageTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TextMessageTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TextMessageTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TextMessageTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using Apache.NMS.Util;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+       //[TestFixture]
+       public class TextMessageTest : NMSTest
+       {
+               protected TextMessageTest(NMSTestSupport testSupport)
+                       : base(testSupport)
+               {
+               }
+
+               //[Test]
+               public virtual void TestSendReceiveTextMessage(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       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");
+                                       }
+                               }
+                       }
+               }
+
+               /// <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.");
+               }
+       }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TransactionTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TransactionTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TransactionTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/TransactionTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,439 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using Apache.NMS.Util;
+using NUnit.Framework;
+
+namespace Apache.NMS.Test
+{
+       //[TestFixture]
+       public class TransactionTest : NMSTest
+       {
+               protected TransactionTest(NMSTestSupport testSupport)
+                       : base(testSupport)
+               {
+               }
+
+               //[Test]
+               public virtual void TestSendRollback(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(AcknowledgementMode.Transactional))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       using(IMessageConsumer consumer = 
session.CreateConsumer(destination))
+                                       using(IMessageProducer producer = 
session.CreateProducer(destination))
+                                       {
+                                               producer.DeliveryMode = 
deliveryMode;
+                                               ITextMessage firstMsgSend = 
session.CreateTextMessage("First Message");
+                                               producer.Send(firstMsgSend);
+                                               session.Commit();
+
+                                               ITextMessage rollbackMsg = 
session.CreateTextMessage("I'm going to get rolled back.");
+                                               producer.Send(rollbackMsg);
+                                               session.Rollback();
+
+                                               ITextMessage secondMsgSend = 
session.CreateTextMessage("Second Message");
+                                               producer.Send(secondMsgSend);
+                                               session.Commit();
+
+                                               // Receive the messages
+
+                                               IMessage message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+
+                                               message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(secondMsgSend, message, "Second message does not 
match.");
+
+                                               // validates that the rollback 
was not consumed
+                                               session.Commit();
+                                       }
+                               }
+                       }
+               }
+
+               //[Test]
+               public virtual void TestSendSessionClose(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       ITextMessage firstMsgSend;
+                       ITextMessage secondMsgSend;
+
+                       using(IConnection connection1 = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection1.Start();
+                               using(ISession session1 = 
connection1.CreateSession(AcknowledgementMode.Transactional))
+                               {
+                                       IDestination destination1 = 
GetClearDestination(session1, DestinationType.Queue, testQueueRef);
+                                       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()))
+                                               {
+                                                       connection2.Start();
+                                                       using(ISession session2 
= connection2.CreateSession(AcknowledgementMode.Transactional))
+                                                       {
+                                                               IDestination 
destination2 = GetClearDestination(session2, DestinationType.Queue, 
testQueueRef);
+                                                               
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.");
+                                                                       
producer.Send(rollbackMsg);
+                                                               }
+                                                       }
+                                               }
+
+                                               // Second connection session 
that will send one message.
+                                               using(IConnection connection2 = 
CreateConnection(GetTestClientId()))
+                                               {
+                                                       connection2.Start();
+                                                       using(ISession session2 
= connection2.CreateSession(AcknowledgementMode.Transactional))
+                                                       {
+                                                               IDestination 
destination2 = GetClearDestination(session2, DestinationType.Queue, 
testQueueRef);
+                                                               
using(IMessageProducer producer = session2.CreateProducer(destination2))
+                                                               {
+                                                                       
producer.DeliveryMode = deliveryMode;
+                                                                       
secondMsgSend = session2.CreateTextMessage("Second Message");
+                                                                       
producer.Send(secondMsgSend);
+                                                                       
session2.Commit();
+                                                               }
+                                                       }
+                                               }
+
+                                               // Check the consumer to verify 
which messages were actually received.
+                                               IMessage message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+
+                                               message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(secondMsgSend, message, "Second message does not 
match.");
+
+                                               // validates that the rollback 
was not consumed
+                                               session1.Commit();
+                                       }
+                               }
+                       }
+               }
+
+               //[Test]
+               public virtual void TestReceiveRollback(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(AcknowledgementMode.Transactional))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       using(IMessageConsumer consumer = 
session.CreateConsumer(destination))
+                                       using(IMessageProducer producer = 
session.CreateProducer(destination))
+                                       {
+                                               producer.DeliveryMode = 
deliveryMode;
+                                               // Send both messages
+                                               ITextMessage firstMsgSend = 
session.CreateTextMessage("First Message");
+                                               producer.Send(firstMsgSend);
+                                               ITextMessage secondMsgSend = 
session.CreateTextMessage("Second Message");
+                                               producer.Send(secondMsgSend);
+                                               session.Commit();
+
+                                               // Receive the messages
+
+                                               IMessage message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+                                               session.Commit();
+
+                                               message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(secondMsgSend, message, "Second message does not 
match.");
+
+                                               // Rollback so we can get that 
last message again.
+                                               session.Rollback();
+                                               IMessage rollbackMsg = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(secondMsgSend, rollbackMsg, "Rollback message does not 
match.");
+                                               session.Commit();
+                                       }
+                               }
+                       }
+               }
+
+
+               //[Test]
+               public virtual void TestReceiveTwoThenRollback(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(AcknowledgementMode.Transactional))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       using(IMessageConsumer consumer = 
session.CreateConsumer(destination))
+                                       using(IMessageProducer producer = 
session.CreateProducer(destination))
+                                       {
+                                               producer.DeliveryMode = 
deliveryMode;
+                                               // Send both messages
+                                               ITextMessage firstMsgSend = 
session.CreateTextMessage("First Message");
+                                               producer.Send(firstMsgSend);
+                                               ITextMessage secondMsgSend = 
session.CreateTextMessage("Second Message");
+                                               producer.Send(secondMsgSend);
+                                               session.Commit();
+
+                                               // Receive the messages
+
+                                               IMessage message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+                                               message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(secondMsgSend, message, "Second message does not 
match.");
+
+                                               // Rollback so we can get that 
last two messages again.
+                                               session.Rollback();
+                                               IMessage rollbackMsg = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(firstMsgSend, rollbackMsg, "First rollback message does 
not match.");
+                                               rollbackMsg = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(secondMsgSend, rollbackMsg, "Second rollback message 
does not match.");
+
+                                               
Assert.IsNull(consumer.ReceiveNoWait());
+                                               session.Commit();
+                                       }
+                               }
+                       }
+               }
+
+               //[Test]
+               public virtual void TestSendCommitNonTransaction(
+                       //[Values(AcknowledgementMode.AutoAcknowledge, 
AcknowledgementMode.ClientAcknowledge)]
+                       AcknowledgementMode ackMode,
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(ackMode))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       using(IMessageConsumer consumer = 
session.CreateConsumer(destination))
+                                       using(IMessageProducer producer = 
session.CreateProducer(destination))
+                                       {
+                                               producer.DeliveryMode = 
deliveryMode;
+                                               ITextMessage firstMsgSend = 
session.CreateTextMessage("SendCommitNonTransaction Message");
+                                               producer.Send(firstMsgSend);
+                                               try
+                                               {
+                                                       session.Commit();
+                                                       Assert.Fail("Should 
have thrown an InvalidOperationException.");
+                                               }
+                                               catch(InvalidOperationException)
+                                               {
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               //[Test]
+               public virtual void TestReceiveCommitNonTransaction(
+                       //[Values(AcknowledgementMode.AutoAcknowledge, 
AcknowledgementMode.ClientAcknowledge)]
+                       AcknowledgementMode ackMode,
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(ackMode))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       using(IMessageConsumer consumer = 
session.CreateConsumer(destination))
+                                       using(IMessageProducer producer = 
session.CreateProducer(destination))
+                                       {
+                                               producer.DeliveryMode = 
deliveryMode;
+                                               ITextMessage firstMsgSend = 
session.CreateTextMessage("ReceiveCommitNonTransaction Message");
+                                               producer.Send(firstMsgSend);
+
+                                               // Receive the messages
+
+                                               IMessage message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+                                               
if(AcknowledgementMode.ClientAcknowledge == ackMode)
+                                               {
+                                                       message.Acknowledge();
+                                               }
+
+                                               try
+                                               {
+                                                       session.Commit();
+                                                       Assert.Fail("Should 
have thrown an InvalidOperationException.");
+                                               }
+                                               catch(InvalidOperationException)
+                                               {
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               //[Test]
+               public virtual void TestReceiveRollbackNonTransaction(
+                       //[Values(AcknowledgementMode.AutoAcknowledge, 
AcknowledgementMode.ClientAcknowledge)]
+                       AcknowledgementMode ackMode,
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               using(ISession session = 
connection.CreateSession(ackMode))
+                               {
+                                       IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+                                       using(IMessageConsumer consumer = 
session.CreateConsumer(destination))
+                                       using(IMessageProducer producer = 
session.CreateProducer(destination))
+                                       {
+                                               producer.DeliveryMode = 
deliveryMode;
+                                               ITextMessage firstMsgSend = 
session.CreateTextMessage("ReceiveCommitNonTransaction Message");
+                                               producer.Send(firstMsgSend);
+
+                                               // Receive the messages
+
+                                               IMessage message = 
consumer.Receive(receiveTimeout);
+                                               
AssertTextMessageEqual(firstMsgSend, message, "First message does not match.");
+                                               
if(AcknowledgementMode.ClientAcknowledge == ackMode)
+                                               {
+                                                       message.Acknowledge();
+                                               }
+
+                                               try
+                                               {
+                                                       session.Rollback();
+                                                       Assert.Fail("Should 
have thrown an InvalidOperationException.");
+                                               }
+                                               catch(InvalidOperationException)
+                                               {
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               /// <summary>
+               /// Assert that two messages are ITextMessages and their text 
bodies are equal.
+               /// </summary>
+               /// <param name="expected"></param>
+               /// <param name="actual"></param>
+               /// <param name="message"></param>
+               protected void AssertTextMessageEqual(IMessage expected, 
IMessage actual, String message)
+               {
+                       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, message);
+               }
+
+               //[Test]
+               public virtual void TestRedispatchOfRolledbackTx(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               ISession session = 
connection.CreateSession(AcknowledgementMode.Transactional);
+                               IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+
+                               SendMessages(connection, destination, 
deliveryMode, 2);
+
+                               IMessageConsumer consumer = 
session.CreateConsumer(destination);
+                               
Assert.IsNotNull(consumer.Receive(TimeSpan.FromMilliseconds(1500)));
+                               
Assert.IsNotNull(consumer.Receive(TimeSpan.FromMilliseconds(1500)));
+
+                               // install another consumer while message 
dispatch is unacked/uncommitted
+                               ISession redispatchSession = 
connection.CreateSession(AcknowledgementMode.Transactional);
+                               IMessageConsumer redispatchConsumer = 
redispatchSession.CreateConsumer(destination);
+
+                               session.Rollback();
+                               session.Close();
+
+                               IMessage msg = 
redispatchConsumer.Receive(TimeSpan.FromMilliseconds(1500));
+                               Assert.IsNotNull(msg);
+                               Assert.IsTrue(msg.NMSRedelivered);
+                               Assert.AreEqual(2, 
msg.Properties.GetLong("NMSXDeliveryCount"));
+                               msg = 
redispatchConsumer.Receive(TimeSpan.FromMilliseconds(1500));
+                               Assert.IsNotNull(msg);
+                               Assert.IsTrue(msg.NMSRedelivered);
+                               Assert.AreEqual(2, 
msg.Properties.GetLong("NMSXDeliveryCount"));
+                               redispatchSession.Commit();
+
+                               
Assert.IsNull(redispatchConsumer.Receive(TimeSpan.FromMilliseconds(500)));
+                               redispatchSession.Close();
+                       }
+               }
+
+               //[Test]
+               public virtual void TestRedispatchOfUncommittedTx(
+                       //[Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode, string testQueueRef)
+               {
+                       using(IConnection connection = 
CreateConnection(GetTestClientId()))
+                       {
+                               connection.Start();
+                               ISession session = 
connection.CreateSession(AcknowledgementMode.Transactional);
+                               IDestination destination = 
GetClearDestination(session, DestinationType.Queue, testQueueRef);
+
+                               SendMessages(connection, destination, 
deliveryMode, 2);
+
+                               IMessageConsumer consumer = 
session.CreateConsumer(destination);
+                               
Assert.IsNotNull(consumer.Receive(TimeSpan.FromMilliseconds(2000)));
+                               
Assert.IsNotNull(consumer.Receive(TimeSpan.FromMilliseconds(2000)));
+
+                               // install another consumer while message 
dispatch is unacked/uncommitted
+                               ISession redispatchSession = 
connection.CreateSession(AcknowledgementMode.Transactional);
+                               IMessageConsumer redispatchConsumer = 
redispatchSession.CreateConsumer(destination);
+
+                               // no commit so will auto rollback and get 
re-dispatched to redisptachConsumer
+                               session.Close();
+
+                               IMessage msg = 
redispatchConsumer.Receive(TimeSpan.FromMilliseconds(2000));
+                               Assert.IsNotNull(msg);
+                               Assert.IsTrue(msg.NMSRedelivered);
+                               Assert.AreEqual(2, 
msg.Properties.GetLong("NMSXDeliveryCount"));
+
+                               msg = 
redispatchConsumer.Receive(TimeSpan.FromMilliseconds(2000));
+                               Assert.IsNotNull(msg);
+                               Assert.IsTrue(msg.NMSRedelivered);
+                               Assert.AreEqual(2, 
msg.Properties.GetLong("NMSXDeliveryCount"));
+                               redispatchSession.Commit();
+
+                               
Assert.IsNull(redispatchConsumer.Receive(TimeSpan.FromMilliseconds(500)));
+                               redispatchSession.Close();
+                       }
+               }
+       }
+}
+
+

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/XMSAsyncConsumeTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/XMSAsyncConsumeTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/XMSAsyncConsumeTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/XMSAsyncConsumeTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,106 @@
+/*
+ * 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.Threading;
+using Apache.NMS.Test;
+using NUnit.Framework;
+
+namespace Apache.NMS.XMS.Test
+{
+       [TestFixture]
+       public class XMSAsyncConsumeTest : AsyncConsumeTest
+       {
+               protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue";
+
+               public XMSAsyncConsumeTest() :
+                       base(new XMSTestSupport())
+               {
+               }
+
+               [SetUp]
+               public override void SetUp()
+               {
+                       base.SetUp();
+               }
+
+               [TearDown]
+               public override void TearDown()
+               {
+                       base.TearDown();
+               }
+
+               [Test]
+               public void TestAsynchronousConsume(
+                       [Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode)
+               {
+                       base.TestAsynchronousConsume(deliveryMode, 
DEFAULT_TEST_QUEUE);
+               }
+
+               [Test]
+               public void TestCreateConsumerAfterSend(
+                       [Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode)
+               {
+                       base.TestCreateConsumerAfterSend(deliveryMode, 
DEFAULT_TEST_QUEUE);
+               }
+
+               [Test]
+               public void TestCreateConsumerBeforeSendAddListenerAfterSend(
+                       [Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode)
+               {
+                       
base.TestCreateConsumerBeforeSendAddListenerAfterSend(deliveryMode, 
DEFAULT_TEST_QUEUE);
+               }
+
+               [Test]
+               public void TestAsynchronousTextMessageConsume(
+                       [Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode)
+               {
+                       base.TestAsynchronousTextMessageConsume(deliveryMode, 
DEFAULT_TEST_QUEUE);
+               }
+
+               [Test]
+               public void TestTemporaryQueueAsynchronousConsume(
+                       [Values(MsgDeliveryMode.Persistent, 
MsgDeliveryMode.NonPersistent)]
+                       MsgDeliveryMode deliveryMode)
+               {
+                       using(IConnection connection = 
CreateConnectionAndStart(GetTestClientId()))
+                       using(ISession syncSession = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+                       using(ISession asyncSession = 
connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+                       using(IDestination destination = 
GetClearDestination(syncSession, DestinationType.Queue, DEFAULT_TEST_QUEUE))
+                       using(ITemporaryQueue tempReplyDestination = 
syncSession.CreateTemporaryQueue())
+                       using(IMessageConsumer consumer = 
asyncSession.CreateConsumer(destination))
+                       using(IMessageConsumer tempConsumer = 
asyncSession.CreateConsumer(tempReplyDestination))
+                       using(IMessageProducer producer = 
syncSession.CreateProducer(destination))
+                       {
+                               producer.DeliveryMode = deliveryMode;
+                               tempConsumer.Listener += new 
MessageListener(OnMessage);
+                               consumer.Listener += new 
MessageListener(OnQueueMessage);
+
+                               IMessage request = syncSession.CreateMessage();
+                               request.NMSCorrelationID = 
"TemqQueueAsyncConsume";
+                               request.NMSType = "Test";
+                               request.NMSReplyTo = tempReplyDestination;
+                               producer.Send(request);
+
+                               WaitForMessageToArrive();
+                               Assert.AreEqual("TempQueueAsyncResponse", 
receivedMsg.NMSCorrelationID, "Invalid correlation ID.");
+                       }
+               }
+       }
+}

Added: 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/XMSBadConsumeTest.cs
URL: 
http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/XMSBadConsumeTest.cs?rev=1723221&view=auto
==============================================================================
--- 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/XMSBadConsumeTest.cs
 (added)
+++ 
activemq/activemq-dotnet/Apache.NMS.XMS/trunk/src/test/csharp/XMSBadConsumeTest.cs
 Wed Jan  6 02:19:56 2016
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using NUnit.Framework;
+using Apache.NMS.Test;
+
+namespace Apache.NMS.XMS.Test
+{
+       [TestFixture]
+       public class XMSBadConsumeTest : BadConsumeTest
+       {
+               public XMSBadConsumeTest()
+                       : base(new NMSTestSupport())
+               {
+               }
+
+               [SetUp]
+               public override void SetUp()
+               {
+                       base.SetUp();
+               }
+
+               [TearDown]
+               public override void TearDown()
+               {
+                       base.TearDown();
+               }
+
+               [Test]
+               [ExpectedException(Handler="ExceptionValidationCheck")]
+               public override void TestBadConsumerException()
+               {
+                       base.TestBadConsumerException();
+               }
+       }
+}


Reply via email to