Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpClient



   @Test
   public void testIt()
   {
      HttpClient client = new HttpClient();
      _test(client, "http://localhost:8080/application-scan-test/app-path/my", "\"hello\"");
      _test(client, "http://localhost:8080/application-scan-test/app-path/my", "\"hello\"");
      _test(client, "http://localhost:8080/application-scan-test/app-path/my", "\"hello\"");
   }
View Full Code Here



   @Test
   public void testIt()
   {
      HttpClient client = new HttpClient();
      _test(client, "http://localhost:8080/application-config-test/my", "\"hello\"");
   }
View Full Code Here

    * @return int http response code
    * @throws Exception on any failure
    */
   public static int accessURL(URL url) throws Exception
   {
      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = createMethod(url, GET);

      int hdrCount = null != null ? ((Header[]) null).length : 0;
      for(int n = 0; n < hdrCount; n ++)
         request.addRequestHeader(((Header[]) null)[n]);
      try
      {
         log.info("Connecting to: "+ url);
         String userInfo = url.getUserInfo();

         if( userInfo != null )
         {
            UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
            httpConn.getState().setCredentials("JBossTest Servlets", 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);
         return responseCode;
View Full Code Here

   public static HttpMethodBase accessURL(URL url, String realm,
      int expectedHttpCode, int type)
      throws Exception
   {
      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = createMethod(url, type);

      int hdrCount = null != null ? ((Header[]) null).length : 0;
      for(int n = 0; n < hdrCount; n ++)
         request.addRequestHeader(((Header[]) null)[n]);
      try
      {
         log.info("Connecting to: "+ url);
         String userInfo = url.getUserInfo();

         if( userInfo != null )
         {
            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

    long timeout = expectContent ? 65000000000L : 0;
   
    while (true)
    {
        // Create an instance of HttpClient.
        HttpClient client = new HttpClient();
 
        if (!node0ok)
        {   
           node0ok = makeGet(client, getHttpURLs()[0] + "/huge/index.html", expectContent);
        }
       
        if (node0ok && !node1ok)
        {
          client = new HttpClient();
       
          node1ok = makeGet(client, getHttpURLs()[1] + "/huge/index.html", expectContent);
        }
       
        if ((node0ok && node1ok) || (System.nanoTime() - start > timeout))
View Full Code Here

  
   public void testFarmDWar() throws Exception
   {
      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

      checkAvailable("/farmF/index.html");
   }

   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

      params.setDefaultMaxConnectionsPerHost(MAX_THREADS);
      params.setMaxTotalConnections(MAX_THREADS);
     
      this.manager.setParams(params);

      this.client = new HttpClient();
      this.executor = Executors.newFixedThreadPool(MAX_THREADS);
   }
View Full Code Here

      deploy(true);
      deploy(false);
     
      // Create an instance of HttpClient.
      HttpClient client = new HttpClient();

      // Set the session attribute first
      makeGet(client, baseURL0_ +setUrl_);

      // Create a method instance.
View Full Code Here

      deploy(true);
      undeploy(false);
     
      // Create an instance of HttpClient.
      HttpClient client = new HttpClient();

      // Set the session attribute first
      makeGet(client, baseURL0_ +setUrl_);

      // Create a method instance.
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.HttpClient

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.