Author: gert
Date: 2008-01-25 15:22:12 -0500 (Fri, 25 Jan 2008)
New Revision: 93956

Added:
   
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/
   
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/ChangeLog
   
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
Modified:
   trunk/mcs/class/System.Runtime.Remoting/ChangeLog
   
trunk/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources
   trunk/mcs/class/System.Runtime.Remoting/Test/ChangeLog
   trunk/mcs/class/System.Runtime.Remoting/Test/RemotingServicesTest.cs
Log:
* System.Runtime.Remoting_test.dll.sources: add TcpChannelTest.cs.
* RemotingServicesTest.cs: Do not hide exception that occur when
unregistering a channel. Code formatting and removed extra tabs.
* TcpChannelTest.cs: Added simple ctor test that covers bug #355905.
* System.Runtime.Remoting_test.dll.sources: add TcpChannelTest.cs.


Modified: trunk/mcs/class/System.Runtime.Remoting/ChangeLog
===================================================================
--- trunk/mcs/class/System.Runtime.Remoting/ChangeLog   2008-01-25 20:15:18 UTC 
(rev 93955)
+++ trunk/mcs/class/System.Runtime.Remoting/ChangeLog   2008-01-25 20:22:12 UTC 
(rev 93956)
@@ -1,3 +1,7 @@
+2008-01-25  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * System.Runtime.Remoting_test.dll.sources: add TcpChannelTest.cs.
+
 2007-05-19  Robert Jordan  <[EMAIL PROTECTED]>
 
        * System.Runtime.Remoting_test.dll.sources: add IpcChannelTest.cs

Modified: 
trunk/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources
===================================================================
--- 
trunk/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources
    2008-01-25 20:15:18 UTC (rev 93955)
+++ 
trunk/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting_test.dll.sources
    2008-01-25 20:22:12 UTC (rev 93956)
@@ -1,3 +1,4 @@
+System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
 ServerObject.cs
 ContextsTest.cs
 CallSeq.cs

Modified: trunk/mcs/class/System.Runtime.Remoting/Test/ChangeLog
===================================================================
--- trunk/mcs/class/System.Runtime.Remoting/Test/ChangeLog      2008-01-25 
20:15:18 UTC (rev 93955)
+++ trunk/mcs/class/System.Runtime.Remoting/Test/ChangeLog      2008-01-25 
20:22:12 UTC (rev 93956)
@@ -1,3 +1,8 @@
+2008-01-25  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * RemotingServicesTest.cs: Do not hide exception that occur when
+       unregistering a channel. Code formatting and removed extra tabs.
+
 2007-10-30  Robert Jordan  <[EMAIL PROTECTED]>
 
        * GenericTest.cs: Add tests for bug #324232.

Modified: trunk/mcs/class/System.Runtime.Remoting/Test/RemotingServicesTest.cs
===================================================================
--- trunk/mcs/class/System.Runtime.Remoting/Test/RemotingServicesTest.cs        
2008-01-25 20:15:18 UTC (rev 93955)
+++ trunk/mcs/class/System.Runtime.Remoting/Test/RemotingServicesTest.cs        
2008-01-25 20:22:12 UTC (rev 93956)
@@ -139,25 +139,23 @@
                public void Method1()
                {
                        _called++;
-                       methodOneWay = 
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());                       
 
+                       methodOneWay = 
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
                }
                
                public void Method2()
                {
-                       methodOneWay = 
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());                       
 
+                       methodOneWay = 
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
                }
                
                public void Method2(int i)
                {
-                       methodOneWay = 
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());                       
 
-                       
+                       methodOneWay = 
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
                }
                
                [OneWay()]
                public void Method3()
                {
-                       methodOneWay = 
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());                       
 
-                       
+                       methodOneWay = 
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
                }
                
                public static int Called
