aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2012-08-31 09:23:47 (EDT)
committerThomas Becker2012-08-31 09:23:47 (EDT)
commit842f30fb87be4f742656311775588b443b994860 (patch)
tree2b3d0ab866f1b346b16bf4e8e0ff68869761f1e7
parentc3844a43c94a21ff95f069462f09d1cc1e9ac506 (diff)
downloadorg.eclipse.jetty.project-842f30fb87be4f742656311775588b443b994860.zip
org.eclipse.jetty.project-842f30fb87be4f742656311775588b443b994860.tar.gz
org.eclipse.jetty.project-842f30fb87be4f742656311775588b443b994860.tar.bz2
Additional test to make sure that jetty sends a 500 response code when an exception is thrown.
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java40
1 files changed, 33 insertions, 7 deletions
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java
index 16d62f5..81329e9 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java
@@ -131,7 +131,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
byte[] buffer = new byte[64*1024];
Arrays.fill(buffer,(byte)'A');
-
+
os.write(buffer);
os.flush();
@@ -152,6 +152,32 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
}
@Test
+ public void testExceptionThrownInHandler() throws Exception
+ {
+ configureServer(new AbstractHandler()
+ {
+ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+ {
+ throw new ServletException("handler exception");
+ }
+ });
+
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(true);
+
+ StringBuffer request = new StringBuffer("GET / HTTP/1.0\r\n");
+ request.append("Host: localhost\r\n\r\n");
+
+ Socket client = newSocket(HOST, _connector.getLocalPort());
+ OutputStream os = client.getOutputStream();
+
+ os.write(request.toString().getBytes());
+ os.flush();
+
+ String response = readResponse(client);
+ assertThat("response code is 500", response.contains("500"), is(true));
+ }
+
+ @Test
public void testInterruptedRequest() throws Exception
{
final AtomicBoolean fourBytesRead = new AtomicBoolean(false);
@@ -194,7 +220,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
String response = readResponse(client);
client.close();
- assertThat("response contains 500", response, Matchers.containsString(" 500 "));
+ assertThat("response contains 500", response, Matchers.containsString(" 500 "));
assertThat("The 4th byte (-1) has not been passed to the handler", fourBytesRead.get(), is(false));
assertThat("EofException has been caught", earlyEOFException.get(), is(true));
}
@@ -1144,8 +1170,8 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
buf+=(char)in.read();
avail=in.available();
}
-
-
+
+
out.println(avail);
out.println(buf);
out.close();
@@ -1346,9 +1372,9 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
}
}
}.start();
-
+
String resps = readResponse(client);
-
+
int offset=0;
for (int i=0;i<(REQS+1);i++)
{
@@ -1369,7 +1395,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
response.setStatus(200);
}
}
-
+
@Test
public void testSuspendedPipeline() throws Exception