Package org.apache.commons.httpclient

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


         {
            UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
            httpConn.getState().setCredentials(realm, url.getHost(), auth);
         }
         log.info("RequestURI: "+request.getURI());
         int responseCode = httpConn.executeMethod(request);
         String response = request.getStatusText();
         log.info("responseCode="+responseCode+", response="+response);
         String content = request.getResponseBodyAsString();
         log.info(content);
         // Validate that we are seeing the requested response code
View Full Code Here


      String index = "/farmD/index.html";

      HttpClient client = new HttpClient();

      GetMethod get = new GetMethod(getHttpURLs()[0] +index);
      assertEquals("farmD is unavailable on node0", HttpURLConnection.HTTP_NOT_FOUND, client.executeMethod(get));
      get = new GetMethod(getHttpURLs()[1] +index);
      assertEquals("farmD is unavailable on node1", HttpURLConnection.HTTP_NOT_FOUND, client.executeMethod(get));
   }
  
   /**
 
View Full Code Here

      HttpClient client = new HttpClient();

      GetMethod get = new GetMethod(getHttpURLs()[0] +index);
      assertEquals("farmD is unavailable on node0", HttpURLConnection.HTTP_NOT_FOUND, client.executeMethod(get));
      get = new GetMethod(getHttpURLs()[1] +index);
      assertEquals("farmD is unavailable on node1", HttpURLConnection.HTTP_NOT_FOUND, client.executeMethod(get));
   }
  
   /**
    * Confirms a zipped war replicated from node0 to node1
    *
 
View Full Code Here

   private void checkAvailable(String url) throws Exception, IOException, HttpException
   {
      HttpClient client = new HttpClient();

      GetMethod get = new GetMethod(getHttpURLs()[0] +url);
      assertEquals(url + " is available on node0", HttpURLConnection.HTTP_OK, client.executeMethod(get));
      get = new GetMethod(getHttpURLs()[1] +url);
      assertEquals(url + " is available on node1", HttpURLConnection.HTTP_OK, client.executeMethod(get));
   }
}
View Full Code Here

      HttpClient client = new HttpClient();

      GetMethod get = new GetMethod(getHttpURLs()[0] +url);
      assertEquals(url + " is available on node0", HttpURLConnection.HTTP_OK, client.executeMethod(get));
      get = new GetMethod(getHttpURLs()[1] +url);
      assertEquals(url + " is available on node1", HttpURLConnection.HTTP_OK, client.executeMethod(get));
   }
}
View Full Code Here

    */
   protected void testHost(URL url, String virtualHost) throws Exception
   {
      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = new OverrideGetMethod(url.toString(), virtualHost);
      int responseCode = httpConn.executeMethod(request);
     
      if( responseCode != HttpURLConnection.HTTP_OK )
      {
         throw new IOException("Expected reply code:"+ HttpURLConnection.HTTP_OK
            +", actual="+responseCode);
View Full Code Here

      // Start by accessing the secured index.html of war1
      HttpClient httpConn = new HttpClient();
     
      // Try to access protected resource
      GetMethod indexGet = new GetMethod(url + "index.jsp");
      int responseCode = httpConn.executeMethod(indexGet);
      String body = indexGet.getResponseBodyAsString();
      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
      assertTrue("Redirected to login page", body.indexOf("j_security_check") > 0 );

      // Submit the login form
View Full Code Here

   
      PostMethod formPost = new PostMethod(url + "j_security_check");
      formPost.addRequestHeader("Referer", url + "login.html");
      formPost.addParameter("j_username", "admin");
      formPost.addParameter("j_password", "admin");
      responseCode = httpConn.executeMethod(formPost.getHostConfiguration(),
         formPost, httpConn.getState());
      assertTrue("Saw HTTP_MOVED_TEMP("+responseCode+")",
         responseCode == HttpURLConnection.HTTP_MOVED_TEMP);

      //  Follow the redirect to the index.html page
View Full Code Here

      //  Follow the redirect to the index.html page
      Header location = formPost.getResponseHeader("Location");
      String indexURI = location.getValue();
      GetMethod warIndex = new GetMethod(indexURI);
      responseCode = httpConn.executeMethod(warIndex.getHostConfiguration(),
         warIndex, httpConn.getState());
      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
      body = warIndex.getResponseBodyAsString();
      if( body.indexOf("j_security_check") > 0 )
         fail("get of "+indexURI+" redirected to login page");
View Full Code Here

      // Start by accessing the secured index.html of war1
      HttpClient httpConn = new HttpClient();
      String url = httpNoAuth+"clientcert-auth/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);
   }
   public void doHttps(String httpsNoAuth) throws Exception
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.