Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 20303 invoked from network); 9 Oct 2006 21:00:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Oct 2006 21:00:15 -0000 Received: (qmail 10569 invoked by uid 500); 9 Oct 2006 21:00:15 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 10523 invoked by uid 500); 9 Oct 2006 21:00:14 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 10513 invoked by uid 99); 9 Oct 2006 21:00:14 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Oct 2006 14:00:14 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Oct 2006 14:00:08 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id B8CD41A982F; Mon, 9 Oct 2006 13:59:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r454506 [10/11] - in /incubator/activemq/activemq-dotnet/trunk/src: main/csharp/ActiveMQ/ main/csharp/ActiveMQ/Commands/ main/csharp/ActiveMQ/OpenWire/ main/csharp/ActiveMQ/OpenWire/V2/ main/csharp/ActiveMQ/Transport/ main/csharp/ActiveMQ/U... Date: Mon, 09 Oct 2006 20:59:17 -0000 To: activemq-commits@geronimo.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061009205922.B8CD41A982F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Modified: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/DurableTest.cs URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/DurableTest.cs?view=diff&rev=454506&r1=454505&r2=454506 ============================================================================== --- incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/DurableTest.cs (original) +++ incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/DurableTest.cs Mon Oct 9 13:59:14 2006 @@ -1,107 +1,107 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -using System; -using NUnit.Framework; - -namespace NMS.Test -{ - [TestFixture] - public abstract class DurableTest : NMSTestSupport - { - private static string TOPIC = "TestTopic"; - private static String CLIENT_ID = "DurableClientId"; - private static String CONSUMER_ID = "ConsumerId"; - - private int count = 0; - - public void RegisterDurableConsumer() - { - using (IConnection connection = Factory.CreateConnection()) - { - connection.ClientId = CLIENT_ID; - connection.Start(); - - using (ISession session = connection.CreateSession( - AcknowledgementMode.DupsOkAcknowledge)) - { - ITopic topic = session.GetTopic(TOPIC); - IMessageConsumer consumer = session.CreateDurableConsumer( - topic, CONSUMER_ID, "2 > 1", false); - consumer.Dispose(); - } - - connection.Stop(); - } - } - - public void SendPersistentMessage() - { - using (IConnection connection = Factory.CreateConnection()) - { - connection.Start(); - using (ISession session = connection.CreateSession( - AcknowledgementMode.DupsOkAcknowledge)) - { - ITopic topic = session.GetTopic(TOPIC); - ITextMessage message = session.CreateTextMessage("Hello"); - message.NMSPersistent = true; - IMessageProducer producer = session.CreateProducer(); - producer.Send(topic, message); - producer.Dispose(); - } - - connection.Stop(); - } - } - - [Test] - public void TestMe() - { - count = 0; - - RegisterDurableConsumer(); - SendPersistentMessage(); - - using (IConnection connection = Factory.CreateConnection()) - { - connection.ClientId = CLIENT_ID; - connection.Start(); - - using (ISession session = connection.CreateSession( - AcknowledgementMode.DupsOkAcknowledge)) - { - ITopic topic = session.GetTopic(TOPIC); - IMessageConsumer consumer = session.CreateDurableConsumer( - topic, CONSUMER_ID, "2 > 1", false); - consumer.Listener += new MessageListener(consumer_Listener); - /// Don't know how else to give the system enough time. /// Thread.Sleep(5000); Assert.AreEqual(0, count); Console.WriteLine("Count = " + count); SendPersistentMessage(); Thread.Sleep(5000); Assert.AreEqual(2, count); Console.WriteLine("Count = " + count); consumer.Dispose(); } - - connection.Stop(); - } - } - } - - /// - /// - /// - /// - private void consumer_Listener(IMessage message) - { - ++count; - } - } +/* + * 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 NMS.Test +{ + [TestFixture] + public abstract class DurableTest : NMSTestSupport + { + private static string TOPIC = "TestTopic"; + private static String CLIENT_ID = "DurableClientId"; + private static String CONSUMER_ID = "ConsumerId"; + + private int count = 0; + + public void RegisterDurableConsumer() + { + using (IConnection connection = Factory.CreateConnection()) + { + connection.ClientId = CLIENT_ID; + connection.Start(); + + using (ISession session = connection.CreateSession( + AcknowledgementMode.DupsOkAcknowledge)) + { + ITopic topic = session.GetTopic(TOPIC); + IMessageConsumer consumer = session.CreateDurableConsumer( + topic, CONSUMER_ID, "2 > 1", false); + consumer.Dispose(); + } + + connection.Stop(); + } + } + + public void SendPersistentMessage() + { + using (IConnection connection = Factory.CreateConnection()) + { + connection.Start(); + using (ISession session = connection.CreateSession( + AcknowledgementMode.DupsOkAcknowledge)) + { + ITopic topic = session.GetTopic(TOPIC); + ITextMessage message = session.CreateTextMessage("Hello"); + message.NMSPersistent = true; + IMessageProducer producer = session.CreateProducer(); + producer.Send(topic, message); + producer.Dispose(); + } + + connection.Stop(); + } + } + + [Test] + public void TestMe() + { + count = 0; + + RegisterDurableConsumer(); + SendPersistentMessage(); + + using (IConnection connection = Factory.CreateConnection()) + { + connection.ClientId = CLIENT_ID; + connection.Start(); + + using (ISession session = connection.CreateSession( + AcknowledgementMode.DupsOkAcknowledge)) + { + ITopic topic = session.GetTopic(TOPIC); + IMessageConsumer consumer = session.CreateDurableConsumer( + topic, CONSUMER_ID, "2 > 1", false); + consumer.Listener += new MessageListener(consumer_Listener); + /// Don't know how else to give the system enough time. /// Thread.Sleep(5000); Assert.AreEqual(0, count); Console.WriteLine("Count = " + count); SendPersistentMessage(); Thread.Sleep(5000); Assert.AreEqual(2, count); Console.WriteLine("Count = " + count); consumer.Dispose(); } + + connection.Stop(); + } + } + } + + /// + /// + /// + /// + private void consumer_Listener(IMessage message) + { + ++count; + } + } } Propchange: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/DurableTest.cs ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/JMSPropertyTest.cs URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/JMSPropertyTest.cs?view=diff&rev=454506&r1=454505&r2=454506 ============================================================================== --- incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/JMSPropertyTest.cs (original) +++ incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/JMSPropertyTest.cs Mon Oct 9 13:59:14 2006 @@ -1,142 +1,142 @@ -/* - * 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 ActiveMQ; -using NMS; -using NUnit.Framework; -using System; - -namespace NMS.Test -{ - [ TestFixture ] - abstract public class NMSPropertyTest : NMSTestSupport - { - // standard NMS properties - string expectedText = "Hey this works!"; - string correlationID = "abc"; - ITemporaryQueue replyTo; - bool persistent = true; - byte priority = 5; - String type = "FooType"; - String groupID = "MyGroup"; - int groupSeq = 1; - - // custom properties - string customText = "Cheese"; - bool custom1 = true; - byte custom2 = 12; - short custom3 = 0x1234; - int custom4 = 0x12345678; - long custom5 = 0x1234567812345678; - char custom6 = 'J'; - - [SetUp] - override public void SetUp() - { - base.SetUp(); - } - - [TearDown] - override public void TearDown() - { - base.TearDown(); - } - - [ Test ] - public override void SendAndSyncReceive() - { - base.SendAndSyncReceive(); - } - - protected override IMessage CreateMessage() - { - ITextMessage message = Session.CreateTextMessage(expectedText); - replyTo = Session.CreateTemporaryQueue(); - - // lets set the headers - message.NMSCorrelationID = correlationID; - message.NMSReplyTo = replyTo; - message.NMSPersistent = persistent; - message.NMSPriority = priority; - message.NMSType = type; - message.Properties["NMSXGroupID"] = groupID; - message.Properties["NMSXGroupSeq"] = groupSeq; - - // lets set the custom headers - message.Properties["customText"] = customText; - message.Properties["custom1"] = custom1; - message.Properties["custom2"] = custom2; - message.Properties["custom3"] = custom3; - message.Properties["custom4"] = custom4; - message.Properties["custom5"] = custom5; - message.Properties["custom6"] = custom6; - - return message; - } - - protected override void AssertValidMessage(IMessage message) - { - Assert.IsTrue(message is ITextMessage, "Did not receive a ITextMessage!"); - - Console.WriteLine("Received Message: " + message); - - ITextMessage textMessage = (ITextMessage) message; - String text = textMessage.Text; - Assert.AreEqual(expectedText, text, "the message text"); - - // compare standard NMS headers - Assert.AreEqual(correlationID, message.NMSCorrelationID, "NMSCorrelationID"); - Assert.AreEqual(replyTo, message.NMSReplyTo, "NMSReplyTo"); - Assert.AreEqual(persistent, message.NMSPersistent, "NMSPersistent"); - Assert.AreEqual(priority, message.NMSPriority, "NMSPriority"); - Assert.AreEqual(type, message.NMSType, "NMSType"); - Assert.AreEqual(groupID, message.Properties["NMSXGroupID"], "NMSXGroupID"); - Assert.AreEqual(groupSeq, message.Properties["NMSXGroupSeq"], "NMSXGroupSeq"); - - // compare custom headers - Assert.AreEqual(customText, message.Properties["customText"], "customText"); - Assert.AreEqual(custom1, message.Properties["custom1"], "custom1"); - Assert.AreEqual(custom2, message.Properties["custom2"], "custom2"); - Assert.AreEqual(custom3, message.Properties["custom3"], "custom3"); - Assert.AreEqual(custom4, message.Properties["custom4"], "custom4"); - // TODO - Assert.AreEqual(custom5, message.Properties["custom5"], "custom5"); - Object value6 = message.Properties["custom6"]; - Object expected6 = custom6; - Console.WriteLine("actual type is: " + value6.GetType() + " value: " + value6); - Console.WriteLine("expected type is: " + expected6.GetType() + " value: " + expected6); - Assert.AreEqual(custom6, value6, "custom6 which is of type: " + value6.GetType()); - - Assert.AreEqual(custom1, message.Properties.GetBool("custom1"), "custom1"); - Assert.AreEqual(custom2, message.Properties.GetByte("custom2"), "custom2"); - Assert.AreEqual(custom3, message.Properties.GetShort("custom3"), "custom3"); - Assert.AreEqual(custom4, message.Properties.GetInt("custom4"), "custom4"); - Assert.AreEqual(custom5, message.Properties.GetLong("custom5"), "custom5"); - //Assert.AreEqual(custom6, message.Properties.GetChar("custom6"), "custom6"); - - // lets now look at some standard NMS headers - Console.WriteLine("NMSExpiration: " + message.NMSExpiration); - Console.WriteLine("NMSMessageId: " + message.NMSMessageId); - Console.WriteLine("NMSRedelivered: " + message.NMSRedelivered); - Console.WriteLine("NMSTimestamp: " + message.NMSTimestamp); - Console.WriteLine("NMSXDeliveryCount: " + message.Properties["NMSXDeliveryCount"]); - Console.WriteLine("NMSXProducerTXID: " + message.Properties["NMSXProducerTXID"]); - } - } -} - - - +/* + * 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 ActiveMQ; +using NMS; +using NUnit.Framework; +using System; + +namespace NMS.Test +{ + [ TestFixture ] + abstract public class NMSPropertyTest : NMSTestSupport + { + // standard NMS properties + string expectedText = "Hey this works!"; + string correlationID = "abc"; + ITemporaryQueue replyTo; + bool persistent = true; + byte priority = 5; + String type = "FooType"; + String groupID = "MyGroup"; + int groupSeq = 1; + + // custom properties + string customText = "Cheese"; + bool custom1 = true; + byte custom2 = 12; + short custom3 = 0x1234; + int custom4 = 0x12345678; + long custom5 = 0x1234567812345678; + char custom6 = 'J'; + + [SetUp] + override public void SetUp() + { + base.SetUp(); + } + + [TearDown] + override public void TearDown() + { + base.TearDown(); + } + + [ Test ] + public override void SendAndSyncReceive() + { + base.SendAndSyncReceive(); + } + + protected override IMessage CreateMessage() + { + ITextMessage message = Session.CreateTextMessage(expectedText); + replyTo = Session.CreateTemporaryQueue(); + + // lets set the headers + message.NMSCorrelationID = correlationID; + message.NMSReplyTo = replyTo; + message.NMSPersistent = persistent; + message.NMSPriority = priority; + message.NMSType = type; + message.Properties["NMSXGroupID"] = groupID; + message.Properties["NMSXGroupSeq"] = groupSeq; + + // lets set the custom headers + message.Properties["customText"] = customText; + message.Properties["custom1"] = custom1; + message.Properties["custom2"] = custom2; + message.Properties["custom3"] = custom3; + message.Properties["custom4"] = custom4; + message.Properties["custom5"] = custom5; + message.Properties["custom6"] = custom6; + + return message; + } + + protected override void AssertValidMessage(IMessage message) + { + Assert.IsTrue(message is ITextMessage, "Did not receive a ITextMessage!"); + + Console.WriteLine("Received Message: " + message); + + ITextMessage textMessage = (ITextMessage) message; + String text = textMessage.Text; + Assert.AreEqual(expectedText, text, "the message text"); + + // compare standard NMS headers + Assert.AreEqual(correlationID, message.NMSCorrelationID, "NMSCorrelationID"); + Assert.AreEqual(replyTo, message.NMSReplyTo, "NMSReplyTo"); + Assert.AreEqual(persistent, message.NMSPersistent, "NMSPersistent"); + Assert.AreEqual(priority, message.NMSPriority, "NMSPriority"); + Assert.AreEqual(type, message.NMSType, "NMSType"); + Assert.AreEqual(groupID, message.Properties["NMSXGroupID"], "NMSXGroupID"); + Assert.AreEqual(groupSeq, message.Properties["NMSXGroupSeq"], "NMSXGroupSeq"); + + // compare custom headers + Assert.AreEqual(customText, message.Properties["customText"], "customText"); + Assert.AreEqual(custom1, message.Properties["custom1"], "custom1"); + Assert.AreEqual(custom2, message.Properties["custom2"], "custom2"); + Assert.AreEqual(custom3, message.Properties["custom3"], "custom3"); + Assert.AreEqual(custom4, message.Properties["custom4"], "custom4"); + // TODO + Assert.AreEqual(custom5, message.Properties["custom5"], "custom5"); + Object value6 = message.Properties["custom6"]; + Object expected6 = custom6; + Console.WriteLine("actual type is: " + value6.GetType() + " value: " + value6); + Console.WriteLine("expected type is: " + expected6.GetType() + " value: " + expected6); + Assert.AreEqual(custom6, value6, "custom6 which is of type: " + value6.GetType()); + + Assert.AreEqual(custom1, message.Properties.GetBool("custom1"), "custom1"); + Assert.AreEqual(custom2, message.Properties.GetByte("custom2"), "custom2"); + Assert.AreEqual(custom3, message.Properties.GetShort("custom3"), "custom3"); + Assert.AreEqual(custom4, message.Properties.GetInt("custom4"), "custom4"); + Assert.AreEqual(custom5, message.Properties.GetLong("custom5"), "custom5"); + //Assert.AreEqual(custom6, message.Properties.GetChar("custom6"), "custom6"); + + // lets now look at some standard NMS headers + Console.WriteLine("NMSExpiration: " + message.NMSExpiration); + Console.WriteLine("NMSMessageId: " + message.NMSMessageId); + Console.WriteLine("NMSRedelivered: " + message.NMSRedelivered); + Console.WriteLine("NMSTimestamp: " + message.NMSTimestamp); + Console.WriteLine("NMSXDeliveryCount: " + message.Properties["NMSXDeliveryCount"]); + Console.WriteLine("NMSXProducerTXID: " + message.Properties["NMSXProducerTXID"]); + } + } +} + + + Propchange: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/JMSPropertyTest.cs ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MapMessageTest.cs URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MapMessageTest.cs?view=diff&rev=454506&r1=454505&r2=454506 ============================================================================== --- incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MapMessageTest.cs (original) +++ incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MapMessageTest.cs Mon Oct 9 13:59:14 2006 @@ -1,126 +1,126 @@ -/* - * 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 NMS; -using NUnit.Framework; -using System; - - - -namespace NMS.Test -{ - [ TestFixture ] - abstract public class MapMessageTest : NMSTestSupport - { - 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; - - [SetUp] - override public void SetUp() - { - base.SetUp(); - } - - [TearDown] - override public void TearDown() - { - base.TearDown(); - } - - [ Test ] - public override void SendAndSyncReceive() - { - base.SendAndSyncReceive(); - } - - protected override IMessage CreateMessage() - { - IMapMessage message = Session.CreateMapMessage(); - - message.Body["a"] = a; - message.Body["b"] = b; - message.Body["c"] = c; - message.Body["d"] = d; - message.Body["e"] = e; - message.Body["f"] = f; - message.Body["g"] = g; - message.Body["h"] = h; - message.Body["i"] = i; - message.Body["j"] = j; - message.Body["k"] = k; - message.Body["l"] = l; - - return message; - } - - protected override void AssertValidMessage(IMessage message) - { - Assert.IsTrue(message is IMapMessage, "Did not receive a MapMessage!"); - IMapMessage mapMessage = (IMapMessage) message; - - Console.WriteLine("Received MapMessage: " + message); - Console.WriteLine("Received Count: " + mapMessage.Body.Count); - - Assert.AreEqual(ToHex(f), ToHex(mapMessage.Body.GetLong("f")), "map entry: f as hex"); - - // use generic API to access entries - Assert.AreEqual(a, mapMessage.Body["a"], "generic map entry: a"); - Assert.AreEqual(b, mapMessage.Body["b"], "generic map entry: b"); - Assert.AreEqual(c, mapMessage.Body["c"], "generic map entry: c"); - Assert.AreEqual(d, mapMessage.Body["d"], "generic map entry: d"); - Assert.AreEqual(e, mapMessage.Body["e"], "generic map entry: e"); - Assert.AreEqual(f, mapMessage.Body["f"], "generic map entry: f"); - Assert.AreEqual(g, mapMessage.Body["g"], "generic map entry: g"); - Assert.AreEqual(h, mapMessage.Body["h"], "generic map entry: h"); - Assert.AreEqual(i, mapMessage.Body["i"], "generic map entry: i"); - Assert.AreEqual(j, mapMessage.Body["j"], "generic map entry: j"); - Assert.AreEqual(k, mapMessage.Body["k"], "generic map entry: k"); - Assert.AreEqual(l, mapMessage.Body["l"], "generic map entry: l"); - - // use type safe APIs - Assert.AreEqual(a, mapMessage.Body.GetBool("a"), "map entry: a"); - Assert.AreEqual(b, mapMessage.Body.GetByte("b"), "map entry: b"); - Assert.AreEqual(c, mapMessage.Body.GetChar("c"), "map entry: c"); - Assert.AreEqual(d, mapMessage.Body.GetShort("d"), "map entry: d"); - Assert.AreEqual(e, mapMessage.Body.GetInt("e"), "map entry: e"); - Assert.AreEqual(f, mapMessage.Body.GetLong("f"), "map entry: f"); - Assert.AreEqual(g, mapMessage.Body.GetString("g"), "map entry: g"); - Assert.AreEqual(h, mapMessage.Body.GetBool("h"), "map entry: h"); - Assert.AreEqual(i, mapMessage.Body.GetByte("i"), "map entry: i"); - Assert.AreEqual(j, mapMessage.Body.GetShort("j"), "map entry: j"); - Assert.AreEqual(k, mapMessage.Body.GetInt("k"), "map entry: k"); - Assert.AreEqual(l, mapMessage.Body.GetLong("l"), "map entry: l"); - - } - - protected string ToHex(long value) - { - return String.Format("{0:x}", value); - } - } -} - - +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using NMS; +using NUnit.Framework; +using System; + + + +namespace NMS.Test +{ + [ TestFixture ] + abstract public class MapMessageTest : NMSTestSupport + { + 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; + + [SetUp] + override public void SetUp() + { + base.SetUp(); + } + + [TearDown] + override public void TearDown() + { + base.TearDown(); + } + + [ Test ] + public override void SendAndSyncReceive() + { + base.SendAndSyncReceive(); + } + + protected override IMessage CreateMessage() + { + IMapMessage message = Session.CreateMapMessage(); + + message.Body["a"] = a; + message.Body["b"] = b; + message.Body["c"] = c; + message.Body["d"] = d; + message.Body["e"] = e; + message.Body["f"] = f; + message.Body["g"] = g; + message.Body["h"] = h; + message.Body["i"] = i; + message.Body["j"] = j; + message.Body["k"] = k; + message.Body["l"] = l; + + return message; + } + + protected override void AssertValidMessage(IMessage message) + { + Assert.IsTrue(message is IMapMessage, "Did not receive a MapMessage!"); + IMapMessage mapMessage = (IMapMessage) message; + + Console.WriteLine("Received MapMessage: " + message); + Console.WriteLine("Received Count: " + mapMessage.Body.Count); + + Assert.AreEqual(ToHex(f), ToHex(mapMessage.Body.GetLong("f")), "map entry: f as hex"); + + // use generic API to access entries + Assert.AreEqual(a, mapMessage.Body["a"], "generic map entry: a"); + Assert.AreEqual(b, mapMessage.Body["b"], "generic map entry: b"); + Assert.AreEqual(c, mapMessage.Body["c"], "generic map entry: c"); + Assert.AreEqual(d, mapMessage.Body["d"], "generic map entry: d"); + Assert.AreEqual(e, mapMessage.Body["e"], "generic map entry: e"); + Assert.AreEqual(f, mapMessage.Body["f"], "generic map entry: f"); + Assert.AreEqual(g, mapMessage.Body["g"], "generic map entry: g"); + Assert.AreEqual(h, mapMessage.Body["h"], "generic map entry: h"); + Assert.AreEqual(i, mapMessage.Body["i"], "generic map entry: i"); + Assert.AreEqual(j, mapMessage.Body["j"], "generic map entry: j"); + Assert.AreEqual(k, mapMessage.Body["k"], "generic map entry: k"); + Assert.AreEqual(l, mapMessage.Body["l"], "generic map entry: l"); + + // use type safe APIs + Assert.AreEqual(a, mapMessage.Body.GetBool("a"), "map entry: a"); + Assert.AreEqual(b, mapMessage.Body.GetByte("b"), "map entry: b"); + Assert.AreEqual(c, mapMessage.Body.GetChar("c"), "map entry: c"); + Assert.AreEqual(d, mapMessage.Body.GetShort("d"), "map entry: d"); + Assert.AreEqual(e, mapMessage.Body.GetInt("e"), "map entry: e"); + Assert.AreEqual(f, mapMessage.Body.GetLong("f"), "map entry: f"); + Assert.AreEqual(g, mapMessage.Body.GetString("g"), "map entry: g"); + Assert.AreEqual(h, mapMessage.Body.GetBool("h"), "map entry: h"); + Assert.AreEqual(i, mapMessage.Body.GetByte("i"), "map entry: i"); + Assert.AreEqual(j, mapMessage.Body.GetShort("j"), "map entry: j"); + Assert.AreEqual(k, mapMessage.Body.GetInt("k"), "map entry: k"); + Assert.AreEqual(l, mapMessage.Body.GetLong("l"), "map entry: l"); + + } + + protected string ToHex(long value) + { + return String.Format("{0:x}", value); + } + } +} + + Propchange: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MapMessageTest.cs ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MessageTest.cs URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MessageTest.cs?view=diff&rev=454506&r1=454505&r2=454506 ============================================================================== --- incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MessageTest.cs (original) +++ incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MessageTest.cs Mon Oct 9 13:59:14 2006 @@ -1,123 +1,123 @@ -/* - * 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 NMS; -using NUnit.Framework; -using System; - - -namespace NMS.Test -{ - [ TestFixture ] - abstract public class MessageTest : NMSTestSupport - { - - 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; - - [SetUp] - override public void SetUp() - { - base.SetUp(); - } - - [TearDown] - override public void TearDown() - { - base.TearDown(); - } - - [ Test ] - public override void SendAndSyncReceive() - { - base.SendAndSyncReceive(); - } - - protected override IMessage CreateMessage() - { - IMessage message = Session.CreateMessage(); - - message.Properties["a"] = a; - message.Properties["b"] = b; - message.Properties["c"] = c; - message.Properties["d"] = d; - message.Properties["e"] = e; - message.Properties["f"] = f; - message.Properties["g"] = g; - message.Properties["h"] = h; - message.Properties["i"] = i; - message.Properties["j"] = j; - message.Properties["k"] = k; - message.Properties["l"] = l; - - return message; - } - - protected override void AssertValidMessage(IMessage message) - { - Console.WriteLine("Received message: " + message); - Console.WriteLine("Received Count: " + message.Properties.Count); - - Assert.AreEqual(ToHex(f), ToHex(message.Properties.GetLong("f")), "map entry: f as hex"); - - // use generic API to access entries - Assert.AreEqual(a, message.Properties["a"], "generic map entry: a"); - Assert.AreEqual(b, message.Properties["b"], "generic map entry: b"); - Assert.AreEqual(c, message.Properties["c"], "generic map entry: c"); - Assert.AreEqual(d, message.Properties["d"], "generic map entry: d"); - Assert.AreEqual(e, message.Properties["e"], "generic map entry: e"); - Assert.AreEqual(f, message.Properties["f"], "generic map entry: f"); - Assert.AreEqual(g, message.Properties["g"], "generic map entry: g"); - Assert.AreEqual(h, message.Properties["h"], "generic map entry: h"); - Assert.AreEqual(i, message.Properties["i"], "generic map entry: i"); - Assert.AreEqual(j, message.Properties["j"], "generic map entry: j"); - Assert.AreEqual(k, message.Properties["k"], "generic map entry: k"); - Assert.AreEqual(l, message.Properties["l"], "generic map entry: l"); - - // use type safe APIs - Assert.AreEqual(a, message.Properties.GetBool("a"), "map entry: a"); - Assert.AreEqual(b, message.Properties.GetByte("b"), "map entry: b"); - Assert.AreEqual(c, message.Properties.GetChar("c"), "map entry: c"); - Assert.AreEqual(d, message.Properties.GetShort("d"), "map entry: d"); - Assert.AreEqual(e, message.Properties.GetInt("e"), "map entry: e"); - Assert.AreEqual(f, message.Properties.GetLong("f"), "map entry: f"); - Assert.AreEqual(g, message.Properties.GetString("g"), "map entry: g"); - Assert.AreEqual(h, message.Properties.GetBool("h"), "map entry: h"); - Assert.AreEqual(i, message.Properties.GetByte("i"), "map entry: i"); - Assert.AreEqual(j, message.Properties.GetShort("j"), "map entry: j"); - Assert.AreEqual(k, message.Properties.GetInt("k"), "map entry: k"); - Assert.AreEqual(l, message.Properties.GetLong("l"), "map entry: l"); - - } - - protected string ToHex(long value) - { - return String.Format("{0:x}", value); - } - - } -} - +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using NMS; +using NUnit.Framework; +using System; + + +namespace NMS.Test +{ + [ TestFixture ] + abstract public class MessageTest : NMSTestSupport + { + + 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; + + [SetUp] + override public void SetUp() + { + base.SetUp(); + } + + [TearDown] + override public void TearDown() + { + base.TearDown(); + } + + [ Test ] + public override void SendAndSyncReceive() + { + base.SendAndSyncReceive(); + } + + protected override IMessage CreateMessage() + { + IMessage message = Session.CreateMessage(); + + message.Properties["a"] = a; + message.Properties["b"] = b; + message.Properties["c"] = c; + message.Properties["d"] = d; + message.Properties["e"] = e; + message.Properties["f"] = f; + message.Properties["g"] = g; + message.Properties["h"] = h; + message.Properties["i"] = i; + message.Properties["j"] = j; + message.Properties["k"] = k; + message.Properties["l"] = l; + + return message; + } + + protected override void AssertValidMessage(IMessage message) + { + Console.WriteLine("Received message: " + message); + Console.WriteLine("Received Count: " + message.Properties.Count); + + Assert.AreEqual(ToHex(f), ToHex(message.Properties.GetLong("f")), "map entry: f as hex"); + + // use generic API to access entries + Assert.AreEqual(a, message.Properties["a"], "generic map entry: a"); + Assert.AreEqual(b, message.Properties["b"], "generic map entry: b"); + Assert.AreEqual(c, message.Properties["c"], "generic map entry: c"); + Assert.AreEqual(d, message.Properties["d"], "generic map entry: d"); + Assert.AreEqual(e, message.Properties["e"], "generic map entry: e"); + Assert.AreEqual(f, message.Properties["f"], "generic map entry: f"); + Assert.AreEqual(g, message.Properties["g"], "generic map entry: g"); + Assert.AreEqual(h, message.Properties["h"], "generic map entry: h"); + Assert.AreEqual(i, message.Properties["i"], "generic map entry: i"); + Assert.AreEqual(j, message.Properties["j"], "generic map entry: j"); + Assert.AreEqual(k, message.Properties["k"], "generic map entry: k"); + Assert.AreEqual(l, message.Properties["l"], "generic map entry: l"); + + // use type safe APIs + Assert.AreEqual(a, message.Properties.GetBool("a"), "map entry: a"); + Assert.AreEqual(b, message.Properties.GetByte("b"), "map entry: b"); + Assert.AreEqual(c, message.Properties.GetChar("c"), "map entry: c"); + Assert.AreEqual(d, message.Properties.GetShort("d"), "map entry: d"); + Assert.AreEqual(e, message.Properties.GetInt("e"), "map entry: e"); + Assert.AreEqual(f, message.Properties.GetLong("f"), "map entry: f"); + Assert.AreEqual(g, message.Properties.GetString("g"), "map entry: g"); + Assert.AreEqual(h, message.Properties.GetBool("h"), "map entry: h"); + Assert.AreEqual(i, message.Properties.GetByte("i"), "map entry: i"); + Assert.AreEqual(j, message.Properties.GetShort("j"), "map entry: j"); + Assert.AreEqual(k, message.Properties.GetInt("k"), "map entry: k"); + Assert.AreEqual(l, message.Properties.GetLong("l"), "map entry: l"); + + } + + protected string ToHex(long value) + { + return String.Format("{0:x}", value); + } + + } +} + Propchange: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/MessageTest.cs ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs?view=diff&rev=454506&r1=454505&r2=454506 ============================================================================== --- incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs (original) +++ incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs Mon Oct 9 13:59:14 2006 @@ -1,232 +1,232 @@ -/* - * 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 NMS; -using NUnit.Framework; -using System; - -/// -/// useful base class for test cases -/// - -namespace NMS.Test -{ - [ TestFixture ] - public abstract class NMSTestSupport - { - - // enable/disable logging of message flows - protected bool logging = false; - - private IConnectionFactory factory; - private IConnection connection; - private ISession session; - private IDestination destination; - - protected int receiveTimeout = 1000; - protected string clientId; - protected DestinationType destinationType = DestinationType.Queue; - protected AcknowledgementMode acknowledgementMode = AcknowledgementMode.ClientAcknowledge; - - [SetUp] - virtual public void SetUp() - { - } - - [TearDown] - virtual public void TearDown() - { - Disconnect(); - } - - // Properties - public bool Connected - { - get { return connection!=null; } - set { if( value ) Connect(); else Disconnect(); } - } - - public IConnectionFactory Factory - { - get { - if( factory == null ) { - factory = CreateConnectionFactory(); - Assert.IsNotNull(factory, "no factory created"); - } - return factory; - } - set { this.factory = value; } - } - - public IConnection Connection - { - get { - if( connection == null ) { - Connect(); - } - return connection; - } - set { this.connection = value; } - } - - public ISession Session - { - get { - if( session == null ) { - session = Connection.CreateSession(acknowledgementMode); - Assert.IsNotNull(connection != null, "no session created"); - } - return session; - } - set { this.session = value; } - } - - virtual protected void Connect() - { - Console.WriteLine("Connectting..."); - connection = CreateConnection(); - Assert.IsNotNull(connection, "no connection created"); - connection.Start(); - Console.WriteLine("Connected."); - Assert.IsNotNull(connection, "no connection created"); - } - - virtual protected void Disconnect() - { - if (connection != null) - { - Console.WriteLine("Disconnecting..."); - connection.Dispose(); - connection = null; - session=null; - Console.WriteLine("Disconnected."); - } - } - - virtual protected void Reconnect() - { - Disconnect(); - Connect(); - } - - protected virtual void Drain() - { - using (ISession session = Connection.CreateSession()) - { - // Tries to consume any messages on the Destination - IMessageConsumer consumer = session.CreateConsumer(Destination); - - // Should only need to wait for first message to arrive due to the way - // prefetching works. - IMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(receiveTimeout)); - while (msg != null) - { - msg = consumer.ReceiveNoWait(); - } - } - } - - public virtual void SendAndSyncReceive() - { - using (ISession session = Connection.CreateSession()) - { - - IMessageConsumer consumer = session.CreateConsumer(Destination); - IMessageProducer producer = session.CreateProducer(Destination); - - IMessage request = CreateMessage(); - producer.Send(request); - - IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(receiveTimeout)); - Assert.IsNotNull(message, "No message returned!"); - AssertValidMessage(message); - } - } - - abstract protected IConnectionFactory CreateConnectionFactory(); - - protected virtual IConnection CreateConnection() - { - IConnection connection = Factory.CreateConnection(); - if( clientId!=null ) { - connection.ClientId = clientId; - } - return connection; - } - - protected virtual IMessageProducer CreateProducer() - { - IMessageProducer producer = Session.CreateProducer(Destination); - return producer; - } - - protected virtual IMessageConsumer CreateConsumer() - { - IMessageConsumer consumer = Session.CreateConsumer(Destination); - return consumer; - } - - protected virtual IDestination CreateDestination() - { - if( destinationType == DestinationType.Queue ) { - return Session.GetQueue(CreateDestinationName()); - } else if( destinationType == DestinationType.Topic ) { - return Session.GetTopic(CreateDestinationName()); - } else if( destinationType == DestinationType.TemporaryQueue ) { - return Session.CreateTemporaryQueue(); - } else if( destinationType == DestinationType.TemporaryTopic ) { - return Session.CreateTemporaryTopic(); - } else { - throw new Exception("Unknown destination type: "+destinationType); - } - } - - protected virtual string CreateDestinationName() - { - return "Test.DotNet." + GetType().Name + "." + DateTime.Now.Ticks; - } - - protected virtual IMessage CreateMessage() - { - return Session.CreateMessage(); - } - - protected virtual void AssertValidMessage(IMessage message) - { - Assert.IsNotNull(message, "Null Message!"); - } - - - public IDestination Destination - { - get { - if (destination == null) - { - destination = CreateDestination(); - Assert.IsNotNull(destination, "No destination available!"); - Console.WriteLine("Using destination: " + destination); - } - return destination; - } - set { - destination = value; - } - } - - } -} - - +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using NMS; +using NUnit.Framework; +using System; + +/// +/// useful base class for test cases +/// + +namespace NMS.Test +{ + [ TestFixture ] + public abstract class NMSTestSupport + { + + // enable/disable logging of message flows + protected bool logging = false; + + private IConnectionFactory factory; + private IConnection connection; + private ISession session; + private IDestination destination; + + protected int receiveTimeout = 1000; + protected string clientId; + protected DestinationType destinationType = DestinationType.Queue; + protected AcknowledgementMode acknowledgementMode = AcknowledgementMode.ClientAcknowledge; + + [SetUp] + virtual public void SetUp() + { + } + + [TearDown] + virtual public void TearDown() + { + Disconnect(); + } + + // Properties + public bool Connected + { + get { return connection!=null; } + set { if( value ) Connect(); else Disconnect(); } + } + + public IConnectionFactory Factory + { + get { + if( factory == null ) { + factory = CreateConnectionFactory(); + Assert.IsNotNull(factory, "no factory created"); + } + return factory; + } + set { this.factory = value; } + } + + public IConnection Connection + { + get { + if( connection == null ) { + Connect(); + } + return connection; + } + set { this.connection = value; } + } + + public ISession Session + { + get { + if( session == null ) { + session = Connection.CreateSession(acknowledgementMode); + Assert.IsNotNull(connection != null, "no session created"); + } + return session; + } + set { this.session = value; } + } + + virtual protected void Connect() + { + Console.WriteLine("Connectting..."); + connection = CreateConnection(); + Assert.IsNotNull(connection, "no connection created"); + connection.Start(); + Console.WriteLine("Connected."); + Assert.IsNotNull(connection, "no connection created"); + } + + virtual protected void Disconnect() + { + if (connection != null) + { + Console.WriteLine("Disconnecting..."); + connection.Dispose(); + connection = null; + session=null; + Console.WriteLine("Disconnected."); + } + } + + virtual protected void Reconnect() + { + Disconnect(); + Connect(); + } + + protected virtual void Drain() + { + using (ISession session = Connection.CreateSession()) + { + // Tries to consume any messages on the Destination + IMessageConsumer consumer = session.CreateConsumer(Destination); + + // Should only need to wait for first message to arrive due to the way + // prefetching works. + IMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(receiveTimeout)); + while (msg != null) + { + msg = consumer.ReceiveNoWait(); + } + } + } + + public virtual void SendAndSyncReceive() + { + using (ISession session = Connection.CreateSession()) + { + + IMessageConsumer consumer = session.CreateConsumer(Destination); + IMessageProducer producer = session.CreateProducer(Destination); + + IMessage request = CreateMessage(); + producer.Send(request); + + IMessage message = consumer.Receive(TimeSpan.FromMilliseconds(receiveTimeout)); + Assert.IsNotNull(message, "No message returned!"); + AssertValidMessage(message); + } + } + + abstract protected IConnectionFactory CreateConnectionFactory(); + + protected virtual IConnection CreateConnection() + { + IConnection connection = Factory.CreateConnection(); + if( clientId!=null ) { + connection.ClientId = clientId; + } + return connection; + } + + protected virtual IMessageProducer CreateProducer() + { + IMessageProducer producer = Session.CreateProducer(Destination); + return producer; + } + + protected virtual IMessageConsumer CreateConsumer() + { + IMessageConsumer consumer = Session.CreateConsumer(Destination); + return consumer; + } + + protected virtual IDestination CreateDestination() + { + if( destinationType == DestinationType.Queue ) { + return Session.GetQueue(CreateDestinationName()); + } else if( destinationType == DestinationType.Topic ) { + return Session.GetTopic(CreateDestinationName()); + } else if( destinationType == DestinationType.TemporaryQueue ) { + return Session.CreateTemporaryQueue(); + } else if( destinationType == DestinationType.TemporaryTopic ) { + return Session.CreateTemporaryTopic(); + } else { + throw new Exception("Unknown destination type: "+destinationType); + } + } + + protected virtual string CreateDestinationName() + { + return "Test.DotNet." + GetType().Name + "." + DateTime.Now.Ticks; + } + + protected virtual IMessage CreateMessage() + { + return Session.CreateMessage(); + } + + protected virtual void AssertValidMessage(IMessage message) + { + Assert.IsNotNull(message, "Null Message!"); + } + + + public IDestination Destination + { + get { + if (destination == null) + { + destination = CreateDestination(); + Assert.IsNotNull(destination, "No destination available!"); + Console.WriteLine("Using destination: " + destination); + } + return destination; + } + set { + destination = value; + } + } + + } +} + + Propchange: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/NMSTestSupport.cs ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TemporaryQueueTest.cs URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TemporaryQueueTest.cs?view=diff&rev=454506&r1=454505&r2=454506 ============================================================================== --- incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TemporaryQueueTest.cs (original) +++ incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TemporaryQueueTest.cs Mon Oct 9 13:59:14 2006 @@ -1,92 +1,92 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -using NMS; -using NUnit.Framework; -using System; -using System.Threading; - -namespace NMS.Test -{ - [ TestFixture ] - abstract public class TemporaryQueueTest : NMSTestSupport { - - protected Object semaphore = new Object(); - protected bool received; - - [ SetUp ] - override public void SetUp() { - base.SetUp(); - } - - [ TearDown ] - override public void TearDown() { - base.TearDown(); - } - - [ Test ] - public void TestAsynchronousConsume() { - // lets consume to a regular queue - IMessageConsumer consumer = CreateConsumer(); - consumer.Listener += new MessageListener(OnQueueMessage); - - // lets create a temporary queue and a consumer on it - ITemporaryQueue tempQ = Session.CreateTemporaryQueue(); - IMessageConsumer tempQueueConsumer = Session.CreateConsumer(tempQ); - tempQueueConsumer.Listener += new MessageListener(OnTempQueueMessage); - - // Send message to queue which has a listener to reply to the temporary queue - IMessageProducer producer = CreateProducer(); - - IMessage request = CreateMessage(); - request.NMSCorrelationID = "abc"; - request.NMSReplyTo = tempQ; - request.NMSPersistent = false; - producer.Send(request); - - // now lets wait for the message to arrive on the temporary queue - WaitForMessageToArrive(); - } - - protected void OnQueueMessage(IMessage message) { - Console.WriteLine("First message received: " + message + " so about to reply to temporary queue"); - - ITextMessage response = Session.CreateTextMessage("this is a response!!"); - response.NMSCorrelationID = message.NMSCorrelationID; - - IMessageProducer producerTempQ = Session.CreateProducer(message.NMSReplyTo); - //Write msg to temp q. - producerTempQ.Send(response); - } - - protected void OnTempQueueMessage(IMessage message) { - Console.WriteLine("Received message on temporary queue: " + message); - lock (semaphore) { - received = true; - Monitor.PulseAll(semaphore); - } - } - - protected void WaitForMessageToArrive() { - lock (semaphore) { - if (!received) { - Monitor.Wait(semaphore, receiveTimeout); - } - Assert.AreEqual(true, received, "Should have received a message by now!"); - } - } - } -} +/* + * 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 NMS; +using NUnit.Framework; +using System; +using System.Threading; + +namespace NMS.Test +{ + [ TestFixture ] + abstract public class TemporaryQueueTest : NMSTestSupport { + + protected Object semaphore = new Object(); + protected bool received; + + [ SetUp ] + override public void SetUp() { + base.SetUp(); + } + + [ TearDown ] + override public void TearDown() { + base.TearDown(); + } + + [ Test ] + public void TestAsynchronousConsume() { + // lets consume to a regular queue + IMessageConsumer consumer = CreateConsumer(); + consumer.Listener += new MessageListener(OnQueueMessage); + + // lets create a temporary queue and a consumer on it + ITemporaryQueue tempQ = Session.CreateTemporaryQueue(); + IMessageConsumer tempQueueConsumer = Session.CreateConsumer(tempQ); + tempQueueConsumer.Listener += new MessageListener(OnTempQueueMessage); + + // Send message to queue which has a listener to reply to the temporary queue + IMessageProducer producer = CreateProducer(); + + IMessage request = CreateMessage(); + request.NMSCorrelationID = "abc"; + request.NMSReplyTo = tempQ; + request.NMSPersistent = false; + producer.Send(request); + + // now lets wait for the message to arrive on the temporary queue + WaitForMessageToArrive(); + } + + protected void OnQueueMessage(IMessage message) { + Console.WriteLine("First message received: " + message + " so about to reply to temporary queue"); + + ITextMessage response = Session.CreateTextMessage("this is a response!!"); + response.NMSCorrelationID = message.NMSCorrelationID; + + IMessageProducer producerTempQ = Session.CreateProducer(message.NMSReplyTo); + //Write msg to temp q. + producerTempQ.Send(response); + } + + protected void OnTempQueueMessage(IMessage message) { + Console.WriteLine("Received message on temporary queue: " + message); + lock (semaphore) { + received = true; + Monitor.PulseAll(semaphore); + } + } + + protected void WaitForMessageToArrive() { + lock (semaphore) { + if (!received) { + Monitor.Wait(semaphore, receiveTimeout); + } + Assert.AreEqual(true, received, "Should have received a message by now!"); + } + } + } +} Propchange: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TemporaryQueueTest.cs ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TextMessage.cs URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TextMessage.cs?view=diff&rev=454506&r1=454505&r2=454506 ============================================================================== --- incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TextMessage.cs (original) +++ incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TextMessage.cs Mon Oct 9 13:59:14 2006 @@ -1,59 +1,59 @@ -/* - * 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 NMS.Test -{ - [TestFixture] - public abstract class TextMessage : NMSTestSupport - { - private string expected = "Hello World!"; - - [SetUp] - public override void SetUp() - { - base.SetUp(); - } - - [TearDown] - public override void TearDown() - { - base.TearDown(); - } - - [Test] - public override void SendAndSyncReceive() - { - base.SendAndSyncReceive(); - } - - protected override IMessage CreateMessage() - { - IMessage request = Session.CreateTextMessage(expected); - return request; - } - - protected override void AssertValidMessage(IMessage message) - { - ITextMessage textMessage = (ITextMessage) message; - String text = textMessage.Text; - Console.WriteLine("Received message with text: " + text); - Assert.AreEqual(expected, text, "the message text"); - } - } +/* + * 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 NMS.Test +{ + [TestFixture] + public abstract class TextMessage : NMSTestSupport + { + private string expected = "Hello World!"; + + [SetUp] + public override void SetUp() + { + base.SetUp(); + } + + [TearDown] + public override void TearDown() + { + base.TearDown(); + } + + [Test] + public override void SendAndSyncReceive() + { + base.SendAndSyncReceive(); + } + + protected override IMessage CreateMessage() + { + IMessage request = Session.CreateTextMessage(expected); + return request; + } + + protected override void AssertValidMessage(IMessage message) + { + ITextMessage textMessage = (ITextMessage) message; + String text = textMessage.Text; + Console.WriteLine("Received message with text: " + text); + Assert.AreEqual(expected, text, "the message text"); + } + } } Propchange: incubator/activemq/activemq-dotnet/trunk/src/test/csharp/NMS/Test/TextMessage.cs ------------------------------------------------------------------------------ svn:eol-style = native