Author: gert
Date: 2008-01-12 04:41:10 -0500 (Sat, 12 Jan 2008)
New Revision: 92722

Added:
   trunk/gert/standalone/bug351049/
   trunk/gert/standalone/bug351049/default.build
   trunk/gert/standalone/bug351049/test.cs
   trunk/gert/standalone/bug351049/web/
   trunk/gert/standalone/bug351049/web/Default.aspx
Log:
Added test for bug #351049.


Added: trunk/gert/standalone/bug351049/default.build
===================================================================
--- trunk/gert/standalone/bug351049/default.build       2008-01-12 08:21:23 UTC 
(rev 92721)
+++ trunk/gert/standalone/bug351049/default.build       2008-01-12 09:41:10 UTC 
(rev 92722)
@@ -0,0 +1,45 @@
+<project name="bug351049" default="rebuild">
+       <include buildfile="../../build/common.build" />
+
+       <target name="mono-2.0-init">
+               <property name="xsp.package" value="xsp-2" />
+       </target>
+
+       <target name="net-2.0-init">
+               <property name="xsp.package" value="xsp-2" />
+       </target>
+
+       <property name="frameworks" value="mono-2.0,net-2.0" />
+
+       <target name="clean">
+               <delete>
+                       <fileset>
+                               <include name="out" />
+                               <include name="test.exe" />
+                       </fileset>
+               </delete>
+       </target>
+
+       <target name="compile" depends="init">
+               <csc target="exe" define="${csc.defines}" output="test.exe" 
warnaserror="false" warninglevel="4">
+                       <sources>
+                               <include name="../../build/common/Assert.cs" />
+                               <include name="test.cs" />
+                       </sources>
+               </csc>
+       </target>
+
+       <target name="run-test" depends="compile">
+               <exec 
program="${pkg-config::get-variable(xsp.package,'Executable')}" managed="true" 
spawn="true" pidproperty="server.pid">
+                       <arg value="--root" />
+                       <arg dir="web" />
+                       <arg value="--port" />
+                       <arg value="8081" />
+               </exec>
+               <sleep milliseconds="1000" />
+               <exec program="test.exe" managed="true" output="out" />
+               <fail if="${file::exists('out')}" />
+               <kill pid="${server.pid}" />
+               <sleep milliseconds="1000" />
+       </target>
+</project>


Property changes on: trunk/gert/standalone/bug351049/default.build
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/gert/standalone/bug351049/test.cs
===================================================================
--- trunk/gert/standalone/bug351049/test.cs     2008-01-12 08:21:23 UTC (rev 
92721)
+++ trunk/gert/standalone/bug351049/test.cs     2008-01-12 09:41:10 UTC (rev 
92722)
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Specialized;
+using System.Text;
+using System.Net;
+using System.Threading;
+
+class Program
+{
+       static void Main ()
+       {
+               GetFreshWebClient ("http://localhost:8081/Default.aspx";);
+               m_nvcollectionmain = new NameValueCollection ();
+               m_nvcollectionmain.Add ("q", "mono");
+               m_nvcollectionmain.Add ("q", "rocks");
+               m_nvcollectionmain.Add ("t", "ASP.NET&Mono" + 
Environment.NewLine + "!");
+               m_nvcollectionmain.Add ("x", "Open\nSource");
+               m_nvcollectionmain.Add ("z", "Open\r\nSuse");
+               m_threadmain = new Thread (BeginCaptureLoop);
+               m_threadmain.Start ();
+               while (m_threadmain.IsAlive)
+                       Thread.Sleep (3000);
+               Assert.IsNotNull (_response, "#1");
+               Assert.IsTrue (_response.IndexOf ("<p>Total: 4</p>") != -1, 
"#2: " + _response);
+               Assert.IsTrue (_response.IndexOf ("<p key=\"q\">Lenght: 1</p>") 
!= -1, "#3: " + _response);
+               Assert.IsTrue (_response.IndexOf ("<p key=\"q\">P[0]: 
mono,rocks</p>") != -1, "#4: " + _response);
+               Assert.IsTrue (_response.IndexOf ("<p key=\"t\">Lenght: 1</p>") 
!= -1, "#5: " + _response);
+               Assert.IsTrue (_response.IndexOf ("<p key=\"t\">P[0]: 
ASP.NET&Mono" + Environment.NewLine + "!</p>") != -1, "#6: " + _response);
+               Assert.IsTrue (_response.IndexOf ("<p key=\"x\">Lenght: 1</p>") 
!= -1, "#7: " + _response);
+               Assert.IsTrue (_response.IndexOf ("<p key=\"x\">P[0]: 
Open\nSource</p>") != -1, "#8: " + _response);
+               Assert.IsTrue (_response.IndexOf ("<p key=\"z\">Lenght: 1</p>") 
!= -1, "#9: " + _response);
+               Assert.IsTrue (_response.IndexOf ("<p key=\"z\">P[0]: 
Open\r\nSuse</p>") != -1, "#10: " + _response);
+       }
+
+       static void BeginCapture_UploadValuesCompleted (object sender, 
UploadValuesCompletedEventArgs e)
+       {
+               byte [] bytResponse = e.Result;
+               _response = Encoding.UTF7.GetString (bytResponse);
+       }
+
+       static void GetFreshWebClient (string q)
+       {
+               m_urimainforcapture = new System.Uri (q);
+               m_webclientforcapture = new WebClient ();
+               m_webclientforcapture.Headers.Add ("user-agent", "Mozilla/4.0 
(compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
+               m_webclientforcapture.UploadValuesCompleted += new 
UploadValuesCompletedEventHandler (BeginCapture_UploadValuesCompleted);
+       }
+
+       static void BeginCaptureLoop ()
+       {
+               m_webclientforcapture.UploadValuesAsync (m_urimainforcapture, 
"POST", m_nvcollectionmain);
+               Thread.Sleep (3000);
+               while (m_webclientforcapture.IsBusy)
+                       Thread.Sleep (3000);
+       }
+
+       private static WebClient m_webclientforcapture;
+       private static Uri m_urimainforcapture;
+       private static NameValueCollection m_nvcollectionmain;
+       private static Thread m_threadmain;
+       private static string _response;
+}


Property changes on: trunk/gert/standalone/bug351049/test.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/gert/standalone/bug351049/web/Default.aspx
===================================================================
--- trunk/gert/standalone/bug351049/web/Default.aspx    2008-01-12 08:21:23 UTC 
(rev 92721)
+++ trunk/gert/standalone/bug351049/web/Default.aspx    2008-01-12 09:41:10 UTC 
(rev 92722)
@@ -0,0 +1,14 @@
+<%@ Page Language="C#" %>
+<html>
+<body>
+       <%
+               Response.Write ("<p>Total: " + Request.Form.Count + "</p>");
+               foreach (string key in Request.Form.Keys) {
+                       string [] P = Request.Form.GetValues (key);
+                       Response.Write ("<p key=\"" + key + "\">Lenght: " + 
P.Length + "</p>");
+                       for (int i = 0; i < P.Length; i++)
+                               Response.Write ("<p key=\"" + key + "\">P[" + i 
+ "]: " + P [i] + "</p>");
+               }
+       %>
+</body>
+</html>


Property changes on: trunk/gert/standalone/bug351049/web/Default.aspx
___________________________________________________________________
Name: svn:eol-style
   + native

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

Reply via email to