@@ -183,7 +181,7 @@
                public DerivedMarshalObject(){}
                
                public DerivedMarshalObject(int id, string uri): base(id, uri) 
{}
-       }       
+       }
        
        interface A
        {
@@ -267,7 +265,7 @@
                        
                        Assert("#A04", objRef.URI.EndsWith(objMarshal.Uri));
                        // TODO: uncomment when RemotingServices.Disconnect is 
implemented
-                       //RemotingServices.Disconnect(objMarshal);              
+                       //RemotingServices.Disconnect(objMarshal);
                }
                
                [Test]
@@ -324,7 +322,6 @@
                
                // Tests RemotingServices.Marshal()
                [Test]
-               [ExpectedException(typeof(RemotingException))]  
                public void MarshalThrowException()
                {
                        MarshalObject objMarshal = NewMarshalObject();
@@ -338,22 +335,19 @@
                        RemotingServices.Marshal(objMarshal,objMarshal.Uri);
                        
                        MarshalObject objRem = (MarshalObject) 
RemotingServices.Connect(typeof(MarshalObject), "tcp://localhost:1237/" + 
objMarshal.Uri);
-                       // This line sould throw a RemotingException
+                       // This line should throw a RemotingException
                        // It is forbidden to export an object which is not
                        // a real object
-                       try
-                       {
+                       try {
                                RemotingServices.Marshal(objRem, 
objMarshal.Uri);
-                       }
-                       catch(Exception e)
-                       {
+                               Fail ("#1");
+                       } catch (RemotingException e) {
+                       } finally {
                                ChannelServices.UnregisterChannel(chn);
                        
-                       // TODO: uncomment when RemotingServices.Disconnect is 
implemented
-                       //RemotingServices.Disconnect(objMarshal);
-                       
-                               throw e;
-                       }               
+                               // TODO: uncomment when 
RemotingServices.Disconnect is implemented
+                               //RemotingServices.Disconnect(objMarshal);
+                       }
                }
                
                // Tests RemotingServices.ExecuteMessage()
