Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebConversation


        } catch (HttpInternalErrorException e) {
        }
    }

    public void testRedirect() throws Exception {
        WebConversation conversation = new WebConversation();
        conversation.getClientProperties().setAutoRedirect(false);

        WebRequest request = new GetMethodWebRequest(baseUrl + "/redirect");

        WebResponse response = conversation.getResponse(request);

        assertEquals(302, response.getResponseCode());
        assertEquals(baseUrl + "/get", response.getHeaderField("Location"));
    }
View Full Code Here


   }  

   public void testJSFAppWithBundledMyFaces() throws Exception
   {
      String baseURL = HttpUtils.getBaseURL();
      WebConversation webConversation = new WebConversation();
     
      // Initial JSF request
      WebRequest req = new GetMethodWebRequest(baseURL + "bundled-myfaces-hellojsf/index.faces");
      WebResponse webResponse = webConversation.getResponse(req);
      assertTrue(contains(webResponse.getText(), "Enter your name"));

      // submit data
      WebForm form = webResponse.getFormWithID("form1");
      form.setParameter("form1:input_foo_text", "Stan");
View Full Code Here

    }

    public void testJSONRPCBinding() throws Exception {
        JSONObject jsonRequest = new JSONObject("{ \"method\": \"echo\", \"params\": [\"Hello JSON-RPC\"], \"id\": 1}");

        WebConversation wc = new WebConversation();
        WebRequest request   = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
        WebResponse response = wc.getResource(request);

        assertEquals(200, response.getResponseCode());
        JSONObject jsonResp = new JSONObject(response.getText());
        assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
    }
View Full Code Here

   
    @Test
    public void testRuntimeException() throws Exception{
      JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoRuntimeException\", \"params\": [], \"id\": 2}");
     
      WebConversation wc = new WebConversation();
        WebRequest request   = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(200, response.getResponseCode());
       
        JSONObject jsonErr = new JSONObject(response.getText()).getJSONObject("error");
       
View Full Code Here

   
    @Test
    public void testBusinessException() throws Exception{
      JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBusinessException\", \"params\": [], \"id\": 3}");
     
      WebConversation wc = new WebConversation();
        WebRequest request   = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(200, response.getResponseCode());
       
        JSONObject jsonErr = new JSONObject(response.getText()).getJSONObject("error");
       
View Full Code Here

    @Test
    public void testJSONRPCBinding() throws Exception {
        JSONObject jsonRequest = new JSONObject("{ \"method\": \"echo\", \"params\": [\"Hello JSON-RPC\"], \"id\": 1}");

        WebConversation wc = new WebConversation();
        WebRequest request   = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
        Assert.assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
View Full Code Here

    @Test
    public void testInt() throws Exception {
        JSONObject jsonRequest = new JSONObject(
            "{ \"method\": \"echoInt\", \"params\": [12345], \"id\": 4}");

        WebConversation wc = new WebConversation();
        WebRequest request = new PostMethodWebRequest(SERVICE_URL,
                                                      new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here

    @Test
    public void testBoolean() throws Exception {
        JSONObject jsonRequest = new JSONObject(
            "{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}");

        WebConversation wc = new WebConversation();
        WebRequest request = new PostMethodWebRequest(SERVICE_URL,
                                                      new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here

    @Test
    public void testMap() throws Exception {
        JSONObject jsonRequest = new JSONObject(
            "{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}");

        WebConversation wc = new WebConversation();
        WebRequest request = new PostMethodWebRequest(SERVICE_URL,
                                                      new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here

    @Test
    public void testBean() throws Exception {
        JSONObject jsonRequest = new JSONObject(
            "{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"bean.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}");

        WebConversation wc = new WebConversation();
        WebRequest request = new PostMethodWebRequest(SERVICE_URL,
                                                      new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")), "application/json");
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here

TOP

Related Classes of com.meterware.httpunit.WebConversation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.