Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpClient.executeMethod()


      //  Follow the redirect to the index.jsp
      Header location = formPost.getResponseHeader("Location");
      String indexURI = location.getValue();
      GetMethod war1Index = new GetMethod(indexURI);
      responseCode = httpConn.executeMethod(war1Index.getHostConfiguration(),
            war1Index, state);
      response = war1Index.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
      body = war1Index.getResponseBodyAsString();
View Full Code Here


    log.info("testCookieSetCorrectly");
    URL url = new URL(baseURL+"jbosstest-cookie/CookieReadServlet");
    HttpClient httpClient = new HttpClient();       
    HttpMethodBase request = HttpUtils.createMethod(url,HttpUtils.GET);
    //sending a blank request
    httpClient.executeMethod(request);
   
    log.info("sending request with cookie");   
    request = HttpUtils.createMethod(url,HttpUtils.POST);
    int responseCode = httpClient.executeMethod(request);
    assertEquals(HttpURLConnection.HTTP_OK, responseCode);   
View Full Code Here

    //sending a blank request
    httpClient.executeMethod(request);
   
    log.info("sending request with cookie");   
    request = HttpUtils.createMethod(url,HttpUtils.POST);
    int responseCode = httpClient.executeMethod(request);
    assertEquals(HttpURLConnection.HTTP_OK, responseCode);   
  }
 
  public void testCookieRetrievedCorrectly() throws Exception
  {
View Full Code Here

  public void testCookieRetrievedCorrectly() throws Exception
  {
    URL url = new URL(baseURL+"jbosstest-cookie/CookieServlet");
    HttpClient httpClient = new HttpClient();       
    HttpMethodBase request = HttpUtils.createMethod(url,HttpUtils.GET);      
    int responseCode =httpClient.executeMethod(request);
    //assert that we are able to hit servlet successfully
    assertEquals(HttpURLConnection.HTTP_OK, responseCode);
    request.getResponseHeader("Set-Cookie");
   
    Cookie[] cookies = httpClient.getState().getCookies();       
View Full Code Here

   }

   private String getResponseBody(String warName) throws Exception
   {
      HttpClient client = new HttpClient();
      client.executeMethod(makeRequest(warName));
     
      HttpMethodBase result = makeRequest(warName);

      // need to hit it twice with the same session for test to pass
      client.executeMethod(result);
View Full Code Here

      client.executeMethod(makeRequest(warName));
     
      HttpMethodBase result = makeRequest(warName);

      // need to hit it twice with the same session for test to pass
      client.executeMethod(result);

      String responseBody = result.getResponseBodyAsString();
      if (responseBody == null) {
         throw new Exception("Unable to get response from server.");
      }
View Full Code Here

      // Submit the login form
      PostMethod formPost = new PostMethod(baseURL0_ + securityCheckUrl_);
      formPost.addRequestHeader("Referer", baseURL0_ + loginFormUrl_);
      formPost.addParameter("j_username", "admin");
      formPost.addParameter("j_password", "admin");
      int responseCode = client.executeMethod(formPost.getHostConfiguration(),
         formPost, state);
      String response = formPost.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
      assertTrue("Saw HTTP_MOVED_TEMP("+responseCode+")",
         responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
View Full Code Here

   public void testStatusServlet() throws Exception
   {
      HttpClient httpConn = new HttpClient();
      String url = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/status?full=true";
      GetMethod getMethod = new GetMethod(url);
      int responseCode = httpConn.executeMethod(getMethod);
      assertEquals("GET " + url + " OK", HttpURLConnection.HTTP_OK, responseCode);
   }
}
View Full Code Here

      // Start by accessing the secured index.html of war1
      HttpClient httpConn = new HttpClient();
      String url = httpsNoAuth+"clientcert-jaspi/unrestricted/SecureServlet";
      log.info("Accessing: "+url);
      GetMethod get = new GetMethod(url);
      int responseCode = httpConn.executeMethod(get);
      String status = get.getStatusText();
      log.debug(status);
      assertTrue("Get OK("+responseCode+")", responseCode == HttpURLConnection.HTTP_OK);
   }
   
View Full Code Here

   {
      HttpClient client = new HttpClient();

      {
         GetMethod method = new GetMethod("http://localhost:8080/spring-integration-test/basic");
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("basic", method.getResponseBodyAsString());
         method.releaseConnection();
      }
      {
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.