Move tests that do not reference RabbitMQ to System.Messaging.
authorMichael Barker <mike@middlesoft.co.uk>
Mon, 20 Jul 2009 18:20:32 +0000 (18:20 -0000)
committerMichael Barker <mike@middlesoft.co.uk>
Mon, 20 Jul 2009 18:20:32 +0000 (18:20 -0000)
svn path=/trunk/mcs/; revision=138229

69 files changed:
mcs/build/ChangeLog
mcs/build/profiles/monotouch.make [new file with mode: 0644]
mcs/class/ChangeLog
mcs/class/Makefile
mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ_test.dll.sources
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AdminTest.cs [deleted file]
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AsyncPeekTest.cs [deleted file]
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AsyncReceiveTest.cs [deleted file]
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/BasicMessagingTest.cs [deleted file]
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/ChangeLog
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MQUtil.cs [deleted file]
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs [deleted file]
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/PeekTest.cs [deleted file]
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/SelectorTest.cs [deleted file]
mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/TransactionMessagingTest.cs [deleted file]
mcs/class/Mono.Messaging/Makefile
mcs/class/System.Core/ChangeLog
mcs/class/System.Core/Makefile
mcs/class/System.Core/System.Linq/ChangeLog
mcs/class/System.Core/System.Linq/Lookup.cs
mcs/class/System.Core/Test/System.Linq/LookupTest.cs
mcs/class/System.Messaging/System.Messaging_test.dll.sources
mcs/class/System.Messaging/Test/System.Messaging/AdminTest.cs [new file with mode: 0644]
mcs/class/System.Messaging/Test/System.Messaging/AsyncPeekTest.cs [new file with mode: 0644]
mcs/class/System.Messaging/Test/System.Messaging/AsyncReceiveTest.cs [new file with mode: 0644]
mcs/class/System.Messaging/Test/System.Messaging/BasicMessagingTest.cs [new file with mode: 0644]
mcs/class/System.Messaging/Test/System.Messaging/ChangeLog
mcs/class/System.Messaging/Test/System.Messaging/MQUtil.cs [new file with mode: 0644]
mcs/class/System.Messaging/Test/System.Messaging/MessageEnumeratorTest.cs [new file with mode: 0644]
mcs/class/System.Messaging/Test/System.Messaging/PeekTest.cs [new file with mode: 0644]
mcs/class/System.Messaging/Test/System.Messaging/SelectorTest.cs [new file with mode: 0644]
mcs/class/System.Messaging/Test/System.Messaging/TransactionMessagingTest.cs [new file with mode: 0644]
mcs/class/System.Net/ChangeLog
mcs/class/System.Net/Makefile
mcs/class/System.Runtime.Serialization/ChangeLog
mcs/class/System.Runtime.Serialization/Makefile
mcs/class/System.Runtime.Serialization/monotouch_System.Runtime.Serialization.dll.sources [new file with mode: 0644]
mcs/class/System.ServiceModel.Web/ChangeLog
mcs/class/System.ServiceModel.Web/Makefile
mcs/class/System.ServiceModel.Web/monotouch_System.ServiceModel.Web.dll.sources [new file with mode: 0644]
mcs/class/System.ServiceModel/ChangeLog
mcs/class/System.ServiceModel/Makefile
mcs/class/System.ServiceModel/monotouch_System.ServiceModel.dll.sources [new file with mode: 0644]
mcs/class/System.XML/monotouch_System.Xml.dll.sources [new file with mode: 0644]
mcs/class/System.Xml.Linq/ChangeLog
mcs/class/System.Xml.Linq/Makefile
mcs/class/System.Xml.Linq/System.Xml.Linq/ChangeLog
mcs/class/System.Xml.Linq/System.Xml.Linq/XNodeNavigator.cs
mcs/class/System.Xml.Linq/System.Xml.Schema/ChangeLog
mcs/class/System.Xml.Linq/System.Xml.Schema/Extensions.cs
mcs/class/System.Xml.Linq/System.Xml.XPath/ChangeLog
mcs/class/System.Xml.Linq/System.Xml.XPath/Extensions.cs
mcs/class/System.Xml.Linq/net_2_1_raw_System.Xml.Linq.dll.sources [deleted file]
mcs/class/System/monotouch_System.dll.sources [new file with mode: 0644]
mcs/class/corlib/System.Threading/ChangeLog
mcs/class/corlib/System.Threading/Thread.cs
mcs/class/corlib/System.Threading/ThreadPool.cs
mono/io-layer/ChangeLog
mono/io-layer/thread-private.h
mono/metadata/ChangeLog
mono/metadata/gc.c
mono/mini/ChangeLog
mono/mini/aot-compiler.c
mono/mini/mini-x86.c
mono/mini/mini.c
mono/mini/mini.h
mono/utils/ChangeLog
mono/utils/Makefile.am
mono/utils/mono-semaphore.h [new file with mode: 0644]

index d2233f5bb63c0afd1c41be739aef83a2d6286c61..b7e5d6ad6e1d7cdc8f35ea1fce209961c2dc23d4 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * profiles/monotouch.make: add monotouch profile.
+
 2009-07-16  Raja R Harinath  <harinath@hurrynot.org>
 
        * profiles/net_2_0_bootstrap.make (BOOTSTRAP_PROFILE): Set to
diff --git a/mcs/build/profiles/monotouch.make b/mcs/build/profiles/monotouch.make
new file mode 100644 (file)
index 0000000..4966cda
--- /dev/null
@@ -0,0 +1,19 @@
+#! -*- makefile -*-
+
+my_runtime = $(RUNTIME) $(RUNTIME_FLAGS) --security=temporary-smcs-hack
+INTERNAL_SMCS = $(my_runtime) $(topdir)/class/lib/$(PROFILE)/smcs.exe
+
+BOOTSTRAP_PROFILE = net_2_1_bootstrap
+
+BOOTSTRAP_MCS = MONO_PATH="$(topdir)/class/lib/$(BOOTSTRAP_PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(my_runtime) $(topdir)/class/lib/$(BOOTSTRAP_PROFILE)/smcs.exe
+MCS = MONO_PATH="$(topdir)/class/lib/$(PROFILE)$(PLATFORM_PATH_SEPARATOR)$$MONO_PATH" $(INTERNAL_SMCS)
+
+profile-check:
+       @:
+
+PROFILE_MCS_FLAGS = -d:NET_1_1 -d:NET_2_0 -d:NET_2_1 -d:MONOTOUCH
+FRAMEWORK_VERSION = 2.1
+NO_TEST = yes
+
+# the tuner takes care of the install
+NO_INSTALL = yes
index eabfefc622dcd309bd4e5a01d03def66bd88a1f3..29410a99025ba2d31e01f1dcaa58bdb02dac7536 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: set monotouch_SUBDIRS to the net_2_1 assemblies set.
+
 
 2009-07-18  Michael Barker  <mike@middlesoft.co.uk>
 
index 2ee011971373e4c3c78d80aa061e767d2939dcf2..b14c218103370b07fd1c3c579031497a6029936b 100644 (file)
@@ -155,6 +155,7 @@ net_2_0_bootstrap_SUBDIRS := $(bootstrap_dirs) PEAPI
 net_2_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_2_0_only_dirs)
 net_2_1_bootstrap_SUBDIRS := corlib System Mono.CompilerServices.SymbolWriter
 net_2_1_raw_SUBDIRS := $(net_2_1_dirs)
+monotouch_SUBDIRS := $(net_2_1_dirs)
 net_3_5_SUBDIRS := $(net_3_5_dirs)
 net_4_0_bootstrap_SUBDIRS := $(bootstrap_dirs) PEAPI
 net_4_0_SUBDIRS := $(common_dirs) $(net_2_0_dirs) $(net_4_0_dirs)
index 3ba70c17b486f8ccd501dfecbb6b8bcefeeb5748..c0ad4d9bcaf4a2d6ef19510cdc84dbb7b92d33de 100644 (file)
@@ -1,14 +1,5 @@
-Mono.Messaging.RabbitMQ/MQUtil.cs
-Mono.Messaging.RabbitMQ/BasicMessagingTest.cs
-Mono.Messaging.RabbitMQ/AdminTest.cs
 Mono.Messaging.RabbitMQ/FailuresTest.cs
 Mono.Messaging.RabbitMQ/RabbitMQMessagingProviderTest.cs
-Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs
-Mono.Messaging.RabbitMQ/PeekTest.cs
-Mono.Messaging.RabbitMQ/TransactionMessagingTest.cs
-Mono.Messaging.RabbitMQ/SelectorTest.cs
-Mono.Messaging.RabbitMQ/AsyncReceiveTest.cs
-Mono.Messaging.RabbitMQ/AsyncPeekTest.cs
 Mono.Messaging.RabbitMQ/BinaryMessageFormatterTest.cs
 Mono.Messaging.RabbitMQ/XmlMessageFormatterTest.cs
 Mono.Messaging.RabbitMQ/TestUtils.cs
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AdminTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AdminTest.cs
deleted file mode 100644 (file)
index 954cdf4..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-//
-// Test.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 System.Reflection;
-using System.Threading;
-using System.Text.RegularExpressions;
-
-using NUnit.Framework;
-
-namespace MonoTests.Mono.Messaging.RabbitMQ
-{
-       [TestFixture]
-       public class AdminTest {
-               
-               [Test]
-               public void CreateNonTransactionalQueue ()
-               {
-                       string qName = @".\private$\admin-queue-1";
-                       Assert.IsFalse (MessageQueue.Exists (qName), "Queue should not exist");
-                       MessageQueue q = MessageQueue.Create (qName);
-                       Assert.IsFalse (q.Transactional);
-                       Assert.IsTrue (MessageQueue.Exists (qName), "Queue should exist");
-               }
-               
-               [Test]
-               public void CreateTransactionalQueue ()
-               {
-                       string qName = @".\private$\admin-queue-2";
-                       Assert.IsFalse (MessageQueue.Exists (qName), "Queue should not exist");
-                       MessageQueue q = MessageQueue.Create (qName, true);
-                       Assert.IsTrue (q.Transactional, "Queue should be transactional");
-                       Assert.IsTrue (MessageQueue.Exists (qName), "Queue should exist");
-               }
-               
-               private bool Contains(MessageQueue[] qs, String qName)
-               {
-                       foreach (MessageQueue q in qs)
-                       {
-                               if (q.QueueName == qName)
-                                       return true;
-                       }
-                       return false;
-               }
-
-               [Test]
-               public void GetPublicQueues ()
-               {
-                       string qName1 = @".\admin-queue-3";
-                       string qName2 = @".\admin-queue-4";
-                       
-                       MessageQueue.Create (qName1);
-                       MessageQueue.Create (qName2);
-                       
-                       MessageQueue[] mq = MessageQueue.GetPublicQueues ();
-                       Assert.IsTrue (Contains (mq, "admin-queue-3"), qName1 + " not found");
-                       Assert.IsTrue (Contains (mq, "admin-queue-4"), qName2 + " not found");
-               }
-               
-               [Test]
-               public void GetQueue ()
-               {
-                       MessageQueue q1 = MQUtil.GetQueue(@".\private$\admin-queue-5", true);
-                       Assert.IsTrue (q1.Transactional, "Queue should be transactional");
-                       MessageQueue q2 = MQUtil.GetQueue(@".\private$\admin-queue-5", true);
-                       Assert.IsTrue (q2.Transactional, "Queue should be transactional");
-               }
-               
-               [Test]
-               [ExpectedException (typeof (MessageQueueException))]
-               public void PurgeQueue ()
-               {
-                       MessageQueue q = MQUtil.GetQueue(@".\private$\purge-queue");
-                       Message m1 = new Message ("foobar1", new BinaryMessageFormatter ());
-                       Message m2 = new Message ("foobar2", new BinaryMessageFormatter ());
-                       Message m3 = new Message ("foobar3", new BinaryMessageFormatter ());
-                       Message m4 = new Message ("foobar4", new BinaryMessageFormatter ());
-                       
-                       q.Send (m1);
-                       q.Send (m2);
-                       q.Send (m3);
-                       q.Send (m4);
-                       
-                       q.Receive ();                   
-                       q.Purge ();
-                       q.Receive (new TimeSpan (0, 0, 2));
-               }
-                               
-               [Test]
-               public void DeleteQueue ()
-               {
-                       MessageQueue q = MQUtil.GetQueue(@".\private$\delete-queue");
-                       Message m1 = new Message ("foobar1", new BinaryMessageFormatter ());
-                       
-                       q.Send (m1);
-                       
-                       q.Receive ();
-
-                       MessageQueue.Delete(@".\private$\delete-queue");
-               }
-       }
-}
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AsyncPeekTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AsyncPeekTest.cs
deleted file mode 100644 (file)
index ae4b2d8..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-//
-// Test.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 System.Reflection;
-using System.Threading;
-using System.Text.RegularExpressions;
-
-using NUnit.Framework;
-
-namespace MonoTests.Mono.Messaging.RabbitMQ
-{
-       [TestFixture]
-       public class AsyncPeekTest {
-
-               bool eventCalled = false;
-               
-               private void HandleMessage (object source, PeekCompletedEventArgs args) {
-                       eventCalled = true;
-               }
-
-               [Test]
-               public void BeginPeek()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-1");
-                       Message s = new Message (new BinaryMessageFormatter ());
-                       string body = "foo-" + DateTime.Now.ToString ();
-                       s.Body = body;
-                       q.Send (s);
-                       
-                       q.PeekCompleted += new PeekCompletedEventHandler (HandleMessage);
-                       IAsyncResult result = q.BeginPeek ();
-                       result.AsyncWaitHandle.WaitOne ();
-                       Message rMsg = q.EndPeek (result);
-                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
-                       Assert.IsTrue (eventCalled, "Handle Message not called");
-                       
-                       Assert.IsNotNull (q.Receive (), "Message not peeked");
-               }
-               
-               [Test]
-               public void BeginPeekWithTimeout()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-2");
-                       Message s = new Message (new BinaryMessageFormatter ());
-                       string body = "foo-" + DateTime.Now.ToString ();
-                       s.Body = body;
-                       q.Send (s);
-                       
-                       IAsyncResult result = q.BeginPeek (new TimeSpan (0, 0, 2));
-                       result.AsyncWaitHandle.WaitOne ();
-                       Message rMsg = q.EndPeek (result);
-                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
-                       
-                       Assert.IsNotNull (q.Receive (), "Message not peeked");
-               }
-               
-               [Test]
-               public void BeginPeekWithStateAndTimeout()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-3");
-                       Message s = new Message (new BinaryMessageFormatter ());
-                       string body = "foo-" + DateTime.Now.ToString ();
-                       s.Body = body;
-                       q.Send (s);
-                       
-                       IAsyncResult result = q.BeginPeek (new TimeSpan (0, 0, 2), "foo");
-                       result.AsyncWaitHandle.WaitOne ();
-                       Message rMsg = q.EndPeek (result);
-                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
-                       Assert.AreEqual ("foo", result.AsyncState, "State not passed properly");
-                       
-                       Assert.IsNotNull (q.Receive (), "Message not peeked");
-               }
-               
-               private bool success = false;
-               
-               public void TestCallback (IAsyncResult result)
-               {
-                       success = true;
-               }
-               
-               [Test]
-               public void BeginPeekWithStateAndTimeoutAndCallback()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-4");
-                       Message s = new Message (new BinaryMessageFormatter ());
-                       string body = "foo-" + DateTime.Now.ToString ();
-                       s.Body = body;
-                       q.Send (s);
-                       AsyncCallback ac = new AsyncCallback (TestCallback);
-                       IAsyncResult result = q.BeginPeek (new TimeSpan (0, 0, 2), "foo", ac);
-                       result.AsyncWaitHandle.WaitOne ();
-                       Message rMsg = q.EndPeek (result);
-                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
-                       Assert.AreEqual ("foo", result.AsyncState, "State not passed properly");
-                       Assert.IsTrue (success, "Callback not run");
-                       
-                       Assert.IsNotNull (q.Receive (), "Message not peeked");
-               }
-               
-               [Test]
-               [ExpectedException (typeof (MessageQueueException))]
-               public void BeginPeekWithException()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-5");
-                       IAsyncResult result = q.BeginPeek (new TimeSpan (0, 0, 2));
-                       result.AsyncWaitHandle.WaitOne ();
-                       q.EndPeek (result);
-               }               
-       }
-}
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AsyncReceiveTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/AsyncReceiveTest.cs
deleted file mode 100644 (file)
index 1027a7e..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-//
-// Test.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 System.Reflection;
-using System.Threading;
-using System.Text.RegularExpressions;
-
-using NUnit.Framework;
-
-namespace MonoTests.Mono.Messaging.RabbitMQ
-{
-       [TestFixture]
-       public class AsyncReceiveTest {
-
-               private Message m;
-               private string failureMessage = null;
-               private string state = null;
-               
-               private void HandleMessage (object source, ReceiveCompletedEventArgs args) {
-                       try {
-                               MessageQueue q = (MessageQueue) source;
-                               m = q.EndReceive (args.AsyncResult);
-                               state = (string) args.AsyncResult.AsyncState;
-                       } catch (Exception e) {
-                               failureMessage = e.Message;
-                       }
-               }
-
-               [Test]
-               public void BeginReceive()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-receive-1");
-                       Message s = new Message (new BinaryMessageFormatter ());
-                       string body = "foo-" + DateTime.Now.ToString ();
-                       s.Body = body;
-                       q.Send (s);
-                       
-                       q.ReceiveCompleted += new ReceiveCompletedEventHandler (HandleMessage);
-                       IAsyncResult result = q.BeginReceive ();
-                       result.AsyncWaitHandle.WaitOne ();
-                       Message rMsg = q.EndReceive (result);
-                       Assert.IsNotNull (rMsg, "No message received");
-                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
-               }
-               
-               [Test]
-               public void BeginReceiveWithTimeout()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-receive-2");
-                       Message s = new Message (new BinaryMessageFormatter ());
-                       string body = "foo-" + DateTime.Now.ToString ();
-                       s.Body = body;
-                       q.Send (s);
-                       
-                       IAsyncResult result = q.BeginReceive (new TimeSpan (0, 0, 2));
-                       result.AsyncWaitHandle.WaitOne ();
-                       Message rMsg = q.EndReceive (result);
-                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
-               }
-               
-               [Test]
-               public void BeginReceiveWithStateAndTimeout()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-receive-3");
-                       Message s = new Message (new BinaryMessageFormatter ());
-                       string body = "foo-" + DateTime.Now.ToString ();
-                       s.Body = body;
-                       q.Send (s);
-                       
-                       IAsyncResult result = q.BeginReceive (new TimeSpan (0, 0, 2), "foo");
-                       result.AsyncWaitHandle.WaitOne ();
-                       Message rMsg = q.EndReceive (result);
-                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
-                       Assert.AreEqual ("foo", result.AsyncState, "State not passed properly");
-               }
-               
-               private bool success = false;
-               
-               public void TestCallback (IAsyncResult result)
-               {
-                       success = true;
-               }
-               
-               [Test]
-               public void BeginReceiveWithStateAndTimeoutAndCallback()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-receive-4");
-                       Message s = new Message (new BinaryMessageFormatter ());
-                       string body = "foo-" + DateTime.Now.ToString ();
-                       s.Body = body;
-                       q.Send (s);
-                       AsyncCallback ac = new AsyncCallback (TestCallback);
-                       IAsyncResult result = q.BeginReceive (new TimeSpan (0, 0, 2), "foo", ac);
-                       result.AsyncWaitHandle.WaitOne ();
-                       Message rMsg = q.EndReceive (result);
-                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
-                       Assert.AreEqual ("foo", result.AsyncState, "State not passed properly");
-                       Assert.IsTrue (success, "Callback not run");
-               }
-               
-               [Test]
-               [ExpectedException (typeof (MessageQueueException))]
-               public void BeginReceiveWithException()
-               {
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-5");
-                       IAsyncResult result = q.BeginReceive (new TimeSpan (0, 0, 2));
-                       result.AsyncWaitHandle.WaitOne ();
-                       q.EndReceive (result);
-               }               
-       }
-}
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/BasicMessagingTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/BasicMessagingTest.cs
deleted file mode 100644 (file)
index 3d2e380..0000000
+++ /dev/null
@@ -1,483 +0,0 @@
-//
-// Test.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 System.Reflection;
-using System.Threading;
-using System.Text.RegularExpressions;
-
-using NUnit.Framework;
-
-namespace MonoTests.Mono.Messaging.RabbitMQ
-{
-       [TestFixture]
-       public class BasicMessageTest {
-
-               [Test]
-               public void SendReceiveBinaryMessage ()
-               {
-                       String qName = @"private$\testq";
-                       String qPath = @".\" + qName;
-                       MessageQueue mq = MQUtil.GetQueue (qPath);
-                       Assert.AreEqual(qName, mq.QueueName, "Queue name not set properly");
-                       String s = "Test: " + DateTime.Now;
-                       Message m = new Message (s, new BinaryMessageFormatter ());
-                       m.CorrelationId = Guid.NewGuid () + "\\0";
-                       mq.MessageReadPropertyFilter.SetAll ();
-
-                       mq.Send (m);
-
-                       Message m2 = mq.Receive ();
-                       m2.Formatter = new BinaryMessageFormatter ();
-                       Assert.AreEqual (s, m2.Body);
-
-                       //Assert.IsTrue (DateTime.MinValue == m.ArrivedTime);
-                       Assert.IsNotNull(m2.Id, "Id is null");
-                       Assert.IsTrue (Guid.Empty.ToString () !=  m2.Id, "Id is Empty");
-                       Assert.IsTrue (DateTime.MinValue != m2.ArrivedTime, "Arrived Time is not set");
-                       Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
-                       Assert.AreEqual (m.CorrelationId, m2.CorrelationId, "CorrelationId not set properly");
-                       Assert.IsTrue (0 != m2.SenderVersion);
-                       // TODO: This is not support on a workgroup installation.
-                       //Assert.IsNotNull (m2.SourceMachine, "SourceMachine is null");
-                       Assert.AreEqual (qName, m2.DestinationQueue.QueueName, "Destination Queue not set");
-                       
-                       mq.Close ();
-               }
-               
-               [Test]
-               public void SendMessageWithLabel ()
-               {
-                       String qName = @".\private$\testq";
-                       String label = "mylabel";
-                       MessageQueue mq = MQUtil.GetQueue (qName);
-                       Assert.AreEqual (@"private$\testq", mq.QueueName, "Queue name not set properly");
-                       String s = "Test: " + DateTime.Now;
-                       Message m = new Message (s, new BinaryMessageFormatter ());
-                       m.CorrelationId = Guid.NewGuid () + "\\0" ;
-
-                       mq.Send (m, label);
-
-                       Message m2 = mq.Receive ();
-                       m2.Formatter = new BinaryMessageFormatter ();
-                       Assert.AreEqual (s, m2.Body, "Message not passed correctly");
-                       Assert.AreEqual (label, m2.Label, "Label not passed correctly");
-               }
-               
-               
-               [Test]
-               public void CheckDefaults ()
-               {
-                       Message m = new Message ("Test", new BinaryMessageFormatter ());
-                       Assert.AreEqual (true, m.AttachSenderId, "AttachSenderId has incorrect default");
-                       Assert.AreEqual (Guid.Empty.ToString () + "\\0", m.Id, "Id has incorrect default");
-                       Assert.AreEqual ("Microsoft Base Cryptographic Provider, Ver. 1.0", 
-                                        m.AuthenticationProviderName, 
-                                        "AuthenticationProviderName has incorrect default"); 
-                       Assert.AreEqual (0, m.Extension.Length, "Extension has incorrect default");
-                       Assert.AreEqual ("", m.Label, "Label has incorrect default");
-                       Assert.IsFalse (m.Recoverable, "Recoverable has incorrect default");
-                       Assert.IsFalse (m.IsFirstInTransaction, "IsFirstInTransaction has incorrect default");
-                       Assert.IsFalse (m.IsLastInTransaction, "IsLastInTransaction has incorrect default");
-                       Assert.AreEqual ("", m.TransactionId, "TransactionId has incorrect default");
-                       Assert.AreEqual (MessagePriority.Normal, m.Priority, "MessagePriority has incorrect default");
-               }
-               
-               private static void CheckInvalidOperation (Message m, String property)
-               {
-                       PropertyInfo pi = m.GetType ().GetProperty (property);
-                       try {
-                               Assert.IsNotNull (pi, "Property not defined: " + property);
-                               object o = pi.GetValue (m, null);
-                               Assert.Fail (property + ": " + o);
-                       } catch (InvalidOperationException) {
-                       } catch (TargetInvocationException e) {
-                               Assert.AreEqual (typeof (InvalidOperationException), 
-                                                e.InnerException.GetType ());
-                       }
-               }
-               
-               [Test]
-               public void CheckInvalidPropertyOperations ()
-               {
-                       Message m = new Message ("Test", new BinaryMessageFormatter ());
-                       CheckInvalidOperation (m, "Acknowledgment");
-                       CheckInvalidOperation (m, "ArrivedTime");
-                       CheckInvalidOperation (m, "Authenticated");
-                       CheckInvalidOperation (m, "DestinationQueue");
-                       //CheckInvalidOperation (m, "Id");
-                       //CheckInvalidOperation (m, "IsFirstInTransaction");
-                       //CheckInvalidOperation (m, "IsLastInTransaction");
-                       // TODO: Support 2.0 features.
-                       //CheckInvalidOperation (m, "LookupId");
-                       CheckInvalidOperation (m, "MessageType");
-                       CheckInvalidOperation (m, "SenderId");
-                       CheckInvalidOperation (m, "SenderVersion");
-                       CheckInvalidOperation (m, "SentTime");
-                       CheckInvalidOperation (m, "SourceMachine");
-                       //CheckInvalidOperation (m, "TransactionId");
-               }
-               
-               private static void CheckArgumentInvalid(Message m, String property, Type exceptionType)
-               {
-                       PropertyInfo pi = m.GetType().GetProperty(property);
-                       try {
-                               Assert.IsNotNull(pi, "Property not defined: " + property);
-                               pi.SetValue(m, null, null);
-                               Assert.Fail(property);
-                       } catch (InvalidOperationException) {
-                       } catch (TargetInvocationException e) {
-                               Assert.AreEqual(exceptionType,
-                                               e.InnerException.GetType(),
-                                               property);
-                       }
-               }
-
-               [Test]
-               public void CheckArgumentInvalidForProperties ()
-               {
-                       Message m = new Message ("Stuff");
-                       CheckArgumentInvalid (m, "DestinationSymmetricKey", typeof (ArgumentNullException));
-                       CheckArgumentInvalid (m, "DigitalSignature", typeof(ArgumentNullException));
-                       CheckArgumentInvalid (m, "Extension", typeof(ArgumentNullException));
-               }
-
-               [Test]
-               public void SendReceiveBinaryMessageWithAllPropertiesSet ()
-               {
-                       String qName = @"private$\testq";
-                       String qPath = @".\" + qName;
-                       MessageQueue mq = MQUtil.GetQueue (qPath);
-                       mq.MessageReadPropertyFilter.SetAll ();
-                       Assert.AreEqual(qName, mq.QueueName, "Queue name not set properly");
-                       
-                       MessageQueue adminQ = MQUtil.GetQueue (@".\private$\myadmin");
-                       MessageQueue responseQ = MQUtil.GetQueue (@".\private$\myresponse");
-                       Guid connectorType = Guid.NewGuid ();
-                       String s = "Test: " + DateTime.Now;
-                       
-                       Message m = new Message (s, new BinaryMessageFormatter ());
-                       m.CorrelationId = Guid.NewGuid () + "\\0";
-                       m.AcknowledgeType = AcknowledgeTypes.PositiveArrival;
-                       m.AdministrationQueue = adminQ;
-                       m.AppSpecific = 5;
-                       //m.AuthenticationProviderName = "Test Provider Name";
-                       //m.AuthenticationProviderType = CryptographicProviderType.None;
-                       //m.ConnectorType = connectorType;
-                       //m.DestinationSymmetricKey = new byte[] { 0x0A, 0x0B, 0x0C };
-                       //m.DigitalSignature = new byte[] { 0x0C, 0x0D, 0x0E };
-                       //m.EncryptionAlgorithm = EncryptionAlgorithm.Rc4;
-                       m.Extension = new byte[] { 0x01, 0x02, 0x03 };
-                       //m.HashAlgorithm = HashAlgorithm.Sha;
-                       m.Label = "MyLabel";
-                       m.Priority = MessagePriority.AboveNormal;
-                       m.Recoverable = true;
-                       m.ResponseQueue = responseQ;
-                       m.SenderCertificate = new byte[] { 0x04, 0x05, 0x06 };
-                       m.TimeToBeReceived = new TimeSpan(0, 0, 10);
-                       m.TimeToReachQueue = new TimeSpan(0, 0, 5);
-                       //m.UseAuthentication = true;
-                       m.UseDeadLetterQueue = true;
-                       //m.UseEncryption = true;
-                       
-                       mq.Send (m);
-                       
-                       Message m2 = mq.Receive ();
-                       
-                       m2.Formatter = new BinaryMessageFormatter ();
-                       Assert.AreEqual (s, m2.Body);
-                       
-                       Assert.AreEqual (AcknowledgeTypes.PositiveArrival, m2.AcknowledgeType, 
-                                        "AcknowledgeType not passed correctly");
-                       Assert.AreEqual (adminQ.QueueName, m2.AdministrationQueue.QueueName, 
-                                        "AdministrationQueue not passed correctly");
-                       Assert.AreEqual (5, m2.AppSpecific, "AppSpecific not passed correctly");
-                       //Assert.AreEqual (m.AuthenticationProviderName, m2.AuthenticationProviderName,
-                       //                 "AuthenticationProviderName not passed correctly");
-                       //Assert.AreEqual (m.AuthenticationProviderType, m2.AuthenticationProviderType,
-                       //                 "AuthenticationProviderType not passed correctly");
-                       //Assert.AreEqual (connectorType, m2.ConnectorType, 
-                       //                 "ConnectorType not passed correctly");
-                       Assert.AreEqual (m.CorrelationId, m2.CorrelationId, 
-                                        "CorrelationId not passed correctly");
-                       //AreEqual (m.DestinationSymmetricKey, m2.DestinationSymmetricKey, 
-                       //          "DestinationSymmetricKey not passed correctly");
-                       //AreEqual (m.DigitalSignature, m2.DigitalSignature,
-                       //          "DigitalSignature not passed properly");
-                       //Assert.AreEqual (EncryptionAlgorithm.Rc4, m2.EncryptionAlgorithm,
-                       //                 "EncryptionAlgorithm not passed properly");
-                       AreEqual (m.Extension, m2.Extension, "Extension not passed properly");
-                       //Assert.AreEqual (m.HashAlgorithm, m2.HashAlgorithm,
-                       //                 "HashAlgorithm not passed properly");
-                       Assert.AreEqual (m.Label, m2.Label, "Label not passed correctly");
-                       Assert.AreEqual (MessagePriority.AboveNormal, m2.Priority,
-                                        "Priority not passed properly");
-                       Assert.AreEqual (true, m2.Recoverable, "Recoverable not passed properly");
-                       Assert.AreEqual (responseQ.QueueName, m2.ResponseQueue.QueueName,
-                                        "ResponseQueue not passed properly");
-                       AreEqual (m.SenderCertificate, m2.SenderCertificate,
-                                 "SenderCertificate not passed properly");
-                       Assert.AreEqual (m.TimeToBeReceived, m2.TimeToBeReceived,
-                                        "TimeToBeReceived not passed properly");
-                       Assert.AreEqual (m.TimeToReachQueue, m2.TimeToReachQueue,
-                                        "TimeToReachQueue not passed properly");
-                       //Assert.IsTrue (m2.UseAuthentication,
-                       //               "UseAuthentication not passed properly");
-                       Assert.IsTrue (m2.UseDeadLetterQueue,
-                                      "UseDeadLetterQueue not passed properly");
-                       //Assert.IsTrue (m2.UseEncryption, "UseEncryption not pass properly");
-                       //Assert.AreEqual ();
-                       
-                       Assert.IsNotNull (m2.Id, "Id is null");
-                       Assert.IsTrue (Guid.Empty.ToString () !=  m2.Id, "Id is Empty");
-                       Assert.IsTrue (DateTime.MinValue != m2.ArrivedTime, "Arrived Time is not set");
-                       Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
-                       Assert.IsTrue (0 != m2.SenderVersion);
-                       
-                       //Assert.IsNotNull (m2.SourceMachine, "SourceMachine is null");
-                       
-               }
-               
-               private static void AreEqual(byte[] expected, byte[] actual, string message)
-               {
-                       Assert.AreEqual (expected.Length, actual.Length, message);
-                       for (int i = 0; i < expected.Length; i++)
-                               Assert.AreEqual (expected[i], actual[i], message);
-               }
-               
-               //[Test]
-               // No supported by Rabbit
-               public void SendPriorityMessages ()
-               {
-                       MessageQueue mq = MQUtil.GetQueue ("testpriority");
-                       Message sent1 = new Message ("Highest", new BinaryMessageFormatter ());
-                       sent1.Priority = MessagePriority.Highest;
-                       Message sent2 = new Message ("Lowest", new BinaryMessageFormatter ());
-                       sent2.Priority = MessagePriority.Lowest;
-                       
-                       mq.Send (sent1);
-                       mq.Send (sent2);
-                       
-                       Message received1 = mq.Receive ();
-                       Message received2 = mq.Receive ();
-                       
-                       Assert.AreEqual (MessagePriority.Highest, received2.Priority,
-                                        "Priority delivery incorrect");
-                       Assert.AreEqual (MessagePriority.Lowest, received1.Priority,
-                                        "Priority delivery incorrect");
-               }
-               
-               [Test]
-               public void SendReceiveXmlMessage ()
-               {
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\testq");
-                       String s = "Test: " + DateTime.Now;
-                       Message m = new Message (s, new XmlMessageFormatter (new Type[] { typeof (string) }));
-                       mq.MessageReadPropertyFilter.SetAll();
-                  
-                       mq.Send (m);
-                       Message m2 = mq.Receive ();
-                       m2.Formatter = new XmlMessageFormatter (new Type[] { typeof (string) });
-                       Assert.AreEqual (s, m2.Body);
-                  
-                       Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
-                       Assert.IsNotNull (m2.ArrivedTime, "Acknowledgment");
-                       Assert.IsNotNull (m2.Id, "Id");
-               }
-          
-               [Test]
-               public void SendBinaryText ()
-               {
-                       string path = @".\private$\MyQ";
-                       string body = "This is a test";
-                  
-                       MessageQueue q = MQUtil.GetQueue (path);
-
-                       q.Formatter = new BinaryMessageFormatter ();
-
-                       q.Send (body);
-
-                       Message m2 = q.Receive ();
-                  
-                       Assert.IsNotNull (m2.Formatter, "Formatter is null");
-                       Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
-                       Assert.AreEqual (body, m2.Body);
-               }
-
-               [Test]
-               public void SendDefaultText ()
-               {
-                       string path = @".\private$\MyQ";
-                       string body = "This is a test";
-
-                       MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
-
-                       q.Send (body);
-
-                       Message m2 = q.Receive ();
-                       XmlMessageFormatter xmlf = (XmlMessageFormatter) q.Formatter;
-                       //Assert.AreEqual (typeof (string), xmlf.TargetTypes[0]);
-                       Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
-                       Assert.AreEqual (body, m2.Body);
-                       Assert.AreEqual (0, m2.BodyType);
-               }
-
-               [Test]
-               public void SendBinaryObject ()
-               {
-                       string path = @".\private$\MyQ";
-                       Thingy body = new Thingy ();
-                       body.MyProperty1 = 42;
-                       body.MyProperty2 = "Something";
-                       body.MyProperty3 = "Something else";
-
-                       MessageQueue q = MQUtil.GetQueue (path);
-
-                       q.Formatter = new BinaryMessageFormatter ();
-
-                       q.Send (body);
-                  
-                       Message m2 = q.Receive ();
-                       Thingy body2 = (Thingy) m2.Body;
-
-                       Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
-                       Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
-                       Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
-                       Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
-                       Assert.AreEqual (768, m2.BodyType);
-               }
-
-               [Test]
-               public void SendDefaultObject ()
-               {
-                       string path = @".\private$\MyQ";
-                       Thingy body = new Thingy();
-                       body.MyProperty1 = 42;
-                       body.MyProperty2 = "Something";
-                       body.MyProperty3 = "Something else";
-
-                       MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
-
-                       q.Send (body);
-
-                       MessageQueue q2 = MQUtil.GetQueue (path);
-                       q2.Formatter = new XmlMessageFormatter (new Type[] { typeof(Thingy) });
-
-                       Message m2 = q2.Receive ();
-                       Thingy body2 = (Thingy) m2.Body;
-
-                       Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
-                       Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
-                       Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
-                       Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
-               }
-
-               [Test]
-               public void SendBinaryMessage ()
-               {
-                       string path = @".\private$\MyQ";
-                       Thingy body = new Thingy ();
-                       body.MyProperty1 = 42;
-                       body.MyProperty2 = "Something";
-                       body.MyProperty3 = "Something else";
-                       Message m1 = new Message (body);
-                       m1.Formatter = new BinaryMessageFormatter ();
-
-                       MessageQueue q = MQUtil.GetQueue (path);
-
-                       q.Send (m1);
-
-                       Message m2 = q.Receive ();
-                       m2.Formatter = new BinaryMessageFormatter ();
-                       Assert.IsNotNull (m2.Formatter);
-                       Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
-                       Thingy body2 = (Thingy) m2.Formatter.Read (m2);
-
-                       Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
-                       Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
-                       Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
-               }
-
-               [Test]
-               public void SendDefaultMessage ()
-               {
-                       string path = @".\private$\MyQ";
-                       Thingy body = new Thingy ();
-                       body.MyProperty1 = 42;
-                       body.MyProperty2 = "Something";
-                       body.MyProperty3 = "Something else";
-                       Message m1 = new Message (body);
-                       Assert.IsNull (m1.Formatter);
-
-                       MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
-
-                       q.Send (m1);
-
-                       Message m2 = q.Receive ();
-                       m2.Formatter = new XmlMessageFormatter (new Type[] { typeof (Thingy) });
-                       Assert.IsNotNull (m2.Formatter);
-                       Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
-                       Thingy body2 = (Thingy) m2.Formatter.Read (m2);
-
-                       Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
-                       Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
-                       Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
-               }                         
-       }
-
-       [Serializable]
-       public class Thingy
-       {
-               private int myVar1;
-
-               public int MyProperty1
-               {
-                       get { return myVar1; }
-                       set { myVar1 = value; }
-               }
-
-               private string myVar2;
-
-               public string MyProperty2
-               {
-                       get { return myVar2; }
-                       set { myVar2 = value; }
-               }
-
-               private string myVar3;
-
-               public string MyProperty3
-               {
-                       get { return myVar3; }
-                       set { myVar3 = value; }
-               }
-       }
-}
index 90a48b0e0e8636d0bb0b70c5f19f300c7f531598..9e94bdc60edbab527efde32349ee74762ece4df7 100644 (file)
@@ -1,3 +1,15 @@
+2009-07-19  Michael Barker  <mike@middlesoft.co.uk>
+
+       * AdminTest.cs:  Moved to System.Messaging
+       * AsyncPeekTest.cs:  Moved to System.Messaging
+       * AsyncReceiveTest.cs:  Moved to System.Messaging
+       * BasicMessagingTest.cs:  Moved to System.Messaging
+       * MessageEnumeratorTest.cs:  Moved to System.Messaging
+       * MQUtil.cs:  Moved to System.Messaging
+       * PeekTest.cs:  Moved to System.Messaging
+       * SelectorTest.cs:  Moved to System.Messaging
+
+
 2009-07-11  Michael Barker  <mike@middlesoft.co.uk>
 
        * MessageBaseTest.cs: Moved from Mono.Messaging.Test
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MQUtil.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MQUtil.cs
deleted file mode 100644 (file)
index 6c32aca..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-//
-// Test.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;
-
-namespace MonoTests.Mono.Messaging.RabbitMQ
-{
-       public class MQUtil
-       {
-               public static MessageQueue GetQueue (string path)
-               {
-                       return GetQueue (path, false);
-               }
-               
-               public static MessageQueue GetQueue (string path, bool isTransactional)
-               {
-                       return GetQueue (path, isTransactional,
-                                        new BinaryMessageFormatter ());
-               }
-               
-               public static MessageQueue GetQueue (string path, IMessageFormatter formatter)
-               {
-                       return GetQueue (path, false, formatter);
-               }
-               
-               public static MessageQueue GetQueue (string path, bool isTransactional, 
-                                                    IMessageFormatter formatter)
-               {
-                       MessageQueue q;
-                       if (MessageQueue.Exists (path)) {
-                               q = new MessageQueue (path);
-                       } else {
-                               q = MessageQueue.Create (path, isTransactional);
-                       }
-                       q.Formatter = formatter;
-                       return q;
-               }               
-       }
-}
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/MessageEnumeratorTest.cs
deleted file mode 100644 (file)
index 5535dd7..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-//
-// Test.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 Mono.Messaging;
-//using Mono.Messaging.RabbitMQ;
-
-using NUnit.Framework;
-
-namespace MonoTests.Mono.Messaging.RabbitMQ
-{
-       [TestFixture]
-       public class MessageEnumeratorTest {
-               
-               private readonly String qName = @".\private$\testq2";
-               
-               private void SendMessage (string s) {
-                       MessageQueue mq = MQUtil.GetQueue (qName);
-                       Message m = new Message (s, new BinaryMessageFormatter ());
-                       m.CorrelationId = Guid.NewGuid () + "\\0";
-                       mq.Send (m);
-               }
-               
-               [Test]
-               public void RemoveMessage ()
-               {
-                       SendMessage ("message 1");
-                       SendMessage ("message 2");
-                       SendMessage ("message 3");
-                       SendMessage ("message 4");
-                       
-                       MessageQueue mq0 = MQUtil.GetQueue (qName);
-                       MessageEnumerator me0 = mq0.GetMessageEnumerator ();
-                       
-                       me0.MoveNext ();
-                       me0.MoveNext ();
-                       me0.MoveNext ();
-                       
-                       Message m0 = me0.RemoveCurrent ();
-                       
-                       me0.MoveNext ();
-                       
-                       me0.Dispose ();
-                       mq0.Dispose ();
-                       
-                       MessageQueue mq1 = MQUtil.GetQueue (qName);
-                       MessageEnumerator me1 = mq1.GetMessageEnumerator ();
-                       
-                       me1.MoveNext();
-                       me1.MoveNext();
-                       me1.MoveNext();
-                       
-                       Message m1 = me1.Current;
-                       m1.Formatter = new BinaryMessageFormatter ();
-                       Assert.AreEqual ("message 4", (String) m1.Body, "body incorrect");
-                       
-                       mq1.Purge ();
-                       MessageQueue.Delete (qName);
-               }
-               
-               [Test]
-               public void RemoveMessageWithTimeout ()
-               {
-                       SendMessage ("message 1");
-                       SendMessage ("message 2");
-                       SendMessage ("message 3");
-                       SendMessage ("message 4");
-                       
-                       MessageQueue mq0 = MQUtil.GetQueue (qName);
-                       MessageEnumerator me0 = mq0.GetMessageEnumerator ();
-                       
-                       TimeSpan ts = new TimeSpan (0, 0, 2);
-                       
-                       me0.MoveNext (ts);
-                       me0.MoveNext (ts);
-                       me0.MoveNext (ts);
-                       
-                       Message m0 = me0.RemoveCurrent (ts);
-                       
-                       me0.MoveNext (ts);
-                       
-                       me0.Dispose ();
-                       mq0.Dispose ();
-                       
-                       MessageQueue mq1 = MQUtil.GetQueue (qName);
-                       MessageEnumerator me1 = mq1.GetMessageEnumerator ();
-                       
-                       me1.MoveNext (ts);
-                       me1.MoveNext (ts);
-                       me1.MoveNext (ts);
-                       
-                       Message m1 = me1.Current;
-                       m1.Formatter = new BinaryMessageFormatter ();
-                       Assert.AreEqual ("message 4", (String) m1.Body, "body incorrect");
-                       
-                       mq1.Purge ();
-                       MessageQueue.Delete (qName);
-               }
-               
-               //[Test]
-               // Not supported with AMQP
-               public void RemoveMessageWithTx ()
-               {
-                       MessageQueue q = MQUtil.GetQueue ("testq3");
-                       
-                       q.Formatter = new BinaryMessageFormatter ();
-                       q.Send ("foo1");
-                       q.Send ("foo2");
-                       
-                       MessageEnumerator me1 = q.GetMessageEnumerator ();
-                       MessageQueueTransaction tx = new MessageQueueTransaction ();
-                       me1.MoveNext ();
-                       Message m1 = me1.Current;
-                       me1.RemoveCurrent (tx);
-                       tx.Commit ();
-                       me1.Close ();
-                       
-                       MessageEnumerator me2 = q.GetMessageEnumerator ();
-                       Assert.IsTrue (me1.MoveNext ());
-                       me2.RemoveCurrent ();
-                       Assert.IsFalse (me2.MoveNext ());
-               }
-       }
-}
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/PeekTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/PeekTest.cs
deleted file mode 100644 (file)
index 2c6c60b..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-//
-// Test.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.RabbitMQ
-{
-       [TestFixture]
-       public class PeekTest {
-               
-               [Test]
-               public void PeekMessage ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message s1 = new Message(body, new BinaryMessageFormatter());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\peek-queue-1");
-                       mq.Send (s1);
-                       
-                       Message r1 = mq.Peek ();
-                       Assert.AreEqual (body, r1.Body);
-                       
-                       Message r2 = mq.Receive ();
-                       Assert.AreEqual (body, r2.Body);
-               }
-               
-               [Test]
-               public void PeekMessageWithTimeout ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString();
-                       Message s1 = new Message(body, new BinaryMessageFormatter());
-                       MessageQueue mq = MQUtil.GetQueue(@".\private$\peek-queue-2");
-                       mq.Send (s1);
-                       
-                       Message r1 = mq.Peek (new TimeSpan (0, 0, 2));
-                       Assert.AreEqual (body, r1.Body);
-                       
-                       Message r2 = mq.Receive ();
-                       Assert.AreEqual (body, r2.Body);
-               }
-               
-               [Test]
-               [ExpectedException (typeof (MessageQueueException))]
-               public void PeekNoMessageWithTimeout ()
-               {
-                       MessageQueue mq = MQUtil.GetQueue(@".\private$\peek-queue-3");
-                       Message r1 = mq.Peek (new TimeSpan (0, 0, 2));
-               }
-               
-               [Test]
-               public void PeekById ()
-               {
-                       String body = "Foo-" + DateTime.Now.ToString ();
-                       Message s1 = new Message (body, new BinaryMessageFormatter());
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-4");
-                       q.Send (s1);
-                       
-                       String id = s1.Id;
-                       try {
-                               Message r1 = q.PeekById (id);
-                               Assert.AreEqual (body, r1.Body, "Unable to PeekById correctly");
-                       } finally {
-                               q.Purge ();
-                       }
-               }
-               
-               [Test]
-               public void PeekByIdWithTimeout ()
-               {
-                       String body = "Foo-" + DateTime.Now.ToString ();
-                       Message s1 = new Message (body, new BinaryMessageFormatter());
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-5");
-                       q.Send (s1);
-                       
-                       String id = s1.Id;
-                       try {
-                               Message r1 = q.PeekById (id, new TimeSpan (0, 0, 2));
-                               Assert.AreEqual (body, r1.Body, "Unable to PeekById correctly");
-                       } finally {
-                               q.Purge ();
-                       }
-               }
-               
-               [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
-               public void PeekByIdNotFound ()
-               {
-                       String body = "Foo-" + DateTime.Now.ToString ();
-                       Message s1 = new Message (body, new BinaryMessageFormatter());
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-6");
-                       q.Send (s1);
-                       
-                       String id = "fail!";
-                       
-                       try {
-                               Message r1 = q.PeekById (id);
-                       } finally {
-                               q.Purge ();
-                       }
-               }
-               
-               [Test]
-               public void PeekByCorrelationId ()
-               {
-                       String correlationId = Guid.NewGuid () + "\\0";
-                       String body = "Foo-" + DateTime.Now.ToString ();
-                       Message s1 = new Message (body, new BinaryMessageFormatter());
-                       s1.CorrelationId = correlationId;
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-7");
-                       q.Formatter = new BinaryMessageFormatter ();
-                       q.Send (s1);
-                       
-                       try {
-                               Message r1 = q.PeekByCorrelationId (correlationId);
-                               Assert.AreEqual (body, r1.Body, "Unable to PeekByCorrelationId correctly");
-                       } finally {
-                               q.Purge ();
-                       }
-               }
-               
-               [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
-               public void PeekByCorrelationIdNotFound ()
-               {
-                       String body = "Foo-" + DateTime.Now.ToString ();
-                       Message s1 = new Message (body);
-                       String correlationId = Guid.NewGuid() + "\\0";
-                       MessageQueue q = MQUtil.GetQueue(@".\private$\peek-queue-8");
-                       q.Formatter = new BinaryMessageFormatter ();
-                       q.Send (s1);
-                       
-                       try {
-                               Message r1 = q.PeekByCorrelationId ("fail!");
-                       } finally {
-                               q.Purge ();
-                       }
-               }
-               
-               [Test]
-               public void PeekByCorrelationIdWithTimeout ()
-               {
-                       String correlationId = Guid.NewGuid () + "\\0";
-                       String body = "Foo-" + DateTime.Now.ToString ();
-                       Message s1 = new Message (body, new BinaryMessageFormatter());
-                       s1.CorrelationId = correlationId;
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-9");
-                       q.Formatter = new BinaryMessageFormatter ();
-                       q.Send (s1);
-                       
-                       try {
-                               Message r1 = q.PeekByCorrelationId (correlationId, new TimeSpan (0, 0, 2));
-                               Assert.AreEqual (body, r1.Body, "Unable to PeekByCorrelationId correctly");
-                       } finally {
-                               q.Purge ();
-                       }
-               }               
-       }
-}
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/SelectorTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/SelectorTest.cs
deleted file mode 100644 (file)
index 73caaed..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-//
-// Test.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.RabbitMQ
-{
-       [TestFixture]
-       public class SelectorTest
-       {
-               
-               [Test]
-               public void SelectById ()
-               {
-                       String body = "Foo-" + DateTime.Now.ToString ();
-                       Message s1 = new Message (body, new BinaryMessageFormatter());
-                       MessageQueue q = MQUtil.GetQueue (@".\private$\selector-queue-1");
-                       q.Send (s1);
-                       
-                       String id = s1.Id;
-                       
-                       Message r1 = q.ReceiveById (id);
-                       
-                       Assert.AreEqual (body, r1.Body, "Unable to ReceiveById correctly");
-               }
-               
-               [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
-               public void SelectByIdNotFound ()
-               {
-                       String body = "Foo-" + DateTime.Now.ToString();
-                       Message s1 = new Message(body, new BinaryMessageFormatter());
-                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-2");
-                       q.Send (s1);
-                       
-                       String id = "fail!";
-                       
-                       try {
-                               Message r1 = q.ReceiveById (id);
-                       } finally {
-                               q.Purge ();
-                       }
-               }
-               
-               [Test]
-               public void SelectByCorrelationId ()
-               {
-                       string correlationId = Guid.NewGuid () + "\\0";
-                       String body = "Foo-" + DateTime.Now.ToString();
-                       Message s1 = new Message(body, new BinaryMessageFormatter());
-                       s1.CorrelationId = correlationId;
-                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-3");
-                       q.Send (s1);
-                       
-                       Message r1 = q.ReceiveByCorrelationId (correlationId);
-                       
-                       Assert.AreEqual (body, r1.Body, "Unable to ReceiveByCorrelationId correctly");
-               }
-               
-               [Test]
-               [ExpectedException (typeof (InvalidOperationException))]
-               public void SelectByCorrelationIdNotFound ()
-               {
-                       string correlationId = Guid.NewGuid() + "\\0";
-                       String body = "Foo-" + DateTime.Now.ToString();
-                       Message s1 = new Message(body, new BinaryMessageFormatter());
-                       s1.CorrelationId = correlationId;
-                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-4");
-                       q.Send (s1);
-                       
-                       try {
-                               Message r1 = q.ReceiveByCorrelationId ("fail!");
-                       } finally {
-                               q.Purge ();
-                       }
-               }
-               
-               [Test]
-               public void SelectByIdWithTimeout ()
-               {
-                       String body = "Foo-" + DateTime.Now.ToString();
-                       Message s1 = new Message(body, new BinaryMessageFormatter());
-                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-5");
-                       q.Send (s1);
-                       
-                       String id = s1.Id;
-                       
-                       Message r1 = q.ReceiveById (id, new TimeSpan (0, 0, 2));
-                       
-                       Assert.AreEqual (body, r1.Body, "Unable to ReceiveById correctly");
-               }
-                               
-               [Test]
-               public void SelectByCorrelationIdWithTimeout ()
-               {
-                       string correlationId = Guid.NewGuid() + "\\0";
-                       String body = "Foo-" + DateTime.Now.ToString();
-                       Message s1 = new Message(body, new BinaryMessageFormatter());
-                       s1.CorrelationId = correlationId;
-                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-3");
-                       q.Send (s1);
-                       
-                       Message r1 = q.ReceiveByCorrelationId (correlationId, new TimeSpan (0, 0, 2));
-                       
-                       Assert.AreEqual (body, r1.Body, "Unable to ReceiveByCorrelationId correctly");
-               }
-       }
-}
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/TransactionMessagingTest.cs b/mcs/class/Mono.Messaging.RabbitMQ/Test/Mono.Messaging.RabbitMQ/TransactionMessagingTest.cs
deleted file mode 100644 (file)
index e023095..0000000
+++ /dev/null
@@ -1,467 +0,0 @@
-//
-// Test.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 System.Reflection;
-using System.Threading;
-using System.Text.RegularExpressions;
-
-using NUnit.Framework;
-
-namespace MonoTests.Mono.Messaging.RabbitMQ
-{
-       [TestFixture]
-       public class TransactionMessageTest {
-               
-               [Test]
-               public void Send2WithTransaction ()
-               {
-                       Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
-                       Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-1", true);
-                       mq.MessageReadPropertyFilter.SetAll ();
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               mq.Send (sent1, tx);
-                               mq.Send (sent2, tx);
-                               
-                               tx.Commit ();
-                               
-                               Message received1 = mq.Receive ();
-                               Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
-                               Message received2 = mq.Receive ();
-                               Assert.IsNotNull (received2.TransactionId, "TransactionId not set");
-                               
-                               Assert.AreEqual (received1.TransactionId, received2.TransactionId, "Messages have differing TransactionIds");
-                               Assert.IsTrue (received1.TransactionId.Length > 1);
-                               Assert.AreEqual (sent1.Body, received1.Body, "Message 1 not delivered correctly");
-                               Assert.AreEqual (sent2.Body, received2.Body, "Message 2 not delivered correctly");
-                       }
-               }
-               
-               [Test]
-               public void Send2WithLabelWithTransaction ()
-               {
-                       String label1 = "label1";
-                       String label2 = "label2";
-                       Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
-                       Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-2", true);
-                       mq.MessageReadPropertyFilter.SetAll ();
-                       Assert.IsTrue(mq.Transactional, "Message Queue should be transactional");
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               mq.Send (sent1, label1, tx);
-                               mq.Send (sent2, label2, tx);
-                               
-                               tx.Commit ();
-                               
-                               Message received1 = mq.Receive ();
-                               Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
-                               Message received2 = mq.Receive ();
-                               Assert.IsNotNull (received2.TransactionId, "TransactionId not set");
-                               
-                               Assert.AreEqual (received1.TransactionId, received2.TransactionId, "Messages have differing TransactionIds");
-                               Assert.IsTrue (received1.TransactionId.Length > 1);
-                               Assert.AreEqual (sent1.Body, received1.Body, "Message 1 not delivered correctly");
-                               Assert.AreEqual (sent2.Body, received2.Body, "Message 2 not delivered correctly");
-                               Assert.AreEqual (label1, received1.Label, "Label 1 not passed correctly");
-                               Assert.AreEqual (label2, received2.Label, "Label 2 not passed correctly");
-                       }
-               }
-                               
-               [Test]
-               [ExpectedException (typeof (MessageQueueException))]
-               public void Send2WithTransactionAbort ()
-               {
-                       Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
-                       Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-1", true);
-                       mq.MessageReadPropertyFilter.SetAll ();
-                       Assert.IsTrue(mq.Transactional, "Message Queue should be transactional");
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               mq.Send (sent1, tx);
-                               mq.Send (sent2, tx);
-                               
-                               tx.Abort ();
-                               mq.Receive (new TimeSpan (0, 0, 2));
-                       }
-               }
-               
-               [Test]
-               public void ReceiveWithTransaction ()
-               {
-                       String body = "Message 4";
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-4", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               Message received1 = mq.Receive (tx);
-                               
-                               tx.Commit ();
-                               
-                               Assert.AreEqual (body, received1.Body);
-                       }
-               }
-               
-               [Test]
-               public void ReceiveWithTransactionAbort ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-5", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               Message received1 = mq.Receive (tx);
-                               
-                               tx.Abort ();
-                       }
-                       
-                       Message received2 = mq.Receive ();
-                       Assert.AreEqual (body, received2.Body);
-               }
-               
-               [Test]
-               public void ReceiveWithTransactionType ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-6", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       
-                       Message received1 = mq.Receive (MessageQueueTransactionType.Single);
-                       
-                       Assert.AreEqual (body, received1.Body);
-               }
-               
-               [Test]
-               public void SendWithTransactionType ()
-               {
-                       Message sent1 = new Message ("Message 1");
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-7", true);
-                       mq.MessageReadPropertyFilter.SetAll();
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       
-                       Message received1 = mq.Receive ();
-                       Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
-               }
-               
-               [Test]
-               public void SendWithTransactionTypeAndLabel ()
-               {
-                       Message sent1 = new Message ("Message 1");
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-8", true);
-                       mq.MessageReadPropertyFilter.SetAll();
-                       String label = "mylabel";
-                       
-                       mq.Send (sent1, label, MessageQueueTransactionType.Single);
-                       
-                       Message received1 = mq.Receive ();
-                       Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
-                       Assert.AreEqual (label, received1.Label, "Label not set");
-               }
-
-               [Test]
-               public void ReceiveByIdWithTransaction ()
-               {
-                       String body = "Message 4";
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-9", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               Message received1 = mq.ReceiveById (id, tx);
-                               
-                               tx.Commit ();
-                               
-                               Assert.AreEqual (body, received1.Body);
-                       }
-               }
-               
-               [Test]
-               public void ReceiveByIdWithTransactionAbort ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-10", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               Message received1 = mq.ReceiveById (id, tx);
-                               
-                               tx.Abort ();
-                       }
-                       
-                       Message received2 = mq.Receive ();
-                       Assert.AreEqual (body, received2.Body);
-               }
-               
-               [Test]
-               public void ReceiveByIdWithTransactionType ()
-               {
-                       String body = "Message 4";
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-11", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-
-                       Message received1 = mq.ReceiveById (id, MessageQueueTransactionType.Single);
-                       Assert.AreEqual (body, received1.Body);
-               }
-
-               [Test]
-               public void ReceiveByCorrelationIdWithTransaction ()
-               {
-                       string correlationId = Guid.NewGuid() + "\\0";
-                       String body = "Message 4";
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       sent1.CorrelationId = correlationId;
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-12", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-
-                               Message received1 = mq.ReceiveByCorrelationId(correlationId, tx);
-                               
-                               tx.Commit ();
-                               
-                               Assert.AreEqual (body, received1.Body);
-                       }
-               }
-               
-               [Test]
-               public void ReceiveByCorrelationIdWithTransactionAbort ()
-               {
-                       string correlationId = Guid.NewGuid() + "\\0";
-                       String body = "foo-" + DateTime.Now.ToString();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       sent1.CorrelationId = correlationId;
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-13", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               Message received1 = mq.ReceiveByCorrelationId (correlationId, tx);
-                               
-                               tx.Abort ();
-                       }
-                       
-                       Message received2 = mq.Receive ();
-                       Assert.AreEqual (body, received2.Body);
-               }
-
-               [Test]
-               public void ReceiveByCorrelationIdWithTransactionType ()
-               {
-                       string correlationId = Guid.NewGuid() + "\\0";
-                       String body = "Message 10";
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       sent1.CorrelationId = correlationId;
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-14", true);
-                       mq.Formatter = new BinaryMessageFormatter ();
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-                       
-                       Message received1 = mq.ReceiveByCorrelationId (correlationId, MessageQueueTransactionType.Single);
-                       Assert.AreEqual (body, received1.Body);
-               }
-
-               [Test]
-               public void ReceiveWithTransactionAndTimeout ()
-               {
-                       String body = "Message 11";
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-15", true);
-                       mq.Formatter = new BinaryMessageFormatter ();
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               Message received1 = mq.Receive (new TimeSpan (0, 0, 2), tx);
-                               
-                               tx.Commit ();
-                               
-                               Assert.AreEqual (body, received1.Body);
-                       }
-               }
-
-               [Test]
-               public void ReceiveWithTransactionAndTimeoutAndAbort ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-16", true);
-                       mq.Formatter = new BinaryMessageFormatter ();
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               Message received1 = mq.Receive (new TimeSpan (0, 0, 2), tx);
-                               
-                               tx.Abort ();
-                       }
-                       
-                       Message received2 = mq.Receive ();
-                       Assert.AreEqual (body, received2.Body);
-               }
-               
-               [Test]
-               public void ReceiveWithTransactionTypeAndTimeout ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-17", true);
-                       mq.Formatter = new BinaryMessageFormatter ();
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       
-                       Message received1 = mq.Receive (new TimeSpan (0, 0, 5), MessageQueueTransactionType.Single);
-                       
-                       Assert.AreEqual (body, received1.Body);
-               }
-
-               [Test]
-               [ExpectedException (typeof (MessageQueueException))]
-               public void ReceiveWithTransactionTypeAndTimeoutFailure ()
-               {
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-18", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       Message received1 = mq.Receive (new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
-               }
-               
-               [Test]
-               public void ReceiveByIdWithTransactionAndTimeout ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-19", true);
-                       mq.Formatter = new BinaryMessageFormatter ();
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-                               
-                               Message received1 = mq.ReceiveById (id, new TimeSpan (0, 0, 2), tx);
-                               
-                               tx.Commit ();
-                               
-                               Assert.AreEqual (body, received1.Body);
-                       }
-               }
-               
-               [Test]
-               public void ReceiveByIdWithTransactionTypeAndTimeout ()
-               {
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-20", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-                       
-                       Message received1 = mq.ReceiveById (id, new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
-                       Assert.AreEqual (body, received1.Body);
-               }
-
-               [Test]
-               public void ReceiveByCorrelationIdWithTransactionAndTimeout ()
-               {
-                       string correlationId = Guid.NewGuid () + "\\0";
-                       String body = "foo-" + DateTime.Now.ToString ();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       sent1.CorrelationId = correlationId;
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-21", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-                       
-                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
-                               tx.Begin ();
-
-                               Message received1 = mq.ReceiveByCorrelationId (correlationId, new TimeSpan (0, 0, 2), tx);
-                               tx.Commit ();
-                               Assert.AreEqual (body, received1.Body);
-                       }
-               }               
-
-               [Test]
-               public void ReceiveByCorrelationIdWithTransactionTypeAndTimeout ()
-               {
-                       string correlationId = Guid.NewGuid() + "\\0";
-                       String body = "foo-" + DateTime.Now.ToString();
-                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
-                       sent1.CorrelationId = correlationId;
-                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-22", true);
-                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
-                       mq.Send (sent1, MessageQueueTransactionType.Single);
-                       string id = sent1.Id;
-
-                       Message received1 = mq.ReceiveByCorrelationId (correlationId,  new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
-                       Assert.AreEqual (body, received1.Body);
-               }               
-       }
-}
index 0d019182c495239bb9a93bbd5f701bbce0b2049d..a3c654c59197d1c923883e7e9317cbe677d91ee7 100644 (file)
@@ -4,9 +4,7 @@ include ../../build/rules.make
 
 LIBRARY = Mono.Messaging.dll
 
