Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.GetMethod.releaseConnection()


   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(getRequestURL(MyProvider.Consumer1Key, "foo"));
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpResponseCodes.SC_UNAUTHORIZED, status);
      method.releaseConnection();
   }

   @Test
   public void testRequestInvalidConsumerKey() throws Exception
   {
View Full Code Here


   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(getRequestURL("bar", "foo"));
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpResponseCodes.SC_UNAUTHORIZED, status);
      method.releaseConnection();
   }

   @Test
   public void testRequestAllParams() throws Exception
   {
View Full Code Here

      Assert.assertTrue(response.containsKey(OAuth.OAUTH_TOKEN_SECRET));
      Assert.assertTrue(response.get(OAuth.OAUTH_TOKEN_SECRET).length() > 0);
      Assert.assertTrue(response.containsKey(OAuthUtils.OAUTH_CALLBACK_CONFIRMED_PARAM));
      Assert.assertEquals(response.get(OAuthUtils.OAUTH_CALLBACK_CONFIRMED_PARAM), "true");

      method.releaseConnection();
   }

   private Map<String, String> getResponse(GetMethod method) throws Exception {
     return OAuth.newMap(OAuth.decodeForm(method.getResponseBodyAsString()));
   }
View Full Code Here

      HttpClient client = new HttpClient();
     
      GetMethod method = new GetMethod(AccessURL);
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpResponseCodes.SC_BAD_REQUEST, status);
      method.releaseConnection();
   }

   @Test
   public void testAccessAllParams() throws Exception
   {
View Full Code Here

      Assert.assertTrue(response.containsKey(OAuth.OAUTH_TOKEN));
      Assert.assertTrue(response.get(OAuth.OAUTH_TOKEN).length() > 0);
      Assert.assertTrue(response.containsKey(OAuth.OAUTH_TOKEN_SECRET));
      Assert.assertTrue(response.get(OAuth.OAUTH_TOKEN_SECRET).length() > 0);

      method.releaseConnection();
   }

   @Test
   public void testAccessAllParamsAgain() throws Exception
   {
View Full Code Here

   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(getAccessURL(MyProvider.Consumer1Key, MyProvider.Consumer1Secret, MyProvider.Consumer1Request1Key, MyProvider.Consumer1Request1Secret, MyProvider.Consumer1Request1Verifier));
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpResponseCodes.SC_UNAUTHORIZED, status);
      method.releaseConnection();
   }

   @Test
   public void testAccessNonAuthorized() throws Exception
   {
View Full Code Here

   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(getAccessURL(MyProvider.Consumer1Key, MyProvider.Consumer1Secret, MyProvider.Consumer1Request2Key, MyProvider.Consumer1Request2Secret, "foo"));
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpResponseCodes.SC_UNAUTHORIZED, status);
      method.releaseConnection();
   }

  @Test
  public void testProtectedResourceAdminRole() throws Exception
  {
View Full Code Here

   private void testProtectedURL(String url, int expectedStatus) throws Exception{
     HttpClient client = new HttpClient();
     GetMethod method = new GetMethod(getProtectedURL(url, MyProvider.Consumer1Key, MyProvider.Consumer1Secret, MyProvider.Consumer1Access1Key, MyProvider.Consumer1Access1Secret));
     int status = client.executeMethod(method);
     Assert.assertEquals(expectedStatus, status);
     method.releaseConnection();
   }

   private String getRequestURL(String consumerKey, String consumerSecret) throws Exception {
     OAuthMessage message = new OAuthMessage("GET", RequestURL, Collections.<Map.Entry>emptyList());
     OAuthConsumer consumer = new OAuthConsumer("http://callback.net", consumerKey, consumerSecret, null);
View Full Code Here

         SimpleClient proxy = ProxyFactory.create(SimpleClient.class, generateBaseUrl());
         proxy.deleteCustomer();

         Assert.assertEquals(204, proxy.deleteComplex().getStatus());

         method.releaseConnection();
         client.getHttpConnectionManager().closeIdleConnections(0);
      }
      EmbeddedContainer.stop();
   }
View Full Code Here

         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals(method.getResponseHeader("content-type").getValue(), "text/plain");
         byte[] responseBody = method.getResponseBody();
         String response = new String(responseBody, "US-ASCII");
         Assert.assertEquals("hello world", response);
         method.releaseConnection();
         client.getHttpConnectionManager().closeIdleConnections(0);
      }
      EmbeddedContainer.stop();
   }
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.