Author: andrews
Date: 2006-11-23 10:26:32 -0500 (Thu, 23 Nov 2006)
New Revision: 68398

Added:
   
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyPageHandlerFactory.cs
   
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax
   trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx
Modified:
   trunk/mcs/class/System.Web/Makefile
   trunk/mcs/class/System.Web/System.Web_test.dll.sources
   
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/NunitWeb20.vmwcsproj
   trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/WebTest.cs
Log:
Improvements for NunitWeb test framework: instrument pages through custom 
handler factory, handle errors through Global.asax


Modified: trunk/mcs/class/System.Web/Makefile
===================================================================
--- trunk/mcs/class/System.Web/Makefile 2006-11-23 15:20:15 UTC (rev 68397)
+++ trunk/mcs/class/System.Web/Makefile 2006-11-23 15:26:32 UTC (rev 68398)
@@ -68,6 +68,8 @@
 
 OTHER_RES = $(RESOURCE_FILES_1)
 TEST_RESOURCE_FILES = \
+       Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax \
+       Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx \
        Test/mainsoft/NunitWeb/NunitWeb/Resources/My.master \
        Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx \
        Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx.cs \

Modified: trunk/mcs/class/System.Web/System.Web_test.dll.sources
===================================================================
--- trunk/mcs/class/System.Web/System.Web_test.dll.sources      2006-11-23 
15:20:15 UTC (rev 68397)
+++ trunk/mcs/class/System.Web/System.Web_test.dll.sources      2006-11-23 
15:26:32 UTC (rev 68398)
@@ -23,6 +23,7 @@
 mainsoft/NunitWeb/NunitWeb/HandlerInvoker.cs
 mainsoft/NunitWeb/NunitWeb/MyHandler.cs
 mainsoft/NunitWeb/NunitWeb/MyHost.cs
+mainsoft/NunitWeb/NunitWeb/MyPageHandlerFactory.cs
 mainsoft/NunitWeb/NunitWeb/PageDelegates.cs
 mainsoft/NunitWeb/NunitWeb/PageInvoker.cs
 mainsoft/NunitWeb/NunitWeb/PostableRequest.cs

Added: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyPageHandlerFactory.cs
===================================================================
--- 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyPageHandlerFactory.cs
  2006-11-23 15:20:15 UTC (rev 68397)
+++ 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/MyPageHandlerFactory.cs
  2006-11-23 15:26:32 UTC (rev 68398)
@@ -0,0 +1,44 @@
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoTests.SystemWeb.Framework
+{
+       class MyPageHandlerFactory : IHttpHandlerFactory
+       {
+               public virtual IHttpHandler GetHandler (HttpContext context, 
string requestType, string url, string path)
+               {
+                       IHttpHandler h = PageParser.GetCompiledPageInstance 
(url, path, context);
+                       Page p = (Page)h; //some configuration error if cannot 
cast, let it crash
+                       WebTest.CurrentTest.Invoke (p);
+                       return h;
+               }
+
+               public virtual void ReleaseHandler (IHttpHandler handler)
+               {
+               }
+       }
+
+}
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoTests.SystemWeb.Framework
+{
+       class MyPageHandlerFactory : IHttpHandlerFactory
+       {
+               public virtual IHttpHandler GetHandler (HttpContext context, 
string requestType, string url, string path)
+               {
+                       IHttpHandler h = PageParser.GetCompiledPageInstance 
(url, path, context);
+                       Page p = (Page)h; //some configuration error if cannot 
cast, let it crash
+                       WebTest.CurrentTest.Invoke (p);
+                       return h;
+               }
+
+               public virtual void ReleaseHandler (IHttpHandler handler)
+               {
+               }
+       }
+
+}

Modified: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/NunitWeb20.vmwcsproj
===================================================================
--- 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/NunitWeb20.vmwcsproj 
    2006-11-23 15:20:15 UTC (rev 68397)
+++ 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/NunitWeb20.vmwcsproj 
    2006-11-23 15:26:32 UTC (rev 68398)