-ifdef NET_1_0
-LIB_MCS_FLAGS = /r:System.dll
-else NET_1_1
+ifeq (1, $(FRAMEWORK_VERSION_MAJOR))
 LIB_MCS_FLAGS = /r:System.dll
 else
 LIB_MCS_FLAGS = /r:System.dll /r:System.Configuration
index c65ec4c27f52ba8fe620ac902e206b29f7cb8716..265ee4a8e450e39386fec46d92ec3276814bad81 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: filter the valid profile on the framework version,
+       to make it easier to have custom variants.
+
 2009-07-02  Marek Safar  <marek.safar@gmail.com>
 
        * net_4_0_System.Core.dll.sources: New file.
index 801f450e33fe81e8319640fc2d786b6a97ee2ab6..407fd19ed6b6cd6c563674842369e7a8bbf87bbe 100644 (file)
@@ -17,7 +17,7 @@ endif
 TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
 
 # This is a .NET 2.0+ only assembly
-VALID_PROFILE := $(filter net_2_0 net_2_1_raw net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter 2.0 2.1 4.0, $(FRAMEWORK_VERSION))
 ifndef VALID_PROFILE
 LIBRARY_NAME = dummy-System.Core.dll
 NO_INSTALL = yes
index 734a0d07a31dfbb4d5be14276b0f2ae7a82f5fd7..71b371c2d88882509a5f6bbed195460339050ecb 100644 (file)
@@ -1,3 +1,12 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Lookup.cs: avoid a double dictionary lookup on the indexer.
+
+2009-07-19 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * Lookup.cs: when there are no matching elements, return an empty
+       enumerable. Fixes bug #523386.
+
 2009-05-18  Jb Evain  <jbevain@novell.com>
 
        * Enumerable.cs (Max, Min): fix generic versions.
