private static final String POST_DATA = "<request> hello world </request>";
private static final String CONTENT_TYPE = "text/xml";
@Test
public void testHttpClient() throws Exception {
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/hello", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
assertEquals("Get wrong content type", "text/xml", response.getContentType());
assertTrue("UTF-8".equalsIgnoreCase(response.getCharacterSet()));
assertEquals("Get a wrong message header", "/hello", response.getHeaderField("PATH"));
assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
req = new PostMethodWebRequest(CONTEXT_URL + "/services/helloworld", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
response = client.getResponse(req);
assertEquals("Get wrong content type", "text/xml", response.getContentType());
assertTrue("UTF-8".equalsIgnoreCase(response.getCharacterSet()));
assertEquals("Get a wrong message header", "/helloworld", response.getHeaderField("PATH"));