@@ -1,4 +1,4 @@
-<Project DefaultTargets="Build" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
+<Project DefaultTargets="Build" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' 
">Debug_Java</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -85,6 +85,7 @@
       <Private>False</Private>
     </Reference>
     <Reference Include="System" />
+    <Reference Include="System.Configuration"/>
     <Reference Include="System.Data" />
     <Reference Include="System.Runtime.Serialization.Formatters.Soap" />
     <Reference Include="System.Web" />
@@ -112,6 +113,7 @@
     <Compile Include="BaseInvoker.cs" />
     <Compile Include="BaseRequest.cs" />
     <Compile Include="BaseWorkerRequest.cs" />
+    <Compile Include="FakeMembershipProvider.cs" />
     <Compile Include="FormRequest.cs" />
     <Compile Include="HandlerInvoker.cs" />
     <Compile Include="IForeignData.cs" />

Added: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax
===================================================================
--- 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax
    2006-11-23 15:20:15 UTC (rev 68397)
+++ 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax
    2006-11-23 15:26:32 UTC (rev 68398)
@@ -0,0 +1,72 @@
+<%@ Application Language="C#" %>
+
+<script runat="server" Language="C#">
+
+    void Application_Start(object sender, EventArgs e) 
+    {
+        // Code that runs on application startup
+    }
+    
+    void Application_End(object sender, EventArgs e) 
+    {
+        //  Code that runs on application shutdown
+    }
+        
+    void Application_Error(object sender, EventArgs e) 
+    { 
+        // Code that runs when an unhandled error occurs
+        Exception objErr = Server.GetLastError().GetBaseException();
+        MonoTests.SystemWeb.Framework.WebTest.RegisterException (objErr);
+        Server.ClearError();
+    }
+
+    void Session_Start(object sender, EventArgs e) 
+    {
+        // Code that runs when a new session is started
+    }
+
+    void Session_End(object sender, EventArgs e) 
+    {
+        // Code that runs when a session ends. 
+        // Note: The Session_End event is raised only when the sessionstate 
mode
+        // is set to InProc in the Web.config file. If session mode is set to 
StateServer 
+        // or SQLServer, the event is not raised.
+    }
+       
+</script>
+<%@ Application Language="C#" %>
+
+<script runat="server" Language="C#">
+
+    void Application_Start(object sender, EventArgs e) 
+    {
+        // Code that runs on application startup
+    }
+    
+    void Application_End(object sender, EventArgs e) 
+    {
+        //  Code that runs on application shutdown
+    }
+        
+    void Application_Error(object sender, EventArgs e) 
+    { 
+        // Code that runs when an unhandled error occurs
+        Exception objErr = Server.GetLastError().GetBaseException();
+        MonoTests.SystemWeb.Framework.WebTest.RegisterException (objErr);
+        Server.ClearError();
+    }
+
+    void Session_Start(object sender, EventArgs e) 
+    {
+        // Code that runs when a new session is started
+    }
+
+    void Session_End(object sender, EventArgs e) 
+    {
+        // Code that runs when a session ends. 
+        // Note: The Session_End event is raised only when the sessionstate 
mode
+        // is set to InProc in the Web.config file. If session mode is set to 
StateServer 
+        // or SQLServer, the event is not raised.
+    }
+       
+</script>

Added: 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx
===================================================================
--- 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx    
    2006-11-23 15:20:15 UTC (rev 68397)
+++ 
trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx    
    2006-11-23 15:26:32 UTC (rev 68398)
@@ -0,0 +1,2 @@
+<%@ WebHandler Class="MonoTests.SystemWeb.Framework.MyHandler" Language="C#" %>
+<%@ WebHandler Class="MonoTests.SystemWeb.Framework.MyHandler" Language="C#" %>

