2009-05-24 Robert Jordan <robertj@gmx.net>
authorRobert Jordan <robertj@gmx.net>
Sun, 24 May 2009 12:46:29 +0000 (12:46 -0000)
committerRobert Jordan <robertj@gmx.net>
Sun, 24 May 2009 12:46:29 +0000 (12:46 -0000)
* GenericTest.cs (TestTcpChannel): create a unique channel and
unregister it upon termination. Fixes issues that were uncovered
by the NUnit upgrade (see Atsushi's changelogs below).

svn path=/trunk/mcs/; revision=134646

mcs/class/System.Runtime.Remoting/Test/ChangeLog
mcs/class/System.Runtime.Remoting/Test/GenericTest.cs

index 2f3514c237783148e16efaeffa4ba5fc800c0090..6bb5cc50ecf3a8d17d1a2288842344d9ad17c890 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-24  Robert Jordan  <robertj@gmx.net>
+
+       * GenericTest.cs (TestTcpChannel): create a unique channel and
+       unregister it upon termination. Fixes issues that were uncovered
+       by the NUnit upgrade (see Atsushi's changelogs below).
+
 2009-01-07  Atsushi Enomoto  <atsushi@ximian.com>
 
        * RemotingServicesTest.cs : mark failing test as NotWorking, and 
index 8488a8df146f540f0e788d7f8306ba2e4d66674b..6d8ed0e2b0abd9e2b89a801abf6ec755336d10f9 100644 (file)
@@ -8,6 +8,7 @@
 #if NET_2_0
 
 using System;
+using System.Collections;
 using System.Runtime.Remoting;
 using System.Runtime.Remoting.Channels;
 using System.Runtime.Remoting.Channels.Tcp;
@@ -155,30 +156,43 @@ namespace MonoTests.Remoting
                [Test]
                public void TestCrossAppDomainChannel ()
                {
-                       RunTests (GetRemObject <Server<object>> ());
+                       RunTests (RegisterAndConnect <Server<object>> ());
                }
 
                [Test]
-               [Ignore ("disabled as it got not working by NUnit upgrade to 2.4.8 (applies to .NET too)")]
                public void TestTcpChannel ()
                {
-                       RunTests (GetRemObjectTcp <Server<object>> ());
+                       IDictionary props = new Hashtable ();
+                       props ["name"] = Guid.NewGuid ().ToString("N");
+                       props ["port"] = 18191;
+                       TcpChannel chan = new TcpChannel (props, null, null);
+                       ChannelServices.RegisterChannel (chan);
+                       
+                       try {
+                               Register <Server<object>> ("gentcptest.rem");
+                               RunTests (Connect <Server<object>> ("tcp://localhost:18191/gentcptest.rem"));
+                       } finally {
+                               ChannelServices.UnregisterChannel (chan);
+                       }
                }
 
-               static T GetRemObject <T> () where T: MarshalByRefObject
+               static T RegisterAndConnect <T> () where T: MarshalByRefObject
                {
-                       AppDomain d = BaseCallTest.CreateDomain ("Foo");
+                       AppDomain d = BaseCallTest.CreateDomain ("GenericTests");
                        return (T) d.CreateInstanceAndUnwrap (
                                typeof (T).Assembly.FullName,
                                typeof (T).FullName);
                }
 
-               static T GetRemObjectTcp <T> () where T: MarshalByRefObject
+               static void Register <T> (string uri) where T: MarshalByRefObject
                {
-                       new TcpChannel (18191);
                        object obj = Activator.CreateInstance (typeof(T));
-                       RemotingServices.Marshal ((MarshalByRefObject)obj, "test.rem");
-                       return (T) RemotingServices.Connect (typeof (T), "tcp://localhost:18191/test.rem");
+                       RemotingServices.Marshal ((MarshalByRefObject)obj, uri);
+               }
+
+               static T Connect <T> (string uri) where T: MarshalByRefObject
+               {
+                       return (T) RemotingServices.Connect (typeof (T), uri);
                }
 
                static void RunTests (ServerBase<object> rem)