@@ -363,8 +357,7 @@
                public void ExecuteMessage()
                {
                        TcpChannel chn = null;
-                       try
-                       {
+                       try {
                                chn = new TcpChannel(1235);
                                ChannelServices.RegisterChannel(chn);
                                
@@ -388,11 +381,10 @@
                                // Tests RemotingServices.ExecuteMessage();
                                // If ExecuteMessage does it job well, Method1 
should be called 2 times
                                AssertEquals("#A10", 2, MarshalObject.Called);
+                       } finally {
+                               if (chn != null)
+                                       ChannelServices.UnregisterChannel (chn);
                        }
-                       finally
-                       {
-                               if(chn != null) 
ChannelServices.UnregisterChannel(chn);
-                       }
                }
                
                // Tests the IsOneWay method
@@ -400,8 +392,7 @@
                public void IsOneWay()
                {
                        TcpChannel chn = null;
-                       try
-                       {
+                       try {
                                chn = new TcpChannel(1238);
                                ChannelServices.RegisterChannel(chn);
                                
RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), 
"MarshalObject.rem", WellKnownObjectMode.Singleton);
@@ -416,19 +407,17 @@
                                objRem.Method3();
                                Thread.Sleep(20);
                                Assert("#A10.3", MarshalObject.IsMethodOneWay);
+                       } finally {
+                               if (chn != null)
+                                       ChannelServices.UnregisterChannel (chn);
                        }
-                       finally
-                       {
-                               if(chn != null) 
ChannelServices.UnregisterChannel(chn);
-                       }
                }
                
                [Test]
                public void GetObjRefForProxy()
                {
                        TcpChannel chn = null;
-                       try
-                       {
+                       try {
                                chn = new TcpChannel(1239);
                                ChannelServices.RegisterChannel(chn);
                                
@@ -443,11 +432,10 @@
                                ObjRef objRefRem = 
RemotingServices.GetObjRefForProxy((MarshalByRefObject)objRem);
                                
                                Assert("#A11", objRefRem != null);
+                       } finally {
+                               if (chn != null)
+                                       ChannelServices.UnregisterChannel (chn);
                        }
-                       finally
-                       {
-                               if(chn != null) 
ChannelServices.UnregisterChannel(chn);                         
-                       }
                }
                
                // Tests GetRealProxy
@@ -455,8 +443,7 @@
                public void GetRealProxy()
                {
                        TcpChannel chn = null;
-                       try
-                       {
+                       try {
                                chn = new TcpChannel(1241);
                                ChannelServices.RegisterChannel(chn);
                                
@@ -469,11 +456,10 @@
                                
                                Assert("#A12", rp != null);
                                AssertEquals("#A13", 
"MonoTests.System.Runtime.Remoting.RemotingServicesInternal.MyProxy", 
rp.GetType().ToString());
+                       } finally {
+                               if (chn != null)
+                                       ChannelServices.UnregisterChannel(chn);
                        }
-                       finally
-                       {
-                               if(chn != null) 
ChannelServices.UnregisterChannel(chn);
-                       }
                }
                
                // Tests SetObjectUriForMarshal()
@@ -481,8 +467,7 @@
                public void SetObjectUriForMarshal()
                {
                        TcpChannel chn = null;
-                       try
-                       {
+                       try {
                                chn = new TcpChannel(1242);
                                ChannelServices.RegisterChannel(chn);
                                
@@ -492,11 +477,10 @@
                                
                                objRem = (MarshalObject) 
Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1242/"+objRem.Uri);
                                Assert("#A14", objRem != null);
+                       } finally {
+                               if (chn != null)
+                                       ChannelServices.UnregisterChannel (chn);
                        }
-                       finally
-                       {
-                               if(chn != null) 
ChannelServices.UnregisterChannel(chn);
-                       }                       
                        
                }
                
@@ -506,8 +490,7 @@
                {
                        TcpChannel chn = null;
                        Type type = typeof(MarshalObject);
-                       try
-                       {
+                       try {
                                chn = new TcpChannel(1243);
                                ChannelServices.RegisterChannel(chn);
                                
@@ -517,11 +500,10 @@
                                
                                Type typeRem = 
RemotingServices.GetServerTypeForUri(RemotingServices.GetObjectUri(objRem));
                                AssertEquals("#A15", type, typeRem);
+                       } finally {
+                               if (chn != null)
+                                       ChannelServices.UnregisterChannel (chn);
                        }
-                       finally
-                       {
-                               if(chn != null) 
ChannelServices.UnregisterChannel(chn);
-                       }                       
                }
                
                // Tests IsObjectOutOfDomain
@@ -530,8 +512,7 @@
                public void IsObjectOutOf()
                {
                        TcpChannel chn = null;
-                       try
-                       {
+                       try {
                                chn = new TcpChannel(1245);
                                ChannelServices.RegisterChannel(chn);
                                
@@ -545,11 +526,10 @@
                                MarshalObject objMarshal = new MarshalObject();
                                Assert("#A18", 
!RemotingServices.IsObjectOutOfAppDomain(objMarshal));
                                Assert("#A19", 
!RemotingServices.IsObjectOutOfContext(objMarshal));
+                       } finally {
+                               if (chn != null)
+                                       ChannelServices.UnregisterChannel (chn);
                        }
-                       finally
-                       {
-                               ChannelServices.UnregisterChannel(chn);
-                       }
                }
 
                [Test]
@@ -557,8 +537,7 @@
                {
                        RemotingConfiguration.ApplicationName = "app";
                        TcpChannel chn = null;
-                       try
-                       {
+                       try {
                                chn = new TcpChannel(1246);
                                ChannelServices.RegisterChannel(chn);
                                
@@ -577,13 +556,9 @@
                                AssertNull ("#AN7", 
RemotingServices.GetServerTypeForUri ("/whatever/obj3.rem"));
                                AssertNotNull ("#AN8", 
RemotingServices.GetServerTypeForUri ("/obj3.rem"));
                                AssertNull ("#AN9", 
RemotingServices.GetServerTypeForUri ("//obj3.rem"));
-                       }
-                       finally
-                       {
-                               try {
+                       } finally {
+                               if (chn != null)
                                        ChannelServices.UnregisterChannel(chn);
-                               } catch {
-                               }
                        }
                }
 
@@ -599,12 +574,9 @@
 
                                string channelData = "test";
                                AssertNotNull ("#01", 
Activator.GetObject(typeof(MarshalObject), 
"tcp://localhost:1247/getobjectwithchanneldata.rem", channelData));
-
                        } finally {
-                               try {
-                                       ChannelServices.UnregisterChannel(chn);
-                               } catch {
-                               }
+                               if (chn != null)
+                                       ChannelServices.UnregisterChannel (chn);
                        }
                }
                

Added: 
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/ChangeLog
===================================================================
--- 
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/ChangeLog
 2008-01-25 20:15:18 UTC (rev 93955)
+++ 
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/ChangeLog
 2008-01-25 20:22:12 UTC (rev 93956)
@@ -0,0 +1,4 @@
+2008-01-25  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * TcpChannelTest.cs: Added simple ctor test that covers bug #355905.
+


Property changes on: 
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/ChangeLog
___________________________________________________________________
Name: svn:eol-style
   + native

Added: 
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
===================================================================
--- 
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
 2008-01-25 20:15:18 UTC (rev 93955)
+++ 
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
 2008-01-25 20:22:12 UTC (rev 93956)
@@ -0,0 +1,93 @@
+//
+// TcpChanneltest.cs
+//
+// Author:
+//     Gert Driesen <[EMAIL PROTECTED]>
+//
+// Copyright (C) 2008 Gert Driesen
+//
+// 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.Collections;
+using System.Net;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Tcp;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.Remoting.Channels.Tcp
+{
+       [TestFixture]
+       public class TcpChannelTest
+       {
+               [Test] // TcpChannel (IDictionary, IClientChannelSinkProvider, 
IServerChannelSinkProvider)
+               public void Constructor3 ()
+               {
+                       const string SERVICE_URI = "MarshalSvc";
+                       string [] urls;
+                       ChannelDataStore ds;
+                       TcpChannel chn;
+
+                       MarshalObject marshal = new MarshalObject ();
+
+                       IDictionary props = new Hashtable ();
+                       props ["name"] = "marshal channel";
+                       props ["port"] = 1236;
+                       props ["bindTo"] = IPAddress.Loopback.ToString ();
+                       chn = new TcpChannel (props, null, null);
+
+                       ChannelServices.RegisterChannel (chn);
+
+                       Assert.AreEqual ("marshal channel", chn.ChannelName, 
"#A1");
+                       urls = chn.GetUrlsForUri (SERVICE_URI);
+                       Assert.IsNotNull (urls, "#A2");
+                       Assert.AreEqual (1, urls.Length, "#A3");
+                       Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString 
() + ":1236/" + SERVICE_URI, urls [0], "#A6");
+                       ds = chn.ChannelData as ChannelDataStore;
+                       Assert.IsNotNull (ds, "#A4");
+                       Assert.AreEqual (1, ds.ChannelUris.Length, "#A5");
+                       Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString 
() + ":1236", ds.ChannelUris [0], "#A6");
+
+                       ChannelServices.UnregisterChannel (chn);
+
+                       chn = new TcpChannel ((IDictionary) null, null, null);
+
+                       ChannelServices.RegisterChannel (chn);
+
+                       Assert.AreEqual ("tcp", chn.ChannelName, "#B1");
+                       urls = chn.GetUrlsForUri (SERVICE_URI);
+                       Assert.IsNull (urls, "#B1");
+                       ds = chn.ChannelData as ChannelDataStore;
+                       Assert.IsNull (ds, "#B2");
+
+                       ChannelServices.UnregisterChannel (chn);
+               }
+
+               public class MarshalObject : ContextBoundObject
+               {
+                       public MarshalObject ()
+                       {
+                       }
+               }
+       }
+}


Property changes on: 
trunk/mcs/class/System.Runtime.Remoting/Test/System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
___________________________________________________________________
Name: svn:eol-style
   + native

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to