Modified: trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/WebTest.cs
===================================================================
--- trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/WebTest.cs       
2006-11-23 15:20:15 UTC (rev 68397)
+++ trunk/mcs/class/System.Web/Test/mainsoft/NunitWeb/NunitWeb/WebTest.cs       
2006-11-23 15:26:32 UTC (rev 68398)
@@ -9,10 +9,10 @@
 
 namespace MonoTests.SystemWeb.Framework
 {
-       /// <summary>
-       /// The most important class from user perspective. See <see 
cref="Request"/>,
-       /// <see cref="Response"/>, <see cref="Invoker"/>, <see cref="Run"/> for
-       /// more information.
+       /// <summary>
+       /// The most important class from user perspective. See <see 
cref="Request"/>,
+       /// <see cref="Response"/>, <see cref="Invoker"/>, <see cref="Run"/> for
+       /// more information.
        /// </summary>
        /// <seealso cref="Request"/>
        /// <seealso cref="Response"/>
@@ -22,23 +22,23 @@
        public class WebTest
        {
                object _userData;
-               /// <summary>
-               /// Any user-defined data. Must be serializable to pass between 
appdomains.
-               /// </summary>
-               /// <example>
-               /// [Test]
-               /// public void SampleTest ()
-               /// {
-               ///     WebTest t = new WebTest (new HandlerInvoker 
(MyCallback));
-               ///     t.Run ();
-               ///     Assert.AreEqual ("Was here", t.UserData.ToString());
-               /// }
-               /// 
-               /// static public void MyCallback ()
-               /// {
-               ///     WebTest.CurrentTest.UserData = "Was here";
-               /// }
-               /// </example>
+               /// <summary>
+               /// Any user-defined data. Must be serializable to pass between 
appdomains.
+               /// </summary>
+               /// <example>
+               /// [Test]
+               /// public void SampleTest ()
+               /// {
+               ///     WebTest t = new WebTest (new HandlerInvoker 
(MyCallback));
+               ///     t.Run ();
+               ///     Assert.AreEqual ("Was here", t.UserData.ToString());
+               /// }
+               /// 
+               /// static public void MyCallback ()
+               /// {
+               ///     WebTest.CurrentTest.UserData = "Was here";
+               /// }
+               /// </example>
 
                public object UserData
                {
@@ -47,9 +47,9 @@
                }
 
                Response _response;
-               /// <summary>
-               /// The result of the last <see cref="Run"/>. See <see 
cref="MonoTests.SystemWeb.Framework.Response"/>,
-               /// <see cref="FormRequest"/>.
+               /// <summary>
+               /// The result of the last <see cref="Run"/>. See <see 
cref="MonoTests.SystemWeb.Framework.Response"/>,
+               /// <see cref="FormRequest"/>.
                /// </summary>
                /// <seealso cref="Run"/>
                /// <seealso cref="MonoTests.SystemWeb.Framework.Response"/>
@@ -61,10 +61,10 @@
                }
 
                BaseInvoker _invoker;
-               /// <summary>
-               /// Set the invoker, which is executed in the web context by 
<see cref="Invoke"/>
-               /// method. Most commonly used <see cref="PageInvoker"/>. See 
also: <see cref="BaseInvoker"/>,
-               /// <see cref="HandlerInvoker"/>
+               /// <summary>
+               /// Set the invoker, which is executed in the web context by 
<see cref="Invoke"/>
+               /// method. Most commonly used <see cref="PageInvoker"/>. See 
also: <see cref="BaseInvoker"/>,
+               /// <see cref="HandlerInvoker"/>
                /// </summary>
                /// <seealso cref="Invoke"/>
                /// <seealso cref="PageInvoker"/>
@@ -77,10 +77,10 @@
                }
 
                BaseRequest _request;
-               /// <summary>
-               /// Contains all the data necessary to create an <see 
cref="System.Web.HttpWorkerRequest"/> in
-               /// the application appdomain. See also <see 
cref="BaseRequest"/>,
-               /// <see cref="PostableRequest"/>, <see cref="FormRequest"/>.
+               /// <summary>
+               /// Contains all the data necessary to create an <see 
cref="System.Web.HttpWorkerRequest"/> in
+               /// the application appdomain. See also <see 
cref="BaseRequest"/>,
+               /// <see cref="PostableRequest"/>, <see cref="FormRequest"/>.
                /// </summary>
                /// <seealso cref="System.Web.HttpWorkerRequest"/>
                /// <seealso cref="BaseRequest"/>
