Examples of WebResponse


Examples of com.meterware.httpunit.WebResponse

        // Check for a simple connection
        WebConversation wc = new WebConversation();
        WebRequest wreq = new GetMethodWebRequest(
                "http://localhost:10005/examples/TestWriteAfterServlet");
        WebResponse wresp1 = wc.getResponse(wreq);
        Logger.logDirectMessage(Logger.INFO, "log", "Output: " + wresp1.getText(), null);
        assertTrue(wresp1.getText().endsWith("Hello"));
        winstone.shutdown();
        Thread.sleep(500);
    }
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

            if (this.webConv == null)
                this.webConv = new WebConversation();

            // Access the URL
            WebRequest wreq = new GetMethodWebRequest(this.url);
            WebResponse wresp = this.webConv.getResponse(wreq);
            int responseCode = wresp.getResponseCode();
            if (responseCode >= 400)
                throw new IOException("Failed with status " + responseCode);
            InputStream inContent = wresp.getInputStream();
            int contentLength = wresp.getContentLength();
            byte content[] = new byte[contentLength == -1 ? 100 * 1024
                    : contentLength];
            int position = 0;
            int value = inContent.read();
            while ((value != -1)
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

        // Check for a simple connection
        WebConversation wc = new WebConversation();
        WebRequest wreq = new GetMethodWebRequest(
                "http://localhost:10003/examples/CountRequestsServlet");
        WebResponse wresp = wc.getResponse(wreq);
        InputStream content = wresp.getInputStream();
        assertTrue("Loading CountRequestsServlet", content.available() > 0);
        content.close();
        winstone.shutdown();
        Thread.sleep(500);
    }
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

        // Check for a simple connection
        WebConversation wc = new WebConversation();
        WebRequest wreq = new GetMethodWebRequest(
                "http://localhost:10004/examples/CountRequestsServlet");
        WebResponse wresp1 = wc.getResponse(wreq);
        WebImage img[] = wresp1.getImages();
        for (int n = 0; n < img.length; n++)
            wc.getResponse(img[n].getRequest());
        // Thread.sleep(2000);
        // WebResponse wresp2 = wc.getResponse(wreq);
        // Thread.sleep(2000);
        //WebResponse wresp3 = wc.getResponse(wreq);
        InputStream content = wresp1.getInputStream();
        assertTrue("Loading CountRequestsServlet + child images", content
                .available() > 0);
        content.close();
        winstone.shutdown();
        Thread.sleep(500);
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

    public void testExposeService() throws Exception
    {
        ServletUnitClient client = newClient();

    WebResponse response = client.getResponse("http://localhost/services/SparePartInfo?method=getPartInfo&PartSKU=test");

    //assertIsXml( response.getText() );
    //assertStringInBody( response, "<getPartInfoReturn" );
    //assertStringInBody( response, "test - Part Info" );
    }
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

   
    public void testComplexSerialization() throws Exception
    {
        ServletUnitClient client = newClient();

    WebResponse response = client.getResponse("http://localhost/services/SparePartInfo?method=getSparePart");
   
    //assertIsXml( response.getText() );
        //assertStringInBody( response, "<SKU" );
    }
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

      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(webResponse.getText().contains("Enter your name"));

      // submit data
      WebForm form = webResponse.getFormWithID("form1");
      form.setParameter("form1:input_foo_text", "Stan");
      SubmitButton submitButton = form.getSubmitButtonWithID("form1:submit_button");
      webResponse = form.submit(submitButton);
      assertTrue(webResponse.getText().contains("Hello Stan"));
   }
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

  
   public void testBeanValidationIntegratedWithJSF() throws Exception
   {
      WebConversation wc = new WebConversation();
      String url = makeRequestString("jbosstest-jsf", "/beanvalidation.jsf");
      WebResponse response = wc.getResponse(url);
      WebForm form = response.getFormWithID("form1");
      form.setParameter("form1:input_name", "a");
      SubmitButton submitButton = form.getSubmitButtonWithID("form1:submit_button");
      response = form.submit(submitButton);
      assertTrue(response.getText().contains("size must be between 2 and"));
   }
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

        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());
        String text = jsonResp.getString("result");
        Assert.assertTrue(text.endsWith("Hello Ray"));
    }
View Full Code Here

Examples of com.meterware.httpunit.WebResponse

    @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());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.