Fix failing tests on .net
authorMarek Safar <marek.safar@gmail.com>
Wed, 7 Dec 2011 10:21:20 +0000 (10:21 +0000)
committerMarek Safar <marek.safar@gmail.com>
Wed, 7 Dec 2011 18:34:26 +0000 (18:34 +0000)
mcs/class/System/Test/System.Net/HttpListener2Test.cs
mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs
mcs/class/System/Test/System.Net/HttpWebRequestTest.cs

index 2848644fb3fa9a22844680aa581f8e88dea2d1fd..f519c3fb1c1b305961da2df60c364a9a7a86d7a2 100644 (file)
@@ -26,7 +26,7 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
+
 using System;
 using System.Collections.Generic;
 using System.Globalization;
@@ -738,5 +738,3 @@ namespace MonoTests.System.Net {
                }
        }
 }
-#endif
-
index 95dc3d2472be22725ae46faf9c6bacd2576e45b4..ce90511e115f3dc7fd67275b45770a1b5d2f745b 100644 (file)
@@ -26,8 +26,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 using System;
 using System.IO;
 using System.Net;
@@ -160,21 +158,19 @@ namespace MonoTests.System.Net
                        Assert.AreEqual ("pOsT", request.HttpMethod);
                        listener.Close ();
                }
-               
+
                [Test]
-               public void HttpBasicAuthScheme()
-               {
-                       HttpListener listener = HttpListener2Test.CreateAndStartListener("http://*:9000/authTest/", AuthenticationSchemes.Basic);
-                       //dummy-wait for context
-                       listener.BeginGetContext(null, listener);
-                       NetworkStream ns = HttpListener2Test.CreateNS(9000);
-                       HttpListener2Test.Send(ns, "GET /authTest/ HTTP/1.0\r\n\r\n");
-                       String response = HttpListener2Test.Receive(ns, 512);
-                       Assert.IsTrue(response.Contains("WWW-Authenticate: Basic realm"), "#A");
-                       ns.Close();
-                       listener.Close();
-               }
+               public void HttpBasicAuthScheme ()
+               {
+                       HttpListener listener = HttpListener2Test.CreateAndStartListener ("http://*:9000/authTest/", AuthenticationSchemes.Basic);
+                       //dummy-wait for context
+                       listener.BeginGetContext (null, listener);
+                       NetworkStream ns = HttpListener2Test.CreateNS (9000);
+                       HttpListener2Test.Send (ns, "GET /authTest/ HTTP/1.0\r\n\r\n");
+                       String response = HttpListener2Test.Receive (ns, 512);
+                       Assert.IsTrue (response.Contains ("WWW-Authenticate: Basic realm"), "#A");
+                       ns.Close ();
+                       listener.Close ();
+               }
        }
 }
-
-#endif
index 589eea95f53b1be68c1439e47e9c6b62daaa39dc..a61cbb49319289ab015448fed104a3019e6e22fe 100644 (file)
@@ -396,6 +396,7 @@ namespace MonoTests.System.Net
                                req.SendChunked = true;
                                req.KeepAlive = false;
                                req.AllowWriteStreamBuffering = false;
+                               req.GetRequestStream ().WriteByte (1);
                                req.BeginGetResponse (null, null);
                                req.Abort ();
 
@@ -405,6 +406,7 @@ namespace MonoTests.System.Net
                                req.SendChunked = false;
                                req.KeepAlive = false;
                                req.AllowWriteStreamBuffering = false;
+                               req.GetRequestStream ().WriteByte (5);
                                req.BeginGetResponse (null, null);
                                req.Abort ();
 
@@ -2277,6 +2279,15 @@ namespace MonoTests.System.Net
                        req.Host = "go-mono.com:65536";
                }
 
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void HostTooLong ()
+               {
+                       HttpWebRequest req = (HttpWebRequest) WebRequest.Create ("http://go-mono.com");
+                       string s = new string ('a', 100);
+                       req.Host = s + "." + s + "." + s + "." + s + "." + s + "." + s; // Over 255 bytes
+               }
+
                [Test]
                public void InvalidNamesThatWork ()
                {
@@ -2285,8 +2296,6 @@ namespace MonoTests.System.Net
                        req.Host = "-.-";
                        req.Host = "รก";
                        req.Host = new string ('a', 64); // Should fail. Max. is 63.
-                       string s = new string ('a', 100);
-                       req.Host = s + "." + s + "." + s + "." + s + "." + s + "." + s; // Over 255 bytes
                }
 
                [Test]