Author: remy.maucherat(a)jboss.com
Date: 2008-03-24 13:51:46 -0400 (Mon, 24 Mar 2008)
New Revision: 538
Added:
trunk/test/webapps/reader/index.html
trunk/test/webapps/reader/test.jsp
Removed:
trunk/test/webapps/reader/index.jsp
trunk/test/webapps/reader/indexAscii.jsp
Modified:
trunk/build.properties.default
trunk/test/webapps/reader/read.jsp
trunk/test/webapps/reader/readCharB.jsp
trunk/test/webapps/reader/readLine.jsp
Log:
- New version of the test.
Modified: trunk/build.properties.default
===================================================================
--- trunk/build.properties.default 2008-03-23 12:58:58 UTC (rev 537)
+++ trunk/build.properties.default 2008-03-24 17:51:46 UTC (rev 538)
@@ -12,7 +12,7 @@
# ----- Version Control Flags -----
version.major=2
version.minor=1
-version.build=0
+version.build=1
version.patch=0
version.tag=SNAPSHOT
Added: trunk/test/webapps/reader/index.html
===================================================================
--- trunk/test/webapps/reader/index.html (rev 0)
+++ trunk/test/webapps/reader/index.html 2008-03-24 17:51:46 UTC (rev 538)
@@ -0,0 +1,23 @@
+<HTML>
+<HEAD>
+<META http-equiv="Content-Type" content="text/html;
charset=UTF-8">
+<TITLE>request#getReader test.</TITLE>
+</HEAD>
+<BODY>
+<FORM method="GET" action="test.jsp" >
+Characters size:<input type="text" name="size"
value="8192" /><BR>
+Use MultiByte Character:
+<input value="false" type="radio" checked
name="ascii"/>yes
+<input value="true" type="radio" name="ascii"/>no
+<BR>
+<input type="submit" value="send" /></FORM>
+<HR>
+Note:
+ The real post body will be added followings:<BR>
+<ul>
+<li>multipart boundary.
+<li>Content-Disposition: form-data; name="[text form area name]"
+<li>Some CR/LFs.
+</ul>
+</BODY>
+</HTML>
Deleted: trunk/test/webapps/reader/index.jsp
===================================================================
--- trunk/test/webapps/reader/index.jsp 2008-03-23 12:58:58 UTC (rev 537)
+++ trunk/test/webapps/reader/index.jsp 2008-03-24 17:51:46 UTC (rev 538)
@@ -1,42 +0,0 @@
-<%@ page pageEncoding="UTF-8"%>
-<%@ page import="java.io.*"%>
-<HTML>
-<HEAD>
-<META http-equiv="Content-Type" content="text/html;
charset=UTF-8">
-<TITLE>request#getReader test.</TITLE>
-</HEAD>
-<BODY>
-
-<%!
- int charSize = 8193;
- char character = 'あ';
-%>
-
-<%
-response.setContentType("text/html; charset=UTF-8");
-StringBuffer sb = new StringBuffer(charSize);
-for(int i=0 ; i < charSize ; i++){
- sb.append(character);
-}
-%>
-
-<FORM method="POST" action="readLine.jsp"
enctype="text/plain">
-request#getReader()#readLine test<BR>
-<input type="text" name="thetext" value="<%=
sb.toString()+sb.toString()+sb.toString() %>"/>
-<input type="submit" value="send" />
-</FORM>
-
-<FORM method="POST" action="read.jsp"
enctype="text/plain">
-request#getReader()#read() test<BR>
-<input type="text" name="thetext" value="<%= sb.toString()
%>"/>
-<input type="submit" value="send" />
-</FORM>
-
-<FORM method="POST" action="readCharB.jsp"
enctype="text/plain">
-request#getReader()#read(char[1]) test<BR>
-<input type="text" name="thetext" value="<%= sb.toString()
%>"/>
-<input type="submit" value="send" />
-</FORM>
-
-</BODY>
-</HTML>
\ No newline at end of file
Deleted: trunk/test/webapps/reader/indexAscii.jsp
===================================================================
--- trunk/test/webapps/reader/indexAscii.jsp 2008-03-23 12:58:58 UTC (rev 537)
+++ trunk/test/webapps/reader/indexAscii.jsp 2008-03-24 17:51:46 UTC (rev 538)
@@ -1,42 +0,0 @@
-<%@ page pageEncoding="UTF-8"%>
-<%@ page import="java.io.*"%>
-<HTML>
-<HEAD>
-<META http-equiv="Content-Type" content="text/html;
charset=UTF-8">
-<TITLE>request#getReader test.</TITLE>
-</HEAD>
-<BODY>
-
-<%!
- int charSize = 8193;
- char character = 'a';
-%>
-
-<%
-response.setContentType("text/html; charset=UTF-8");
-StringBuffer sb = new StringBuffer(charSize);
-for(int i=0 ; i < charSize ; i++){
- sb.append(character);
-}
-%>
-
-<FORM method="POST" action="readLine.jsp"
enctype="text/plain">
-request#getReader()#readLine test<BR>
-<input type="text" name="thetext" value="<%=
sb.toString()+sb.toString()+sb.toString() %>"/>
-<input type="submit" value="send" />
-</FORM>
-
-<FORM method="POST" action="read.jsp"
enctype="text/plain">
-request#getReader()#read() test<BR>
-<input type="text" name="thetext" value="<%= sb.toString()
%>"/>
-<input type="submit" value="send" />
-</FORM>
-
-<FORM method="POST" action="readCharB.jsp"
enctype="text/plain">
-request#getReader()#read(char[1]) test<BR>
-<input type="text" name="thetext" value="<%= sb.toString()
%>"/>
-<input type="submit" value="send" />
-</FORM>
-
-</BODY>
-</HTML>
\ No newline at end of file
Modified: trunk/test/webapps/reader/read.jsp
===================================================================
--- trunk/test/webapps/reader/read.jsp 2008-03-23 12:58:58 UTC (rev 537)
+++ trunk/test/webapps/reader/read.jsp 2008-03-24 17:51:46 UTC (rev 538)
@@ -10,34 +10,43 @@
<HR>
<%
- request.setCharacterEncoding("UTF-8");
- response.setContentType("text/html; charset=UTF-8");
- BufferedReader reader = request.getReader();
- StringBuffer sb = new StringBuffer();
+String expected = (String) session.getAttribute("expected");
+String formName = (String) session.getAttribute("formName");
+request.setCharacterEncoding("UTF-8");
+response.setContentType("text/html; charset=UTF-8");
+BufferedReader reader = request.getReader();
+StringBuffer sb = new StringBuffer();
read(reader, sb);
- // TODO check if the read data is correct.
//outln(out,sb.toString());
- outln(out,"Content-Type:" + request.getContentType());
- outln(out,"Character Encoding:" + request.getCharacterEncoding());
- outln(out, "Content-Length:"+ request.getContentLength());
- outln(out, "read:" + sb.length()); // includes form text area name
"thetext="
-
+
+ String boundary = null;
+ String contentType = request.getContentType();
+ if(contentType != null){
+ int delim = contentType.indexOf("boundary=");
+ boundary = contentType.substring(delim+9).trim();
+ }
+ expected = "--"+boundary+"\r\nContent-Disposition: form-data;
name=\""+formName+"\"\r\n\r\n"+expected+"\r\n--"+boundary+"--\r\n";
+
+ outln(out, "Content-Type:" + request.getContentType());
+ outln(out, "Character Encoding:" +
request.getCharacterEncoding());
+ outln(out, "Content-Length:" + request.getContentLength());
+ outln(out, "expected:" + expected.length());
+ outln(out, "real read:" + sb.length());
+ outln(out, "isSame:" + (sb.toString().equals(expected)));
%>
</BODY>
</HTML>
-<%!
- void read(BufferedReader br, StringBuffer sb) throws IOException{
- int read = 0;
- while((read = br.read())!= -1){
- sb.append((char)read);
- }
+<%!void read(BufferedReader br, StringBuffer sb) throws IOException {
+ int read = 0;
+ while ((read = br.read()) != -1) {
+ sb.append((char) read);
+ }
}
- void outln(JspWriter out, String str) throws IOException{
- out.println(str+"<BR>");
- System.out.println(str);
- }
-%>
\ No newline at end of file
+ void outln(JspWriter out, String str) throws IOException {
+ out.println(str + "<BR>");
+ System.out.println(str);
+ }%>
Modified: trunk/test/webapps/reader/readCharB.jsp
===================================================================
--- trunk/test/webapps/reader/readCharB.jsp 2008-03-23 12:58:58 UTC (rev 537)
+++ trunk/test/webapps/reader/readCharB.jsp 2008-03-24 17:51:46 UTC (rev 538)
@@ -10,37 +10,45 @@
<HR>
<%
- request.setCharacterEncoding("UTF-8");
- response.setContentType("text/html; charset=UTF-8");
- BufferedReader reader = request.getReader();
- StringBuffer sb = new StringBuffer();
+String expected = (String) session.getAttribute("expected");
+String formName = (String) session.getAttribute("formName");
+request.setCharacterEncoding("UTF-8");
+response.setContentType("text/html; charset=UTF-8");
+BufferedReader reader = request.getReader();
+StringBuffer sb = new StringBuffer();
readCharB(reader, sb, 1);
+
+ //outln(out,sb.toString());
- // TODO check if the read data is correct.
+ String boundary = null;
+ String contentType = request.getContentType();
+ if(contentType != null){
+ int delim = contentType.indexOf("boundary=");
+ boundary = contentType.substring(delim+9).trim();
+ }
+ expected = "--"+boundary+"\r\nContent-Disposition: form-data;
name=\""+formName+"\"\r\n\r\n"+expected+"\r\n--"+boundary+"--\r\n";
- //outln(out,sb.toString());
- outln(out,"Content-Type:" + request.getContentType());
- outln(out,"Character Encoding:" + request.getCharacterEncoding());
- outln(out, "Content-Length:"+ request.getContentLength());
- outln(out, "read:" + sb.length()); // includes form text area name
"thetext=" and last CR/LF
-
+ outln(out, "Content-Type:" + request.getContentType());
+ outln(out, "Character Encoding:" +
request.getCharacterEncoding());
+ outln(out, "Content-Length:" + request.getContentLength());
+ outln(out, "expected:" + expected.length());
+ outln(out, "real read:" + sb.length());
+ outln(out, "isSame:" + (sb.toString().equals(expected)));
%>
</BODY>
</HTML>
-<%!
-
- void readCharB(BufferedReader br, StringBuffer sb, int bufferSize) throws IOException{
- char[] buf = new char[bufferSize];
- int read = 0;
- while((read = br.read(buf))!= -1){
- sb.append(buf, 0, read);
- }
- }
-
- void outln(JspWriter out, String str) throws IOException{
- out.println(str+"<BR>");
- System.out.println(str);
- }
-%>
\ No newline at end of file
+<%!void readCharB(BufferedReader br, StringBuffer sb, int bufferSize)
+ throws IOException {
+ char[] buf = new char[bufferSize];
+ int read = 0;
+ while ((read = br.read(buf)) != -1) {
+ sb.append(buf, 0, read);
+ }
+ }
+
+ void outln(JspWriter out, String str) throws IOException {
+ out.println(str + "<BR>");
+ System.out.println(str);
+ }%>
Modified: trunk/test/webapps/reader/readLine.jsp
===================================================================
--- trunk/test/webapps/reader/readLine.jsp 2008-03-23 12:58:58 UTC (rev 537)
+++ trunk/test/webapps/reader/readLine.jsp 2008-03-24 17:51:46 UTC (rev 538)
@@ -10,36 +10,43 @@
<HR>
<%
+ String expected = (String) session.getAttribute("expected");
+ String formName = (String) session.getAttribute("formName");
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
BufferedReader reader = request.getReader();
StringBuffer sb = new StringBuffer();
-
+
readLine(reader, sb);
+
+ //outln(out,sb.toString());
- // TODO check if the read data is correct.
+ String boundary = null;
+ String contentType = request.getContentType();
+ if(contentType != null){
+ int delim = contentType.indexOf("boundary=");
+ boundary = contentType.substring(delim+9).trim();
+ }
+ expected = "--"+boundary+"\r\nContent-Disposition: form-data;
name=\""+formName+"\"\r\n\r\n"+expected+"\r\n--"+boundary+"--\r\n";
- //outln(out,sb.toString());
- outln(out,"Content-Type:" + request.getContentType());
- outln(out,"Character Encoding:" + request.getCharacterEncoding());
- outln(out, "Content-Length:"+ request.getContentLength());
- outln(out, "read:" + sb.length()); // includes form text area name
"thetext=" and last CR/LF
-
+ outln(out, "Content-Type:" + request.getContentType());
+ outln(out, "Character Encoding:" +
request.getCharacterEncoding());
+ outln(out, "Content-Length:" + request.getContentLength());
+ outln(out, "expected:" + expected.length());
+ outln(out, "real read:" + sb.length());
+ outln(out, "isSame:" + (sb.toString().equals(expected)));
%>
</BODY>
</HTML>
-<%!
+<%!void readLine(BufferedReader br, StringBuffer sb) throws IOException {
+ String read = null;
+ while ((read = br.readLine()) != null) {
+ sb.append(read+"\r\n");
+ }
+ }
- void readLine(BufferedReader br, StringBuffer sb) throws IOException{
- String read = null;
- while((read = br.readLine())!=null){
- sb.append(read);// CR/LF lost.
- }
- }
-
- void outln(JspWriter out, String str) throws IOException{
- out.println(str+"<BR>");
- System.out.println(str);
- }
-%>
\ No newline at end of file
+ void outln(JspWriter out, String str) throws IOException {
+ out.println(str + "<BR>");
+ System.out.println(str);
+ }%>
Added: trunk/test/webapps/reader/test.jsp
===================================================================
--- trunk/test/webapps/reader/test.jsp (rev 0)
+++ trunk/test/webapps/reader/test.jsp 2008-03-24 17:51:46 UTC (rev 538)
@@ -0,0 +1,64 @@
+<%@ page pageEncoding="UTF-8"%>
+<%@ page import="java.io.*"%>
+<HTML>
+<HEAD>
+<META http-equiv="Content-Type" content="text/html;
charset=UTF-8">
+<TITLE>request#getReader test.</TITLE>
+</HEAD>
+<BODY>
+
+<%!static char JP[] = "あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよわゐゑをん"
+ .toCharArray();
+
+ static char ASCII[] = "abcdefghijklmnopqrstuvwxyz".toCharArray();
+
+ static String formName = "n";%>
+
+<%
+ response.setContentType("text/html; charset=UTF-8");
+
+ int size = 8192;
+ String sizeS = request.getParameter("size");
+ if (sizeS != null) {
+ size = Integer.parseInt(sizeS);
+ }
+
+ boolean isAscii = true;
+ String ascii = request.getParameter("ascii");
+ if (ascii != null) {
+ isAscii = Boolean.parseBoolean(ascii);
+ }
+
+ char[] chars = isAscii ? ASCII : JP;
+
+ StringBuffer sb = new StringBuffer(size + formName.length() + 1
+ + chars.length);
+ while (sb.length() < size) {
+ sb.append(chars);
+ }
+ if (sb.length() > size) {
+ sb.delete(size, sb.length());
+ }
+%>
+
+<FORM method="POST" action="<%=
response.encodeURL("readLine.jsp") %>"
enctype="multipart/form-data">
+request#getReader()#readLine test<BR>
+<input type="text" name="<%= formName %>" value="<%=
sb.toString() %>" />
+<input type="submit" value="send" /></FORM>
+
+<FORM method="POST" action="<%=
response.encodeURL("read.jsp") %>"
enctype="multipart/form-data">
+request#getReader()#read() test<BR>
+<input type="text" name="<%= formName %>" value="<%=
sb.toString() %>" />
+<input type="submit" value="send" /></FORM>
+
+<FORM method="POST" action="<%=
response.encodeURL("readCharB.jsp") %>"
enctype="multipart/form-data" >
+request#getReader()#read(char[1]) test<BR>
+<input type="text" name="<%= formName %>" value="<%=
sb.toString() %>" />
+<input type="submit" value="send" /></FORM>
+
+<%
+ session.setAttribute("expected", sb.toString());
+ session.setAttribute("formName", formName);
+%>
+</BODY>
+</HTML>