index 0398ad6a53a099de67230d9415ec23b6b5210de1..16cac37fd97efd3564282a3334f3c171c538f9bc 100644 (file)
@@ -44,7 +44,13 @@ namespace System.Linq {
                }
 
                public IEnumerable<TElement> this [TKey key] {
-                       get { return groups [key]; }
+                       get {
+                               IGrouping<TKey, TElement> group;
+                               if (groups.TryGetValue (key, out group))
+                                       return group;
+
+                               return new TElement [0];
+                       }
                }
 
                internal Lookup (Dictionary<TKey, List<TElement>> lookup)
index 85007758d5f44c12ad6a0583c718a10857b81a6a..6f790a5b3c7bb5b39d48431d4405e4ef53290cab 100644 (file)
@@ -68,5 +68,19 @@ namespace MonoTests.System.Linq {
                        Assert.AreEqual (0x00ff00, lookup ["GrEeN"].First ());
                        Assert.AreEqual (0x0000ff, lookup ["Blue"].First ());
                }
+
+               [Test]
+               public void EmptyResult ()
+               {
+                       var lookup = GetColors ().ToLookup (
+                               c => c.Name,
+                               c => c.Value,
+                               StringComparer.OrdinalIgnoreCase);
+
+                       var l = lookup ["notexist"];
+                       Assert.IsNotNull (l);
+                       int [] values = (int []) l;
+                       Assert.AreEqual (values.Length, 0);
+               }
        }
 }
index d77abc91ced4c2ca466b0cd138751850ddcee28a..8347a558b3bac1b448859f5545f890766de2cbfd 100644 (file)
@@ -1 +1,10 @@
+System.Messaging/AdminTest.cs
+System.Messaging/AsyncPeekTest.cs
+System.Messaging/AsyncReceiveTest.cs
+System.Messaging/BasicMessagingTest.cs
+System.Messaging/MessageEnumeratorTest.cs
 System.Messaging/MessageQueuePermissionAttributeTest.cs
