Examples of HttpMethodBase


Examples of org.apache.commons.httpclient.HttpMethodBase

   }

   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);
      return content;
   }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

   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
         if( responseCode != expectedHttpCode )
         {
            throw new IOException("Expected reply code:"+expectedHttpCode
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

      return request;
   }

   public static HttpMethodBase createMethod(URL url, int type)
   {
      HttpMethodBase request = null;
      switch( type )
      {
         case GET:
            request = new GetMethod(url.toString());
            break;
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

      return url;
   }

   protected void accessWebApp(String urlPath, String...tokens) throws Exception
   {
      HttpMethodBase request = HttpUtils.accessURL(new URL(HttpUtils.getBaseURL() + urlPath));
      String body = request.getResponseBodyAsString();
     
      assertTrue("Body was not transformed to html:\n" + body, body.indexOf("<h:") < 0);
     
      System.out.println(body);
     
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

    * @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;
         // Validate that we are seeing the requested response code
      }
      catch(IOException e)
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

   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
         if( responseCode != expectedHttpCode)
         {
            throw new IOException("Expected reply code:"+ expectedHttpCode
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

      return request;
   }

   public static HttpMethodBase createMethod(URL url, int type)
   {
      HttpMethodBase request = null;
      switch( type )
      {
         case GET:
            request = new GetMethod(url.toString());
            break;
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

    * @throws Exception
    */
   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
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

    */
   public void testAltRequestInfoServlet()
      throws Exception
   {
      URL url = new URL(baseURL+"simple-xmlonly/ENCServlet");
      HttpMethodBase request = HttpUtils.accessURL(url);
      Header errors = request.getResponseHeader("X-Exception");
      log.info("X-Exception: "+errors);
      assertTrue("X-Exception("+errors+") is null", errors == null);     
   }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpMethodBase

    */
   public void testAltRequestInfoServlet()
      throws Exception
   {
      URL url = new URL(baseURL+"simple-annonly/ENCServlet");
      HttpMethodBase request = HttpUtils.accessURL(url);
      Header errors = request.getResponseHeader("X-Exception");
      log.info("X-Exception: "+errors);
      assertTrue("X-Exception("+errors+") is null", errors == null);     
   }
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.