Author: gert
Date: 2007-02-02 01:29:26 -0500 (Fri, 02 Feb 2007)
New Revision: 72146

Modified:
   trunk/mcs/class/System/Test/System.Net/ChangeLog
   trunk/mcs/class/System/Test/System.Net/FileWebRequestTest.cs
Log:
* FileWebRequestTest.cs: Separate tests that fail on Windows due to
bug #80700, and ignore them on Windows.


Modified: trunk/mcs/class/System/Test/System.Net/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.Net/ChangeLog    2007-02-01 23:40:10 UTC 
(rev 72145)
+++ trunk/mcs/class/System/Test/System.Net/ChangeLog    2007-02-02 06:29:26 UTC 
(rev 72146)
@@ -1,3 +1,8 @@
+2007-02-02  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * FileWebRequestTest.cs: Separate tests that fail on Windows due to
+       bug #80700, and ignore them on Windows.
+
 2007-02-01  Gert Driesen  <[EMAIL PROTECTED]>
 
        * WebProxyTest.cs: Added tests that cover regression introduced by

Modified: trunk/mcs/class/System/Test/System.Net/FileWebRequestTest.cs
===================================================================
--- trunk/mcs/class/System/Test/System.Net/FileWebRequestTest.cs        
2007-02-01 23:40:10 UTC (rev 72145)
+++ trunk/mcs/class/System/Test/System.Net/FileWebRequestTest.cs        
2007-02-02 06:29:26 UTC (rev 72146)
@@ -54,18 +54,11 @@
                [TearDown]
                public void TearDown ()
                {
-                       if (Directory.Exists (_tempDirectory)) {
-                               string [] files = Directory.GetFiles 
(_tempDirectory, "*");
-                               foreach (string file in files)
-                                       File.Delete (file);
+                       if (Directory.Exists (_tempDirectory))
                                Directory.Delete (_tempDirectory, true);
-                       }
                }
 
                [Test]
-#if TARGET_JVM
-               [Ignore ("Bug in resource releasing - cannot delete file")]
-#endif
                public void Async ()
                {
                        WebResponse res = null;
@@ -94,33 +87,19 @@
                                        // a previous call is still in progress
                                }
 
-                               try {
-                                       req.GetResponse ();
-                                       Assert.Fail ("#4 should've failed");
-                               } catch (WebException) {
-                                       // The operation has timed out
-                               }
+                               using (Stream wstream = req.EndGetRequestStream 
(async)) {
+                                       Assert.IsFalse (wstream.CanRead, "#1r");
+                                       Assert.IsTrue (wstream.CanWrite, "#1w");
+                                       Assert.IsTrue (wstream.CanSeek, "#1s");
 
-                               try {
-                                       req.BeginGetResponse (null, null);
-                                       Assert.Fail ("#5 should've failed");
-                               } catch (InvalidOperationException) {
-                                       // Cannot re-call 
BeginGetRequestStream/BeginGetResponse while
-                                       // a previous call is still in progress
+                                       wstream.WriteByte (72);
+                                       wstream.WriteByte (101);
+                                       wstream.WriteByte (108);
+                                       wstream.WriteByte (108);
+                                       wstream.WriteByte (111);
+                                       wstream.Close ();
                                }
 
-                               Stream wstream = req.EndGetRequestStream 
(async);
-                               Assert.IsFalse (wstream.CanRead, "#1r");
-                               Assert.IsTrue (wstream.CanWrite, "#1w");
-                               Assert.IsTrue (wstream.CanSeek, "#1s");
-
-                               wstream.WriteByte (72);
-                               wstream.WriteByte (101);
-                               wstream.WriteByte (108);
-                               wstream.WriteByte (108);
-                               wstream.WriteByte (111);
-                               wstream.Close ();
-
                                Assert.AreEqual (1, req.ContentLength, "#1cl");
                                Assert.AreEqual ("image/png", req.ContentType, 
"#1ct");
 
@@ -192,6 +171,42 @@
                }
 
                [Test]
+               public void Async_GetResponse_Failure ()
+               {
+                       if (!RunningOnUnix)
+                               Assert.Ignore ("bug #80700");
+
+                       FileWebRequest req = (FileWebRequest) WebRequest.Create 
(_tempFileUri);
+                       req.Method = "PUT";
+                       req.ContentLength = 1;
+                       req.ContentType = "image/png";
+                       req.Timeout = 500;
+
+                       IAsyncResult async = req.BeginGetRequestStream (null, 
null);
+                       try {
+                               req.GetResponse ();
+                               Assert.Fail ("#1");
+                       } catch (WebException) {
+                               // The operation has timed out
+                       }
+
+                       try {
+                               req.BeginGetResponse (null, null);
+                               Assert.Fail ("#2");
+                       } catch (InvalidOperationException) {
+                               // Cannot re-call 
BeginGetRequestStream/BeginGetResponse while
+                               // a previous call is still in progress
+                       }
+
+                       using (Stream wstream = req.EndGetRequestStream 
(async)) {
+                               wstream.WriteByte (72);
+                       }
+
+                       // the temp file should not be in use
+                       Directory.Delete (_tempDirectory, true);
+               }
+
+               [Test]
                public void Sync ()
                {
                        WebResponse res = null;
@@ -268,6 +283,39 @@
                }
 
                [Test]
+               public void Sync_GetResponse_Failure ()
+               {
+                       if (!RunningOnUnix)
+                               Assert.Ignore ("bug #80700");
+
+                       FileWebRequest req = (FileWebRequest) WebRequest.Create 
(_tempFileUri);
+                       req.Method = "PUT";
+                       req.ContentLength = 1;
+                       req.ContentType = "image/png";
+                       req.Timeout = 500;
+
+                       using (Stream rs = req.GetRequestStream ()) {
+                               try {
+                                       req.GetResponse ();
+                                       Assert.Fail ("#1");
+                               } catch (WebException) {
+                                       // The operation has timed out
+                               }
+
+                               try {
+                                       req.BeginGetResponse (null, null);
+                                       Assert.Fail ("#2");
+                               } catch (InvalidOperationException) {
+                                       // Cannot re-call 
BeginGetRequestStream/BeginGetResponse while
+                                       // a previous call is still in progress
+                               }
+                       }
+
+                       // the temp file should not be in use
+                       Directory.Delete (_tempDirectory, true);
+               }
+
+               [Test]
                public void ConnectionGroupName ()
                {
                        FileWebRequest req = (FileWebRequest) WebRequest.Create 
(_tempFileUri);
@@ -846,9 +894,9 @@
         
         private bool RunningOnUnix {
                        get {
-                Type t = Type.GetType("java.lang.System");
-                MethodInfo mi = t.GetMethod("getProperty", new Type[] { 
typeof(string) });
-                string osName = (string) mi.Invoke(null, new object[] { 
"os.name" });
+                               Type t = Type.GetType("java.lang.System");
+                               MethodInfo mi = t.GetMethod("getProperty", new 
Type[] { typeof(string) });
+                               string osName = (string) mi.Invoke(null, new 
object[] { "os.name" });
                                
                                if(osName == null) {
                                        return false;

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

Reply via email to