+System.Messaging/MQUtil.cs
+System.Messaging/PeekTest.cs
+System.Messaging/SelectorTest.cs
+System.Messaging/TransactionMessagingTest.cs
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/AdminTest.cs b/mcs/class/System.Messaging/Test/System.Messaging/AdminTest.cs
new file mode 100644 (file)
index 0000000..954cdf4
--- /dev/null
@@ -0,0 +1,130 @@
+//
+// Test.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 System.Reflection;
+using System.Threading;
+using System.Text.RegularExpressions;
+
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Messaging.RabbitMQ
+{
+       [TestFixture]
+       public class AdminTest {
+               
+               [Test]
+               public void CreateNonTransactionalQueue ()
+               {
+                       string qName = @".\private$\admin-queue-1";
+                       Assert.IsFalse (MessageQueue.Exists (qName), "Queue should not exist");
+                       MessageQueue q = MessageQueue.Create (qName);
+                       Assert.IsFalse (q.Transactional);
+                       Assert.IsTrue (MessageQueue.Exists (qName), "Queue should exist");
+               }
+               
+               [Test]
+               public void CreateTransactionalQueue ()
+               {
+                       string qName = @".\private$\admin-queue-2";
+                       Assert.IsFalse (MessageQueue.Exists (qName), "Queue should not exist");
+                       MessageQueue q = MessageQueue.Create (qName, true);
+                       Assert.IsTrue (q.Transactional, "Queue should be transactional");
+                       Assert.IsTrue (MessageQueue.Exists (qName), "Queue should exist");
+               }
+               
+               private bool Contains(MessageQueue[] qs, String qName)
+               {
+                       foreach (MessageQueue q in qs)
+                       {
+                               if (q.QueueName == qName)
+                                       return true;
+                       }
+                       return false;
+               }
+
+               [Test]
+               public void GetPublicQueues ()
+               {
+                       string qName1 = @".\admin-queue-3";
+                       string qName2 = @".\admin-queue-4";
+                       
+                       MessageQueue.Create (qName1);
+                       MessageQueue.Create (qName2);
+                       
+                       MessageQueue[] mq = MessageQueue.GetPublicQueues ();
+                       Assert.IsTrue (Contains (mq, "admin-queue-3"), qName1 + " not found");
+                       Assert.IsTrue (Contains (mq, "admin-queue-4"), qName2 + " not found");
+               }
+               
+               [Test]
+               public void GetQueue ()
+               {
+                       MessageQueue q1 = MQUtil.GetQueue(@".\private$\admin-queue-5", true);
+                       Assert.IsTrue (q1.Transactional, "Queue should be transactional");
+                       MessageQueue q2 = MQUtil.GetQueue(@".\private$\admin-queue-5", true);
+                       Assert.IsTrue (q2.Transactional, "Queue should be transactional");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (MessageQueueException))]
+               public void PurgeQueue ()
+               {
+                       MessageQueue q = MQUtil.GetQueue(@".\private$\purge-queue");
+                       Message m1 = new Message ("foobar1", new BinaryMessageFormatter ());
+                       Message m2 = new Message ("foobar2", new BinaryMessageFormatter ());
+                       Message m3 = new Message ("foobar3", new BinaryMessageFormatter ());
+                       Message m4 = new Message ("foobar4", new BinaryMessageFormatter ());
+                       
+                       q.Send (m1);
+                       q.Send (m2);
+                       q.Send (m3);
+                       q.Send (m4);
+                       
+                       q.Receive ();                   
+                       q.Purge ();
+                       q.Receive (new TimeSpan (0, 0, 2));
+               }
+                               
+               [Test]
+               public void DeleteQueue ()
+               {
+                       MessageQueue q = MQUtil.GetQueue(@".\private$\delete-queue");
+                       Message m1 = new Message ("foobar1", new BinaryMessageFormatter ());
+                       
+                       q.Send (m1);
+                       
+                       q.Receive ();
+
+                       MessageQueue.Delete(@".\private$\delete-queue");
+               }
+       }
+}
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/AsyncPeekTest.cs b/mcs/class/System.Messaging/Test/System.Messaging/AsyncPeekTest.cs
new file mode 100644 (file)
index 0000000..ae4b2d8
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// Test.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 System.Reflection;
+using System.Threading;
+using System.Text.RegularExpressions;
+
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Messaging.RabbitMQ
+{
+       [TestFixture]
+       public class AsyncPeekTest {
+
+               bool eventCalled = false;
+               
+               private void HandleMessage (object source, PeekCompletedEventArgs args) {
+                       eventCalled = true;
+               }
+
+               [Test]
+               public void BeginPeek()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-1");
+                       Message s = new Message (new BinaryMessageFormatter ());
+                       string body = "foo-" + DateTime.Now.ToString ();
+                       s.Body = body;
+                       q.Send (s);
+                       
+                       q.PeekCompleted += new PeekCompletedEventHandler (HandleMessage);
+                       IAsyncResult result = q.BeginPeek ();
+                       result.AsyncWaitHandle.WaitOne ();
+                       Message rMsg = q.EndPeek (result);
+                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
+                       Assert.IsTrue (eventCalled, "Handle Message not called");
+                       
+                       Assert.IsNotNull (q.Receive (), "Message not peeked");
+               }
+               
+               [Test]
+               public void BeginPeekWithTimeout()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-2");
+                       Message s = new Message (new BinaryMessageFormatter ());
+                       string body = "foo-" + DateTime.Now.ToString ();
+                       s.Body = body;
+                       q.Send (s);
+                       
+                       IAsyncResult result = q.BeginPeek (new TimeSpan (0, 0, 2));
+                       result.AsyncWaitHandle.WaitOne ();
+                       Message rMsg = q.EndPeek (result);
+                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
+                       
+                       Assert.IsNotNull (q.Receive (), "Message not peeked");
+               }
+               
+               [Test]
+               public void BeginPeekWithStateAndTimeout()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-3");
+                       Message s = new Message (new BinaryMessageFormatter ());
+                       string body = "foo-" + DateTime.Now.ToString ();
+                       s.Body = body;
+                       q.Send (s);
+                       
+                       IAsyncResult result = q.BeginPeek (new TimeSpan (0, 0, 2), "foo");
+                       result.AsyncWaitHandle.WaitOne ();
+                       Message rMsg = q.EndPeek (result);
+                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
+                       Assert.AreEqual ("foo", result.AsyncState, "State not passed properly");
+                       
+                       Assert.IsNotNull (q.Receive (), "Message not peeked");
+               }
+               
+               private bool success = false;
+               
+               public void TestCallback (IAsyncResult result)
+               {
+                       success = true;
+               }
+               
+               [Test]
+               public void BeginPeekWithStateAndTimeoutAndCallback()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-4");
+                       Message s = new Message (new BinaryMessageFormatter ());
+                       string body = "foo-" + DateTime.Now.ToString ();
+                       s.Body = body;
+                       q.Send (s);
+                       AsyncCallback ac = new AsyncCallback (TestCallback);
+                       IAsyncResult result = q.BeginPeek (new TimeSpan (0, 0, 2), "foo", ac);
+                       result.AsyncWaitHandle.WaitOne ();
+                       Message rMsg = q.EndPeek (result);
+                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
+                       Assert.AreEqual ("foo", result.AsyncState, "State not passed properly");
+                       Assert.IsTrue (success, "Callback not run");
+                       
+                       Assert.IsNotNull (q.Receive (), "Message not peeked");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (MessageQueueException))]
+               public void BeginPeekWithException()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-5");
+                       IAsyncResult result = q.BeginPeek (new TimeSpan (0, 0, 2));
+                       result.AsyncWaitHandle.WaitOne ();
+                       q.EndPeek (result);
+               }               
+       }
+}
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/AsyncReceiveTest.cs b/mcs/class/System.Messaging/Test/System.Messaging/AsyncReceiveTest.cs
new file mode 100644 (file)
index 0000000..1027a7e
--- /dev/null
@@ -0,0 +1,140 @@
+//
+// Test.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 System.Reflection;
+using System.Threading;
+using System.Text.RegularExpressions;
+
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Messaging.RabbitMQ
+{
+       [TestFixture]
+       public class AsyncReceiveTest {
+
+               private Message m;
+               private string failureMessage = null;
+               private string state = null;
+               
+               private void HandleMessage (object source, ReceiveCompletedEventArgs args) {
+                       try {
+                               MessageQueue q = (MessageQueue) source;
+                               m = q.EndReceive (args.AsyncResult);
+                               state = (string) args.AsyncResult.AsyncState;
+                       } catch (Exception e) {
+                               failureMessage = e.Message;
+                       }
+               }
+
+               [Test]
+               public void BeginReceive()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-receive-1");
+                       Message s = new Message (new BinaryMessageFormatter ());
+                       string body = "foo-" + DateTime.Now.ToString ();
+                       s.Body = body;
+                       q.Send (s);
+                       
+                       q.ReceiveCompleted += new ReceiveCompletedEventHandler (HandleMessage);
+                       IAsyncResult result = q.BeginReceive ();
+                       result.AsyncWaitHandle.WaitOne ();
+                       Message rMsg = q.EndReceive (result);
+                       Assert.IsNotNull (rMsg, "No message received");
+                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
+               }
+               
+               [Test]
+               public void BeginReceiveWithTimeout()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-receive-2");
+                       Message s = new Message (new BinaryMessageFormatter ());
+                       string body = "foo-" + DateTime.Now.ToString ();
+                       s.Body = body;
+                       q.Send (s);
+                       
+                       IAsyncResult result = q.BeginReceive (new TimeSpan (0, 0, 2));
+                       result.AsyncWaitHandle.WaitOne ();
+                       Message rMsg = q.EndReceive (result);
+                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
+               }
+               
+               [Test]
+               public void BeginReceiveWithStateAndTimeout()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-receive-3");
+                       Message s = new Message (new BinaryMessageFormatter ());
+                       string body = "foo-" + DateTime.Now.ToString ();
+                       s.Body = body;
+                       q.Send (s);
+                       
+                       IAsyncResult result = q.BeginReceive (new TimeSpan (0, 0, 2), "foo");
+                       result.AsyncWaitHandle.WaitOne ();
+                       Message rMsg = q.EndReceive (result);
+                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
+                       Assert.AreEqual ("foo", result.AsyncState, "State not passed properly");
+               }
+               
+               private bool success = false;
+               
+               public void TestCallback (IAsyncResult result)
+               {
+                       success = true;
+               }
+               
+               [Test]
+               public void BeginReceiveWithStateAndTimeoutAndCallback()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-receive-4");
+                       Message s = new Message (new BinaryMessageFormatter ());
+                       string body = "foo-" + DateTime.Now.ToString ();
+                       s.Body = body;
+                       q.Send (s);
+                       AsyncCallback ac = new AsyncCallback (TestCallback);
+                       IAsyncResult result = q.BeginReceive (new TimeSpan (0, 0, 2), "foo", ac);
+                       result.AsyncWaitHandle.WaitOne ();
+                       Message rMsg = q.EndReceive (result);
+                       Assert.AreEqual (body, rMsg.Body, "Async Send Failed, bodies not equal");
+                       Assert.AreEqual ("foo", result.AsyncState, "State not passed properly");
+                       Assert.IsTrue (success, "Callback not run");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (MessageQueueException))]
+               public void BeginReceiveWithException()
+               {
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\async-peek-5");
+                       IAsyncResult result = q.BeginReceive (new TimeSpan (0, 0, 2));
+                       result.AsyncWaitHandle.WaitOne ();
+                       q.EndReceive (result);
+               }               
+       }
+}
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/BasicMessagingTest.cs b/mcs/class/System.Messaging/Test/System.Messaging/BasicMessagingTest.cs
new file mode 100644 (file)
index 0000000..3d2e380
--- /dev/null
@@ -0,0 +1,483 @@
+//
+// Test.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 System.Reflection;
+using System.Threading;
+using System.Text.RegularExpressions;
+
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Messaging.RabbitMQ
+{
+       [TestFixture]
+       public class BasicMessageTest {
+
+               [Test]
+               public void SendReceiveBinaryMessage ()
+               {
+                       String qName = @"private$\testq";
+                       String qPath = @".\" + qName;
+                       MessageQueue mq = MQUtil.GetQueue (qPath);
+                       Assert.AreEqual(qName, mq.QueueName, "Queue name not set properly");
+                       String s = "Test: " + DateTime.Now;
+                       Message m = new Message (s, new BinaryMessageFormatter ());
+                       m.CorrelationId = Guid.NewGuid () + "\\0";
+                       mq.MessageReadPropertyFilter.SetAll ();
+
+                       mq.Send (m);
+
+                       Message m2 = mq.Receive ();
+                       m2.Formatter = new BinaryMessageFormatter ();
+                       Assert.AreEqual (s, m2.Body);
+
+                       //Assert.IsTrue (DateTime.MinValue == m.ArrivedTime);
+                       Assert.IsNotNull(m2.Id, "Id is null");
+                       Assert.IsTrue (Guid.Empty.ToString () !=  m2.Id, "Id is Empty");
+                       Assert.IsTrue (DateTime.MinValue != m2.ArrivedTime, "Arrived Time is not set");
+                       Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
+                       Assert.AreEqual (m.CorrelationId, m2.CorrelationId, "CorrelationId not set properly");
+                       Assert.IsTrue (0 != m2.SenderVersion);
+                       // TODO: This is not support on a workgroup installation.
+                       //Assert.IsNotNull (m2.SourceMachine, "SourceMachine is null");
+                       Assert.AreEqual (qName, m2.DestinationQueue.QueueName, "Destination Queue not set");
+                       
+                       mq.Close ();
+               }
+               
+               [Test]
+               public void SendMessageWithLabel ()
+               {
+                       String qName = @".\private$\testq";
+                       String label = "mylabel";
+                       MessageQueue mq = MQUtil.GetQueue (qName);
+                       Assert.AreEqual (@"private$\testq", mq.QueueName, "Queue name not set properly");
+                       String s = "Test: " + DateTime.Now;
+                       Message m = new Message (s, new BinaryMessageFormatter ());
+                       m.CorrelationId = Guid.NewGuid () + "\\0" ;
+
+                       mq.Send (m, label);
+
+                       Message m2 = mq.Receive ();
+                       m2.Formatter = new BinaryMessageFormatter ();
+                       Assert.AreEqual (s, m2.Body, "Message not passed correctly");
+                       Assert.AreEqual (label, m2.Label, "Label not passed correctly");
+               }
+               
+               
+               [Test]
+               public void CheckDefaults ()
+               {
+                       Message m = new Message ("Test", new BinaryMessageFormatter ());
+                       Assert.AreEqual (true, m.AttachSenderId, "AttachSenderId has incorrect default");
+                       Assert.AreEqual (Guid.Empty.ToString () + "\\0", m.Id, "Id has incorrect default");
+                       Assert.AreEqual ("Microsoft Base Cryptographic Provider, Ver. 1.0", 
+                                        m.AuthenticationProviderName, 
+                                        "AuthenticationProviderName has incorrect default"); 
+                       Assert.AreEqual (0, m.Extension.Length, "Extension has incorrect default");
+                       Assert.AreEqual ("", m.Label, "Label has incorrect default");
+                       Assert.IsFalse (m.Recoverable, "Recoverable has incorrect default");
+                       Assert.IsFalse (m.IsFirstInTransaction, "IsFirstInTransaction has incorrect default");
+                       Assert.IsFalse (m.IsLastInTransaction, "IsLastInTransaction has incorrect default");
+                       Assert.AreEqual ("", m.TransactionId, "TransactionId has incorrect default");
+                       Assert.AreEqual (MessagePriority.Normal, m.Priority, "MessagePriority has incorrect default");
+               }
+               
+               private static void CheckInvalidOperation (Message m, String property)
+               {
+                       PropertyInfo pi = m.GetType ().GetProperty (property);
+                       try {
+                               Assert.IsNotNull (pi, "Property not defined: " + property);
+                               object o = pi.GetValue (m, null);
+                               Assert.Fail (property + ": " + o);
+                       } catch (InvalidOperationException) {
+                       } catch (TargetInvocationException e) {
+                               Assert.AreEqual (typeof (InvalidOperationException), 
+                                                e.InnerException.GetType ());
+                       }
+               }
+               
+               [Test]
+               public void CheckInvalidPropertyOperations ()
+               {
+                       Message m = new Message ("Test", new BinaryMessageFormatter ());
+                       CheckInvalidOperation (m, "Acknowledgment");
+                       CheckInvalidOperation (m, "ArrivedTime");
+                       CheckInvalidOperation (m, "Authenticated");
+                       CheckInvalidOperation (m, "DestinationQueue");
+                       //CheckInvalidOperation (m, "Id");
+                       //CheckInvalidOperation (m, "IsFirstInTransaction");
+                       //CheckInvalidOperation (m, "IsLastInTransaction");
+                       // TODO: Support 2.0 features.
+                       //CheckInvalidOperation (m, "LookupId");
+                       CheckInvalidOperation (m, "MessageType");
+                       CheckInvalidOperation (m, "SenderId");
+                       CheckInvalidOperation (m, "SenderVersion");
+                       CheckInvalidOperation (m, "SentTime");
+                       CheckInvalidOperation (m, "SourceMachine");
+                       //CheckInvalidOperation (m, "TransactionId");
+               }
+               
+               private static void CheckArgumentInvalid(Message m, String property, Type exceptionType)
+               {
+                       PropertyInfo pi = m.GetType().GetProperty(property);
+                       try {
+                               Assert.IsNotNull(pi, "Property not defined: " + property);
+                               pi.SetValue(m, null, null);
+                               Assert.Fail(property);
+                       } catch (InvalidOperationException) {
+                       } catch (TargetInvocationException e) {
+                               Assert.AreEqual(exceptionType,
+                                               e.InnerException.GetType(),
+                                               property);
+                       }
+               }
+
+               [Test]
+               public void CheckArgumentInvalidForProperties ()
+               {
+                       Message m = new Message ("Stuff");
+                       CheckArgumentInvalid (m, "DestinationSymmetricKey", typeof (ArgumentNullException));
+                       CheckArgumentInvalid (m, "DigitalSignature", typeof(ArgumentNullException));
+                       CheckArgumentInvalid (m, "Extension", typeof(ArgumentNullException));
+               }
+
+               [Test]
+               public void SendReceiveBinaryMessageWithAllPropertiesSet ()
+               {
+                       String qName = @"private$\testq";
+                       String qPath = @".\" + qName;
+                       MessageQueue mq = MQUtil.GetQueue (qPath);
+                       mq.MessageReadPropertyFilter.SetAll ();
+                       Assert.AreEqual(qName, mq.QueueName, "Queue name not set properly");
+                       
+                       MessageQueue adminQ = MQUtil.GetQueue (@".\private$\myadmin");
+                       MessageQueue responseQ = MQUtil.GetQueue (@".\private$\myresponse");
+                       Guid connectorType = Guid.NewGuid ();
+                       String s = "Test: " + DateTime.Now;
+                       
+                       Message m = new Message (s, new BinaryMessageFormatter ());
+                       m.CorrelationId = Guid.NewGuid () + "\\0";
+                       m.AcknowledgeType = AcknowledgeTypes.PositiveArrival;
+                       m.AdministrationQueue = adminQ;
+                       m.AppSpecific = 5;
+                       //m.AuthenticationProviderName = "Test Provider Name";
+                       //m.AuthenticationProviderType = CryptographicProviderType.None;
+                       //m.ConnectorType = connectorType;
+                       //m.DestinationSymmetricKey = new byte[] { 0x0A, 0x0B, 0x0C };
+                       //m.DigitalSignature = new byte[] { 0x0C, 0x0D, 0x0E };
+                       //m.EncryptionAlgorithm = EncryptionAlgorithm.Rc4;
+                       m.Extension = new byte[] { 0x01, 0x02, 0x03 };
+                       //m.HashAlgorithm = HashAlgorithm.Sha;
+                       m.Label = "MyLabel";
+                       m.Priority = MessagePriority.AboveNormal;
+                       m.Recoverable = true;
+                       m.ResponseQueue = responseQ;
+                       m.SenderCertificate = new byte[] { 0x04, 0x05, 0x06 };
+                       m.TimeToBeReceived = new TimeSpan(0, 0, 10);
+                       m.TimeToReachQueue = new TimeSpan(0, 0, 5);
+                       //m.UseAuthentication = true;
+                       m.UseDeadLetterQueue = true;
+                       //m.UseEncryption = true;
+                       
+                       mq.Send (m);
+                       
+                       Message m2 = mq.Receive ();
+                       
+                       m2.Formatter = new BinaryMessageFormatter ();
+                       Assert.AreEqual (s, m2.Body);
+                       
+                       Assert.AreEqual (AcknowledgeTypes.PositiveArrival, m2.AcknowledgeType, 
+                                        "AcknowledgeType not passed correctly");
+                       Assert.AreEqual (adminQ.QueueName, m2.AdministrationQueue.QueueName, 
+                                        "AdministrationQueue not passed correctly");
+                       Assert.AreEqual (5, m2.AppSpecific, "AppSpecific not passed correctly");
+                       //Assert.AreEqual (m.AuthenticationProviderName, m2.AuthenticationProviderName,
+                       //                 "AuthenticationProviderName not passed correctly");
+                       //Assert.AreEqual (m.AuthenticationProviderType, m2.AuthenticationProviderType,
+                       //                 "AuthenticationProviderType not passed correctly");
+                       //Assert.AreEqual (connectorType, m2.ConnectorType, 
+                       //                 "ConnectorType not passed correctly");
+                       Assert.AreEqual (m.CorrelationId, m2.CorrelationId, 
+                                        "CorrelationId not passed correctly");
+                       //AreEqual (m.DestinationSymmetricKey, m2.DestinationSymmetricKey, 
+                       //          "DestinationSymmetricKey not passed correctly");
+                       //AreEqual (m.DigitalSignature, m2.DigitalSignature,
+                       //          "DigitalSignature not passed properly");
+                       //Assert.AreEqual (EncryptionAlgorithm.Rc4, m2.EncryptionAlgorithm,
+                       //                 "EncryptionAlgorithm not passed properly");
+                       AreEqual (m.Extension, m2.Extension, "Extension not passed properly");
+                       //Assert.AreEqual (m.HashAlgorithm, m2.HashAlgorithm,
+                       //                 "HashAlgorithm not passed properly");
+                       Assert.AreEqual (m.Label, m2.Label, "Label not passed correctly");
+                       Assert.AreEqual (MessagePriority.AboveNormal, m2.Priority,
+                                        "Priority not passed properly");
+                       Assert.AreEqual (true, m2.Recoverable, "Recoverable not passed properly");
+                       Assert.AreEqual (responseQ.QueueName, m2.ResponseQueue.QueueName,
+                                        "ResponseQueue not passed properly");
+                       AreEqual (m.SenderCertificate, m2.SenderCertificate,
+                                 "SenderCertificate not passed properly");
+                       Assert.AreEqual (m.TimeToBeReceived, m2.TimeToBeReceived,
+                                        "TimeToBeReceived not passed properly");
+                       Assert.AreEqual (m.TimeToReachQueue, m2.TimeToReachQueue,
+                                        "TimeToReachQueue not passed properly");
+                       //Assert.IsTrue (m2.UseAuthentication,
+                       //               "UseAuthentication not passed properly");
+                       Assert.IsTrue (m2.UseDeadLetterQueue,
+                                      "UseDeadLetterQueue not passed properly");
+                       //Assert.IsTrue (m2.UseEncryption, "UseEncryption not pass properly");
+                       //Assert.AreEqual ();
+                       
+                       Assert.IsNotNull (m2.Id, "Id is null");
+                       Assert.IsTrue (Guid.Empty.ToString () !=  m2.Id, "Id is Empty");
+                       Assert.IsTrue (DateTime.MinValue != m2.ArrivedTime, "Arrived Time is not set");
+                       Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
+                       Assert.IsTrue (0 != m2.SenderVersion);
+                       
+                       //Assert.IsNotNull (m2.SourceMachine, "SourceMachine is null");
+                       
+               }
+               
+               private static void AreEqual(byte[] expected, byte[] actual, string message)
+               {
+                       Assert.AreEqual (expected.Length, actual.Length, message);
+                       for (int i = 0; i < expected.Length; i++)
+                               Assert.AreEqual (expected[i], actual[i], message);
+               }
+               
+               //[Test]
+               // No supported by Rabbit
+               public void SendPriorityMessages ()
+               {
+                       MessageQueue mq = MQUtil.GetQueue ("testpriority");
+                       Message sent1 = new Message ("Highest", new BinaryMessageFormatter ());
+                       sent1.Priority = MessagePriority.Highest;
+                       Message sent2 = new Message ("Lowest", new BinaryMessageFormatter ());
+                       sent2.Priority = MessagePriority.Lowest;
+                       
+                       mq.Send (sent1);
+                       mq.Send (sent2);
+                       
+                       Message received1 = mq.Receive ();
+                       Message received2 = mq.Receive ();
+                       
+                       Assert.AreEqual (MessagePriority.Highest, received2.Priority,
+                                        "Priority delivery incorrect");
+                       Assert.AreEqual (MessagePriority.Lowest, received1.Priority,
+                                        "Priority delivery incorrect");
+               }
+               
+               [Test]
+               public void SendReceiveXmlMessage ()
+               {
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\testq");
+                       String s = "Test: " + DateTime.Now;
+                       Message m = new Message (s, new XmlMessageFormatter (new Type[] { typeof (string) }));
+                       mq.MessageReadPropertyFilter.SetAll();
+                  
+                       mq.Send (m);
+                       Message m2 = mq.Receive ();
+                       m2.Formatter = new XmlMessageFormatter (new Type[] { typeof (string) });
+                       Assert.AreEqual (s, m2.Body);
+                  
+                       Assert.AreEqual (Acknowledgment.None, m2.Acknowledgment, "Acknowledgment");
+                       Assert.IsNotNull (m2.ArrivedTime, "Acknowledgment");
+                       Assert.IsNotNull (m2.Id, "Id");
+               }
+          
+               [Test]
+               public void SendBinaryText ()
+               {
+                       string path = @".\private$\MyQ";
+                       string body = "This is a test";
+                  
+                       MessageQueue q = MQUtil.GetQueue (path);
+
+                       q.Formatter = new BinaryMessageFormatter ();
+
+                       q.Send (body);
+
+                       Message m2 = q.Receive ();
+                  
+                       Assert.IsNotNull (m2.Formatter, "Formatter is null");
+                       Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
+                       Assert.AreEqual (body, m2.Body);
+               }
+
+               [Test]
+               public void SendDefaultText ()
+               {
+                       string path = @".\private$\MyQ";
+                       string body = "This is a test";
+
+                       MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
+
+                       q.Send (body);
+
+                       Message m2 = q.Receive ();
+                       XmlMessageFormatter xmlf = (XmlMessageFormatter) q.Formatter;
+                       //Assert.AreEqual (typeof (string), xmlf.TargetTypes[0]);
+                       Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
+                       Assert.AreEqual (body, m2.Body);
+                       Assert.AreEqual (0, m2.BodyType);
+               }
+
+               [Test]
+               public void SendBinaryObject ()
+               {
+                       string path = @".\private$\MyQ";
+                       Thingy body = new Thingy ();
+                       body.MyProperty1 = 42;
+                       body.MyProperty2 = "Something";
+                       body.MyProperty3 = "Something else";
+
+                       MessageQueue q = MQUtil.GetQueue (path);
+
+                       q.Formatter = new BinaryMessageFormatter ();
+
+                       q.Send (body);
+                  
+                       Message m2 = q.Receive ();
+                       Thingy body2 = (Thingy) m2.Body;
+
+                       Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
+                       Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
+                       Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
+                       Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
+                       Assert.AreEqual (768, m2.BodyType);
+               }
+
+               [Test]
+               public void SendDefaultObject ()
+               {
+                       string path = @".\private$\MyQ";
+                       Thingy body = new Thingy();
+                       body.MyProperty1 = 42;
+                       body.MyProperty2 = "Something";
+                       body.MyProperty3 = "Something else";
+
+                       MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
+
+                       q.Send (body);
+
+                       MessageQueue q2 = MQUtil.GetQueue (path);
+                       q2.Formatter = new XmlMessageFormatter (new Type[] { typeof(Thingy) });
+
+                       Message m2 = q2.Receive ();
+                       Thingy body2 = (Thingy) m2.Body;
+
+                       Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
+                       Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
+                       Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
+                       Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
+               }
+
+               [Test]
+               public void SendBinaryMessage ()
+               {
+                       string path = @".\private$\MyQ";
+                       Thingy body = new Thingy ();
+                       body.MyProperty1 = 42;
+                       body.MyProperty2 = "Something";
+                       body.MyProperty3 = "Something else";
+                       Message m1 = new Message (body);
+                       m1.Formatter = new BinaryMessageFormatter ();
+
+                       MessageQueue q = MQUtil.GetQueue (path);
+
+                       q.Send (m1);
+
+                       Message m2 = q.Receive ();
+                       m2.Formatter = new BinaryMessageFormatter ();
+                       Assert.IsNotNull (m2.Formatter);
+                       Assert.AreEqual (typeof (BinaryMessageFormatter), m2.Formatter.GetType ());
+                       Thingy body2 = (Thingy) m2.Formatter.Read (m2);
+
+                       Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
+                       Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
+                       Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
+               }
+
+               [Test]
+               public void SendDefaultMessage ()
+               {
+                       string path = @".\private$\MyQ";
+                       Thingy body = new Thingy ();
+                       body.MyProperty1 = 42;
+                       body.MyProperty2 = "Something";
+                       body.MyProperty3 = "Something else";
+                       Message m1 = new Message (body);
+                       Assert.IsNull (m1.Formatter);
+
+                       MessageQueue q = MQUtil.GetQueue (path, new XmlMessageFormatter ());
+
+                       q.Send (m1);
+
+                       Message m2 = q.Receive ();
+                       m2.Formatter = new XmlMessageFormatter (new Type[] { typeof (Thingy) });
+                       Assert.IsNotNull (m2.Formatter);
+                       Assert.AreEqual (typeof (XmlMessageFormatter), m2.Formatter.GetType ());
+                       Thingy body2 = (Thingy) m2.Formatter.Read (m2);
+
+                       Assert.AreEqual (body.MyProperty1, body2.MyProperty1);
+                       Assert.AreEqual (body.MyProperty2, body2.MyProperty2);
+                       Assert.AreEqual (body.MyProperty3, body2.MyProperty3);
+               }                         
+       }
+
+       [Serializable]
+       public class Thingy
+       {
+               private int myVar1;
+
+               public int MyProperty1
+               {
+                       get { return myVar1; }
+                       set { myVar1 = value; }
+               }
+
+               private string myVar2;
+
+               public string MyProperty2
+               {
+                       get { return myVar2; }
+                       set { myVar2 = value; }
+               }
+
+               private string myVar3;
+
+               public string MyProperty3
+               {
+                       get { return myVar3; }
+                       set { myVar3 = value; }
+               }
+       }
+}
index 5774642753f5b4918fc9c919ebce74d12f2e45c9..1a9a9afbc5246910ea3fdca4b96495ebb059219d 100644 (file)
@@ -1,3 +1,14 @@
+2009-07-19  Michael Barker  <mike@middlesoft.co.uk>
+
+       * AdminTest.cs:  Moved to System.Messaging
+       * AsyncPeekTest.cs:  Moved to System.Messaging
+       * AsyncReceiveTest.cs:  Moved to System.Messaging
+       * BasicMessagingTest.cs:  Moved to System.Messaging
+       * MessageEnumeratorTest.cs:  Moved to System.Messaging
+       * MQUtil.cs:  Moved to System.Messaging
+       * PeekTest.cs:  Moved to System.Messaging
+       * SelectorTest.cs:  Moved to System.Messaging
+       
 2009-01-05  Michael Barker  <mike@middlesoft.co.uk>
 
        * BinaryMessageFormatter.cs, XMLMessageFormatterTest.cs, TestUtils.cs, 
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/MQUtil.cs b/mcs/class/System.Messaging/Test/System.Messaging/MQUtil.cs
new file mode 100644 (file)
index 0000000..6c32aca
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// Test.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;
+
+namespace MonoTests.Mono.Messaging.RabbitMQ
+{
+       public class MQUtil
+       {
+               public static MessageQueue GetQueue (string path)
+               {
+                       return GetQueue (path, false);
+               }
+               
+               public static MessageQueue GetQueue (string path, bool isTransactional)
+               {
+                       return GetQueue (path, isTransactional,
+                                        new BinaryMessageFormatter ());
+               }
+               
+               public static MessageQueue GetQueue (string path, IMessageFormatter formatter)
+               {
+                       return GetQueue (path, false, formatter);
+               }
+               
+               public static MessageQueue GetQueue (string path, bool isTransactional, 
+                                                    IMessageFormatter formatter)
+               {
+                       MessageQueue q;
+                       if (MessageQueue.Exists (path)) {
+                               q = new MessageQueue (path);
+                       } else {
+                               q = MessageQueue.Create (path, isTransactional);
+                       }
+                       q.Formatter = formatter;
+                       return q;
+               }               
+       }
+}
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/MessageEnumeratorTest.cs b/mcs/class/System.Messaging/Test/System.Messaging/MessageEnumeratorTest.cs
new file mode 100644 (file)
index 0000000..5535dd7
--- /dev/null
@@ -0,0 +1,153 @@
+//
+// Test.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 Mono.Messaging;
+//using Mono.Messaging.RabbitMQ;
+
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Messaging.RabbitMQ
+{
+       [TestFixture]
+       public class MessageEnumeratorTest {
+               
+               private readonly String qName = @".\private$\testq2";
+               
+               private void SendMessage (string s) {
+                       MessageQueue mq = MQUtil.GetQueue (qName);
+                       Message m = new Message (s, new BinaryMessageFormatter ());
+                       m.CorrelationId = Guid.NewGuid () + "\\0";
+                       mq.Send (m);
+               }
+               
+               [Test]
+               public void RemoveMessage ()
+               {
+                       SendMessage ("message 1");
+                       SendMessage ("message 2");
+                       SendMessage ("message 3");
+                       SendMessage ("message 4");
+                       
+                       MessageQueue mq0 = MQUtil.GetQueue (qName);
+                       MessageEnumerator me0 = mq0.GetMessageEnumerator ();
+                       
+                       me0.MoveNext ();
+                       me0.MoveNext ();
+                       me0.MoveNext ();
+                       
+                       Message m0 = me0.RemoveCurrent ();
+                       
+                       me0.MoveNext ();
+                       
+                       me0.Dispose ();
+                       mq0.Dispose ();
+                       
+                       MessageQueue mq1 = MQUtil.GetQueue (qName);
+                       MessageEnumerator me1 = mq1.GetMessageEnumerator ();
+                       
+                       me1.MoveNext();
+                       me1.MoveNext();
+                       me1.MoveNext();
+                       
+                       Message m1 = me1.Current;
+                       m1.Formatter = new BinaryMessageFormatter ();
+                       Assert.AreEqual ("message 4", (String) m1.Body, "body incorrect");
+                       
+                       mq1.Purge ();
+                       MessageQueue.Delete (qName);
+               }
+               
+               [Test]
+               public void RemoveMessageWithTimeout ()
+               {
+                       SendMessage ("message 1");
+                       SendMessage ("message 2");
+                       SendMessage ("message 3");
+                       SendMessage ("message 4");
+                       
+                       MessageQueue mq0 = MQUtil.GetQueue (qName);
+                       MessageEnumerator me0 = mq0.GetMessageEnumerator ();
+                       
+                       TimeSpan ts = new TimeSpan (0, 0, 2);
+                       
+                       me0.MoveNext (ts);
+                       me0.MoveNext (ts);
+                       me0.MoveNext (ts);
+                       
+                       Message m0 = me0.RemoveCurrent (ts);
+                       
+                       me0.MoveNext (ts);
+                       
+                       me0.Dispose ();
+                       mq0.Dispose ();
+                       
+                       MessageQueue mq1 = MQUtil.GetQueue (qName);
+                       MessageEnumerator me1 = mq1.GetMessageEnumerator ();
+                       
+                       me1.MoveNext (ts);
+                       me1.MoveNext (ts);
+                       me1.MoveNext (ts);
+                       
+                       Message m1 = me1.Current;
+                       m1.Formatter = new BinaryMessageFormatter ();
+                       Assert.AreEqual ("message 4", (String) m1.Body, "body incorrect");
+                       
+                       mq1.Purge ();
+                       MessageQueue.Delete (qName);
+               }
+               
+               //[Test]
+               // Not supported with AMQP
+               public void RemoveMessageWithTx ()
+               {
+                       MessageQueue q = MQUtil.GetQueue ("testq3");
+                       
+                       q.Formatter = new BinaryMessageFormatter ();
+                       q.Send ("foo1");
+                       q.Send ("foo2");
+                       
+                       MessageEnumerator me1 = q.GetMessageEnumerator ();
+                       MessageQueueTransaction tx = new MessageQueueTransaction ();
+                       me1.MoveNext ();
+                       Message m1 = me1.Current;
+                       me1.RemoveCurrent (tx);
+                       tx.Commit ();
+                       me1.Close ();
+                       
+                       MessageEnumerator me2 = q.GetMessageEnumerator ();
+                       Assert.IsTrue (me1.MoveNext ());
+                       me2.RemoveCurrent ();
+                       Assert.IsFalse (me2.MoveNext ());
+               }
+       }
+}
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/PeekTest.cs b/mcs/class/System.Messaging/Test/System.Messaging/PeekTest.cs
new file mode 100644 (file)
index 0000000..2c6c60b
--- /dev/null
@@ -0,0 +1,187 @@
+//
+// Test.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.RabbitMQ
+{
+       [TestFixture]
+       public class PeekTest {
+               
+               [Test]
+               public void PeekMessage ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message s1 = new Message(body, new BinaryMessageFormatter());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\peek-queue-1");
+                       mq.Send (s1);
+                       
+                       Message r1 = mq.Peek ();
+                       Assert.AreEqual (body, r1.Body);
+                       
+                       Message r2 = mq.Receive ();
+                       Assert.AreEqual (body, r2.Body);
+               }
+               
+               [Test]
+               public void PeekMessageWithTimeout ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString();
+                       Message s1 = new Message(body, new BinaryMessageFormatter());
+                       MessageQueue mq = MQUtil.GetQueue(@".\private$\peek-queue-2");
+                       mq.Send (s1);
+                       
+                       Message r1 = mq.Peek (new TimeSpan (0, 0, 2));
+                       Assert.AreEqual (body, r1.Body);
+                       
+                       Message r2 = mq.Receive ();
+                       Assert.AreEqual (body, r2.Body);
+               }
+               
+               [Test]
+               [ExpectedException (typeof (MessageQueueException))]
+               public void PeekNoMessageWithTimeout ()
+               {
+                       MessageQueue mq = MQUtil.GetQueue(@".\private$\peek-queue-3");
+                       Message r1 = mq.Peek (new TimeSpan (0, 0, 2));
+               }
+               
+               [Test]
+               public void PeekById ()
+               {
+                       String body = "Foo-" + DateTime.Now.ToString ();
+                       Message s1 = new Message (body, new BinaryMessageFormatter());
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-4");
+                       q.Send (s1);
+                       
+                       String id = s1.Id;
+                       try {
+                               Message r1 = q.PeekById (id);
+                               Assert.AreEqual (body, r1.Body, "Unable to PeekById correctly");
+                       } finally {
+                               q.Purge ();
+                       }
+               }
+               
+               [Test]
+               public void PeekByIdWithTimeout ()
+               {
+                       String body = "Foo-" + DateTime.Now.ToString ();
+                       Message s1 = new Message (body, new BinaryMessageFormatter());
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-5");
+                       q.Send (s1);
+                       
+                       String id = s1.Id;
+                       try {
+                               Message r1 = q.PeekById (id, new TimeSpan (0, 0, 2));
+                               Assert.AreEqual (body, r1.Body, "Unable to PeekById correctly");
+                       } finally {
+                               q.Purge ();
+                       }
+               }
+               
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void PeekByIdNotFound ()
+               {
+                       String body = "Foo-" + DateTime.Now.ToString ();
+                       Message s1 = new Message (body, new BinaryMessageFormatter());
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-6");
+                       q.Send (s1);
+                       
+                       String id = "fail!";
+                       
+                       try {
+                               Message r1 = q.PeekById (id);
+                       } finally {
+                               q.Purge ();
+                       }
+               }
+               
+               [Test]
+               public void PeekByCorrelationId ()
+               {
+                       String correlationId = Guid.NewGuid () + "\\0";
+                       String body = "Foo-" + DateTime.Now.ToString ();
+                       Message s1 = new Message (body, new BinaryMessageFormatter());
+                       s1.CorrelationId = correlationId;
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-7");
+                       q.Formatter = new BinaryMessageFormatter ();
+                       q.Send (s1);
+                       
+                       try {
+                               Message r1 = q.PeekByCorrelationId (correlationId);
+                               Assert.AreEqual (body, r1.Body, "Unable to PeekByCorrelationId correctly");
+                       } finally {
+                               q.Purge ();
+                       }
+               }
+               
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void PeekByCorrelationIdNotFound ()
+               {
+                       String body = "Foo-" + DateTime.Now.ToString ();
+                       Message s1 = new Message (body);
+                       String correlationId = Guid.NewGuid() + "\\0";
+                       MessageQueue q = MQUtil.GetQueue(@".\private$\peek-queue-8");
+                       q.Formatter = new BinaryMessageFormatter ();
+                       q.Send (s1);
+                       
+                       try {
+                               Message r1 = q.PeekByCorrelationId ("fail!");
+                       } finally {
+                               q.Purge ();
+                       }
+               }
+               
+               [Test]
+               public void PeekByCorrelationIdWithTimeout ()
+               {
+                       String correlationId = Guid.NewGuid () + "\\0";
+                       String body = "Foo-" + DateTime.Now.ToString ();
+                       Message s1 = new Message (body, new BinaryMessageFormatter());
+                       s1.CorrelationId = correlationId;
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\peek-queue-9");
+                       q.Formatter = new BinaryMessageFormatter ();
+                       q.Send (s1);
+                       
+                       try {
+                               Message r1 = q.PeekByCorrelationId (correlationId, new TimeSpan (0, 0, 2));
+                               Assert.AreEqual (body, r1.Body, "Unable to PeekByCorrelationId correctly");
+                       } finally {
+                               q.Purge ();
+                       }
+               }               
+       }
+}
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/SelectorTest.cs b/mcs/class/System.Messaging/Test/System.Messaging/SelectorTest.cs
new file mode 100644 (file)
index 0000000..73caaed
--- /dev/null
@@ -0,0 +1,138 @@
+//
+// Test.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.RabbitMQ
+{
+       [TestFixture]
+       public class SelectorTest
+       {
+               
+               [Test]
+               public void SelectById ()
+               {
+                       String body = "Foo-" + DateTime.Now.ToString ();
+                       Message s1 = new Message (body, new BinaryMessageFormatter());
+                       MessageQueue q = MQUtil.GetQueue (@".\private$\selector-queue-1");
+                       q.Send (s1);
+                       
+                       String id = s1.Id;
+                       
+                       Message r1 = q.ReceiveById (id);
+                       
+                       Assert.AreEqual (body, r1.Body, "Unable to ReceiveById correctly");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void SelectByIdNotFound ()
+               {
+                       String body = "Foo-" + DateTime.Now.ToString();
+                       Message s1 = new Message(body, new BinaryMessageFormatter());
+                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-2");
+                       q.Send (s1);
+                       
+                       String id = "fail!";
+                       
+                       try {
+                               Message r1 = q.ReceiveById (id);
+                       } finally {
+                               q.Purge ();
+                       }
+               }
+               
+               [Test]
+               public void SelectByCorrelationId ()
+               {
+                       string correlationId = Guid.NewGuid () + "\\0";
+                       String body = "Foo-" + DateTime.Now.ToString();
+                       Message s1 = new Message(body, new BinaryMessageFormatter());
+                       s1.CorrelationId = correlationId;
+                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-3");
+                       q.Send (s1);
+                       
+                       Message r1 = q.ReceiveByCorrelationId (correlationId);
+                       
+                       Assert.AreEqual (body, r1.Body, "Unable to ReceiveByCorrelationId correctly");
+               }
+               
+               [Test]
+               [ExpectedException (typeof (InvalidOperationException))]
+               public void SelectByCorrelationIdNotFound ()
+               {
+                       string correlationId = Guid.NewGuid() + "\\0";
+                       String body = "Foo-" + DateTime.Now.ToString();
+                       Message s1 = new Message(body, new BinaryMessageFormatter());
+                       s1.CorrelationId = correlationId;
+                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-4");
+                       q.Send (s1);
+                       
+                       try {
+                               Message r1 = q.ReceiveByCorrelationId ("fail!");
+                       } finally {
+                               q.Purge ();
+                       }
+               }
+               
+               [Test]
+               public void SelectByIdWithTimeout ()
+               {
+                       String body = "Foo-" + DateTime.Now.ToString();
+                       Message s1 = new Message(body, new BinaryMessageFormatter());
+                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-5");
+                       q.Send (s1);
+                       
+                       String id = s1.Id;
+                       
+                       Message r1 = q.ReceiveById (id, new TimeSpan (0, 0, 2));
+                       
+                       Assert.AreEqual (body, r1.Body, "Unable to ReceiveById correctly");
+               }
+                               
+               [Test]
+               public void SelectByCorrelationIdWithTimeout ()
+               {
+                       string correlationId = Guid.NewGuid() + "\\0";
+                       String body = "Foo-" + DateTime.Now.ToString();
+                       Message s1 = new Message(body, new BinaryMessageFormatter());
+                       s1.CorrelationId = correlationId;
+                       MessageQueue q = MQUtil.GetQueue(@".\private$\selector-queue-3");
+                       q.Send (s1);
+                       
+                       Message r1 = q.ReceiveByCorrelationId (correlationId, new TimeSpan (0, 0, 2));
+                       
+                       Assert.AreEqual (body, r1.Body, "Unable to ReceiveByCorrelationId correctly");
+               }
+       }
+}
diff --git a/mcs/class/System.Messaging/Test/System.Messaging/TransactionMessagingTest.cs b/mcs/class/System.Messaging/Test/System.Messaging/TransactionMessagingTest.cs
new file mode 100644 (file)
index 0000000..e023095
--- /dev/null
@@ -0,0 +1,467 @@
+//
+// Test.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 System.Reflection;
+using System.Threading;
+using System.Text.RegularExpressions;
+
+using NUnit.Framework;
+
+namespace MonoTests.Mono.Messaging.RabbitMQ
+{
+       [TestFixture]
+       public class TransactionMessageTest {
+               
+               [Test]
+               public void Send2WithTransaction ()
+               {
+                       Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
+                       Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-1", true);
+                       mq.MessageReadPropertyFilter.SetAll ();
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               mq.Send (sent1, tx);
+                               mq.Send (sent2, tx);
+                               
+                               tx.Commit ();
+                               
+                               Message received1 = mq.Receive ();
+                               Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
+                               Message received2 = mq.Receive ();
+                               Assert.IsNotNull (received2.TransactionId, "TransactionId not set");
+                               
+                               Assert.AreEqual (received1.TransactionId, received2.TransactionId, "Messages have differing TransactionIds");
+                               Assert.IsTrue (received1.TransactionId.Length > 1);
+                               Assert.AreEqual (sent1.Body, received1.Body, "Message 1 not delivered correctly");
+                               Assert.AreEqual (sent2.Body, received2.Body, "Message 2 not delivered correctly");
+                       }
+               }
+               
+               [Test]
+               public void Send2WithLabelWithTransaction ()
+               {
+                       String label1 = "label1";
+                       String label2 = "label2";
+                       Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
+                       Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-2", true);
+                       mq.MessageReadPropertyFilter.SetAll ();
+                       Assert.IsTrue(mq.Transactional, "Message Queue should be transactional");
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               mq.Send (sent1, label1, tx);
+                               mq.Send (sent2, label2, tx);
+                               
+                               tx.Commit ();
+                               
+                               Message received1 = mq.Receive ();
+                               Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
+                               Message received2 = mq.Receive ();
+                               Assert.IsNotNull (received2.TransactionId, "TransactionId not set");
+                               
+                               Assert.AreEqual (received1.TransactionId, received2.TransactionId, "Messages have differing TransactionIds");
+                               Assert.IsTrue (received1.TransactionId.Length > 1);
+                               Assert.AreEqual (sent1.Body, received1.Body, "Message 1 not delivered correctly");
+                               Assert.AreEqual (sent2.Body, received2.Body, "Message 2 not delivered correctly");
+                               Assert.AreEqual (label1, received1.Label, "Label 1 not passed correctly");
+                               Assert.AreEqual (label2, received2.Label, "Label 2 not passed correctly");
+                       }
+               }
+                               
+               [Test]
+               [ExpectedException (typeof (MessageQueueException))]
+               public void Send2WithTransactionAbort ()
+               {
+                       Message sent1 = new Message ("Message 1", new BinaryMessageFormatter ());
+                       Message sent2 = new Message ("Message 2", new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-1", true);
+                       mq.MessageReadPropertyFilter.SetAll ();
+                       Assert.IsTrue(mq.Transactional, "Message Queue should be transactional");
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               mq.Send (sent1, tx);
+                               mq.Send (sent2, tx);
+                               
+                               tx.Abort ();
+                               mq.Receive (new TimeSpan (0, 0, 2));
+                       }
+               }
+               
+               [Test]
+               public void ReceiveWithTransaction ()
+               {
+                       String body = "Message 4";
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-4", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               Message received1 = mq.Receive (tx);
+                               
+                               tx.Commit ();
+                               
+                               Assert.AreEqual (body, received1.Body);
+                       }
+               }
+               
+               [Test]
+               public void ReceiveWithTransactionAbort ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-5", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               Message received1 = mq.Receive (tx);
+                               
+                               tx.Abort ();
+                       }
+                       
+                       Message received2 = mq.Receive ();
+                       Assert.AreEqual (body, received2.Body);
+               }
+               
+               [Test]
+               public void ReceiveWithTransactionType ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-6", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       
+                       Message received1 = mq.Receive (MessageQueueTransactionType.Single);
+                       
+                       Assert.AreEqual (body, received1.Body);
+               }
+               
+               [Test]
+               public void SendWithTransactionType ()
+               {
+                       Message sent1 = new Message ("Message 1");
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-7", true);
+                       mq.MessageReadPropertyFilter.SetAll();
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       
+                       Message received1 = mq.Receive ();
+                       Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
+               }
+               
+               [Test]
+               public void SendWithTransactionTypeAndLabel ()
+               {
+                       Message sent1 = new Message ("Message 1");
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-8", true);
+                       mq.MessageReadPropertyFilter.SetAll();
+                       String label = "mylabel";
+                       
+                       mq.Send (sent1, label, MessageQueueTransactionType.Single);
+                       
+                       Message received1 = mq.Receive ();
+                       Assert.IsNotNull (received1.TransactionId, "TransactionId not set");
+                       Assert.AreEqual (label, received1.Label, "Label not set");
+               }
+
+               [Test]
+               public void ReceiveByIdWithTransaction ()
+               {
+                       String body = "Message 4";
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-9", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               Message received1 = mq.ReceiveById (id, tx);
+                               
+                               tx.Commit ();
+                               
+                               Assert.AreEqual (body, received1.Body);
+                       }
+               }
+               
+               [Test]
+               public void ReceiveByIdWithTransactionAbort ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-10", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               Message received1 = mq.ReceiveById (id, tx);
+                               
+                               tx.Abort ();
+                       }
+                       
+                       Message received2 = mq.Receive ();
+                       Assert.AreEqual (body, received2.Body);
+               }
+               
+               [Test]
+               public void ReceiveByIdWithTransactionType ()
+               {
+                       String body = "Message 4";
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-11", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+
+                       Message received1 = mq.ReceiveById (id, MessageQueueTransactionType.Single);
+                       Assert.AreEqual (body, received1.Body);
+               }
+
+               [Test]
+               public void ReceiveByCorrelationIdWithTransaction ()
+               {
+                       string correlationId = Guid.NewGuid() + "\\0";
+                       String body = "Message 4";
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       sent1.CorrelationId = correlationId;
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-12", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+
+                               Message received1 = mq.ReceiveByCorrelationId(correlationId, tx);
+                               
+                               tx.Commit ();
+                               
+                               Assert.AreEqual (body, received1.Body);
+                       }
+               }
+               
+               [Test]
+               public void ReceiveByCorrelationIdWithTransactionAbort ()
+               {
+                       string correlationId = Guid.NewGuid() + "\\0";
+                       String body = "foo-" + DateTime.Now.ToString();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       sent1.CorrelationId = correlationId;
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-13", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               Message received1 = mq.ReceiveByCorrelationId (correlationId, tx);
+                               
+                               tx.Abort ();
+                       }
+                       
+                       Message received2 = mq.Receive ();
+                       Assert.AreEqual (body, received2.Body);
+               }
+
+               [Test]
+               public void ReceiveByCorrelationIdWithTransactionType ()
+               {
+                       string correlationId = Guid.NewGuid() + "\\0";
+                       String body = "Message 10";
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       sent1.CorrelationId = correlationId;
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-14", true);
+                       mq.Formatter = new BinaryMessageFormatter ();
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+                       
+                       Message received1 = mq.ReceiveByCorrelationId (correlationId, MessageQueueTransactionType.Single);
+                       Assert.AreEqual (body, received1.Body);
+               }
+
+               [Test]
+               public void ReceiveWithTransactionAndTimeout ()
+               {
+                       String body = "Message 11";
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-15", true);
+                       mq.Formatter = new BinaryMessageFormatter ();
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               Message received1 = mq.Receive (new TimeSpan (0, 0, 2), tx);
+                               
+                               tx.Commit ();
+                               
+                               Assert.AreEqual (body, received1.Body);
+                       }
+               }
+
+               [Test]
+               public void ReceiveWithTransactionAndTimeoutAndAbort ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-16", true);
+                       mq.Formatter = new BinaryMessageFormatter ();
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               Message received1 = mq.Receive (new TimeSpan (0, 0, 2), tx);
+                               
+                               tx.Abort ();
+                       }
+                       
+                       Message received2 = mq.Receive ();
+                       Assert.AreEqual (body, received2.Body);
+               }
+               
+               [Test]
+               public void ReceiveWithTransactionTypeAndTimeout ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-17", true);
+                       mq.Formatter = new BinaryMessageFormatter ();
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       
+                       Message received1 = mq.Receive (new TimeSpan (0, 0, 5), MessageQueueTransactionType.Single);
+                       
+                       Assert.AreEqual (body, received1.Body);
+               }
+
+               [Test]
+               [ExpectedException (typeof (MessageQueueException))]
+               public void ReceiveWithTransactionTypeAndTimeoutFailure ()
+               {
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-18", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       Message received1 = mq.Receive (new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
+               }
+               
+               [Test]
+               public void ReceiveByIdWithTransactionAndTimeout ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-19", true);
+                       mq.Formatter = new BinaryMessageFormatter ();
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+                               
+                               Message received1 = mq.ReceiveById (id, new TimeSpan (0, 0, 2), tx);
+                               
+                               tx.Commit ();
+                               
+                               Assert.AreEqual (body, received1.Body);
+                       }
+               }
+               
+               [Test]
+               public void ReceiveByIdWithTransactionTypeAndTimeout ()
+               {
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-20", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+                       
+                       Message received1 = mq.ReceiveById (id, new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
+                       Assert.AreEqual (body, received1.Body);
+               }
+
+               [Test]
+               public void ReceiveByCorrelationIdWithTransactionAndTimeout ()
+               {
+                       string correlationId = Guid.NewGuid () + "\\0";
+                       String body = "foo-" + DateTime.Now.ToString ();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       sent1.CorrelationId = correlationId;
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-21", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+                       
+                       using (MessageQueueTransaction tx = new MessageQueueTransaction ()) {
+                               tx.Begin ();
+
+                               Message received1 = mq.ReceiveByCorrelationId (correlationId, new TimeSpan (0, 0, 2), tx);
+                               tx.Commit ();
+                               Assert.AreEqual (body, received1.Body);
+                       }
+               }               
+
+               [Test]
+               public void ReceiveByCorrelationIdWithTransactionTypeAndTimeout ()
+               {
+                       string correlationId = Guid.NewGuid() + "\\0";
+                       String body = "foo-" + DateTime.Now.ToString();
+                       Message sent1 = new Message (body, new BinaryMessageFormatter ());
+                       sent1.CorrelationId = correlationId;
+                       MessageQueue mq = MQUtil.GetQueue (@".\private$\tx-queue-22", true);
+                       Assert.IsTrue (mq.Transactional, "Message Queue should be transactional");
+                       mq.Send (sent1, MessageQueueTransactionType.Single);
+                       string id = sent1.Id;
+
+                       Message received1 = mq.ReceiveByCorrelationId (correlationId,  new TimeSpan (0, 0, 2), MessageQueueTransactionType.Single);
+                       Assert.AreEqual (body, received1.Body);
+               }               
+       }
+}
index 98f49b036640530b4ff6ab2ae22c0eccee90b897..1d999d040c98d4e9f1cfa0707e23629f9cec4a0a 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: filter the valid profile on the framework version,
+       to make it easier to have custom variants.
+
 2009-07-14  Sebastien Pouliot  <sebastien@ximian.com>
 
        * System.Net.dll.sources: Remove extra files not needed to
