activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r890491 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs
Date Mon, 14 Dec 2009 21:42:15 GMT
Author: tabish
Date: Mon Dec 14 21:42:13 2009
New Revision: 890491

URL: http://svn.apache.org/viewvc?rev=890491&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQNET-223

Add test to ensure that a client adhere's to the JMS Spec for MessageProducer destination
handling.

Added:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs   (with props)

Added: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs?rev=890491&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs Mon Dec 14 21:42:13
2009
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading;
+using Apache.NMS;
+using Apache.NMS.Util;
+using NUnit.Framework;
+using NUnit.Framework.Extensions;
+
+namespace Apache.NMS.Test
+{
+	[TestFixture]
+	public class ProducerTest : NMSTestSupport
+	{
+		protected static string TEST_CLIENT_ID = "TestProducerClientId";
+
+        [Test]
+        public void TestProducerSendToNullDestinationWithoutDefault()
+        {
+            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            {
+                connection.Start();
+                using(ISession session = connection.CreateSession())
+                {
+                    IDestination unusedDest = session.CreateTemporaryQueue();
+
+                    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 void TestProducerSendToNullDestinationWithDefault()
+        {
+            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            {
+                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 void TestProducerSendToNonDefaultDestination()
+		{
+            using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+            {
+                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);
+                    }
+				}
+			}
+        }
+	}
+}

Propchange: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/ProducerTest.cs
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message