improved test for unconsumed

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1242 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-02-05 15:06:36 +00:00
parent de841eba43
commit 7865c22209
2 changed files with 85 additions and 0 deletions

View File

@ -63,6 +63,17 @@ public class DumpHandler extends AbstractHandler
{
if (!isStarted())
return;
if (request.getParameter("ISE")!=null)
{
throw new IllegalStateException();
}
if (request.getParameter("error")!=null)
{
response.sendError(Integer.parseInt(request.getParameter("error")));
return;
}
if (request.getParameter("continue")!=null)
{

View File

@ -31,6 +31,7 @@ import junit.framework.TestCase;
import org.eclipse.jetty.http.HttpHeaders;
import org.eclipse.jetty.http.MimeTypes;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
/**
*
@ -246,6 +247,79 @@ public class HttpConnectionTest extends TestCase
}
/* --------------------------------------------------------------- */
public void testUnconsumedError() throws Exception
{
String response=null;
String requests=null;
int offset=0;
offset=0;
requests="GET /R1?error=500 HTTP/1.1\n"+
"Host: localhost\n"+
"Content-Type: text/plain; charset=utf-8\n"+
"Content-Length: 10\n"+
"\n"+
"0123456789\n"+
"GET /R2 HTTP/1.1\n"+
"Host: localhost\n"+
"Content-Type: text/plain; charset=utf-8\n"+
"Content-Length: 10\n"+
"\n"+
"abcdefghij\n";
response=connector.getResponses(requests);
offset = checkContains(response,offset,"HTTP/1.1 500");
offset = checkContains(response,offset,"HTTP/1.1 200");
offset = checkContains(response,offset,"/R2");
offset = checkContains(response,offset,"encoding=UTF-8");
offset = checkContains(response,offset,"abcdefghij");
}
/* --------------------------------------------------------------- */
public void testUnconsumedException() throws Exception
{
String response=null;
String requests=null;
int offset=0;
offset=0;
requests="GET /R1?ISE=true HTTP/1.1\n"+
"Host: localhost\n"+
"Content-Type: text/plain; charset=utf-8\n"+
"Content-Length: 10\n"+
"\n"+
"0123456789\n"+
"GET /R2 HTTP/1.1\n"+
"Host: localhost\n"+
"Content-Type: text/plain; charset=utf-8\n"+
"Content-Length: 10\n"+
"\n"+
"abcdefghij\n";
Logger logger=null;
try
{
if (!Log.isDebugEnabled())
{
logger=Log.getLog();
Log.setLog(null);
}
response=connector.getResponses(requests);
offset = checkContains(response,offset,"HTTP/1.1 500");
offset = checkContains(response,offset,"Connection: close");
checkNotContained(response,offset,"HTTP/1.1 200");
}
finally
{
if (logger!=null)
Log.setLog(logger);
}
}
public void testConnection ()
{
String response=null;