Merge branch 'bugfix-main-thread-root'
[mono.git] / mcs / class / System / Test / System.Net / ServicePointTest.cs
index 01ee2709f1f6c2e8f5d7ec3ed9ec45379452ddd3..457dc5b29f1ec4e1daeb3553b813d97e0f23d5a9 100644 (file)
@@ -34,6 +34,10 @@ public class ServicePointTest
        }\r
 \r
         [Test]\r
+               [Category ("InetAccess")]\r
+#if TARGET_JVM\r
+       [Ignore ("Unsupported - ServicePointManager.FindServicePoint")]\r
+#endif\r
         public void All ()\r
         {\r
                ServicePoint p = ServicePointManager.FindServicePoint (new Uri ("mailto:xx@yyy.com"));\r
@@ -43,7 +47,7 @@ public class ServicePointTest
                ServicePoint google = ServicePointManager.FindServicePoint (new Uri ("http://www.google.com"));\r
                try {                   \r
                        ServicePoint slashdot = ServicePointManager.FindServicePoint (new Uri ("http://www.slashdot.org"));\r
-                       Assertion.Fail ("#1");\r
+                       Assert.Fail ("#1");\r
                } catch (InvalidOperationException) { }\r
                ServicePointManager.MaxServicePoints = 0;\r
                \r
@@ -54,7 +58,7 @@ public class ServicePointTest
                \r
                //WriteServicePoint ("google after getting a response", google);\r
                ServicePoint google2 = ServicePointManager.FindServicePoint (new Uri ("http://www.google.com/dilbert.html"));\r
-               Assertion.AssertEquals ("#equals", google, google2);\r
+               Assert.AreEqual (google, google2, "#equals");\r
                res.Close ();\r
                \r
                // in both instances property CurrentConnections is 0 according to ms.net.\r
@@ -114,6 +118,10 @@ public class ServicePointTest
        // while ConnectionLimit equals 2\r
 \r
        [Test]\r
+       [Category ("InetAccess")]\r
+#if TARGET_JVM\r
+       [Ignore ("The System.Net.ServicePointManager.FindServicePoint(Uri) is not supported")]\r
+#endif \r
        public void ConnectionLimit ()\r
        {               \r
                // the default is already 2, just in case it isn't..\r
@@ -144,6 +152,46 @@ public class ServicePointTest
                }\r
        }\r
 \r
+#if NET_2_0\r
+       [Test]\r
+       [Category ("InetAccess")]\r
+#if TARGET_JVM\r
+       [Ignore ("The System.Net.ServicePointManager.FindServicePoint(Uri) is not supported")]\r
+#endif \r
+       public void EndPointBind ()\r
+       {\r
+               Uri uri = new Uri ("http://www.go-mono.com/");\r
+               ServicePoint sp = ServicePointManager.FindServicePoint (uri);\r
+\r
+               HttpWebRequest req = (HttpWebRequest) WebRequest.Create (uri);\r
+\r
+               bool called = false;\r
+#if !TARGET_JVM\r
+               sp.BindIPEndPointDelegate = delegate {\r
+                       Assert.IsTrue (!called);\r
+                       called = true;\r
+                       return null;\r
+               };\r
+#endif\r
+               req.GetResponse ().Close ();\r
+\r
+               Assert.IsTrue (called);\r
+\r
+               req = (HttpWebRequest) WebRequest.Create (uri);\r
+               called = false;\r
+#if !TARGET_JVM\r
+               sp.BindIPEndPointDelegate = delegate(ServicePoint point, IPEndPoint remote, int times) {\r
+                       Assert.IsTrue (times < 5);\r
+                       called = true;\r
+                       return new IPEndPoint(IPAddress.Parse("0.0.0.0"), 12345 + times);\r
+               };\r
+#endif\r
+               req.GetResponse ().Close ();\r
+\r
+               Assert.IsTrue (called);\r
+       }\r
+#endif\r
+\r
 // Debug code not used now, but could be useful later\r
 /*\r
        private void WriteServicePoint (string label, ServicePoint sp)\r