Skip to content

Commit

Permalink
test for issue StripesFramework#74
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpablo-santos authored Aug 6, 2019
1 parent 7bdfa65 commit 0609a15
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,29 @@ public void testJsonBindingFromRequestBody() throws Exception {
logTripResponse(trip);
}

@Test(groups = "fast")
public void testJsonBindingFromRequestBodyWithTransferEncoding() throws Exception {
MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), "/test/1");
trip.getRequest().addHeader("Content-Type", "application/json");
trip.getRequest().addHeader("Transfer-Encoding", "chunked");
trip.getRequest().setMethod("POST");
String json = "{ \"person\" : { \"firstName\":\"Jane\", \"lastName\":\"Johnson\", \"favoriteFoods\" : [\"Snickers\",\"Scotch\",\"Pizza\"], \"children\" : [{ \"firstName\": \"Jackie\"},{\"firstName\":\"Janie\"}]}}";
trip.getRequest().setRequestBody(json);
trip.execute("boundPersonEvent");
RestActionBeanTest bean = trip.getActionBean(getClass());
Assert.assertEquals(bean.getPerson().getId(), "1");
Assert.assertEquals(bean.getPerson().getFirstName(), "Jane");
Assert.assertEquals(bean.getPerson().getLastName(), "Johnson");
Assert.assertEquals(bean.getPerson().getChildren().size(), 2);
List< String> favoriteFoods = new ArrayList< String>();
favoriteFoods.add("Snickers");
favoriteFoods.add("Scotch");
favoriteFoods.add("Pizza");
Assert.assertEquals(bean.getPerson().getFavoriteFoods(), favoriteFoods);

logTripResponse(trip);
}

@Test(groups = "fast")
public void testThereIsNoJsonBindingWithoutRequestBody() throws Exception {
MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), "/test/1");
Expand Down

0 comments on commit 0609a15

Please sign in to comment.