Search in sources :

Example 6 with GetMethodWebRequest

use of com.meterware.httpunit.GetMethodWebRequest 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 7 with GetMethodWebRequest

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

the class RestServletGetTest method testServletProducerGet.

@Test
public void testServletProducerGet() throws Exception {
    WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/123/basic");
    ServletUnitClient client = newClient();
    client.setExceptionsThrownOnErrorStatus(false);
    WebResponse response = client.getResponse(req);
    assertEquals(200, response.getResponseCode());
    assertEquals("123;Donald Duck", 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 GetMethodWebRequest

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

the class RestServletGetWildcardsTest method testServletProducerGet.

@Test
public void testServletProducerGet() throws Exception {
    WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/123/basic");
    ServletUnitClient client = newClient();
    client.setExceptionsThrownOnErrorStatus(false);
    WebResponse response = client.getResponse(req);
    assertEquals(200, response.getResponseCode());
    assertEquals("123;Donald Duck", 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 GetMethodWebRequest

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

the class RestServletGetWildcardsTest method testServletProducerGetWildcards.

@Test
public void testServletProducerGetWildcards() throws Exception {
    WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/456/name=g*");
    ServletUnitClient client = newClient();
    client.setExceptionsThrownOnErrorStatus(false);
    WebResponse response = client.getResponse(req);
    assertEquals(200, response.getResponseCode());
    assertEquals("456;Goofy", 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 GetMethodWebRequest

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

the class RestServletPojoInOutTest method testServletPojoGet.

@Test
public void testServletPojoGet() throws Exception {
    WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/lives");
    ServletUnitClient client = newClient();
    client.setExceptionsThrownOnErrorStatus(false);
    WebResponse response = client.getResponse(req);
    assertEquals(200, response.getResponseCode());
    String out = response.getText();
    assertNotNull(out);
    assertEquals("{\"iso\":\"EN\",\"country\":\"England\"}", out);
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) Test(org.junit.Test)

Aggregations

GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)74 WebResponse (com.meterware.httpunit.WebResponse)73 WebRequest (com.meterware.httpunit.WebRequest)70 Test (org.junit.Test)53 WebConversation (com.meterware.httpunit.WebConversation)42 ServletUnitClient (com.meterware.servletunit.ServletUnitClient)16 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 PutMethodWebRequest (com.meterware.httpunit.PutMethodWebRequest)8 PostMethodWebRequest (com.meterware.httpunit.PostMethodWebRequest)7 WebForm (com.meterware.httpunit.WebForm)7 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)5 HttpNotFoundException (com.meterware.httpunit.HttpNotFoundException)4 WebLink (com.meterware.httpunit.WebLink)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 AuthorizationRequiredException (com.meterware.httpunit.AuthorizationRequiredException)3 WebTable (com.meterware.httpunit.WebTable)3