http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/EndianBinaryWriterTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/EndianBinaryWriterTest.cs b/src/test/csharp/EndianBinaryWriterTest.cs new file mode 100644 index 0000000..5baf66f --- /dev/null +++ b/src/test/csharp/EndianBinaryWriterTest.cs @@ -0,0 +1,202 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.IO; +using Apache.NMS.Util; +using NUnit.Framework; + +namespace Apache.NMS.Test +{ + [TestFixture] + public class EndianBinaryWriterTest + { + void writeString16TestHelper(char[] input, byte[] expect) + { + MemoryStream stream = new MemoryStream(); + EndianBinaryWriter writer = new EndianBinaryWriter(stream); + + String str = new String(input); + + writer.WriteString16(str); + + byte[] result = stream.GetBuffer(); + + Assert.AreEqual(result[0], 0x00); + Assert.AreEqual(result[1], expect.Length); + + for(int i = 4; i < expect.Length; ++i) + { + Assert.AreEqual(result[i], expect[i - 2]); + } + } + + [Test] + public void testWriteString16_1byteUTF8encoding() + { + // Test data with 1-byte UTF8 encoding. + char[] input = { '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F', '\u0072', '\u006C', '\u0064' }; + byte[] expect = { 0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; + + writeString16TestHelper(input, expect); + } + + [Test] + public void testWriteString16_2byteUTF8encoding() + { + // Test data with 2-byte UT8 encoding. + char[] input = { '\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6' }; + byte[] expect = { 0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6 }; + + writeString16TestHelper(input, expect); + } + + [Test] + public void testWriteString16_1byteAnd2byteEmbeddedNULLs() + { + // Test data with 1-byte and 2-byte encoding with embedded NULL's. + char[] input = { '\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6' }; + byte[] expect = { 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 }; + + writeString16TestHelper(input, expect); + } + + [Test] + public void testWriteString16_nullstring() + { + // test that a null string writes no output. + MemoryStream stream = new MemoryStream(); + EndianBinaryWriter writer = new EndianBinaryWriter(stream); + writer.WriteString16(null); + Assert.AreEqual(0, stream.Length); + } + + [Test] + public void testWriteString16_emptystring() + { + // test that a null string writes no output. + MemoryStream stream = new MemoryStream(); + EndianBinaryWriter writer = new EndianBinaryWriter(stream); + writer.WriteString16(""); + + stream.Seek(0, SeekOrigin.Begin); + EndianBinaryReader reader = new EndianBinaryReader(stream); + Assert.AreEqual(0, reader.ReadInt16()); + } + + [Test] + [ExpectedException(typeof(IOException))] + public void testWriteString16_stringTooLong() + { + // String of length 65536 of Null Characters. + MemoryStream stream = new MemoryStream(); + EndianBinaryWriter writer = new EndianBinaryWriter(stream); + String testStr = new String('a', 65536); + writer.Write(testStr); + } + + [Test] + public void testWriteString16_maxStringLength() + { + // String of length 65535 of non Null Characters since Null encodes as UTF-8. + MemoryStream stream = new MemoryStream(); + EndianBinaryWriter writer = new EndianBinaryWriter(stream); + String testStr = new String('a', 65535); + writer.Write(testStr); + } + + [Test] + [ExpectedException(typeof(IOException))] + public void testWriteString16_invalidEncodingHeader() + { + // Set one of the 65535 bytes to a value that will result in a 2 byte UTF8 encoded sequence. + // This will cause the string of length 65535 to have a utf length of 65536. + MemoryStream stream = new MemoryStream(); + EndianBinaryWriter writer = new EndianBinaryWriter(stream); + String testStr = new String('a', 65535); + char[] array = testStr.ToCharArray(); + array[0] = '\u0000'; + testStr = new String(array); + writer.Write(testStr); + } + + void writeString32TestHelper(char[] input, byte[] expect) + { + MemoryStream stream = new MemoryStream(); + EndianBinaryWriter writer = new EndianBinaryWriter(stream); + + String str = new String(input); + + writer.WriteString32(str); + + byte[] result = stream.GetBuffer(); + + Assert.AreEqual(result[0], 0x00); + Assert.AreEqual(result[1], 0x00); + Assert.AreEqual(result[2], 0x00); + Assert.AreEqual(result[3], expect.Length); + + for(int i = 4; i < expect.Length; ++i) + { + Assert.AreEqual(result[i], expect[i - 4]); + } + } + + [Test] + public void testWriteString32_1byteUTF8encoding() + { + // Test data with 1-byte UTF8 encoding. + char[] input = { '\u0000', '\u000B', '\u0048', '\u0065', '\u006C', '\u006C', '\u006F', '\u0020', '\u0057', '\u006F', '\u0072', '\u006C', '\u0064' }; + byte[] expect = { 0xC0, 0x80, 0x0B, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; + + writeString32TestHelper(input, expect); + } + + [Test] + public void testWriteString32_2byteUTF8encoding() + { + // Test data with 2-byte UT8 encoding. + char[] input = { '\u0000', '\u00C2', '\u00A9', '\u00C3', '\u00A6' }; + byte[] expect = { 0xC0, 0x80, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC2, 0xA6 }; + + writeString32TestHelper(input, expect); + } + + [Test] + public void testWriteString32_1byteAnd2byteEmbeddedNULLs() + { + // Test data with 1-byte and 2-byte encoding with embedded NULL's. + char[] input = { '\u0000', '\u0004', '\u00C2', '\u00A9', '\u00C3', '\u0000', '\u00A6' }; + byte[] expect = { 0xC0, 0x80, 0x04, 0xC3, 0x82, 0xC2, 0xA9, 0xC3, 0x83, 0xC0, 0x80, 0xC2, 0xA6 }; + + writeString32TestHelper(input, expect); + } + + [Test] + public void testWriteString32_nullstring() + { + // test that a null strings writes a -1 + MemoryStream stream = new MemoryStream(); + EndianBinaryWriter writer = new EndianBinaryWriter(stream); + writer.WriteString32(null); + + stream.Seek(0, SeekOrigin.Begin); + EndianBinaryReader reader = new EndianBinaryReader(stream); + Assert.AreEqual(-1, reader.ReadInt32()); + } + } +}
http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/EndianTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/EndianTest.cs b/src/test/csharp/EndianTest.cs new file mode 100644 index 0000000..ad9ce08 --- /dev/null +++ b/src/test/csharp/EndianTest.cs @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System.IO; +using Apache.NMS.Util; +using NUnit.Framework; + +namespace Apache.NMS.Test +{ + [TestFixture] + public class EndianTest + { + [Test] + public void TestLongEndian() + { + long value = 0x0102030405060708L; + long newValue = EndianSupport.SwitchEndian(value); + Assert.AreEqual(0x0807060504030201L, newValue); + long actual = EndianSupport.SwitchEndian(newValue); + Assert.AreEqual(value, actual); + } + + [Test] + public void TestIntEndian() + { + int value = 0x12345678; + int newValue = EndianSupport.SwitchEndian(value); + Assert.AreEqual(0x78563412, newValue); + int actual = EndianSupport.SwitchEndian(newValue); + Assert.AreEqual(value, actual); + } + + [Test] + public void TestCharEndian() + { + char value = 'J'; + char newValue = EndianSupport.SwitchEndian(value); + char actual = EndianSupport.SwitchEndian(newValue); + Assert.AreEqual(value, actual); + } + + [Test] + public void TestShortEndian() + { + short value = 0x1234; + short newValue = EndianSupport.SwitchEndian(value); + Assert.AreEqual(0x3412, newValue); + short actual = EndianSupport.SwitchEndian(newValue); + Assert.AreEqual(value, actual); + } + + [Test] + public void TestNegativeLongEndian() + { + long value = -0x0102030405060708L; + long newValue = EndianSupport.SwitchEndian(value); + long actual = EndianSupport.SwitchEndian(newValue); + Assert.AreEqual(value, actual); + } + + [Test] + public void TestNegativeIntEndian() + { + int value = -0x12345678; + int newValue = EndianSupport.SwitchEndian(value); + int actual = EndianSupport.SwitchEndian(newValue); + Assert.AreEqual(value, actual); + } + + [Test] + public void TestNegativeShortEndian() + { + short value = -0x1234; + short newValue = EndianSupport.SwitchEndian(value); + short actual = EndianSupport.SwitchEndian(newValue); + Assert.AreEqual(value, actual); + } + + [Test] + public void TestFloatDontNeedEndianSwitch() + { + float value = -1.223F; + + // Convert to int so we can compare to Java version. + MemoryStream ms = new MemoryStream(4); + BinaryWriter bw = new BinaryWriter(ms); + bw.Write(value); + bw.Close(); + ms = new MemoryStream(ms.ToArray()); + BinaryReader br = new BinaryReader(ms); + + // System.out.println(Integer.toString(Float.floatToIntBits(-1.223F), 16)); + Assert.AreEqual(-0x406374bc, br.ReadInt32()); + } + + [Test] + public void TestDoublDontNeedEndianSwitch() + { + double value = -1.223D; + + // Convert to int so we can compare to Java version. + MemoryStream ms = new MemoryStream(4); + BinaryWriter bw = new BinaryWriter(ms); + bw.Write(value); + bw.Close(); + ms = new MemoryStream(ms.ToArray()); + BinaryReader br = new BinaryReader(ms); + long longVersion = br.ReadInt64(); + + // System.out.println(Long.toString(Double.doubleToLongBits(-1.223D), 16)); + Assert.AreEqual(-0x400c6e978d4fdf3b, longVersion); + } + } +} + + + http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/ForeignMessageTransformationTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/ForeignMessageTransformationTest.cs b/src/test/csharp/ForeignMessageTransformationTest.cs new file mode 100644 index 0000000..225ae88 --- /dev/null +++ b/src/test/csharp/ForeignMessageTransformationTest.cs @@ -0,0 +1,315 @@ +/* + * 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 Apache.NMS.Commands; +using NUnit.Framework; + +namespace Apache.NMS.Test +{ + //[TestFixture] + public class ForeignMessageTransformationTest : NMSTest + { + private string propertyName = "Test-Property"; + private string propertyValue = "Test-Property-Value"; + private string mapElementName = "Test-Map-Property"; + private string mapElementValue = "Test-Map-Property-Value"; + private string textBody = "This is a TextMessage from a Foreign Provider"; + private byte[] bytesContent = {1, 2, 3, 4, 5, 6, 7, 8}; + + private bool a = true; + private byte b = 123; + private char c = 'c'; + private short d = 0x1234; + private int e = 0x12345678; + private long f = 0x1234567812345678; + private string g = "Hello World!"; + private bool h = false; + private byte i = 0xFF; + private short j = -0x1234; + private int k = -0x12345678; + private long l = -0x1234567812345678; + private float m = 2.1F; + private double n = 2.3; + + protected ForeignMessageTransformationTest(NMSTestSupport testSupport) + : base(testSupport) + { + } + + //[Test] + public virtual void TestSendReceiveForeignMessage( + //[Values(DEFAULT_TEST_QUEUE, DEFAULT_TEST_TOPIC)] + string testDestRef, + //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + using(IConnection connection = CreateConnection()) + { + connection.Start(); + using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + { + IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); + using(IMessageConsumer consumer = session.CreateConsumer(destination)) + using(IMessageProducer producer = session.CreateProducer(destination)) + { + try + { + producer.DeliveryMode = deliveryMode; + Message request = new Message(); + request.Properties[propertyName] = propertyValue; + + producer.Send(request); + + IMessage message = consumer.Receive(receiveTimeout); + Assert.IsNotNull(message, "No message returned!"); + Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties."); + Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match"); + + // use generic API to access entries + Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName); + + // use type safe APIs + Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName); + } + catch(NotSupportedException) + { + } + } + } + } + } + + //[Test] + public virtual void TestSendReceiveForeignTextMessage( + //[Values(DEFAULT_TEST_QUEUE, DEFAULT_TEST_TOPIC)] + string testDestRef, + //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + using(IConnection connection = CreateConnection()) + { + connection.Start(); + using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + { + IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); + using(IMessageConsumer consumer = session.CreateConsumer(destination)) + using(IMessageProducer producer = session.CreateProducer(destination)) + { + try + { + producer.DeliveryMode = deliveryMode; + TextMessage request = new TextMessage(); + request.Properties[propertyName] = propertyValue; + request.Text = textBody; + + producer.Send(request); + + ITextMessage message = consumer.Receive(receiveTimeout) as ITextMessage; + Assert.IsNotNull(message, "No message returned!"); + Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties."); + Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match"); + + // Check the body + Assert.AreEqual(textBody, message.Text, "TextMessage body was wrong."); + + // use generic API to access entries + Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName); + + // use type safe APIs + Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName); + } + catch(NotSupportedException) + { + } + } + } + } + } + + //[Test] + public virtual void TestSendReceiveForeignBytesMessage( + //[Values(DEFAULT_TEST_QUEUE, DEFAULT_TEST_TOPIC)] + string testDestRef, + //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + using(IConnection connection = CreateConnection()) + { + connection.Start(); + using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + { + IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); + using(IMessageConsumer consumer = session.CreateConsumer(destination)) + using(IMessageProducer producer = session.CreateProducer(destination)) + { + try + { + producer.DeliveryMode = deliveryMode; + BytesMessage request = new BytesMessage(); + request.Properties[propertyName] = propertyValue; + request.WriteBytes(bytesContent); + + producer.Send(request); + + IBytesMessage message = consumer.Receive(receiveTimeout) as IBytesMessage; + Assert.IsNotNull(message, "No message returned!"); + Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties."); + Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match"); + + // Check the body + byte[] content = new byte[bytesContent.Length]; + Assert.AreEqual(bytesContent.Length, message.ReadBytes(content)); + Assert.AreEqual(bytesContent, content, "BytesMessage body was wrong."); + + // use generic API to access entries + Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName); + + // use type safe APIs + Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName); + } + catch(NotSupportedException) + { + } + } + } + } + } + + //[Test] + public virtual void TestSendReceiveForeignMapMessage( + //[Values(DEFAULT_TEST_QUEUE, DEFAULT_TEST_TOPIC)] + string testDestRef, + //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + using(IConnection connection = CreateConnection()) + { + connection.Start(); + using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + { + IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); + using(IMessageConsumer consumer = session.CreateConsumer(destination)) + using(IMessageProducer producer = session.CreateProducer(destination)) + { + try + { + producer.DeliveryMode = deliveryMode; + MapMessage request = new MapMessage(); + request.Properties[propertyName] = propertyValue; + request.Body[mapElementName] = mapElementValue; + + producer.Send(request); + + IMapMessage message = consumer.Receive(receiveTimeout) as IMapMessage; + Assert.IsNotNull(message, "No message returned!"); + Assert.AreEqual(request.Properties.Count, message.Properties.Count, "Invalid number of properties."); + Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match"); + + // Check the body + Assert.AreEqual(request.Body.Count, message.Body.Count); + Assert.AreEqual(mapElementValue, message.Body[mapElementName], "MapMessage body was wrong."); + + // use generic API to access entries + Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName); + + // use type safe APIs + Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName); + } + catch(NotSupportedException) + { + } + } + } + } + } + + //[Test] + public virtual void TestSendReceiveForeignStreamMessage( + //[Values(DEFAULT_TEST_QUEUE, DEFAULT_TEST_TOPIC)] + string testDestRef, + //[Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + using(IConnection connection = CreateConnection()) + { + connection.Start(); + using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + { + IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); + using(IMessageConsumer consumer = session.CreateConsumer(destination)) + using(IMessageProducer producer = session.CreateProducer(destination)) + { + try + { + producer.DeliveryMode = deliveryMode; + StreamMessage request = new StreamMessage(); + request.Properties[propertyName] = propertyValue; + + 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(request.Properties.Count, message.Properties.Count, "Invalid number of properties."); + Assert.AreEqual(deliveryMode, message.NMSDeliveryMode, "NMSDeliveryMode does not match"); + + // Check the body + 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"); + + // use generic API to access entries + Assert.AreEqual(propertyValue, message.Properties[propertyName], "generic map entry: " + propertyName); + + // use type safe APIs + Assert.AreEqual(propertyValue, message.Properties.GetString(propertyName), "map entry: " + propertyName); + } + catch(NotSupportedException) + { + } + } + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQAsyncConsumeTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQAsyncConsumeTest.cs b/src/test/csharp/MSMQAsyncConsumeTest.cs new file mode 100644 index 0000000..4aabb1e --- /dev/null +++ b/src/test/csharp/MSMQAsyncConsumeTest.cs @@ -0,0 +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.Threading; +using Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQAsyncConsumeTest : AsyncConsumeTest + { + protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + + public MSMQAsyncConsumeTest() : + base(new MSMQTestSupport()) + { + } + + [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] + [Ignore("Temporary queues are not supported")] + 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 = GetClearDestinationByNodeReference(syncSession, 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."); + } + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQBadConsumeTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQBadConsumeTest.cs b/src/test/csharp/MSMQBadConsumeTest.cs new file mode 100644 index 0000000..b8e9089 --- /dev/null +++ b/src/test/csharp/MSMQBadConsumeTest.cs @@ -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.MSMQ.Test +{ + [TestFixture] + public class MSMQBadConsumeTest : BadConsumeTest + { + public MSMQBadConsumeTest() + : base(new MSMQTestSupport()) + { + } + + [SetUp] + public override void SetUp() + { + base.SetUp(); + } + + [TearDown] + public override void TearDown() + { + base.TearDown(); + } + + [Test] + [ExpectedException(Handler="ExceptionValidationCheck")] + public override void TestBadConsumerException() + { + base.TestBadConsumerException(); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQBytesMessageTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQBytesMessageTest.cs b/src/test/csharp/MSMQBytesMessageTest.cs new file mode 100644 index 0000000..5c58bc9 --- /dev/null +++ b/src/test/csharp/MSMQBytesMessageTest.cs @@ -0,0 +1,51 @@ +/* + * 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 Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQBytesMessageTest : BytesMessageTest + { + protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + + public MSMQBytesMessageTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public void SendReceiveBytesMessage( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.SendReceiveBytesMessage(deliveryMode, DEFAULT_TEST_QUEUE); + } + + [Test] + public void SendReceiveBytesMessageContent( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.SendReceiveBytesMessageContent(deliveryMode, DEFAULT_TEST_QUEUE); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQConnectionTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQConnectionTest.cs b/src/test/csharp/MSMQConnectionTest.cs new file mode 100644 index 0000000..cc3d2d4 --- /dev/null +++ b/src/test/csharp/MSMQConnectionTest.cs @@ -0,0 +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 Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQConnectionTest : ConnectionTest + { + protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; + + public MSMQConnectionTest() + : base(new MSMQTestSupport()) + { + } + + [SetUp] + public override void SetUp() + { + base.SetUp(); + } + + [TearDown] + public override void TearDown() + { + base.TearDown(); + } + + /// <summary> + /// Verify that it is possible to create multiple connections to the broker. + /// There was a bug in the connection factory which set the clientId member which made + /// it impossible to create an additional connection. + /// </summary> + [Test] + public override void TestTwoConnections() + { + base.TestTwoConnections(); + } + + [Test] + public void TestCreateAndDisposeWithConsumer( + [Values(true, false)] + bool disposeConsumer) + { + base.TestCreateAndDisposeWithConsumer(disposeConsumer, DEFAULT_TEST_QUEUE); + } + + [Test] + public void TestCreateAndDisposeWithProducer( + [Values(true, false)] + bool disposeProducer) + { + base.TestCreateAndDisposeWithProducer(disposeProducer, DEFAULT_TEST_QUEUE); + } + + [Test] + public void TestStartAfterSend( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestStartAfterSend(deliveryMode, testDestRef); + } + + /// <summary> + /// Tests if the consumer receives the messages that were sent before the + /// connection was started. + /// </summary> + [Test] + public override void TestStoppedConsumerHoldsMessagesTillStarted( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef) + { + base.TestStoppedConsumerHoldsMessagesTillStarted(testDestRef); + } + + /// <summary> + /// Tests if the consumer is able to receive messages even when the + /// connecction restarts multiple times. + /// </summary> + [Test] + public override void TestMultipleConnectionStops( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef) + { + base.TestMultipleConnectionStops(testDestRef); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQConsumerTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQConsumerTest.cs b/src/test/csharp/MSMQConsumerTest.cs new file mode 100644 index 0000000..b7f7478 --- /dev/null +++ b/src/test/csharp/MSMQConsumerTest.cs @@ -0,0 +1,154 @@ +/* + * 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.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQConsumerTest : ConsumerTest + { + protected const string DEFAULT_TEST_QUEUE = "transactionTestQueue"; + protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; + + public MSMQConsumerTest() + : base(new MSMQTestSupport()) + { + } + +// The .NET CF does not have the ability to interrupt threads, so this test is impossible. +#if !NETCF + [Test] + public override void TestNoTimeoutConsumer( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, + AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] + AcknowledgementMode ackMode) + { + base.TestNoTimeoutConsumer(testDestRef, ackMode); + } + + [Test] + public override void TestSyncReceiveConsumerClose( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, + AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] + AcknowledgementMode ackMode) + { + base.TestSyncReceiveConsumerClose(testDestRef, ackMode); + } + + [Test] + public override void TestDoChangeSentMessage( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, + AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] + AcknowledgementMode ackMode, + [Values(true, false)] bool doClear) + { + base.TestDoChangeSentMessage(testDestRef, ackMode, doClear); + } + + [Test] + public override void TestConsumerReceiveBeforeMessageDispatched( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, + AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] + AcknowledgementMode ackMode) + { + base.TestConsumerReceiveBeforeMessageDispatched(testDestRef, ackMode); + } + + [Test] + public override void TestDontStart( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestDontStart(testDestRef, deliveryMode); + } + + [Test] + public override void TestSendReceiveTransacted( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC, DEFAULT_TEST_TEMP_QUEUE, DEFAULT_TEST_TEMP_TOPIC*/)] + string testDestRef, + [Values(MsgDeliveryMode.NonPersistent, MsgDeliveryMode.Persistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveTransacted(testDestRef, deliveryMode); + } + + [Test] + public void TestAckedMessageAreConsumed() + { + base.TestAckedMessageAreConsumed(DEFAULT_TEST_QUEUE); + } + + [Test] + public void TestLastMessageAcked() + { + base.TestLastMessageAcked(DEFAULT_TEST_QUEUE); + } + + [Test] + public void TestUnAckedMessageAreNotConsumedOnSessionClose() + { + base.TestUnAckedMessageAreNotConsumedOnSessionClose(DEFAULT_TEST_QUEUE); + } + + [Test] + public void TestAsyncAckedMessageAreConsumed() + { + base.TestAsyncAckedMessageAreConsumed(DEFAULT_TEST_QUEUE); + } + + [Test] + public void TestAsyncUnAckedMessageAreNotConsumedOnSessionClose() + { + base.TestAsyncUnAckedMessageAreNotConsumedOnSessionClose(DEFAULT_TEST_QUEUE); + } + + [Test] + public /*override*/ void TestAddRemoveAsnycMessageListener() + { + base.TestAddRemoveAsnycMessageListener(DestinationType.Queue, DEFAULT_TEST_QUEUE); + } + + [Test] + public override void TestReceiveNoWait( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, + AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] + AcknowledgementMode ackMode, + [Values(MsgDeliveryMode.NonPersistent, MsgDeliveryMode.Persistent)] + MsgDeliveryMode deliveryMode) + { + base.TestReceiveNoWait(testDestRef, ackMode, deliveryMode); + } + +#endif + + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQDurableTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQDurableTest.cs b/src/test/csharp/MSMQDurableTest.cs new file mode 100644 index 0000000..fe1d5b5 --- /dev/null +++ b/src/test/csharp/MSMQDurableTest.cs @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using Apache.NMS.Util; +using Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + [Ignore("Topics are not supported")] + public class MSMQDurableTest : DurableTest + { + protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; + protected const string DURABLE_TEST_TOPIC = "durableConsumerTestTopic"; + + public MSMQDurableTest() + : base(new MSMQTestSupport()) + { + } + + [SetUp] + public override void SetUp() + { + base.SetUp(); + } + + [Test] + public void TestSendWhileClosed( + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, + AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] + AcknowledgementMode ackMode) + { + base.TestSendWhileClosed(ackMode, DEFAULT_TEST_TOPIC); + } + + [Test] + public void TestDurableConsumerSelectorChange( + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, + AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] + AcknowledgementMode ackMode) + { + base.TestDurableConsumerSelectorChange(ackMode, DEFAULT_TEST_TOPIC); + } + + [Test] + public void TestDurableConsumer( + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge, + AcknowledgementMode.DupsOkAcknowledge, AcknowledgementMode.Transactional)] + AcknowledgementMode ackMode) + { + string testDurableTopicURI = GetDestinationURI(DURABLE_TEST_TOPIC); + + base.TestDurableConsumer(ackMode, testDurableTopicURI); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQForeignMessageTransformationTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQForeignMessageTransformationTest.cs b/src/test/csharp/MSMQForeignMessageTransformationTest.cs new file mode 100644 index 0000000..17043f3 --- /dev/null +++ b/src/test/csharp/MSMQForeignMessageTransformationTest.cs @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using Apache.NMS.Util; +using Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQForeignMessageTransformationTest : ForeignMessageTransformationTest + { + protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; + + public MSMQForeignMessageTransformationTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public override void TestSendReceiveForeignMessage( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveForeignMessage(testDestRef, deliveryMode); + } + + [Test] + public override void TestSendReceiveForeignTextMessage( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveForeignTextMessage(testDestRef, deliveryMode); + } + + [Test] + public override void TestSendReceiveForeignBytesMessage( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveForeignBytesMessage(testDestRef, deliveryMode); + } + + [Test] + public override void TestSendReceiveForeignMapMessage( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveForeignMapMessage(testDestRef, deliveryMode); + } + + [Test] + public override void TestSendReceiveForeignStreamMessage( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC*/)] + string testDestRef, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveForeignStreamMessage(testDestRef, deliveryMode); + } + } +} + http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQMapMessageTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQMapMessageTest.cs b/src/test/csharp/MSMQMapMessageTest.cs new file mode 100644 index 0000000..3afbcbe --- /dev/null +++ b/src/test/csharp/MSMQMapMessageTest.cs @@ -0,0 +1,49 @@ +/* + * 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.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQMapMessageTest : MapMessageTest + { + protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + + public MSMQMapMessageTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public void TestSendReceiveMapMessage( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveMapMessage(deliveryMode, DEFAULT_TEST_QUEUE); + } + + [Test] + public void TestSendReceiveNestedMapMessage( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveNestedMapMessage(deliveryMode, DEFAULT_TEST_QUEUE); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQMessageSelectorTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQMessageSelectorTest.cs b/src/test/csharp/MSMQMessageSelectorTest.cs new file mode 100644 index 0000000..5a108cd --- /dev/null +++ b/src/test/csharp/MSMQMessageSelectorTest.cs @@ -0,0 +1,169 @@ +/* + * 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 Apache.NMS.Test; +using NUnit.Framework; +using System.Globalization; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + [Category("LongRunning")] + public class MSMQMessageSelectorTest : MessageSelectorTest + { + protected const string SELECTOR_TEST_QUEUE = "messageSelectorTestQueue"; + protected const string SELECTOR_TEST_TOPIC = "messageSelectorTestTopic"; + + public MSMQMessageSelectorTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public override void TestFilterIgnoredMessages( + [Values(SELECTOR_TEST_QUEUE /*, SELECTOR_TEST_TOPIC*/)] + string testDestRef) + { + base.TestFilterIgnoredMessages(testDestRef); + } + + [Test] + public override void TestFilterIgnoredMessagesSlowConsumer( + [Values(SELECTOR_TEST_QUEUE /*, SELECTOR_TEST_TOPIC*/)] + string testDestRef) + { + base.TestFilterIgnoredMessagesSlowConsumer(testDestRef); + } + + + [Test] + public override void TestInvalidSelector( + [Values(SELECTOR_TEST_QUEUE)] + string testDestRef) + { + base.TestInvalidSelector(testDestRef); + } + + [Test] + public void TestSelectByMessageId( + [Values(SELECTOR_TEST_QUEUE)] + string testDestRef) + { + using(IConnection connection = CreateConnection()) + { + connection.Start(); + using(ISession session = connection.CreateSession()) + { + IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); + + using(IMessageProducer producer = session.CreateProducer(destination)) + { + ITextMessage message = null; + + int COUNT = 5; + for(int i = 1; i <= COUNT; i++) + { + message = session.CreateTextMessage("MessageSelectorTest - TestSelectByMessageId: " + i.ToString()); + producer.Send(message); + } + + using(IQueueBrowser browser = session.CreateBrowser((IQueue)destination)) + { + int i = 0; + foreach(IMessage message0 in browser) + { + if(++i == COUNT / 2) + { + message = message0 as ITextMessage; + break; + } + } + } + + string selector = "NMSMessageId = '" + message.NMSMessageId + "'"; + + using(IMessageConsumer consumer = session.CreateConsumer(destination, selector)) + { + ITextMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(2000)) as ITextMessage; + Assert.IsNotNull(msg); + Assert.AreEqual(msg.Text, message.Text); + Assert.AreEqual(msg.NMSMessageId, message.NMSMessageId); + + msg = consumer.Receive(TimeSpan.FromMilliseconds(2000)) as ITextMessage; + Assert.IsNull(msg); + } + } + } + } + } + + [Test] + public void TestSelectByLookupId( + [Values(SELECTOR_TEST_QUEUE)] + string testDestRef) + { + using(IConnection connection = CreateConnection()) + { + connection.Start(); + using(ISession session = connection.CreateSession()) + { + IDestination destination = GetClearDestinationByNodeReference(session, testDestRef); + + using(IMessageProducer producer = session.CreateProducer(destination)) + { + ITextMessage message = null; + + int COUNT = 5; + for(int i = 1; i <= COUNT; i++) + { + message = session.CreateTextMessage("MessageSelectorTest - TestSelectByLookupId: " + i.ToString()); + producer.Send(message); + } + + using(IQueueBrowser browser = session.CreateBrowser((IQueue)destination)) + { + int i = 0; + foreach(IMessage message0 in browser) + { + if(++i == COUNT / 2) + { + message = message0 as ITextMessage; + break; + } + } + } + + long lookupId = (long)(message.Properties["LookupId"]); + string selector = "LookupId = " + lookupId.ToString(CultureInfo.InvariantCulture); + + using(IMessageConsumer consumer = session.CreateConsumer(destination, selector)) + { + ITextMessage msg = consumer.Receive(TimeSpan.FromMilliseconds(2000)) as ITextMessage; + Assert.IsNotNull(msg); + Assert.AreEqual(msg.Text, message.Text); + Assert.AreEqual(msg.Properties["LookupId"], lookupId); + + msg = consumer.Receive(TimeSpan.FromMilliseconds(2000)) as ITextMessage; + Assert.IsNull(msg); + } + } + } + } + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQMessageTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQMessageTest.cs b/src/test/csharp/MSMQMessageTest.cs new file mode 100644 index 0000000..1cfcd70 --- /dev/null +++ b/src/test/csharp/MSMQMessageTest.cs @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQMessageTest : MessageTest + { + protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + + public MSMQMessageTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public void TestSendReceiveMessageProperties( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveMessageProperties(deliveryMode, DEFAULT_TEST_QUEUE); + } + } +} + http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQMessageTransformerTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQMessageTransformerTest.cs b/src/test/csharp/MSMQMessageTransformerTest.cs new file mode 100644 index 0000000..2249db5 --- /dev/null +++ b/src/test/csharp/MSMQMessageTransformerTest.cs @@ -0,0 +1,48 @@ +/* + * 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.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQMessageTransformerTest : MessageTransformerTest + { + public MSMQMessageTransformerTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public override void TestProducerTransformer( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestProducerTransformer(deliveryMode); + } + + [Test] + public override void TestConsumerTransformer( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestConsumerTransformer(deliveryMode); + } + } +} + http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQNMSPropertyTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQNMSPropertyTest.cs b/src/test/csharp/MSMQNMSPropertyTest.cs new file mode 100644 index 0000000..3968aea --- /dev/null +++ b/src/test/csharp/MSMQNMSPropertyTest.cs @@ -0,0 +1,41 @@ +/* + * 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.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQNMSPropertyTest : NMSPropertyTest + { + protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + + public MSMQNMSPropertyTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public void TestSendReceiveNMSProperties( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveNMSProperties(deliveryMode, DEFAULT_TEST_QUEUE); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQProducerTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQProducerTest.cs b/src/test/csharp/MSMQProducerTest.cs new file mode 100644 index 0000000..bbe86fd --- /dev/null +++ b/src/test/csharp/MSMQProducerTest.cs @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQProducerTest : ProducerTest + { + protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + protected const string DEFAULT_TEST_TOPIC = "defaultTestTopic"; + protected const string DEFAULT_TEST_TEMP_QUEUE = "defaultTestTempQueue"; + protected const string DEFAULT_TEST_TEMP_TOPIC = "defaultTestTempTopic"; + + protected const string DEFAULT_TEST_QUEUE2 = "defaultTestQueue2"; + protected const string DEFAULT_TEST_TOPIC2 = "defaultTestTopic2"; + protected const string DEFAULT_TEST_TEMP_QUEUE2 = "defaultTestTempQueue2"; + protected const string DEFAULT_TEST_TEMP_TOPIC2 = "defaultTestTempTopic2"; + + public MSMQProducerTest() + : base(new NMSTestSupport()) + { + } + + [Test] + public override void TestProducerSendToNullDestinationWithoutDefault() + { + base.TestProducerSendToNullDestinationWithoutDefault(); + } + + [Test] + public override void TestProducerSendToNullDestinationWithDefault( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC, DEFAULT_TEST_TEMP_QUEUE, DEFAULT_TEST_TEMP_TOPIC*/)] + string testDestRef) + { + base.TestProducerSendToNullDestinationWithDefault(testDestRef); + } + + [Test] + public override void TestProducerSendToNonDefaultDestination( + [Values(DEFAULT_TEST_QUEUE /*, DEFAULT_TEST_TOPIC, DEFAULT_TEST_TEMP_QUEUE, DEFAULT_TEST_TEMP_TOPIC*/)] + string unusedTestDestRef, + [Values(DEFAULT_TEST_QUEUE2 /*, DEFAULT_TEST_TOPIC2, DEFAULT_TEST_TEMP_QUEUE2, DEFAULT_TEST_TEMP_TOPIC2*/)] + string usedTestDestRef) + { + base.TestProducerSendToNonDefaultDestination(unusedTestDestRef, usedTestDestRef); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQRequestResponseTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQRequestResponseTest.cs b/src/test/csharp/MSMQRequestResponseTest.cs new file mode 100644 index 0000000..1261ab1 --- /dev/null +++ b/src/test/csharp/MSMQRequestResponseTest.cs @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +using System; +using Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQRequestResponseTest : RequestResponseTest + { + protected const string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + protected const string DEFAULT_TEST_QUEUE2 = "defaultTestQueue2"; + + public MSMQRequestResponseTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + [Category("RequestResponse")] + public void TestRequestResponseMessaging() + { + base.TestRequestResponseMessaging(DEFAULT_TEST_QUEUE, DEFAULT_TEST_QUEUE2); + } + } +} + http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQStreamMessageTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQStreamMessageTest.cs b/src/test/csharp/MSMQStreamMessageTest.cs new file mode 100644 index 0000000..75d8c99 --- /dev/null +++ b/src/test/csharp/MSMQStreamMessageTest.cs @@ -0,0 +1,41 @@ +/* + * 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.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQStreamMessageTest : StreamMessageTest + { + protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + + public MSMQStreamMessageTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public void TestSendReceiveStreamMessage( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveStreamMessage(deliveryMode, DEFAULT_TEST_QUEUE); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQTempDestinationDeletionTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQTempDestinationDeletionTest.cs b/src/test/csharp/MSMQTempDestinationDeletionTest.cs new file mode 100644 index 0000000..b2d8a41 --- /dev/null +++ b/src/test/csharp/MSMQTempDestinationDeletionTest.cs @@ -0,0 +1,48 @@ +/* + * 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 Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + [Ignore("Temporary queues are not supported")] + public class MSMQTempDestinationDeletionTest : TempDestinationDeletionTest + { + protected const string DELETION_TEST_QUEUE = "deletionTestQueue"; + protected const string DELETION_TEST_TOPIC = "deletionTestTopic"; + protected const string DELETION_TEST_TEMP_QUEUE = "deletionTestTempQueue"; + protected const string DELETION_TEST_TEMP_TOPIC = "deletionTestTempTopic"; + + public MSMQTempDestinationDeletionTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public override void TestTempDestinationDeletion( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode, + [Values(DELETION_TEST_QUEUE, DELETION_TEST_TOPIC, DELETION_TEST_TEMP_QUEUE, DELETION_TEST_TEMP_TOPIC)] + string testDestRef) + { + base.TestTempDestinationDeletion(deliveryMode, testDestRef); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQTempDestinationTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQTempDestinationTest.cs b/src/test/csharp/MSMQTempDestinationTest.cs new file mode 100644 index 0000000..de62683 --- /dev/null +++ b/src/test/csharp/MSMQTempDestinationTest.cs @@ -0,0 +1,68 @@ +/* + * 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.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + [Ignore("Temporary queues are not supported")] + public class MSMQTempDestinationTest : TempDestinationTest + { + public MSMQTempDestinationTest() + : base(new MSMQTestSupport()) + { + } + + [SetUp] + public override void SetUp() + { + base.SetUp(); + } + + [TearDown] + public override void TearDown() + { + base.TearDown(); + } + + [Test] + public override void TestTempDestOnlyConsumedByLocalConn() + { + base.TestTempDestOnlyConsumedByLocalConn(); + } + + [Test] + public override void TestTempQueueHoldsMessagesWithConsumers() + { + base.TestTempQueueHoldsMessagesWithConsumers(); + } + + [Test] + public override void TestTempQueueHoldsMessagesWithoutConsumers() + { + base.TestTempQueueHoldsMessagesWithoutConsumers(); + } + + [Test] + public override void TestTmpQueueWorksUnderLoad() + { + base.TestTmpQueueWorksUnderLoad(); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQTestSupport.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQTestSupport.cs b/src/test/csharp/MSMQTestSupport.cs new file mode 100644 index 0000000..13725a8 --- /dev/null +++ b/src/test/csharp/MSMQTestSupport.cs @@ -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 System.Xml; +using Apache.NMS.Test; +using Apache.NMS.Util; +using NUnit.Framework; + +using Apache.NMS.MSMQ; + +namespace Apache.NMS.MSMQ.Test +{ + /// <summary> + /// Useful class for test cases support. + /// </summary> + public class MSMQTestSupport : NMSTestSupport + { + /// <summary> + /// Gets the environment variable name for the configuration file path. + /// </summary> + /// <returns>Environment variable name</returns> + public override string GetConfigEnvVarName() + { + return "MSMQTESTCONFIGPATH"; + } + + /// <summary> + /// Gets the default name for the configuration filename. + /// </summary> + /// <returns>Default name of the configuration filename</returns> + public override string GetDefaultConfigFileName() + { + return "msmqprovider-test.config"; + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQTextMessageTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQTextMessageTest.cs b/src/test/csharp/MSMQTextMessageTest.cs new file mode 100644 index 0000000..dfbd061 --- /dev/null +++ b/src/test/csharp/MSMQTextMessageTest.cs @@ -0,0 +1,41 @@ +/* + * 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.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQTextMessageTest : TextMessageTest + { + protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + + public MSMQTextMessageTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public void TestSendReceiveTextMessage( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendReceiveTextMessage(deliveryMode, DEFAULT_TEST_QUEUE); + } + } +} http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQTransactionTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQTransactionTest.cs b/src/test/csharp/MSMQTransactionTest.cs new file mode 100644 index 0000000..c269d0c --- /dev/null +++ b/src/test/csharp/MSMQTransactionTest.cs @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using Apache.NMS.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQTransactionTest : TransactionTest + { + protected static string TRANSACTION_TEST_QUEUE = "transactionTestQueue"; + + public MSMQTransactionTest() + : base(new MSMQTestSupport()) + { + } + + [Test] + public void TestSendRollback( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendRollback(deliveryMode, TRANSACTION_TEST_QUEUE); + } + + [Test] + public void TestSendSessionClose( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendSessionClose(deliveryMode, TRANSACTION_TEST_QUEUE); + } + + [Test] + public void TestReceiveRollback( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestReceiveRollback(deliveryMode, TRANSACTION_TEST_QUEUE); + } + + + [Test] + public void TestReceiveTwoThenRollback( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestReceiveTwoThenRollback(deliveryMode, TRANSACTION_TEST_QUEUE); + } + + [Test] + public void TestSendCommitNonTransaction( + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)] + AcknowledgementMode ackMode, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestSendCommitNonTransaction(ackMode, deliveryMode, TRANSACTION_TEST_QUEUE); + } + + [Test] + public void TestReceiveCommitNonTransaction( + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)] + AcknowledgementMode ackMode, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestReceiveCommitNonTransaction(ackMode, deliveryMode, TRANSACTION_TEST_QUEUE); + } + + [Test] + public void TestReceiveRollbackNonTransaction( + [Values(AcknowledgementMode.AutoAcknowledge, AcknowledgementMode.ClientAcknowledge)] + AcknowledgementMode ackMode, + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestReceiveRollbackNonTransaction(ackMode, deliveryMode, TRANSACTION_TEST_QUEUE); + } + + [Test] + public void TestRedispatchOfRolledbackTx( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestRedispatchOfRolledbackTx(deliveryMode, TRANSACTION_TEST_QUEUE); + } + + [Test] + public void TestRedispatchOfUncommittedTx( + [Values(MsgDeliveryMode.Persistent, MsgDeliveryMode.NonPersistent)] + MsgDeliveryMode deliveryMode) + { + base.TestRedispatchOfUncommittedTx(deliveryMode, TRANSACTION_TEST_QUEUE); + } + } +} + + http://git-wip-us.apache.org/repos/asf/activemq-nms-msmq/blob/7274a80a/src/test/csharp/MSMQXmlMessageTest.cs ---------------------------------------------------------------------- diff --git a/src/test/csharp/MSMQXmlMessageTest.cs b/src/test/csharp/MSMQXmlMessageTest.cs new file mode 100644 index 0000000..757e1f9 --- /dev/null +++ b/src/test/csharp/MSMQXmlMessageTest.cs @@ -0,0 +1,52 @@ +/* + * 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.Test; +using NUnit.Framework; + +namespace Apache.NMS.MSMQ.Test +{ + [TestFixture] + public class MSMQXmlMessageTest : XmlMessageTest + { + protected static string DEFAULT_TEST_QUEUE = "defaultTestQueue"; + + public MSMQXmlMessageTest() + : base(new MSMQTestSupport()) + { + } + +#if NET_3_5 || MONO + + [Test] + public void TestSendReceiveXmlMessage_Net35() + { + base.TestSendReceiveXmlMessage_Net35(DEFAULT_TEST_QUEUE); + } + +#else + + // Test the obsolete API versions until they are completely removed. + [Test] + public void SendReceiveXmlMessage() + { + base.TestSendReceiveXmlMessage(DEFAULT_TEST_QUEUE); + } + +#endif + } +}
