Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebConversation


        long startTime = System.currentTimeMillis();

        try {
            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();
View Full Code Here


                this.endThreads + "", this.stepSize + "", this.stepPeriod + "",
                this.gracePeriod + "" });
    }

    public void test() throws InterruptedException {
        WebConversation wc = null;

        // Loop through in steps
        for (int n = this.startThreads; n <= this.endThreads; n += this.stepSize) {
            if (this.useKeepAlives)
                wc = new WebConversation();

            // Spawn the threads
            int noOfSeconds = (int) this.stepPeriod / 1000;
            List threads = new ArrayList();
            for (int m = 0; m < n; m++)
View Full Code Here

        args.put("logThrowingLineNo", "true");
        Logger.init(Logger.FULL_DEBUG, System.out, true);
        Launcher winstone = new Launcher(args);

        // 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

        args.put("logThrowingLineNo", "true");
        Logger.init(Logger.FULL_DEBUG, System.out, true);
        Launcher winstone = new Launcher(args);

        // 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();
View Full Code Here

        args.put("logThrowingLineNo", "true");
        Logger.init(Logger.FULL_DEBUG, System.out, true);
        Launcher winstone = new Launcher(args);

        // 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

        WebRequest request,
        int errorCode,
        String errorText)
        throws MalformedURLException, IOException, SAXException
    {
        WebConversation session = new WebConversation();
        String failureText =
            "Expected error " + errorCode + " from " + request.getURL();
   
        try
        {
            session.getResponse(request);
            fail(errorText + " -got success instead");
        }
        catch (HttpException e)
        {
            assertEquals(failureText, errorCode, e.getResponseCode());
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(webResponse.getText().contains("Enter your name"));

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

      assertTrue(webResponse.getText().contains("Hello Stan"));
   }
  
   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

    @Test
    public void testJSONRPCBinding() throws Exception {
        JSONObject jsonRequest = new JSONObject("{ \"method\": \"sayHello\", \"params\": [\"Ray\"], \"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());
        String text = jsonResp.getString("result");
View Full Code Here

        //System.in.read();
    }

    @Test
    public void testGetInvocation() throws Exception {
        WebConversation wc = new WebConversation();
        WebRequest request = new GetMethodWebRequest(SERVICE_URL);
        request.setHeaderField("Content-Type", "application/xml");
        WebResponse response = wc.getResource(request);

        //for debug purposes
        //list the response headers
        //for(String headerField : response.getHeaderFieldNames()) {
        //    System.out.println(">>> Header:" + headerField + " - " + response.getHeaderField(headerField));
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.