4 using System.Collections;
5 using System.Runtime.Remoting;
6 using System.Runtime.Remoting.Channels;
7 using System.Runtime.Remoting.Channels.Http;
10 namespace MonoTests.Remoting.Http
12 //Test for Bug 324362 - SoapFormatter cannot deserialize the same MBR twice
14 public class Bug324362
17 // [Category ("NotWorking")] // the assertion fails, and if it's removed, there's an exception
18 [Ignore ("This test somehow keeps http channel registered and then blocks any further http tests working. This also happens under .NET, so this test itself is wrong with nunit 2.4.8.")]
21 new HttpChannel (8086);
22 RemotingServices.Marshal (new Service (), "test");
24 Service remObj = (Service) RemotingServices.Connect (
25 typeof (Service), "http://localhost:8086/test");
28 remObj.Test (out list);
29 // it's of type 'ObjRef' instead of 'Service':
30 Assert.IsTrue (list [0] is Service);
33 remObj.Test (out array);
36 public class Service : MarshalByRefObject
38 public Service Test (out Service[] a)
40 Service obj = new Service ();
41 a = new Service [] { obj };
43 // return null or return otherObj works
46 public Service Test (out ArrayList a)
49 Service obj = new Service ();
52 // return null or return otherObj works
57 //Bug 321420 - SoapReader fails to deserialize some method calls
59 public class Bug321420 : MarshalByRefObject
63 public void Method (string p1, string p2)
70 channel = new HttpChannel (3344);
71 ChannelServices.RegisterChannel (channel);
72 RemotingConfiguration.RegisterWellKnownServiceType
73 (typeof (Bug321420),"Server.soap", WellKnownObjectMode.Singleton);
75 Bug321420 s = (Bug321420) Activator.GetObject (typeof
76 (Bug321420), "http://localhost:3344/Server.soap");
78 // this works: s.Method ("a", "b");
86 ChannelServices.UnregisterChannel (channel);
90 //Bug 315570 - Remoting over HTTP fails when returning a null reference.
92 public class Bug315570
97 [Ignore ("This test somehow keeps http channel registered and then blocks any further http tests working. This also happens under .NET, so this test itself is wrong with nunit 2.4.8.")]
100 Foo foo = (Foo) Activator.GetObject (typeof (Foo),
101 "http://localhost:4321/Test");
103 Bar bar = foo.Login ();
111 AppDomain domain = BaseCallTest.CreateDomain ("testdomain");
112 server = (Server) domain.CreateInstanceAndUnwrap
113 (typeof (Server).Assembly.FullName, typeof (Server).FullName);
117 [TestFixtureTearDown]
123 public class Foo: MarshalByRefObject
131 public class Bar: MarshalByRefObject
133 public void Foobar ()
135 // Console.WriteLine("Bar::foo()");
139 public class Server : MarshalByRefObject
145 c = new HttpChannel (4321);
146 ChannelServices.RegisterChannel (c);
148 Type t = typeof(Foo);
149 RemotingConfiguration.RegisterWellKnownServiceType (t, "Test",
150 WellKnownObjectMode.SingleCall);
155 c.StopListening (null);
156 ChannelServices.UnregisterChannel (c);
161 //Bug 315170 - exception thrown in remoting if interface parameter names differ from the impelmentation method parameter names
163 public class Bug315170
171 channel = new HttpChannel (0);
172 ChannelServices.RegisterChannel (channel);
173 MarshalByRefObject obj = (MarshalByRefObject) RemotingServices.Connect (
175 "http://localhost:60000/MyEndPoint");
176 IFactorial cal = (IFactorial) obj;
177 Assert.AreEqual (cal.CalculateFactorial (4), 24);
183 AppDomain domain = BaseCallTest.CreateDomain ("testdomain");
184 server = (Server) domain.CreateInstanceAndUnwrap
185 (typeof (Server).Assembly.FullName, typeof (Server).FullName);
189 [TestFixtureTearDown]
194 ChannelServices.UnregisterChannel (channel);
197 public interface IFactorial
199 // With this line everything works
200 //ulong CalculateFactorial(uint a);
201 // With this line it doesn't
202 ulong CalculateFactorial(uint b);
206 public class Server : MarshalByRefObject
212 c = new HttpChannel (60000);
213 ChannelServices.RegisterChannel (c);
215 Type t = typeof(Calculator);
216 RemotingConfiguration.RegisterWellKnownServiceType (t, "MyEndPoint",
217 WellKnownObjectMode.Singleton);
222 c.StopListening (null);
223 ChannelServices.UnregisterChannel (c);
227 public class Calculator : MarshalByRefObject, IFactorial
229 public ulong CalculateFactorial (uint a)
232 for (uint i=1 ; i<=a; i++)