index 330da9641d809689d2f311338387dd8eabec3482..89a625fba8ed4de19c9707160d134cdb7187d94a 100644 (file)
@@ -13,7 +13,7 @@ TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
 
 EXTRA_DISTFILES =
 
-VALID_PROFILE := $(filter net_2_0 net_2_1_raw net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter 2.0 2.1 4.0, $(FRAMEWORK_VERSION))
 ifndef VALID_PROFILE
 LIBRARY_NAME = dummy-System.Net.dll
 NO_INSTALL = yes
index 9bf43ac5db4ab3e065143e2e69db3dde9175a5c4..8971caa31ee388b329101722429c8740227c6984 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: filter the valid profile on the framework version,
+       to make it easier to have custom variants.
+
 2009-04-21  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * System.Xml.Schema/*: Remove (not needed for 2.1 anymore)
index e0de13f2a3f6b48e23fcef7e90e1936bf60ff901..1290a9c7193d26f0c64640ef0337d524e864f60d 100644 (file)
@@ -23,7 +23,7 @@ EXTRA_DISTFILES = $(RESOURCE_FILES) \
        Test/Resources/FrameworkTypes/* \
        Test/System.Runtime.Serialization/one.xml
 
-VALID_PROFILE := $(filter net_2_0 net_2_1_raw net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter 2.0 2.1 4.0, $(FRAMEWORK_VERSION))
 ifndef VALID_PROFILE
 LIBRARY_NAME = dummy-System.Runtime.Serialization.dll
 NO_INSTALL = yes
diff --git a/mcs/class/System.Runtime.Serialization/monotouch_System.Runtime.Serialization.dll.sources b/mcs/class/System.Runtime.Serialization/monotouch_System.Runtime.Serialization.dll.sources
new file mode 100644 (file)
index 0000000..e901e2a
--- /dev/null
@@ -0,0 +1 @@
+#include net_2_1_raw_System.Runtime.Serialization.dll.sources
index 2ae713bee10634fbb4e7b0be1d098a90b11e0361..49cc8467d8e9fedcdd843cc433f8958ad7f568f8 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: filter the valid profile on the framework version,
+       to make it easier to have custom variants.
+
 2009-04-22  Sebastien Pouliot  <sebastien@ximian.com>
 
        * net_2_1_raw_System.ServiceModel.Web.dll.sources: Remove the common
index 0a197775cb6a272775c96b659417997b82da9bac..cbe58b0bd87e25ef3003c04259da5988a86fdb0b 100644 (file)
@@ -14,7 +14,7 @@ TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
 
 EXTRA_DISTFILES = $(RESOURCE_FILES)
 
-VALID_PROFILE := $(filter net_2_0 net_2_1_raw net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter 2.0 2.1 4.0, $(FRAMEWORK_VERSION))
 ifndef VALID_PROFILE
 LIBRARY_NAME = dummy-System.ServiceModel.Web.dll
 NO_INSTALL = yes
diff --git a/mcs/class/System.ServiceModel.Web/monotouch_System.ServiceModel.Web.dll.sources b/mcs/class/System.ServiceModel.Web/monotouch_System.ServiceModel.Web.dll.sources
new file mode 100644 (file)
index 0000000..dccf9d6
--- /dev/null
@@ -0,0 +1 @@
+#include net_2_1_raw_System.ServiceModel.Web.dll.sources
index 0d83a15bbd7d838b13640f6ac24ac5c3e045a273..8d0c0cbd299dad98c25b3c818b1b65377bf2ab05 100755 (executable)
@@ -1,3 +1,8 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: filter the valid profile on the framework version,
+       to make it easier to have custom variants.
+
 2009-07-17  Astushi Enomoto  <atsushi@ximian.com>
 
        * System.ServiceModel.dll.sources: add TcpRequestChannel.
index 0b721c4907df965f3726be388720c06923edf79c..d16d22d9e5b2e41d8e6dcc4507e78e91a43c7033 100755 (executable)
@@ -47,7 +47,7 @@ EXTRA_DISTFILES = $(RESOURCE_FILES) $(TEST_EXTRA_FILES)
 # Useful for debugging under Visual Studio 2005
 # NO_SIGN_ASSEMBLY = yes
 
-VALID_PROFILE := $(filter net_2_0 net_2_1_raw net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter 2.0 2.1 4.0, $(FRAMEWORK_VERSION))
 ifndef VALID_PROFILE
 LIBRARY_NAME = dummy-System.ServiceModel.dll
 NO_INSTALL = yes
diff --git a/mcs/class/System.ServiceModel/monotouch_System.ServiceModel.dll.sources b/mcs/class/System.ServiceModel/monotouch_System.ServiceModel.dll.sources
new file mode 100644 (file)
index 0000000..f157eed
--- /dev/null
@@ -0,0 +1 @@
+#include net_2_1_raw_System.ServiceModel.dll.sources
diff --git a/mcs/class/System.XML/monotouch_System.Xml.dll.sources b/mcs/class/System.XML/monotouch_System.Xml.dll.sources
new file mode 100644 (file)
index 0000000..14a6a01
--- /dev/null
@@ -0,0 +1 @@
+#include net_2_1_raw_System.Xml.dll.sources
index 53fe802230199b8477175fcf6c4b2828b9b21733..ffb90188125b69b6a889e0c1b1b388b0442e5374 100644 (file)
@@ -1,3 +1,13 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * net_2_1_raw_System.Xml.Linq.dll: delete, and use ifdefs
+       in the few specific files.
+
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Makefile: filter the valid profile on the framework version,
+       to make it easier to have custom variants.
+
 2009-06-05  Jb Evain  <jbevain@novell.com>
 
        * Makefile: fix the 2.1 build.
index d970d447b1d4a2b9e5f3a757b8b651b289290297..1065d5d5cc021c639b4720e7417a107d790fa5d3 100644 (file)
@@ -17,7 +17,7 @@ TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
 
 EXTRA_DISTFILES =
 
-VALID_PROFILE := $(filter net_2_0 net_2_1_raw net_4_0, $(PROFILE))
+VALID_PROFILE := $(filter 2.0 2.1 4.0, $(FRAMEWORK_VERSION))
 ifndef VALID_PROFILE
 LIBRARY_NAME = dummy-System.Xml.Linq.dll
 NO_INSTALL = yes
index 7f9d2fc759d0518009e174525e6d15f47c65d743..07260baac8361eda1a8228ea51a4fc8a39a3edd4 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * XNodeNavigator.cs: do not compile for a NET_2_1 profile.
+
 2009-05-07  Sebastien Pouliot  <sebastien@ximian.com>
 
        * XElement.cs: Use XmlReaderSettings.DtdProcessing property instead
index 7691dccc94c99b4541cae68afea99590c273008d..fc5aa9da9d35be4f67dc7668f4e94f823ef22da5 100644 (file)
@@ -24,6 +24,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !NET_2_1
+
 using System;
 using System.IO;
 using System.Text;
@@ -384,3 +386,5 @@ namespace System.Xml.Linq
                }
        }
 }
+
+#endif
index 3fe2e7f8681b169f9e6462ae2dc74448a1a7e1ff..aa8706bbfb3e37b8ddd8e4022d9634b79a51e750 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Extensions.cs: do not compile for a NET_2_1 profile.
+
 2007-05-02  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Extensions.cs : new stub file.
index e5c9cd00c30572bddccc9b87d81321df4ae5c4ec..fe8a41c09153379e6e349a25886eb57c32c853e8 100644 (file)
@@ -24,6 +24,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !NET_2_1
+
 using System;
 using System.Xml;
 using System.Xml.Linq;
@@ -83,3 +85,4 @@ namespace System.Xml.Schema
        }
 }
 
+#endif
index 4d7a29123402a2055d833d4603e3579ecd56823f..c403ee2420da2fd859c565e5c551460d786b81e7 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Extensions.cs: do not compile for a NET_2_1 profile.
+
 2007-05-06  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Extensions.cs : implemented.
index 1120dcf075825ebfe596ee20f85f2aa1f29ed16a..a035b99f9facf81ec63ee2644f50cfc31e47c250 100644 (file)
@@ -24,6 +24,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#if !NET_2_1
+
 using System;
 using System.Collections.Generic;
 using System.Xml;
@@ -80,3 +82,4 @@ namespace System.Xml.XPath
        }
 }
 
+#endif
diff --git a/mcs/class/System.Xml.Linq/net_2_1_raw_System.Xml.Linq.dll.sources b/mcs/class/System.Xml.Linq/net_2_1_raw_System.Xml.Linq.dll.sources
deleted file mode 100644 (file)
index ed76158..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-../../build/common/Consts.cs
-../../build/common/Locale.cs
-../../build/common/MonoTODOAttribute.cs
-Assembly/AssemblyInfo.cs
-System.Xml.Linq/Extensions.cs
-System.Xml.Linq/LoadOptions.cs
-System.Xml.Linq/SaveOptions.cs
-System.Xml.Linq/XAttribute.cs
-System.Xml.Linq/XCData.cs
-System.Xml.Linq/XComment.cs
-System.Xml.Linq/XContainer.cs
-System.Xml.Linq/XDeclaration.cs
-System.Xml.Linq/XDocument.cs
-System.Xml.Linq/XDocumentType.cs
-System.Xml.Linq/XElement.cs
-System.Xml.Linq/XIterators.cs
-System.Xml.Linq/XName.cs
-System.Xml.Linq/XNamespace.cs
-System.Xml.Linq/XNode.cs
-System.Xml.Linq/XNodeDocumentOrderComparer.cs
-System.Xml.Linq/XNodeEqualityComparer.cs
-System.Xml.Linq/XNodeReader.cs
-System.Xml.Linq/XNodeWriter.cs
-System.Xml.Linq/XObject.cs
-System.Xml.Linq/XObjectChange.cs
-System.Xml.Linq/XObjectChangeEventArgs.cs
-System.Xml.Linq/XProcessingInstruction.cs
-System.Xml.Linq/XStreamingElement.cs
-System.Xml.Linq/XText.cs
-System.Xml.Linq/XUtil.cs
diff --git a/mcs/class/System/monotouch_System.dll.sources b/mcs/class/System/monotouch_System.dll.sources
new file mode 100644 (file)
index 0000000..4577b0b
--- /dev/null
@@ -0,0 +1 @@
+#include net_2_1_raw_System.dll.sources
index 91826f218fe7434da9068351104de32bc4a683fd..149619c328e882f1ffff2fe464a0882bafffe77c 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-20  Jb Evain  <jbevain@novell.com>
+
+       * Thread.cs: use the moonlight specific thread start
+       hack for the net_2_1 profile exclusively.
+
 2009-06-25  Miguel de Icaza  <miguel@novell.com>
 
        * Timer.cs: Throw ArgumentNullException if the callback is null. 
index f8691c6e5e7f55e78006f2e66b8227e57571682b..3aabb7f1c26d25bd3a2e698ce69dfb5b89e6a093 100644 (file)
@@ -744,7 +744,7 @@ namespace System.Threading {
                        }
                }
 
-#if NET_2_1
+#if NET_2_1 && !MONOTOUCH
                private void StartSafe ()
                {
                        try {
@@ -795,7 +795,7 @@ namespace System.Threading {
                                _principal = CurrentThread._principal;
 
                        // Thread_internal creates and starts the new thread, 
-#if NET_2_1
+#if NET_2_1 && !MONOTOUCH
                        if (Thread_internal((ThreadStart) StartSafe) == (IntPtr) 0)
 #else
                        if (Thread_internal(threadstart) == (IntPtr) 0)
index feca0234aca1995bd22135020e8ca3128c889657..b0737b2bd21bf60c138d294ba0f15da144675b90 100644 (file)
@@ -219,7 +219,7 @@ namespace System.Threading {
 
                static WaitCallback MoonlightHandler (WaitCallback callback)
                {
-#if NET_2_1
+#if NET_2_1 && !MONOTOUCH
                        return delegate (object o) {
                                try {
                                        callback (o);
index 2086a29e8a768a890deeae82c45903ce6d51c2ba..aee282e2548ef48214198d603e39267de9846619 100644 (file)
@@ -1,3 +1,7 @@
+2009-07-20  Geoff Norton  <gnorton@novell.com>
+
+       * thread-private.h: Use the new mono-semaphore.h.
+
 2009-06-25 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * sockets.c: add the error number to the message so we can figure out
index 1eef0669b977bcd1db1a6431961fcaa85e85bf18..1c62618c8128c69712d301a40e178fcc5af648d0 100644 (file)
 #include <config.h>
 #include <glib.h>
 #include <pthread.h>
-#ifdef HAVE_SEMAPHORE_H
-#include <semaphore.h>
-#endif
-
-#ifdef USE_MACH_SEMA
-#  include <mach/mach_init.h>
-#  include <mach/task.h>
-#  include <mach/semaphore.h>
-
-typedef semaphore_t MonoSemType;
-#  define MONO_SEM_INIT(addr,value) semaphore_create (current_task (), (addr), SYNC_POLICY_FIFO, (value))
-#  define MONO_SEM_WAIT(sem) semaphore_wait (*(sem))
-#  define MONO_SEM_POST(sem) semaphore_signal (*(sem))
-#  define MONO_SEM_DESTROY(sem) semaphore_destroy (current_task (), *(sem))
-#else
-
-typedef sem_t MonoSemType;
-#  define MONO_SEM_INIT(addr,value) sem_init ((addr), 0, (value))
-#  define MONO_SEM_WAIT(sem) sem_wait ((sem))
-#  define MONO_SEM_POST(sem) sem_post ((sem))
-#  define MONO_SEM_DESTROY(sem) sem_destroy ((sem))
-#endif
+#include <mono/utils/mono-semaphore.h>
 
 /* There doesn't seem to be a defined symbol for this */
 #define _WAPI_THREAD_CURRENT (gpointer)0xFFFFFFFE
