diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2008-10-20 11:49:40 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2008-10-20 11:49:40 +0400 |
commit | 7b8ca08adfbb964ac42340f983267b031d618eae (patch) | |
tree | 0436bbdcdc09558c6599c31821f75924ad728911 /mcs/class/Mono.Messaging/Test | |
parent | 7966931ae7007b00dc1b664331df719280ef66ba (diff) |
import AMQP/Rabbit based implementation by Michael Barker (see r116493).
svn path=/branches/messaging-2008/mcs/; revision=116494
Diffstat (limited to 'mcs/class/Mono.Messaging/Test')
3 files changed, 189 insertions, 0 deletions
diff --git a/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog b/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog new file mode 100644 index 00000000000..73ad821175a --- /dev/null +++ b/mcs/class/Mono.Messaging/Test/Mono.Messaging/ChangeLog @@ -0,0 +1,4 @@ +2008-09-29 Michael Barker <mike@middlesoft.co.uk> + + * MessageBaseTest.cs: New + * QueueReferenceTest.cs: New diff --git a/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageBaseTest.cs b/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageBaseTest.cs new file mode 100644 index 00000000000..f6c89a3621e --- /dev/null +++ b/mcs/class/Mono.Messaging/Test/Mono.Messaging/MessageBaseTest.cs @@ -0,0 +1,100 @@ +// +// Mono.Messaging.RabbitMQ +// +// Authors: +// Michael Barker (mike@middlesoft.co.uk) +// +// (C) 2008 Michael Barker +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Messaging; + +using NUnit.Framework; + +namespace MonoTests.Mono.Messaging { + + [TestFixture] + public class MessageBaseTest { + + [Test] + public void CheckDefaultValues () + { + Message m = new Message (); + Assert.IsNull (m.Body, "Body default should be Null"); + Assert.IsNull (m.Formatter, "Formatter default should null"); + + Assert.AreEqual (System.Messaging.AcknowledgeTypes.None, + m.AcknowledgeType, + "AcknowledgeType default should be None"); + Assert.AreEqual (null, m.AdministrationQueue, + "AdministrationQueue default should be null"); + Assert.AreEqual (0, m.AppSpecific, "AppSpecific default should be 0"); + Assert.AreEqual (true, m.AttachSenderId, "AttachSenderId default should be true"); + Assert.AreEqual ("", m.AuthenticationProviderName, + "AuthenticationProviderName should default to \"\""); + Assert.AreEqual (System.Messaging.CryptographicProviderType.RsaFull, + m.AuthenticationProviderType, + "AuthenticationProviderType should default to RsaFull"); + Assert.AreEqual (null, m.BodyStream, "BodyStream should default to null"); + Assert.AreEqual (Guid.Empty, m.ConnectorType, "ConnectorType should default to empty"); + Assert.AreEqual (null, m.CorrelationId, "CorrelationId should default to null"); + Assert.AreEqual (new byte[0], m.DestinationSymmetricKey, + "DestinationSymmetricKey should default to an empty array"); + Assert.AreEqual (new byte[0], m.DigitalSignature, + "DigitalSignature default to an empty array"); + Assert.AreEqual (System.Messaging.EncryptionAlgorithm.Rc2, + m.EncryptionAlgorithm, + "EncryptionAlgorithm should default to Rc2"); + Assert.AreEqual (new byte[0], m.Extension, + "Extension should default to an empty array"); + Assert.AreEqual (System.Messaging.HashAlgorithm.Sha, m.HashAlgorithm, + "HashAlgorithm should default to Sha"); + Assert.AreEqual (Guid.Empty.ToString (), m.Id, "Id should default to Guid.Empty"); + Assert.AreEqual ("", m.Label, "Label should default to \"\""); + Assert.AreEqual (false, m.IsFirstInTransaction, "IsFirstInTransaction should default to false"); + Assert.AreEqual (false, m.IsLastInTransaction, "IsLastInTransaction should default to false"); + Assert.AreEqual (MessagePriority.Normal, m.Priority, + "Priority should default to Normal"); + Assert.AreEqual (false, m.Recoverable, "Recoverable should default to false"); + Assert.AreEqual (null, m.ResponseQueue, "ResponseQueue should default to null"); + //Assert.AreEqual (null, m.SecurityContext, "SecurityContext should default to null"); + Assert.AreEqual (new byte[0], m.SenderCertificate, + "SenderCertificate should default to an empty array"); + Assert.AreEqual (Message.InfiniteTimeout, m.TimeToBeReceived, + "TimeToBeReceived should default to InfiniteTimeout"); + Assert.AreEqual (Message.InfiniteTimeout, m.TimeToReachQueue, + "TimeToReadQueue should default to InfiniteTimeout"); + Assert.AreEqual (false, m.UseAuthentication, + "UseAuthentication should default to false"); + Assert.AreEqual (false, m.UseDeadLetterQueue, + "UseDeadLetterQueue should default to false"); + Assert.AreEqual (false, m.UseEncryption, "Encryption should default to false"); + Assert.AreEqual (false, m.UseJournalQueue, + "UseJournalQueue should default to false"); + Assert.AreEqual (false, m.UseTracing, "UseTracing should default to false"); + } + + } +} diff --git a/mcs/class/Mono.Messaging/Test/Mono.Messaging/QueueReferenceTest.cs b/mcs/class/Mono.Messaging/Test/Mono.Messaging/QueueReferenceTest.cs new file mode 100644 index 00000000000..f0fe0786ba5 --- /dev/null +++ b/mcs/class/Mono.Messaging/Test/Mono.Messaging/QueueReferenceTest.cs @@ -0,0 +1,85 @@ +// +// Test.Mono.Messaging +// +// Authors: +// Michael Barker (mike@middlesoft.co.uk) +// +// (C) 2008 Michael Barker +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Text.RegularExpressions; + +using Mono.Messaging; +using NUnit.Framework; + +namespace MonoTests.Mono.Messsaging +{ + [TestFixture] + public class QueueReferenceTest + { + [Test] + public void Equals () + { + QueueReference qr1 = new QueueReference ("abc", "def", false); + QueueReference qr2 = new QueueReference ("abc", "def", false); + //Assert.IsTrue(qr1.Equals(qr2), "QueueReferences should be equal"); + Assert.AreEqual (qr1, qr2, "QueueReferences should be equal"); + } + + [Test] + public void Parse () + { + string[] s = @".\def\ghi".Split (new char[] { '\\' }, 3); + Assert.AreEqual (3, s.Length, "Fail"); + Assert.AreEqual (".", s[0], "Fail"); + + QueueReference qr0 = QueueReference.Parse (@"\\host\$private\myqueue"); + Assert.AreEqual ("host", qr0.Host); + Assert.AreEqual (true, qr0.IsPrivate); + Assert.AreEqual ("myqueue", qr0.Queue); + + QueueReference qr1 = QueueReference.Parse (@"\\host\myqueue"); + Assert.AreEqual ("host", qr1.Host); + Assert.AreEqual (false, qr1.IsPrivate); + Assert.AreEqual ("myqueue", qr1.Queue); + + QueueReference qr2 = QueueReference.Parse ("myqueue"); + Assert.AreEqual (QueueReference.LOCALHOST, qr2.Host); + Assert.AreEqual (false, qr2.IsPrivate); + Assert.AreEqual ("myqueue", qr2.Queue); + } + + [Test] + public void StringLeadingChars () + { + Assert.AreEqual (@"asdfb\asdfasd", + QueueReference.RemoveLeadingSlashes (@"\\asdfb\asdfasd"), + "Failed to removed slashes"); + } + } + + +} + |