Search in sources :

Example 6 with WebResponse

use of com.meterware.httpunit.WebResponse in project camel by apache.

the class MultiServletConsumerTest method getService.

public String getService(String path) throws Exception {
    WebRequest req = new GetMethodWebRequest(CONTEXT_URL + path);
    ServletUnitClient client = newClient();
    WebResponse response = client.getResponse(req);
    return response.getText();
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest)

Example 7 with WebResponse

use of com.meterware.httpunit.WebResponse in project camel by apache.

the class ServletNoSlashNeededTest method testNoSlashNeeded.

@Test
public void testNoSlashNeeded() throws Exception {
    WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
    ServletUnitClient client = newClient();
    WebResponse response = client.getResponse(req);
    assertEquals("The response message is wrong ", "Bye World", response.getText());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) Test(org.junit.Test)

Example 8 with WebResponse

use of com.meterware.httpunit.WebResponse in project camel by apache.

the class ServletRootPathTest method testRootPath.

@Test
public void testRootPath() throws Exception {
    WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/");
    ServletUnitClient client = newClient();
    WebResponse response = client.getResponse(req);
    assertEquals("The response message is wrong ", "Bye World", response.getText());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) Test(org.junit.Test)

Example 9 with WebResponse

use of com.meterware.httpunit.WebResponse in project camel by apache.

the class ServletSetBodyTest method testSetBody.

@Test
public void testSetBody() throws Exception {
    WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
    ServletUnitClient client = newClient();
    WebResponse response = client.getResponse(req);
    assertEquals("The response message is wrong ", "Bye World", response.getText());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) Test(org.junit.Test)

Example 10 with WebResponse

use of com.meterware.httpunit.WebResponse in project camel by apache.

the class ServletTransferExceptionTest method testTransferException.

@Test
public void testTransferException() throws Exception {
    WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/hello", new ByteArrayInputStream("".getBytes()), "text/plain");
    ServletUnitClient client = newClient();
    client.setExceptionsThrownOnErrorStatus(false);
    WebResponse response = client.getResponse(req);
    assertEquals(500, response.getResponseCode());
    assertEquals(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, response.getContentType());
    Object object = HttpHelper.deserializeJavaObjectFromStream(response.getInputStream());
    assertNotNull(object);
    IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, object);
    assertEquals("Damn", cause.getMessage());
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) Test(org.junit.Test)

Aggregations

WebResponse (com.meterware.httpunit.WebResponse)100 WebRequest (com.meterware.httpunit.WebRequest)95 GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)84 Test (org.junit.Test)76 WebConversation (com.meterware.httpunit.WebConversation)43 ServletUnitClient (com.meterware.servletunit.ServletUnitClient)41 PostMethodWebRequest (com.meterware.httpunit.PostMethodWebRequest)30 ByteArrayInputStream (java.io.ByteArrayInputStream)28 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)16 PutMethodWebRequest (com.meterware.httpunit.PutMethodWebRequest)15 TextBlock (com.meterware.httpunit.TextBlock)14 URL (java.net.URL)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)14 HttpServletResponse (javax.servlet.http.HttpServletResponse)14 HttpSession (javax.servlet.http.HttpSession)9 WebForm (com.meterware.httpunit.WebForm)7 HeaderOnlyWebRequest (com.meterware.httpunit.HeaderOnlyWebRequest)5 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)5 HttpException (com.meterware.httpunit.HttpException)4 HttpNotFoundException (com.meterware.httpunit.HttpNotFoundException)4