index 43f374a1957fdefa9d255c43ee02ed6b279f6766..5900861d67e457dc6fb732e88abfdf6a1a91e7de 100644 (file)
@@ -1,3 +1,11 @@
+2009-07-20  Geoff Norton  <gnorton@novell.com>
+
+       * gc.c: Use proper semaphores where available on posix and darwin.
+
+2009-07-19  Geoff Norton  <gnorton@novell.com>
+
+       * gc.c: Unnamed posix semaphores are broken on darwin-arm too.
+
 2009-07-19 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * refletion.c (is_sre_usertype): Change name to is_usertype and
index ab384437d175536676349b3abf83de66d06c24b0..ae245ac2fcb36eeb24d136ebb0eae28a2e239fde 100644 (file)
 #include <mono/metadata/gc-internal.h>
 #include <mono/metadata/marshal.h> /* for mono_delegate_free_ftnptr () */
 #include <mono/metadata/attach.h>
-#if HAVE_SEMAPHORE_H
-#include <semaphore.h>
-/* we do this only for known working systems (OSX for example
- * has the header and functions, but they don't work at all): in other cases
- * we fall back to the io-layer slightly slower and signal-unsafe Event.
- */
-#if defined (__linux__) || (defined(__APPLE__) && defined(__arm__))
-#define USE_POSIX_SEM 1
-#endif
-#endif
+#include <mono/utils/mono-semaphore.h>
 
 #ifndef PLATFORM_WIN32
 #include <pthread.h>
@@ -918,8 +909,8 @@ mono_gchandle_free_domain (MonoDomain *domain)
 
 #ifndef HAVE_NULL_GC
 
-#if USE_POSIX_SEM
-static sem_t finalizer_sem;
+#ifdef MONO_HAS_SEMAPHORES
+static MonoSemType finalizer_sem;
 #endif
 static HANDLE finalizer_event;
 static volatile gboolean finished=FALSE;
@@ -931,8 +922,8 @@ mono_gc_finalize_notify (void)
        g_message (G_GNUC_PRETTY_FUNCTION ": prodding finalizer");
 #endif
 
-#if USE_POSIX_SEM
-       sem_post (&finalizer_sem);
+#ifdef MONO_HAS_SEMAPHORES
+       MONO_SEM_POST (&finalizer_sem);
 #else
        SetEvent (finalizer_event);
 #endif
@@ -1009,8 +1000,8 @@ finalizer_thread (gpointer unused)
                /* Wait to be notified that there's at least one
                 * finaliser to run
                 */
-#if USE_POSIX_SEM
-               sem_wait (&finalizer_sem);
+#ifdef MONO_HAS_SEMAPHORES
+               MONO_SEM_WAIT (&finalizer_sem);
 #else
                /* Use alertable=FALSE since we will be asked to exit using the event too */
                WaitForSingleObjectEx (finalizer_event, INFINITE, FALSE);