@@ -103,25 +103,25 @@
                                if (host != null)
                                        return host;
                                try {
-                                       host = new MyHost (); //Fake instance 
to make EnsureHosting happy
+                                       host = new MyHost (); //Fake instance 
to make EnsureHosting happy
                                        host = InitHosting ();
-
+
                                }
                                catch {
                                        host = null; //Remove the fake instance 
if CreateHosting failed
                                        throw;
-                               }
-#else
-                               host = new MyHost ();
-#endif
+                               }
+#else
+                               host = new MyHost ();
+#endif
                                return host;
                        }
                }
 
-               /// <summary>
-               /// Run the request using <see cref="Request"/> and <see 
cref="Invoker"/>
-               /// values. Keep the result of the request in <see 
cref="Response"/> property.
-               /// </summary>
+               /// <summary>
+               /// Run the request using <see cref="Request"/> and <see 
cref="Invoker"/>
+               /// values. Keep the result of the request in <see 
cref="Response"/> property.
+               /// </summary>
                /// <returns>The body of the HTTP response (<see 
cref="MonoTests.SystemWeb.Framework.Response.Body"/>).</returns>
                /// <seealso cref="Request"/>
                /// <seealso cref="Invoker"/>
@@ -144,19 +144,19 @@
                        this._userData = newTestInstance._userData;
                }
 
-               /// <summary>
-               /// The instance of the currently running test. Defined only in 
the web appdomain.
-               /// In different threads this property may have different 
values.
+               /// <summary>
+               /// The instance of the currently running test. Defined only in 
the web appdomain.
+               /// In different threads this property may have different 
values.
                /// </summary>
                public static WebTest CurrentTest
                {
                        get { return MyHost.GetCurrentTest (); }
                }
 
-               /// <summary>
-               /// This method must be called when custom <see 
cref="System.Web.IHttpHandler.ProcessRequest"/> or aspx code behind is used,
-               /// to allow the framework to invoke all user supplied 
delegates.
-               /// </summary>
+               /// <summary>
+               /// This method must be called when custom <see 
cref="System.Web.IHttpHandler.ProcessRequest"/> or aspx code behind is used,
+               /// to allow the framework to invoke all user supplied 
delegates.
+               /// </summary>
                /// <param name="param">Parameter defined by the <see 
cref="BaseInvoker"/> subclass. For example,
                /// <see cref="PageInvoker"/> expects to receive a <see 
cref="System.Web.UI.Page"/> instance here.</param>
                /// <seealso cref="System.Web.IHttpHandler.ProcessRequest"/>
@@ -171,20 +171,20 @@
                                RegisterException (ex);
                                throw;
                        }
-               }
-
-               public void SendHeaders ()
-               {
-                       Host.SendHeaders (this);
                }
 
-               /// <summary>
-               /// This method is intended for use from <see 
cref="MonoTests.SystemWeb.Framework.BaseInvoker.DoInvoke"/> when
-               /// the invocation causes an exception. In such cases, the 
exception must be registered
-               /// with this method, and then swallowed. Before returning, 
<see cref="WebTest.Run"/>
-               /// will rethrow this exception. This is done to hide the 
exception from <see cref="System.Web.HttpRuntime"/>,
-               /// which normally swallows the exception and returns 500 ERROR 
http result.
-               /// </summary>
+               public void SendHeaders ()
+               {
+                       Host.SendHeaders (this);
+               }
+
+               /// <summary>
+               /// This method is intended for use from <see 
cref="MonoTests.SystemWeb.Framework.BaseInvoker.DoInvoke"/> when
+               /// the invocation causes an exception. In such cases, the 
exception must be registered
+               /// with this method, and then swallowed. Before returning, 
<see cref="WebTest.Run"/>
+               /// will rethrow this exception. This is done to hide the 
exception from <see cref="System.Web.HttpRuntime"/>,
+               /// which normally swallows the exception and returns 500 ERROR 
http result.
+               /// </summary>
                /// <param name="ex">The exception to be registered and 
rethrown.</param>
                /// <seealso 
cref="MonoTests.SystemWeb.Framework.BaseInvoker.DoInvoke"/>
                /// <seealso cref="WebTest.Run"/>
