Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpClient


    /* Feed Support */
    if ("feed".equals(link.getScheme())) //$NON-NLS-1$
      initFeedProtocol();

    /* Init Client */
    HttpClient client = initClient(properties);

    /* Init the connection */
    HttpMethodBase method = null;
    InputStream inS = null;
    try {
View Full Code Here


    /* SSL Support */
    if ("https".equals(link.getScheme())) //$NON-NLS-1$
      initSSLProtocol();

    /* Init Client */
    HttpClient client = initClient(properties);

    /* Init the connection */
    GetMethod getMethod = null;
    InputStream inS = null;
    try {
View Full Code Here

    int conTimeout = DEFAULT_CON_TIMEOUT;
    if (properties != null && properties.containsKey(IConnectionPropertyConstants.CON_TIMEOUT))
      conTimeout = (Integer) properties.get(IConnectionPropertyConstants.CON_TIMEOUT);

    /* Create a new HttpClient */
    HttpClient client = new HttpClient();

    /* Socket Timeout - Max. time to wait for an answer */
    client.getHttpConnectionManager().getParams().setSoTimeout(conTimeout);

    /* Connection Timeout - Max. time to wait for a connection */
    client.getHttpConnectionManager().getParams().setConnectionTimeout(conTimeout);

    return client;
  }
View Full Code Here

      adaptor.invoke(on, "flushSecurityCache", params, signature);
   }
  
   protected void makeWebRequest(String url, String responseContent)
   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(url);
      int responseCode = 0;
      try
      {
         responseCode = client.executeMethod(method);
        
         assertTrue("Get OK with url: " +url + " responseCode: " +responseCode
               , responseCode == HttpURLConnection.HTTP_OK);
        
         InputStream rs = method.getResponseBodyAsStream();
View Full Code Here

      super(name);
   }
  
   private String accessURL(String url) throws Exception
   {
      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = new GetMethod(baseURL + url);
      log.debug("RequestURI: " + request.getURI());
      int responseCode = httpConn.executeMethod(request);
      String response = request.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
      String content = request.getResponseBodyAsString();
      log.debug(content);
      assertEquals(HttpURLConnection.HTTP_OK, responseCode);
View Full Code Here

   }
   public static HttpMethodBase accessURL(URL url, String realm,
      int expectedHttpCode, Header[] hdrs, int type)
      throws Exception
   {
      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = createMethod(url, type);
      int hdrCount = hdrs != null ? hdrs.length : 0;
      for(int n = 0; n < hdrCount; n ++)
         request.addRequestHeader(hdrs[n]);
      try
      {
         log.debug("Connecting to: "+url);
         String userInfo = url.getUserInfo();
         if( userInfo != null )
         {
            UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
            httpConn.getState().setCredentials(realm, url.getHost(), auth);
         }
         log.debug("RequestURI: "+request.getURI());
         int responseCode = httpConn.executeMethod(request);
         String response = request.getStatusText();
         log.debug("responseCode="+responseCode+", response="+response);
         String content = request.getResponseBodyAsString();
         log.debug(content);
         // Validate that we are seeing the requested response code
View Full Code Here

      assertEquals("World", accessURL("Read"));
   }

   public String accessURL(String url) throws Exception
   {
      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = new GetMethod(baseURL + url);
      log.debug("RequestURI: " + request.getURI());
      int responseCode = httpConn.executeMethod(request);
      String response = request.getStatusText();
      log.debug("responseCode="+responseCode+", response="+response);
      String content = request.getResponseBodyAsString();
      log.debug(content);
      assertEquals(HttpURLConnection.HTTP_OK, responseCode);
View Full Code Here

   }
  
   @Test
   public void testTheSameInstanceIsUsedForEveryRequest()
   {
      HttpClient client = new HttpClient();
      GetMethod get1 = new GetMethod(BASE_URI + getTestPrefix());
      get1.addRequestHeader("Accept", "text/plain");
      GetMethod get2 = new GetMethod(BASE_URI + getTestPrefix());
      get2.addRequestHeader("Accept", "text/plain");
      try
      {
         int status1 = client.executeMethod(get1);
         assertEquals(status1, 200);
         String response1 = get1.getResponseBodyAsString();
         get1.releaseConnection();
         int status2 = client.executeMethod(get2);
         assertEquals(status2, 200);
         String response2 = get2.getResponseBodyAsString();
         get2.releaseConnection();
         assertEquals(response1, response2);
      }
View Full Code Here

public class SmokeTest
{
   @Test
   public void testNoDefaultsResource() throws Exception
   {
      HttpClient client = new HttpClient();

      {
         GetMethod method = new GetMethod("http://localhost:8080/resteasy/basic");
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("basic", method.getResponseBodyAsString());
         method.releaseConnection();
      }
      {
         // I'm testing unknown content-length here
         GetMethod method = new GetMethod("http://localhost:8080/resteasy/xml");
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         String result = method.getResponseBodyAsString();
         JAXBContext ctx = JAXBContext.newInstance(Customer.class);
         Customer cust = (Customer) ctx.createUnmarshaller().unmarshal(new StringReader(result));
         Assert.assertEquals("Bill Burke", cust.getName());
View Full Code Here


   @Test
   public void testGzip() throws Exception
   {
      HttpClient client = new HttpClient();
      {
         GetMethod get = new GetMethod("http://localhost:8080/resteasy/gzip");
         get.addRequestHeader("Accept-Encoding", "gzip, deflate");
         int status = client.executeMethod(get);
         Assert.assertEquals(200, status);
         Assert.assertEquals("gzip", get.getResponseHeader("Content-Encoding").getValue());
         GZIPInputStream gzip = new GZIPInputStream(get.getResponseBodyAsStream());
         String response = readString(gzip);
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.