@@ -1069,8 +1060,8 @@ mono_gc_init (void)
        if (finalizer_event == NULL || pending_done_event == NULL || shutdown_event == NULL) {
                g_assert_not_reached ();
        }
-#if USE_POSIX_SEM
-       sem_init (&finalizer_sem, 0, 0);
+#ifdef MONO_HAS_SEMAPHORES
+       MONO_SEM_INIT (&finalizer_sem, 0);
 #endif
 
        gc_thread = mono_thread_create_internal (mono_domain_get (), finalizer_thread, NULL, FALSE);
index 279bf1283973243c7c2f740b2439eee49d518a58..7cec53a76a1872a210e3f327f1b4935c2d39005b 100644 (file)
@@ -1,3 +1,20 @@
+2009-07-20  Geoff Norton  <gnorton@novell.com>
+
+       * mini-x86.c: Fix --trace on darwin-x86 and other systems which require
+       aligned access.
+
+2009-07-20  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini.c (mono_jit_runtime_invoke): Speed this up by adding a hash to
+       MonoJitDomainInfo which maps MonoMethod's to a structure containing all
+       the information which is needed for invokes, so only one locking+hash table
+       lookup is needed.
+
+       * aot-compiler.c: Add a 'tool-prefix' option to be used when cross-compiling.
+       
+       * aot-compiler.c (add_generic_instances): Emit instances of 
+       GenericComparer<T> for primitive types.
+
 2009-07-19 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * mini-posix.c: Fix linux build.
index 6adf8659960501b2515fbe1a2b8cbd2ddead02a3..601ad740b346295324a3b0b5e2407de3f967b4cc 100644 (file)
@@ -99,6 +99,7 @@ typedef struct MonoAotOptions {
        int nthreads;
        int ntrampolines;
        gboolean print_skipped_methods;
+       char *tool_prefix;
 } MonoAotOptions;
 
 typedef struct MonoAotStats {
@@ -2144,6 +2145,50 @@ add_generic_instances (MonoAotCompile *acfg)
                                        add_generic_class (acfg, mono_class_from_mono_type (header->locals [j]));
                }
        }
+
+       if (acfg->image == mono_defaults.corlib) {
+               /* Add GenericComparer<T> instances for primitive types for Enum.ToString () */
+               MonoClass *klass = mono_class_from_name (acfg->image, "System.Collections.Generic", "GenericComparer`1");
+
+               if (klass) {
+                       MonoGenericContext ctx;
+                       MonoType *args [16];
+
+                       memset (&ctx, 0, sizeof (ctx));
+
+                       args [0] = &mono_defaults.byte_class->byval_arg;
+                       ctx.class_inst = mono_metadata_get_generic_inst (1, args);
+                       add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx));
+
+                       args [0] = &mono_defaults.sbyte_class->byval_arg;
+                       ctx.class_inst = mono_metadata_get_generic_inst (1, args);
+                       add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx));
+
+                       args [0] = &mono_defaults.int16_class->byval_arg;
+                       ctx.class_inst = mono_metadata_get_generic_inst (1, args);
+                       add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx));
+
+                       args [0] = &mono_defaults.uint16_class->byval_arg;
+                       ctx.class_inst = mono_metadata_get_generic_inst (1, args);
+                       add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx));
+
+                       args [0] = &mono_defaults.int32_class->byval_arg;
+                       ctx.class_inst = mono_metadata_get_generic_inst (1, args);
+                       add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx));
+
+                       args [0] = &mono_defaults.uint32_class->byval_arg;
+                       ctx.class_inst = mono_metadata_get_generic_inst (1, args);
+                       add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx));
+
+                       args [0] = &mono_defaults.int64_class->byval_arg;
+                       ctx.class_inst = mono_metadata_get_generic_inst (1, args);
+                       add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx));
+
+                       args [0] = &mono_defaults.uint64_class->byval_arg;
+                       ctx.class_inst = mono_metadata_get_generic_inst (1, args);
+                       add_generic_class (acfg, mono_class_inflate_generic_class (klass, &ctx));
+               }
+       }
 }
 
 /*
@@ -3290,6 +3335,8 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts)
                        opts->nodebug = TRUE;
                } else if (str_begins_with (arg, "ntrampolines=")) {
                        opts->ntrampolines = atoi (arg + strlen ("ntrampolines="));
+               } else if (str_begins_with (arg, "tool-prefix=")) {
+                       opts->tool_prefix = g_strdup (arg + strlen ("tool-prefix="));
                } else {
                        fprintf (stderr, "AOT : Unknown argument '%s'.\n", arg);
                        exit (1);
@@ -4837,6 +4884,7 @@ compile_asm (MonoAotCompile *acfg)
 {
        char *command, *objfile;
        char *outfile_name, *tmp_outfile_name;
+       const char *tool_prefix = acfg->aot_opts.tool_prefix ? acfg->aot_opts.tool_prefix : "";
 
 #if defined(TARGET_AMD64)
 #define AS_OPTIONS "--64"
@@ -4868,7 +4916,7 @@ compile_asm (MonoAotCompile *acfg)
        } else {
                objfile = g_strdup_printf ("%s.o", acfg->tmpfname);
        }
-       command = g_strdup_printf ("as %s %s -o %s", AS_OPTIONS, acfg->tmpfname, objfile);
+       command = g_strdup_printf ("%sas %s %s -o %s", tool_prefix, AS_OPTIONS, acfg->tmpfname, objfile);
        printf ("Executing the native assembler: %s\n", command);
        if (system (command) != 0) {
                g_free (command);
@@ -4899,7 +4947,7 @@ compile_asm (MonoAotCompile *acfg)
 #elif defined(PLATFORM_WIN32)
        command = g_strdup_printf ("gcc -shared --dll -mno-cygwin -o %s %s.o", tmp_outfile_name, acfg->tmpfname);
 #else
-       command = g_strdup_printf ("ld %s -shared -o %s %s.o", LD_OPTIONS, tmp_outfile_name, acfg->tmpfname);
+       command = g_strdup_printf ("%sld %s -shared -o %s %s.o", tool_prefix, LD_OPTIONS, tmp_outfile_name, acfg->tmpfname);
 #endif
        printf ("Executing the native linker: %s\n", command);
        if (system (command) != 0) {
@@ -4922,7 +4970,7 @@ compile_asm (MonoAotCompile *acfg)
         * gas generates 'mapping symbols' each time code and data is mixed, which 
         * happens a lot in emit_and_reloc_code (), so we need to get rid of them.
         */
-       command = g_strdup_printf ("strip --strip-symbol=\\$a --strip-symbol=\\$d %s", tmp_outfile_name);
+       command = g_strdup_printf ("%sstrip --strip-symbol=\\$a --strip-symbol=\\$d %s", tool_prefix, tmp_outfile_name);
        printf ("Stripping the binary: %s\n", command);
        if (system (command) != 0) {
                g_free (tmp_outfile_name);
index 1ee4ae4940d00ae43791bba239dc58318592eed9..70a2860e6ab319bbfb196297ecbfbdc56898786a 100644 (file)
@@ -1452,39 +1452,48 @@ void*
 mono_arch_instrument_epilog_full (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments, gboolean preserve_argument_registers)
 {
        guchar *code = p;
-       int arg_size = 0, save_mode = SAVE_NONE;
+       int arg_size = 0, stack_usage = 0, save_mode = SAVE_NONE;
        MonoMethod *method = cfg->method;
        
        switch (mini_type_get_underlying_type (cfg->generic_sharing_context, mono_method_signature (method)->ret)->type) {
        case MONO_TYPE_VOID:
                /* special case string .ctor icall */
-               if (strcmp (".ctor", method->name) && method->klass == mono_defaults.string_class)
+               if (strcmp (".ctor", method->name) && method->klass == mono_defaults.string_class) {
                        save_mode = SAVE_EAX;
-               else
+                       stack_usage = enable_arguments ? 8 : 4;
+               } else
                        save_mode = SAVE_NONE;
                break;
        case MONO_TYPE_I8:
        case MONO_TYPE_U8:
                save_mode = SAVE_EAX_EDX;
+               stack_usage = enable_arguments ? 16 : 8;
                break;
        case MONO_TYPE_R4:
        case MONO_TYPE_R8:
                save_mode = SAVE_FP;
+               stack_usage = enable_arguments ? 16 : 8;
                break;
        case MONO_TYPE_GENERICINST:
                if (!mono_type_generic_inst_is_valuetype (mono_method_signature (method)->ret)) {
                        save_mode = SAVE_EAX;
+                       stack_usage = enable_arguments ? 8 : 4;
                        break;
                }
                /* Fall through */
        case MONO_TYPE_VALUETYPE:
+               // FIXME: Handle SMALL_STRUCT_IN_REG here for proper alignment on darwin-x86
                save_mode = SAVE_STRUCT;
+               stack_usage = enable_arguments ? 4 : 0;
                break;
        default:
                save_mode = SAVE_EAX;
+               stack_usage = enable_arguments ? 8 : 4;
                break;
        }
 
+       x86_alu_reg_imm (code, X86_SUB, X86_ESP, MONO_ARCH_FRAME_ALIGNMENT - stack_usage - 4);
+
        switch (save_mode) {
        case SAVE_EAX_EDX:
                x86_push_reg (code, X86_EDX);
@@ -1532,6 +1541,7 @@ mono_arch_instrument_epilog_full (MonoCompile *cfg, void *func, void *p, gboolea
                mono_add_patch_info (cfg, code-cfg->native_code, MONO_PATCH_INFO_ABS, func);
                x86_call_code (code, 0);
        }
+
        x86_alu_reg_imm (code, X86_ADD, X86_ESP, arg_size + 4);
 
        switch (save_mode) {
@@ -1550,6 +1560,8 @@ mono_arch_instrument_epilog_full (MonoCompile *cfg, void *func, void *p, gboolea
        default:
                break;
        }
+       
+       x86_alu_reg_imm (code, X86_ADD, X86_ESP, MONO_ARCH_FRAME_ALIGNMENT - stack_usage);
 
        return code;
 }
index 3ca88ed198ff1d8c0c57816bf1d7130a5f95ee30..c798516d100f83e11c5ed7703281ab9004ef0181 100644 (file)
@@ -4300,6 +4300,7 @@ mono_jit_free_method (MonoDomain *domain, MonoMethod *method)
        g_hash_table_remove (domain_jit_info (domain)->dynamic_code_hash, method);
        mono_internal_hash_table_remove (&domain->jit_code_hash, method);
        g_hash_table_remove (domain_jit_info (domain)->jump_trampoline_hash, method);
+       g_hash_table_remove (domain_jit_info (domain)->runtime_invoke_hash, method);
        mono_domain_unlock (domain);
 
 #ifdef MONO_ARCH_HAVE_INVALIDATE_METHOD
@@ -4362,6 +4363,13 @@ mono_jit_find_compiled_method (MonoDomain *domain, MonoMethod *method)
        return mono_jit_find_compiled_method_with_jit_info (domain, method, NULL);
 }
 
+typedef struct {
+       MonoMethod *method;
+       gpointer compiled_method;
+       gpointer runtime_invoke;
+       MonoVTable *vtable;
+} RuntimeInvokeInfo;
+
 /**
  * mono_jit_runtime_invoke:
  * @method: the method to invoke
@@ -4372,60 +4380,65 @@ mono_jit_find_compiled_method (MonoDomain *domain, MonoMethod *method)
 static MonoObject*
 mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc)
 {
-       MonoMethod *to_compile;
        MonoMethod *invoke;
        MonoObject *(*runtime_invoke) (MonoObject *this, void **params, MonoObject **exc, void* compiled_method);
-       void* compiled_method;
-       MonoVTable *vtable;
-       gboolean need_rgctx_tramp = FALSE;
-
+       MonoDomain *domain = mono_domain_get ();
+       MonoJitDomainInfo *domain_info;
+       RuntimeInvokeInfo *info, *info2;
+       
        if (obj == NULL && !(method->flags & METHOD_ATTRIBUTE_STATIC) && !method->string_ctor && (method->wrapper_type == 0)) {
                g_warning ("Ignoring invocation of an instance method on a NULL instance.\n");
                return NULL;
        }
 
-       to_compile = method;
+       domain_info = domain_jit_info (domain);
 
-       if (mono_method_needs_static_rgctx_invoke (method, FALSE))
-               need_rgctx_tramp = TRUE;
+       mono_domain_lock (domain);
+       info = g_hash_table_lookup (domain_info->runtime_invoke_hash, method);
+       mono_domain_unlock (domain);            
 
-       /* Special case parameterless ctors to speed up Activator.CreateInstance () */
-       if (method->flags & (METHOD_ATTRIBUTE_SPECIAL_NAME | METHOD_ATTRIBUTE_RT_SPECIAL_NAME) && !strcmp (method->name, ".ctor") && mono_method_signature (method)->param_count == 0 && !method->klass->valuetype) {
-               MonoJitDomainInfo *domain_info = domain_jit_info (mono_domain_get ());
+       if (!info) {
+               info = g_new0 (RuntimeInvokeInfo, 1);
 
-               if (!domain_info->ctor_runtime_invoke) {
-                       invoke = mono_marshal_get_runtime_invoke (method, FALSE);
-                       domain_info->ctor_runtime_invoke = mono_jit_compile_method (invoke);
+               invoke = mono_marshal_get_runtime_invoke (method, FALSE);
+               info->runtime_invoke = mono_jit_compile_method (invoke);
+               info->vtable = mono_class_vtable (domain, method->klass);
+               g_assert (info->vtable);
+
+               if (method->klass->rank && (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) &&
+                       (method->iflags & METHOD_IMPL_ATTRIBUTE_NATIVE)) {
+                       /* 
+                        * Array Get/Set/Address methods. The JIT implements them using inline code 
+                        * inside the runtime invoke wrappers, so no need to compile them.
+                        */
+                       info->compiled_method = NULL;
+               } else {
+                       info->compiled_method = mono_jit_compile_method (method);
+
+                       if (mono_method_needs_static_rgctx_invoke (method, FALSE))
+                               info->compiled_method = mono_create_static_rgctx_trampoline (method, info->compiled_method);
                }
 
-               runtime_invoke = domain_info->ctor_runtime_invoke;
-       } else {
-               invoke = mono_marshal_get_runtime_invoke (method, FALSE);
-               runtime_invoke = mono_jit_compile_method (invoke);
+               mono_domain_lock (domain);
+               info2 = g_hash_table_lookup (domain_info->runtime_invoke_hash, method);
+               if (info2) {
+                       g_free (info);
+                       info = info2;
+               } else {
+                       g_hash_table_insert (domain_info->runtime_invoke_hash, method, info);
+               }
+               mono_domain_unlock (domain);            
        }
 
+       runtime_invoke = info->runtime_invoke;
+
        /*
         * We need this here because mono_marshal_get_runtime_invoke can place 
         * the helper method in System.Object and not the target class.
         */
-       vtable = mono_class_vtable (mono_domain_get (), method->klass);
-       g_assert (vtable);
-       mono_runtime_class_init (vtable);
-
-       if (method->klass->rank && (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) &&
-               (method->iflags & METHOD_IMPL_ATTRIBUTE_NATIVE)) {
-               /* 
-                * Array Get/Set/Address methods. The JIT implements them using inline code 
-                * inside the runtime invoke wrappers, so no need to compile them.
-                */
-               compiled_method = NULL;
-       } else {
-               compiled_method = mono_jit_compile_method (to_compile);
-       }
-       if (need_rgctx_tramp)
-               compiled_method = mono_create_static_rgctx_trampoline (to_compile, compiled_method);
+       mono_runtime_class_init (info->vtable);
 
-       return runtime_invoke (obj, params, exc, compiled_method);
+       return runtime_invoke (obj, params, exc, info->compiled_method);
 }
 
 void
@@ -4680,6 +4693,7 @@ mini_create_jit_domain_info (MonoDomain *domain)
        info->delegate_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
        info->static_rgctx_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
        info->llvm_vcall_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
+       info->runtime_invoke_hash = g_hash_table_new_full (mono_aligned_addr_hash, NULL, NULL, g_free);
 
        domain->runtime_info = info;
 }
@@ -4723,6 +4737,7 @@ mini_free_jit_domain_info (MonoDomain *domain)
        g_hash_table_destroy (info->delegate_trampoline_hash);
        g_hash_table_destroy (info->static_rgctx_trampoline_hash);
        g_hash_table_destroy (info->llvm_vcall_trampoline_hash);
+       g_hash_table_destroy (info->runtime_invoke_hash);
 
        g_free (domain->runtime_info);
        domain->runtime_info = NULL;
index d3047e27f7e4c75cdf5253d5dfc0f544346a5ee2..923522da206745a9890b37763af8bd733b9bf9e7 100644 (file)
@@ -129,7 +129,7 @@ typedef struct MonoAotFileInfo
        guint32 trampoline_got_offset_base [MONO_AOT_TRAMP_NUM];
        guint32 trampoline_size [MONO_AOT_TRAMP_NUM];
 } MonoAotFileInfo;
+
 /* Per-domain information maintained by the JIT */
 typedef struct
 {
@@ -146,8 +146,8 @@ typedef struct
        /* maps MonoMethod -> MonoJitDynamicMethodInfo */
        GHashTable *dynamic_code_hash;
        GHashTable *method_code_hash;
-       /* Compiled runtime invoke function for parameterless ctors */
-       gpointer ctor_runtime_invoke;
+       /* Maps methods to a RuntimeInvokeInfo structure */
+       GHashTable *runtime_invoke_hash;
 } MonoJitDomainInfo;
 
 typedef struct {
index 004aaab6c7e55ebdb8d2cfee14473b24e5c3cb1f..b4adb077f02392eecd4e51f007d3005ff66ae441 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-20  Geoff Norton  <gnorton@novell.com>
+
+       * mono-semaphore.h: Refactor from io-layer/thread-private.h so it
+       can be used by the runtime as well.
+
 2009-07-17 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * mono-proclib.c: fix reading processor usage for a process. Patch
index ab5b9516b2ef3f6dbeedfe2f5aceb4ae0c7fa2bb..45753537666682288532c5112ab6c3911023cc08 100644 (file)
@@ -49,6 +49,7 @@ libmonoutils_la_SOURCES = \
        mono-uri.c              \
        mono-poll.c             \
        mono-path.c             \
+       mono-semaphore.h        \
        mono-stdlib.c           \
        mono-property-hash.h    \
        mono-property-hash.c    \
diff --git a/mono/utils/mono-semaphore.h b/mono/utils/mono-semaphore.h
new file mode 100644 (file)
index 0000000..d2581bc
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * mono-semaphore.h:  Definitions for generic semaphore usage
+ *
+ * Author:
+ *     Geoff Norton  <gnorton@novell.com>
+ *
+ * (C) 2009 Novell, Inc.
+ */
+
+#ifndef _MONO_SEMAPHORE_H_
+#define _MONO_SEMAPHORE_H_
+
+#include <config.h>
+#ifdef HAVE_SEMAPHORE_H
+#include <semaphore.h>
+#endif
+
+#if defined (HAVE_SEMAPHORE_H) || defined (USE_MACH_SEMA)
+#  define MONO_HAS_SEMAPHORES
+
+#  if defined (USE_MACH_SEMA)
+#    include <mach/mach_init.h>
+#    include <mach/task.h>
+#    include <mach/semaphore.h>
+typedef semaphore_t MonoSemType;
+#    define MONO_SEM_INIT(addr,value) semaphore_create (current_task (), (addr), SYNC_POLICY_FIFO, (value))
+#    define MONO_SEM_WAIT(sem) semaphore_wait (*(sem))
+#    define MONO_SEM_POST(sem) semaphore_signal (*(sem))
+#    define MONO_SEM_DESTROY(sem) semaphore_destroy (current_task (), *(sem))
+#  else
+typedef sem_t MonoSemType;
+#    define MONO_SEM_INIT(addr,value) sem_init ((addr), 0, (value))
+#    define MONO_SEM_WAIT(sem) sem_wait ((sem))
+#    define MONO_SEM_POST(sem) sem_post ((sem))
+#    define MONO_SEM_DESTROY(sem) sem_destroy ((sem))
+#  endif
+#endif
+
+#endif /* _MONO_SEMAPHORE_H_ */