Tests
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Fri, 26 Aug 2005 22:55:59 +0000 (22:55 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Fri, 26 Aug 2005 22:55:59 +0000 (22:55 -0000)
svn path=/trunk/mcs/; revision=48942

28 files changed:
mcs/class/System.Web/Test/System.Web.UI.WebControls/HyperLinkColumnTest.cs [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/adrotator/adrotator-adcreated.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/adrotator/adrotator-defaults.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/adrotator/adrotator-fileerror.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/adrotator/adrotator-filenull.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/adrotator/adrotator-filter.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/adrotator/ads-error.xml [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/adrotator/ads.xml [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/adrotator/adsplus.xml [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/htmlanchor/htmlanchor1.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/htmlimage/htmlimage1.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/htmlinputfile/htmlinputfile.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/httprequest/saverequest.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t5.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t5.expected [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t5.oexpected [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t6.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t6.expected [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t6.oexpected [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t7.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t7.expected [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/response/t7.oexpected [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/timeout/index.aspx [new file with mode: 0644]
mcs/class/System.Web/Test/standalone/timeout/web.config [new file with mode: 0644]
mcs/class/System.Web/Test/tools/HtmlWriter.cs [new file with mode: 0644]
mcs/class/System.Web/Test/tools/Makefile [new file with mode: 0644]
mcs/class/System.Web/Test/tools/README [new file with mode: 0644]
mcs/class/System.Web/Test/tools/web.config [new file with mode: 0644]

diff --git a/mcs/class/System.Web/Test/System.Web.UI.WebControls/HyperLinkColumnTest.cs b/mcs/class/System.Web/Test/System.Web.UI.WebControls/HyperLinkColumnTest.cs
new file mode 100644 (file)
index 0000000..98277db
--- /dev/null
@@ -0,0 +1,152 @@
+//
+// PagedDataSourceTest.cs
+//
+// Author: Duncan Mak (duncan@novell.com)
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+using System;
+using System.Collections;
+using System.Diagnostics;
+using System.Web.UI.WebControls;
+
+namespace MonoTests.System.Web.UI.WebControls {
+
+       [TestFixture]
+       public class HyperLinkColumnTest {
+
+               [Test]
+               public void SetUpTest ()
+               {
+                       HyperLinkColumn column = new HyperLinkColumn ();
+                       Assert.AreEqual (String.Empty, column.DataNavigateUrlField, "#1");
+                       Assert.AreEqual (String.Empty, column.DataTextField, "2");
+                       Assert.AreEqual (String.Empty, column.DataTextFormatString, "#3");
+                       Assert.AreEqual (String.Empty, column.NavigateUrl, "#4");                       
+                       Assert.AreEqual (String.Empty, column.Target, "#5");
+                       Assert.AreEqual (String.Empty, column.Text, "#6");
+               }
+
+               [Test]
+               public void DataNavigateUrlFieldTest ()
+               {
+                       HyperLinkColumn column = new HyperLinkColumn ();
+                       string foo = "foo";
+                       string bar = "bar";
+
+                       column.NavigateUrl = foo;
+                       Assert.AreEqual (foo, column.NavigateUrl, "#1");
+
+                       // Test the bit about DataNavigateUrlField having precedence over NavigateUrl
+                       column.DataNavigateUrlField = bar;
+                       Assert.AreEqual (bar, column.DataNavigateUrlField, "#2");
+                       // what does this mean? shouldn't NavigateUrl be "bar" now?
+                       Assert.AreEqual (foo, column.NavigateUrl, "#3"); 
+               }
+
+               public class MyColumn : HyperLinkColumn {
+                       public string FormatUrl (object input)
+                       {
+                               return FormatDataNavigateUrlValue (input);
+                       }
+
+                       public string FormatText (object input)
+                       {
+                               return FormatDataTextValue (input);
+                       }
+
+                       public void InitCell (TableCell cell, int column_index, ListItemType item_type)
+                       {
+                         base.InitializeCell (cell, column_index, item_type);
+                       }
+               }
+
+               [Test]
+               public void FormatTest ()
+               {
+                       MyColumn column = new MyColumn ();
+                       column.DataNavigateUrlFormatString = "!{0}!";
+                       Assert.AreEqual (String.Empty, column.FormatUrl (null), "#1");
+                       Assert.AreEqual ("!foo!", column.FormatUrl ("foo"), "#2");
+
+                       column.DataTextFormatString = "!{0}!";
+                       Assert.AreEqual (String.Empty, column.FormatText (null), "#3");
+                       Assert.AreEqual ("!foo!", column.FormatText ("foo"), "#4");
+               }
+
+               [Test]
+               public void InitCellTest ()
+               {
+                       MyColumn column;
+                       TableCell cell;
+
+                       /* test that for Header it just sets the cell.Text to HeaderText */
+                       column = new MyColumn();
+                       cell = new TableCell();
+                       column.HeaderText = "This is a Header";
+                       column.InitCell (cell, 0, ListItemType.Header);
+
+                       Assert.AreEqual ("This is a Header", cell.Text, "#1");
+
+                       /* test that for Item it adds a HyperLinkControl */
+                       column = new MyColumn();
+                       cell = new TableCell();
+                       column.NavigateUrl = "http://www.novell.com/";
+                       column.Text = "Novell.com";
+                       column.InitCell (cell, 0, ListItemType.Item);
+
+                       Assert.AreEqual (1, cell.Controls.Count, "#2");
+                       Assert.IsTrue (cell.Controls[0] is HyperLink, "#3");
+
+                       /* test that for EditItem it adds a HyperLinkControl */
+                       column = new MyColumn();
+                       cell = new TableCell();
+                       column.NavigateUrl = "http://www.novell.com/";
+                       column.Text = "Novell.com";
+                       column.InitCell (cell, 0, ListItemType.EditItem);
+
+                       Assert.AreEqual (1, cell.Controls.Count, "#4");
+                       Assert.IsTrue (cell.Controls[0] is HyperLink, "#5");
+
+                       /* test that for AlternatingItem it adds a HyperLinkControl */
+                       column = new MyColumn();
+                       cell = new TableCell();
+                       column.NavigateUrl = "http://www.novell.com/";
+                       column.Text = "Novell.com";
+                       column.InitCell (cell, 0, ListItemType.AlternatingItem);
+
+                       Assert.AreEqual (1, cell.Controls.Count, "#6");
+                       Assert.IsTrue (cell.Controls[0] is HyperLink, "#7");
+
+                       /* test that for Footer it just sets the cell.Text to FooterText */
+                       column = new MyColumn();
+                       cell = new TableCell();
+                       column.FooterText = "This is a Footer";
+                       column.InitCell (cell, 0, ListItemType.Footer);
+
+                       Assert.AreEqual ("This is a Footer", cell.Text, "#8");
+               }
+
+       }
+}
diff --git a/mcs/class/System.Web/Test/standalone/adrotator/adrotator-adcreated.aspx b/mcs/class/System.Web/Test/standalone/adrotator/adrotator-adcreated.aspx
new file mode 100644 (file)
index 0000000..44f73d2
--- /dev/null
@@ -0,0 +1,51 @@
+<%@ Page Language="C#" Debug="true" %>
+<%@ Import namespace="System.Collections" %>
+<%@ Import namespace="System.Text" %>
+<html>
+<script runat="server">
+       void Create1 (object sender, AdCreatedEventArgs args)
+       {
+               label1.Text = GetArgsData (args);
+       }
+
+       void Create2 (object sender, AdCreatedEventArgs args)
+       {
+               label2.Text = GetArgsData (args);
+       }
+
+       string GetArgsData (AdCreatedEventArgs args)
+       {
+               StringBuilder sb = new StringBuilder ();
+               sb.AppendFormat ("ImageUrl: {0}<br>", args.ImageUrl);
+               sb.AppendFormat ("NavigateUrl: {0}<br>", args.NavigateUrl);
+               sb.AppendFormat ("AlternateText: {0}<br>", args.AlternateText);
+               sb.Append ("AdProperties:<br><div style='margin-left: 80px;'>");
+               foreach (DictionaryEntry entry in args.AdProperties)
+                       sb.AppendFormat (" {0}: {1}<br>", entry.Key, entry.Value);
+               sb.Append ("</div>");
+               return sb.ToString ();
+       }
+
+</script>
+<body>
+Testing 2 source files, 2 ad rotators. One does not change 'cause it uses a filter.
+It will also show the properties passed to the AdCreated event.<br>
+<form runat="server">
+<asp:button Text="Click me" runat="server" />
+<hr>
+This should rotate:<br>
+<asp:adrotator runat="server" id="ar1"  AdvertisementFile="ads.xml"
+                                       OnAdCreated="Create1" />
+<br>
+<asp:Label id="label1" runat="server" />
+<hr>
+This should always be novell:<br>
+<asp:adrotator runat="server" id="ar2"  KeywordFilter="novell"
+                                       AdvertisementFile="adsplus.xml"
+                                       OnAdCreated="Create2" />
+<br>
+<asp:Label id="label2" runat="server" />
+</form>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/adrotator/adrotator-defaults.aspx b/mcs/class/System.Web/Test/standalone/adrotator/adrotator-defaults.aspx
new file mode 100644 (file)
index 0000000..12fe9d7
--- /dev/null
@@ -0,0 +1,77 @@
+<%@ Page Language="C#" Debug="true" %>
+<html>
+<script runat="server">
+// Output:
+//Version: 1.1.4322.2032
+//Default AdvertisementFile -> '' (null? False)
+//Default Target -> '_top' (null? False)
+//Default KeywordFilter -> '' (null? False)
+//Type of Controls -> 'System.Web.UI.EmptyControlCollection'
+//Number of Controls before adding literal -> '0'
+//Number of Controls -> '0'
+// <hr>
+//Count: 0
+// <hr>
+//Count: 1
+//Target: pepe
+
+       void Page_Load ()
+       {
+               label.Text = String.Format ("Version: {0}<br>", Environment.Version);
+               AdRotator ar = new AdRotator ();
+               // Empty
+               label.Text += String.Format ("Default AdvertisementFile -> '{0}' (null? {1})", ar.AdvertisementFile, ar.AdvertisementFile == null);
+               label.Text += "<br>";
+               // "_top"
+               label.Text += String.Format ("Default Target -> '{0}' (null? {1})", ar.Target, ar.Target == null);
+               label.Text += "<br>";
+               // Empty
+               label.Text += String.Format ("Default KeywordFilter -> '{0}' (null? {1})", ar.KeywordFilter, ar.KeywordFilter == null);
+
+               label.Text += "<br>";
+               // EmptyControlCollection (on 2.0 is a ControlCollection)
+               label.Text += String.Format ("Type of Controls -> '{0}'<br>", ar.Controls.GetType ());
+               // 0
+               label.Text += String.Format ("Number of Controls before adding literal -> '{0}'<br>", ar.Controls.Count);
+               // Next line throws in 1.1, works fine under 2.0
+               //ar.Controls.Add (new LiteralControl ("Hi there"));
+               label.Text += String.Format ("Number of Controls -> '{0}'", ar.Controls.Count);
+               //panel.Controls.Add (ar);
+
+               // Viewstate
+               MyRotator myr = new MyRotator ();
+               label.Text += "<hr>";
+               label.Text += myr.GetVSItems ();
+               myr.Target = "pepe";
+               myr.AdvertisementFile = "ads.xml";
+               //myr.KeywordFilter = "filterthis";
+               label.Text += "<hr>";
+               label.Text += myr.GetVSItems ();
+               panel.Controls.Add (myr);
+
+       }
+
+       class MyRotator : AdRotator {
+               public string GetVSItems ()
+               {
+                       StringBuilder sb = new StringBuilder ();
+                       sb.AppendFormat ("Count: {0}<br>", ViewState.Count);
+                       foreach (string o in ViewState.Keys) {
+                               sb.AppendFormat ("{0}: {1}<br>", o, ViewState [o]);
+                       }
+
+                       return sb.ToString ();
+               }
+       }
+
+</script>
+<body>
+This test shows default property values.
+<br>
+<asp:Label runat="server" id="label" />
+<hr>
+<asp:Panel runat="server" id="panel" />
+<hr>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/adrotator/adrotator-fileerror.aspx b/mcs/class/System.Web/Test/standalone/adrotator/adrotator-fileerror.aspx
new file mode 100644 (file)
index 0000000..5046c2d
--- /dev/null
@@ -0,0 +1,10 @@
+<%@ Page Language="C#" Debug="true" %>
+<html>
+<body>
+<form runat="server">
+This should throw an error that does NOT show the real path to the file:<br>
+<asp:adrotator runat="server" id="ar1"  AdvertisementFile="ads-error.xml" />
+</form>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/adrotator/adrotator-filenull.aspx b/mcs/class/System.Web/Test/standalone/adrotator/adrotator-filenull.aspx
new file mode 100644 (file)
index 0000000..dba2c7d
--- /dev/null
@@ -0,0 +1,20 @@
+<%@ Page Language="C#" Debug="true" %>
+<%@ Import namespace="System.Collections" %>
+<%@ Import namespace="System.Text" %>
+<html>
+<script runat="server">
+       void Page_Load ()
+       {
+               ar1.AdvertisementFile = null;
+       }
+</script>
+<body>
+Setting AdvertisementFile to null in Page_Load. Should display a broken img.
+It used to crash.
+<br>
+<form runat="server">
+<asp:adrotator runat="server" id="ar1" />
+</form>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/adrotator/adrotator-filter.aspx b/mcs/class/System.Web/Test/standalone/adrotator/adrotator-filter.aspx
new file mode 100644 (file)
index 0000000..bfe4531
--- /dev/null
@@ -0,0 +1,16 @@
+<%@ Page Language="C#" Debug="true" %>
+<html>
+<body>
+<form runat="server">
+<asp:button Text="Click me" runat="server" />
+<hr>
+This should rotate:<br>
+<asp:adrotator runat="server" id="ar1"  AdvertisementFile="ads.xml" />
+<hr>
+This should always be novell:<br>
+<asp:adrotator runat="server" id="ar2"  KeywordFilter="novell"
+                                       AdvertisementFile="ads.xml" />
+</form>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/adrotator/ads-error.xml b/mcs/class/System.Web/Test/standalone/adrotator/ads-error.xml
new file mode 100644 (file)
index 0000000..3661dcf
--- /dev/null
@@ -0,0 +1,8 @@
+<Advertisements>
+<Ad>
+       <ImageUrl>~/images/someimage.jpg</ImageUrl>
+       <NavigateUrl>http://www.novell.com</NavigateUrl>
+       <AlternateText>Novell</AlternateText>
+       <Impressions>80</Impressions>
+       <Keyword>novell</Keyword>
+</Ad>
diff --git a/mcs/class/System.Web/Test/standalone/adrotator/ads.xml b/mcs/class/System.Web/Test/standalone/adrotator/ads.xml
new file mode 100644 (file)
index 0000000..0c9775f
--- /dev/null
@@ -0,0 +1,23 @@
+<Advertisements>
+<Ad>
+       <ImageUrl>~/images/someimage.jpg</ImageUrl>
+       <NavigateUrl>http://www.novell.com</NavigateUrl>
+       <AlternateText>Novell</AlternateText>
+       <Impressions>80</Impressions>
+       <Keyword>novell</Keyword>
+</Ad>
+<Ad>
+       <ImageUrl>~/images/google.jpg</ImageUrl>
+       <NavigateUrl>http://www.google.com</NavigateUrl>
+       <AlternateText>Google</AlternateText>
+       <Impressions>80</Impressions>
+       <Keyword>google</Keyword>
+</Ad>
+<Ad>
+       <ImageUrl>~/images/ibm.jpg</ImageUrl>
+       <NavigateUrl>http://www.ibm.com</NavigateUrl>
+       <AlternateText>IBM</AlternateText>
+       <Impressions>80</Impressions>
+       <Keyword>IBM</Keyword>
+</Ad>
+</Advertisements>
diff --git a/mcs/class/System.Web/Test/standalone/adrotator/adsplus.xml b/mcs/class/System.Web/Test/standalone/adrotator/adsplus.xml
new file mode 100644 (file)
index 0000000..68b4235
--- /dev/null
@@ -0,0 +1,24 @@
+<Advertisements>
+<Ad>
+       <ImageUrl>~/images/someimage.jpg</ImageUrl>
+       <NavigateUrl>http://www.novell.com</NavigateUrl>
+       <AlternateText>Novell</AlternateText>
+       <Impressions>80</Impressions>
+       <Keyword>novell</Keyword>
+       <randomtag>Hola</randomtag>
+</Ad>
+<Ad>
+       <ImageUrl>~/images/google.jpg</ImageUrl>
+       <NavigateUrl>http://www.google.com</NavigateUrl>
+       <AlternateText>Google</AlternateText>
+       <Impressions>80</Impressions>
+       <Keyword>google</Keyword>
+</Ad>
+<Ad>
+       <ImageUrl>~/images/ibm.jpg</ImageUrl>
+       <NavigateUrl>http://www.ibm.com</NavigateUrl>
+       <AlternateText>IBM</AlternateText>
+       <Impressions>80</Impressions>
+       <Keyword>IBM</Keyword>
+</Ad>
+</Advertisements>
diff --git a/mcs/class/System.Web/Test/standalone/htmlanchor/htmlanchor1.aspx b/mcs/class/System.Web/Test/standalone/htmlanchor/htmlanchor1.aspx
new file mode 100644 (file)
index 0000000..6c1fcf1
--- /dev/null
@@ -0,0 +1,9 @@
+<%@ Page Language="C#" Debug="true" %>
+<html>
+<body>
+Actual: "<%=anchor1.HRef%>", Expected "~/otherfile.txt" (not resolved)<br>
+<a id="anchor1" runat="server" href="~/otherfile.txt">This link should point at <%= ResolveUrl ("~/otherfile.txt") %></a>
+<br>Actual: "<%=anchor1.HRef%>", Expected "" (empty)<br>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/htmlimage/htmlimage1.aspx b/mcs/class/System.Web/Test/standalone/htmlimage/htmlimage1.aspx
new file mode 100644 (file)
index 0000000..5c4302d
--- /dev/null
@@ -0,0 +1,36 @@
+<%@ Page Language="C#" %>
+<html>
+<head>
+ </head>
+<script language="javascript" type="text/javascript">
+function get_elem(id) {
+       return (document.getElementById) ? document.getElementById (id) :
+                                       ((document.all) ? document.all [id] : null);
+}
+
+function check_src () {
+       var elem = get_elem ("imagen");
+       if (elem) {
+               var out_come = get_elem ("outcome");
+               if (elem.src.indexOf("~/img.jpg") != -1) {
+                       out_come.innerHTML = "Test failed: " + elem.src;
+                       out_come.className = "failed";
+               } else {
+                       out_come.innerHTML = "Test passed: " + elem.src;
+                       out_come.className = "passed";
+               }
+       }
+}
+</script>
+<style type="text/css" media="screen">
+<!--
+  .passed { background-color: green; color: white;}
+  .failed { background-color: red; color: white;}
+-->
+</style>
+ <body onload="check_src()">
+<img id ="imagen" src="~/img.jpg" Alt="Image 1" runat="server" />
+<div id="outcome" class="">Default text. Should not be seen.</div>
+ </body>
+ </html>
+
diff --git a/mcs/class/System.Web/Test/standalone/htmlinputfile/htmlinputfile.aspx b/mcs/class/System.Web/Test/standalone/htmlinputfile/htmlinputfile.aspx
new file mode 100644 (file)
index 0000000..45093ab
--- /dev/null
@@ -0,0 +1,28 @@
+<%@ Page Language="C#" %>
+<html>
+<script runat=server>
+       void Page_Load ()
+       {
+               if (!IsPostBack)
+                       return;
+
+               HttpFileCollection Files = Request.Files;
+               string [] names = Files.AllKeys;
+               for (int i = 0; i < names.Length; i++) {
+                       Files [i].SaveAs ("FILE" + i);
+               }
+       }
+</script>
+<title>HtmlInputFile</title>
+<body>
+This should save the file you upload in the server as 'FILE0'. <br/>
+<form id="myForm" name="myform" method="post" runat="server">
+Pick a file:
+<input id="myFile" type="file" runat="server"> 
+<br>
+<asp:Button id="btn" Text="Go send it!" runat="server" />
+<asp:TextBox Columns="2" MaxLength="3" Text="1" runat="server"/>
+</form>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/httprequest/saverequest.aspx b/mcs/class/System.Web/Test/standalone/httprequest/saverequest.aspx
new file mode 100644 (file)
index 0000000..09c574f
--- /dev/null
@@ -0,0 +1,42 @@
+<% @Page language="c#" debug="true"%>
+<html>
+<script runat="server">
+       void Page_Load ()
+       {
+               // If the request is a GET, SaveAs fails with a socket error
+               // trying to get the InputStream from the request.
+               // XSPWorkerRequest.ReadEntityBody is called too
+               if (!IsPostBack)
+                       return;
+
+               // Files as overwritten if they exist.
+               Request.SaveAs ("request.txt", false);
+               Request.SaveAs ("request-headers.txt", true);
+       }
+</script>
+<body>
+<form runat="server">
+<asp:Button Text="click me" runat="server" />
+</form>
+</body>
+</html>
+<!--
+request.txt:
+__VIEWSTATE=dDwtMTk5NjUxNzkxMzs7PmyYDeLoOgzCSqBwtACVA7RAWyBP&_ctl1=click+me
+
+request-headers.txt:
+POST /saverequest.aspx?test=t HTTP/1.0
+Connection: keep-alive
+Keep-Alive: 300
+Content-Length: 75
+Content-Type: application/x-www-form-urlencoded
+Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
+Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
+Accept-Encoding: gzip,deflate
+Accept-Language: en-us,en;q=0.5
+Host: 127.0.0.1:8080
+Referer: http://127.0.0.1:8080/saverequest.aspx?test=t
+User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
+
+__VIEWSTATE=dDwtMTk5NjUxNzkxMzs7PmyYDeLoOgzCSqBwtACVA7RAWyBP&_ctl1=click+me
+-->
diff --git a/mcs/class/System.Web/Test/standalone/response/t5.aspx b/mcs/class/System.Web/Test/standalone/response/t5.aspx
new file mode 100644 (file)
index 0000000..d77658d
--- /dev/null
@@ -0,0 +1,27 @@
+<%@ Page language="c#" debug="true" %>
+<html>
+<script runat="server">
+       void Page_Load (Object sender,EventArgs e) 
+       {
+               try {
+                       HttpResponse.RemoveOutputCacheItem (null);
+                       throw new Exception ("#01");
+               } catch (ArgumentNullException) {}
+
+               HttpResponse.RemoveOutputCacheItem ("");
+               HttpResponse.RemoveOutputCacheItem ("/");
+               try {
+                       HttpResponse.RemoveOutputCacheItem ("a");
+                       throw new Exception ("#02");
+               } catch (ArgumentException) {}
+
+               HttpResponse.RemoveOutputCacheItem ("/../hola");
+               Response.Clear ();
+               Response.Write ("OK");
+               Response.End ();
+       }
+</script>
+<body>
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/response/t5.expected b/mcs/class/System.Web/Test/standalone/response/t5.expected
new file mode 100644 (file)
index 0000000..a0aba93
--- /dev/null
@@ -0,0 +1 @@
+OK
\ No newline at end of file
diff --git a/mcs/class/System.Web/Test/standalone/response/t5.oexpected b/mcs/class/System.Web/Test/standalone/response/t5.oexpected
new file mode 100644 (file)
index 0000000..d86bac9
--- /dev/null
@@ -0,0 +1 @@
+OK
diff --git a/mcs/class/System.Web/Test/standalone/response/t6.aspx b/mcs/class/System.Web/Test/standalone/response/t6.aspx
new file mode 100644 (file)
index 0000000..9f39747
--- /dev/null
@@ -0,0 +1,27 @@
+<%@ Page language="c#" debug="true"%>
+<html>
+<script runat="server">
+       void Page_Load (Object sender,EventArgs e) 
+       {
+               string browser = Context.ApplicationInstance.GetVaryByCustomString (Context, "browser");
+               if (browser == null)
+                       throw new Exception ("B1");
+
+               try {
+                       browser = Context.ApplicationInstance.GetVaryByCustomString (null, null);
+                       throw new Exception ("B2");
+               } catch (NullReferenceException) {
+               }
+
+               browser = Context.ApplicationInstance.GetVaryByCustomString (Context, "custom");
+               if (browser != null)
+                       throw new Exception ("B3");
+
+               Response.Clear ();
+               Response.Write ("OK");
+               Response.End ();
+       }
+</script>
+<body>
+</body>
+</html>
diff --git a/mcs/class/System.Web/Test/standalone/response/t6.expected b/mcs/class/System.Web/Test/standalone/response/t6.expected
new file mode 100644 (file)
index 0000000..a0aba93
--- /dev/null
@@ -0,0 +1 @@
+OK
\ No newline at end of file
diff --git a/mcs/class/System.Web/Test/standalone/response/t6.oexpected b/mcs/class/System.Web/Test/standalone/response/t6.oexpected
new file mode 100644 (file)
index 0000000..d86bac9
--- /dev/null
@@ -0,0 +1 @@
+OK
diff --git a/mcs/class/System.Web/Test/standalone/response/t7.aspx b/mcs/class/System.Web/Test/standalone/response/t7.aspx
new file mode 100644 (file)
index 0000000..e9dce16
--- /dev/null
@@ -0,0 +1,53 @@
+<%@ Page language="c#" debug="true"%>
+<html>
+<script runat="server">
+       void Page_Load (Object sender,EventArgs e) 
+       {
+               Context.RewritePath ("rewrite_next.aspx?hola=pepe");        
+               string vpath = HttpRuntime.AppDomainAppVirtualPath;
+               if (vpath.EndsWith ("/"))
+                       vpath = vpath.Substring (0, vpath.Length - 1);
+
+               /* This one fails with IIS on /test but works with xsp on '/'
+               if (Request.FilePath != vpath + "/rewrite_next.aspx")
+                       throw new Exception ("#01" + " " + vpath + " " + Request.FilePath);
+               */
+
+               if (Request.QueryString ["hola"] != "pepe")
+                       throw new Exception ("#02");
+
+
+               Context.RewritePath ("rewrite_xxx.aspx");        
+               if (Request.FilePath != vpath + "/rewrite_xxx.aspx")
+                       throw new Exception ("#03");
+
+               // QueryString preserved
+               if (Request.QueryString ["hola"] != "pepe")
+                       throw new Exception ("#04");
+
+               Context.RewritePath ("rewrite_xx1.aspx", null, null);        
+               if (Request.FilePath != vpath + "/rewrite_xx1.aspx")
+                       throw new Exception ("#05");
+
+               // QueryString preserved
+               if (Request.QueryString ["hola"] != "pepe")
+                       throw new Exception ("#06");
+
+               Context.RewritePath ("rewrite_xx2.aspx", "", "");        
+               if (Request.FilePath != vpath + "/rewrite_xx2.aspx")
+                       throw new Exception ("#07");
+
+               // QueryString preserved
+               if (Request.QueryString.Count > 0)
+                       throw new Exception ("#08");
+
+               Response.Clear ();
+               Response.Write ("OK");
+               Response.End ();
+       }
+</script>
+<body>
+The test went OK.
+</body>
+</html>
+
diff --git a/mcs/class/System.Web/Test/standalone/response/t7.expected b/mcs/class/System.Web/Test/standalone/response/t7.expected
new file mode 100644 (file)
index 0000000..a0aba93
--- /dev/null
@@ -0,0 +1 @@
+OK
\ No newline at end of file
diff --git a/mcs/class/System.Web/Test/standalone/response/t7.oexpected b/mcs/class/System.Web/Test/standalone/response/t7.oexpected
new file mode 100644 (file)
index 0000000..d86bac9
--- /dev/null
@@ -0,0 +1 @@
+OK
diff --git a/mcs/class/System.Web/Test/standalone/timeout/index.aspx b/mcs/class/System.Web/Test/standalone/timeout/index.aspx
new file mode 100644 (file)
index 0000000..a79b3d4
--- /dev/null
@@ -0,0 +1,19 @@
+<%@ Page language="c#" %>
+<html>
+<script runat="server">
+       void Page_Load ()
+       {
+               try {
+                       for (int i = 1; i <= 40; i++) {
+                               System.Threading.Thread.Sleep (1000);
+                               Console.WriteLine (i);
+                       }
+               } catch (System.Threading.ThreadAbortException) {
+                       Console.WriteLine ("Aborted! :-)");
+               }
+       }
+</script>
+<body>
+This should not be seen.
+</body>
+</html>
diff --git a/mcs/class/System.Web/Test/standalone/timeout/web.config b/mcs/class/System.Web/Test/standalone/timeout/web.config
new file mode 100644 (file)
index 0000000..8c3fa11
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+       <system.web>
+               <httpRuntime executionTimeout="10" />
+       </system.web>
+</configuration>
+
+
diff --git a/mcs/class/System.Web/Test/tools/HtmlWriter.cs b/mcs/class/System.Web/Test/tools/HtmlWriter.cs
new file mode 100644 (file)
index 0000000..0abaadf
--- /dev/null
@@ -0,0 +1,291 @@
+using System;
+using System.IO;
+using System.Diagnostics;
+using System.Web.UI;
+using System.Reflection;
+
+namespace Helper {
+       public class HtmlWriter : HtmlTextWriter {
+               bool full_trace;
+               TextWriter output;
+               int call_count;
+
+               int NextIndex ()
+               {
+                       return call_count++;
+               }
+
+               public HtmlWriter (TextWriter writer) : this (writer, DefaultTabString)
+               {
+               }
+       
+               public HtmlWriter (TextWriter writer, string tabString) : base (writer, tabString)
+               {
+                       full_trace = (Environment.GetEnvironmentVariable ("HTMLWRITER_FULLTRACE") == "yes");
+                       string file = Environment.GetEnvironmentVariable ("HTMLWRITER_FILE");
+                       Console.WriteLine ("file: '{0}' (null? {1})", file, file == null);
+                       if (file != null && file != "") {
+                               output = new StreamWriter (new FileStream (file, FileMode.OpenOrCreate | FileMode.Append));
+                               Console.WriteLine ("Sending log to '{0}'.", file);
+                       } else {
+                               output = Console.Out;
+                       }
+               }
+
+               void WriteTrace (StackTrace trace)
+               {
+                       int n = trace.FrameCount;
+                       for (int i = 0; i < n; i++) {
+                               StackFrame frame = trace.GetFrame (i);
+                               Type type = frame.GetMethod ().DeclaringType;
+                               string ns = type.Namespace;
+                               if (ns != "Helper" && !ns.StartsWith ("System.Web.UI"))
+                                       break;
+                               output.Write ("\t{0}.{1}", type.Name, frame);
+                       }
+                       output.WriteLine ();
+               }
+
+               public override void AddAttribute (HtmlTextWriterAttribute key, string value, bool fEncode)
+               {
+                       output.WriteLine ("{0:###0} AddAttribute ({1}, {2}, {3}))", NextIndex (), key, value, fEncode);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.AddAttribute (key, value, fEncode);
+               }
+               
+               public override void AddAttribute (string name, string value, bool fEncode)
+               {
+                       output.WriteLine ("{0:###0} AddAttribute ({1}, {2}, {3}))", NextIndex (), name, value, fEncode);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       if (fEncode)
+                               ; // FIXME
+
+                       base.AddAttribute (name, value, (HtmlTextWriterAttribute) 0);
+               }
+               
+               protected override void AddAttribute (string name, string value, HtmlTextWriterAttribute key)
+               {
+                       output.WriteLine ("{0:###0} AddAttribute ({1}, {2}, {3}))", NextIndex (), name, value, key);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.AddAttribute (name, value, key);
+               }
+               
+               protected override void AddStyleAttribute (string name, string value, HtmlTextWriterStyle key)
+               {
+                       output.WriteLine ("{0:###0} AddStyleAttribute ({1}, {2}, {3}))", NextIndex (), name, value, key);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.AddStyleAttribute (name, value, key);
+               }
+               
+               public override void Close ()
+               {
+                       output.WriteLine ("{0:###0} Close ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       if (output != Console.Out)
+                               output.Close ();
+                       base.Close ();  
+               }
+
+               protected override string EncodeAttributeValue (HtmlTextWriterAttribute attrKey, string value)
+               {
+                       output.WriteLine ("{0:###0} EncodeAttributeValue ({1}, {2})", NextIndex (), attrKey, value);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return base.EncodeAttributeValue (attrKey, value);
+               }
+               
+               protected override void FilterAttributes ()
+               {
+                       output.WriteLine ("{0:###0} FilterAttributes ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.FilterAttributes ();
+               }
+       
+               public override void Flush ()
+               {
+                       output.WriteLine ("{0:###0} Flush ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.Flush ();
+               }
+
+               protected override HtmlTextWriterTag GetTagKey (string tagName) 
+               {
+                       output.WriteLine ("{0:###0} GetTagKey ({1})", NextIndex (), tagName);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return base.GetTagKey (tagName);
+               }
+
+               protected override string GetTagName (HtmlTextWriterTag tagKey)
+               {
+                       output.WriteLine ("{0:###0} GetTagName ({1})", NextIndex (), tagKey);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return base.GetTagName (tagKey);
+               }
+               
+               protected override bool OnAttributeRender (string name, string value, HtmlTextWriterAttribute key)
+               {
+                       output.WriteLine ("{0:###0} OnAttributeRender ({1}, {2}, {3})", NextIndex (), name, value, key);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return base.OnAttributeRender (name, value, key);
+               }
+               
+               protected override bool OnStyleAttributeRender (string name, string value, HtmlTextWriterStyle key)
+               {
+                       output.WriteLine ("{0:###0} OnStyleAttributeRender ({1}, {2}, {3})", NextIndex (), name, value, key);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return base.OnStyleAttributeRender (name, value, key);
+               }
+               
+               protected override bool OnTagRender (string name, HtmlTextWriterTag key)
+               {
+                       output.WriteLine ("{0:###0} OnTagRender ({1}, {2})", NextIndex (), name, key);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return base.OnTagRender (name, key);
+               }
+               
+       
+               protected override void OutputTabs ()
+               {
+                       output.WriteLine ("{0:###0} OutputTabs ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.OutputTabs ();
+               }
+       
+               protected override string RenderAfterContent ()
+               {
+                       output.WriteLine ("{0:###0} RenderAfterContent ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return null;
+               }
+               
+               protected override string RenderAfterTag ()
+               {
+                       output.WriteLine ("{0:###0} RenderAfterTag ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return null;
+               }
+               
+               protected override string RenderBeforeContent ()
+               {
+                       output.WriteLine ("{0:###0} RenderBeforeContent ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return null;
+               }
+                       
+               protected override string RenderBeforeTag ()
+               {
+                       output.WriteLine ("{0:###0} RenderBeforeTag ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       return null;
+               }
+
+               public override void RenderBeginTag (string tagName)
+               {
+                       output.WriteLine ("{0:###0} RenderBeginTag ({1})", NextIndex (), tagName);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.RenderBeginTag (tagName);
+               }
+               
+               public override void RenderBeginTag (HtmlTextWriterTag tagKey)
+               {
+                       output.WriteLine ("{0:###0} RenderBeginTag ({1})", NextIndex (), tagKey);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.RenderBeginTag (tagKey);
+               }
+
+               public override void RenderEndTag ()
+               {
+                       output.WriteLine ("{0:###0} RenderEndTag ()", NextIndex ());
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.RenderEndTag ();
+               }
+               
+               public override void WriteAttribute (string name, string value, bool fEncode)
+               {
+                       output.WriteLine ("{0:###0} WriteAttribute ({1}, {2}, {3})", NextIndex (), name, value, fEncode);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.WriteAttribute (name, value, fEncode);
+               }
+               
+       
+               public override void WriteBeginTag (string tagName)
+               {
+                       output.WriteLine ("{0:###0} WriteBeginTag ({1})", NextIndex (), tagName);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.WriteBeginTag (tagName);
+               }
+               
+               public override void WriteEndTag (string tagName)
+               {
+                       output.WriteLine ("{0:###0} WriteEndTag ({1})", NextIndex (), tagName);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.WriteEndTag (tagName);
+               }
+               
+               public override void WriteFullBeginTag (string tagName)
+               {
+                       output.WriteLine ("{0:###0} WriteFullBeginTag ({1})", NextIndex (), tagName);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.WriteFullBeginTag (tagName);
+               }
+                       
+               public override void WriteStyleAttribute (string name, string value, bool fEncode)
+               {
+                       output.WriteLine ("{0:###0} WriteStyleAttribute ({1}, {2}, {3})", NextIndex (), name, value, fEncode);
+                       if (full_trace)
+                               WriteTrace (new StackTrace ());
+
+                       base.WriteStyleAttribute (name, value, fEncode);
+               }
+       }
+}
+
diff --git a/mcs/class/System.Web/Test/tools/Makefile b/mcs/class/System.Web/Test/tools/Makefile
new file mode 100644 (file)
index 0000000..d3a2a32
--- /dev/null
@@ -0,0 +1,10 @@
+CSC=mcs
+
+all: HtmlWriter.dll
+
+HtmlWriter.dll: HtmlWriter.cs
+       $(CSC) -t:library -r:System.Web.dll $<
+
+clean:
+       rm -f HtmlWriter.dll HtmlWriter.*db
+
diff --git a/mcs/class/System.Web/Test/tools/README b/mcs/class/System.Web/Test/tools/README
new file mode 100644 (file)
index 0000000..5add87b
--- /dev/null
@@ -0,0 +1,22 @@
+Tools
+-------
+
+       * HtmlWriter.cs: it provides a custom HtmlTextWriter implementation with
+       logging capabilities to help figuring out which method in HtmlTextWriter
+       you should invoke and where to do it.
+
+       How to use it.
+       ---------------
+               * Run 'make'. It will generate HtmlWriter.dll.
+               * Copy HtmlWriter.dll to the 'bin' directory.
+               * Copy web.config to the directory in which you run xsp
+               (the parent of 'bin').
+               * There are 2 environment variables used:
+                       -HTMLWRITER_FULLTRACE=yes: displays the stack trace for
+                       every method called.
+                       -HTMLWRITER_FILE=[yourfilename]: output goes to a file
+                       instead of stdout.
+
+       The default output is a sequence number, the function called and its
+       arguments.
+
diff --git a/mcs/class/System.Web/Test/tools/web.config b/mcs/class/System.Web/Test/tools/web.config
new file mode 100644 (file)
index 0000000..83ee30e
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+    <system.web>
+        <customErrors mode="Off"/>
+       <authentication mode= "Forms">
+       </authentication>
+       <browserCaps>
+            <use var="HTTP_USER_AGENT" />
+           <filter>
+                   <case match=".*">
+                           tagwriter=Helper.HtmlWriter,HtmlWriter
+                   </case>
+           </filter>
+       </browserCaps>
+    </system.web>
+</configuration>