Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rebranched

git-svn-id: file:///Users/billburke/jboss/resteasy/resteasy-git/svn-server-sync/resteasy/tags/RESTEASY_JAXRS_1_0_BETA_2@138 2b1ed4c4-5db3-0410-90e4-80a7a6204c25
  • Loading branch information...
commit 19f0a08441ab8c2057547a9dadebe7cf71d7b35e 2 parents 98279c4 + f16bd13
patriot1burke authored
View
2  resteasy-jaxrs/src/main/java/org/resteasy/Dispatcher.java
@@ -110,6 +110,7 @@ public void invoke(HttpRequest in, HttpResponse response)
e.printStackTrace();
return;
}
+ response.setStatus(jaxrsResponse.getStatus());
if (jaxrsResponse.getMetadata() != null)
{
List cookies = jaxrsResponse.getMetadata().get(HttpHeaderNames.SET_COOKIE);
@@ -139,7 +140,6 @@ public void invoke(HttpRequest in, HttpResponse response)
MediaType responseContentType = resolveContentType(invoker, in, jaxrsResponse);
writeResponse(response, invoker, jaxrsResponse.getEntity(), responseContentType);
}
- response.setStatus(jaxrsResponse.getStatus());
}
catch (Exception e)
View
17 ...jaxrs/src/test/java/org/resteasy/test/finegrain/resource/WebApplicationExceptionTest.java
@@ -34,6 +34,14 @@ public Response get() throws WebApplicationException
throw new WebApplicationException(Response.status(HttpResponseCodes.SC_UNAUTHORIZED).build());
}
+
+ @Path("/exception/entity")
+ @GET
+ public Response getEntity() throws WebApplicationException
+ {
+ throw new WebApplicationException(Response.status(HttpResponseCodes.SC_UNAUTHORIZED).entity("error").build());
+
+ }
}
@BeforeClass
@@ -72,5 +80,14 @@ public void testException()
_test(new HttpClient(), "http://localhost:8081/exception", HttpResponseCodes.SC_UNAUTHORIZED);
}
+ /**
+ * Test JIRA bug RESTEASY-24
+ */
+ @Test
+ public void testExceptionWithEntity()
+ {
+ _test(new HttpClient(), "http://localhost:8081/exception/entity", HttpResponseCodes.SC_UNAUTHORIZED);
+ }
+
}
View
34 resteasy-jaxrs/src/test/java/org/resteasy/test/regression/RegressionTest.java
@@ -43,6 +43,16 @@ public Response get()
builder.header("CoNtEnT-type", "text/plain");
return builder.build();
}
+
+ @Path("/complex")
+ @GET
+ public Response getComplex()
+ {
+ Response.ResponseBuilder builder = Response.status(HttpResponseCodes.SC_FOUND).entity("hello world".getBytes());
+ builder.header("CoNtEnT-type", "text/plain");
+ return builder.build();
+ }
+
}
/**
@@ -69,4 +79,28 @@ public void test1and2() throws Exception
EmbeddedContainer.stop();
}
+ /**
+ * Test JIRA bug RESTEASY-24
+ */
+ @Test
+ public void test24() throws Exception
+ {
+ dispatcher = EmbeddedContainer.start();
+ dispatcher.getRegistry().addPerRequestResource(SimpleResource.class);
+ {
+ HttpClient client = new HttpClient();
+ GetMethod method = new GetMethod("http://localhost:8081/complex");
+ int status = client.executeMethod(method);
+ Assert.assertEquals(HttpResponseCodes.SC_FOUND, status);
+ Assert.assertEquals(method.getResponseHeader("content-type").getValue(), "text/plain");
+ byte[] responseBody = method.getResponseBody();
+ String response = new String(responseBody, "US-ASCII");
+ Assert.assertEquals("hello world", response);
+ method.releaseConnection();
+ }
+ EmbeddedContainer.stop();
+
+ }
+
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.