@@ -194,13 +194,13 @@
                        Host.RegisterException (ex);
                }
 
-               /// <summary>
-               /// Unload the web appdomain and delete the temporary 
application root
-               /// directory.
+               /// <summary>
+               /// Unload the web appdomain and delete the temporary 
application root
+               /// directory.
                /// </summary>
                public static void Unload ()
                {
-#if !TARGET_JVM
+#if aaa&&  !TARGET_JVM
                        if (host == null)
                                return;
 
@@ -212,10 +212,10 @@
 #endif
                }
 
-               /// <summary>
-               /// Default constructor. Initializes <see cref="Invoker"/> with 
a new
-               /// <see cref="BaseInvoker"/> and <see cref="Request"/> with an 
empty
-               /// <see cref="BaseRequest"/>.
+               /// <summary>
+               /// Default constructor. Initializes <see cref="Invoker"/> with 
a new
+               /// <see cref="BaseInvoker"/> and <see cref="Request"/> with an 
empty
+               /// <see cref="BaseRequest"/>.
                /// </summary>
                /// <seealso cref="Invoker"/>
                /// <seealso cref="BaseInvoker"/>
@@ -227,10 +227,10 @@
                        Request = new BaseRequest ();
                }
 
-               /// <summary>
-               /// Same as <see cref="WebTest()"/>, and set <see 
cref="MonoTests.SystemWeb.Framework.BaseRequest.Url"/> to
-               /// the specified Url.
-               /// </summary>
+               /// <summary>
+               /// Same as <see cref="WebTest()"/>, and set <see 
cref="MonoTests.SystemWeb.Framework.BaseRequest.Url"/> to
+               /// the specified Url.
+               /// </summary>
                /// <param name="url">The URL used for the next <see 
cref="Run"/></param>
                /// <seealso 
cref="MonoTests.SystemWeb.Framework.BaseRequest.Url"/>
                /// <seealso cref="Run"/>
@@ -240,10 +240,10 @@
                        Request.Url = url;
                }
 
-               /// <summary>
-               /// Create a new instance, initializing <see cref="Invoker"/> 
with the given
-               /// value, and the <see cref="Request"/> with <see 
cref="BaseRequest"/>.
-               /// </summary>
+               /// <summary>
+               /// Create a new instance, initializing <see cref="Invoker"/> 
with the given
+               /// value, and the <see cref="Request"/> with <see 
cref="BaseRequest"/>.
+               /// </summary>
                /// <param name="invoker">The invoker used for this 
test.</param>
                /// <seealso cref="Invoker"/>
                /// <seealso cref="Request"/>
@@ -252,16 +252,16 @@
                        : this ()
                {
                        Invoker = invoker;
-               }
-
-               /// <summary>
-               /// Create a new instance, initializing <see cref="Request"/> 
with the given
-               /// value, and the <see cref="Invoker"/> with <see 
cref="BaseInvoker"/>.
-               /// </summary>
-               /// <param name="request">The request used for this 
test.</param>
-               /// <seealso cref="Request"/>
-               /// <seealso cref="Invoker"/>
-               /// <seealso cref="BaseInvoker"/>
+               }
+
+               /// <summary>
+               /// Create a new instance, initializing <see cref="Request"/> 
with the given
+               /// value, and the <see cref="Invoker"/> with <see 
cref="BaseInvoker"/>.
+               /// </summary>
+               /// <param name="request">The request used for this 
test.</param>
+               /// <seealso cref="Request"/>
+               /// <seealso cref="Invoker"/>
+               /// <seealso cref="BaseInvoker"/>
                public WebTest (BaseRequest request)
                        : this ()
                {
@@ -371,7 +371,7 @@
                        host.AppDomain.SetData (HOST_INSTANCE_NAME, host);
                        return host;
                }
-
+
                private static void CopyResources ()
                {
 #if VISUAL_STUDIO
@@ -418,6 +418,6 @@
                        CopyResource (typeof (WebTest), "My.master", 
"My.master");
 #endif
                }
-#endif
+#endif
        }
 }

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

Reply via email to