Examples of ApacheHttpClient4Executor


Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

         try
         {
            response = request.get();
            Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
           //response.releaseConnection();
            ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
            executor.getHttpClient().getConnectionManager().shutdown();
//            request.getExecutor().close();
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
         }
      }

      {
         ClientRequest request = new ClientRequest(generateURL("" + base + "default"));
         request.header(HttpHeaderNames.ACCEPT, "application/" + type);
         ClientResponse<?> response;
         try
         {
            response = request.get();
            Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
           //response.releaseConnection();
            ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
            executor.getHttpClient().getConnectionManager().shutdown();
//            request.getExecutor().close();
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
         }
      }

      {
         ClientRequest request = new ClientRequest(generateURL("" + base + "default/override"));
         request.header(HttpHeaderNames.ACCEPT, "application/" + type);
         request.header(type, value);
         ClientResponse<?> response;
         try
         {
            response = request.get();
            Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
           //response.releaseConnection();
            ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
            executor.getHttpClient().getConnectionManager().shutdown();
//            request.getExecutor().close();
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

         try
         {
            response = request.get();
            Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
           //response.releaseConnection();
            ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
            executor.getHttpClient().getConnectionManager().shutdown();
//            request.getExecutor().close();
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
         }
         IResourceHeaderPrimitiveSet setClient = ProxyFactory.create(IResourceHeaderPrimitiveSet.class,
               generateBaseUrl());
         HashSet<String> set = new HashSet<String>();
         set.add("one");
         set.add("two");
         setClient.doGetBoolean(set);
      }

      {
         ClientRequest request = new ClientRequest(generateURL("/sortedset"));
         request.header(HttpHeaderNames.ACCEPT, "application/boolean");
         request.header("header", "one");
         request.header("header", "one");
         request.header("header", "one");
         request.header("header", "two");
         ClientResponse<?> response;
         try
         {
            response = request.get();
            Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
           //response.releaseConnection();
            ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
            executor.getHttpClient().getConnectionManager().shutdown();
//            request.getExecutor().close();
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

      try
      {
         response = request.get();
         Assert.assertEquals(400, response.getStatus());
        //response.releaseConnection();
         ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
         executor.getHttpClient().getConnectionManager().shutdown();
//         request.getExecutor().close();
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

      try
      {
         response = request.get();
         Assert.assertEquals(400, response.getStatus());
        //response.releaseConnection();
         ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
         executor.getHttpClient().getConnectionManager().shutdown();
//         request.getExecutor().close();
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

      try
      {
         response = request.get();
         Assert.assertEquals(400, response.getStatus());
        //response.releaseConnection();
         ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
         executor.getHttpClient().getConnectionManager().shutdown();
//         request.getExecutor().close();
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

   {
      POJOResourceFactory noDefaults = new POJOResourceFactory(BookStore.class);
      dispatcher.getRegistry().addResourceFactory(noDefaults);

      HttpClient httpClient = new DefaultHttpClient();
      ApacheHttpClient4Executor executor = new ApacheHttpClient4Executor(httpClient);
      BookStoreClient client = ProxyFactory.create(BookStoreClient.class, generateBaseUrl(),
              executor);

      Book book = client.getBookByISBN("596529260");
      Assert.assertNotNull(book);
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

         try
         {
            response = request.get();
            Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
           //response.releaseConnection();
            ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
            executor.getHttpClient().getConnectionManager().shutdown();
//            request.getExecutor().close();
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
         }
      }

      {
         ClientRequest request = new ClientRequest(generateURL("/wrappers"));
         request.header(HttpHeaderNames.ACCEPT, "application/" + type);
         request.header(type, value);
         ClientResponse<?> response;
         try
         {
            response = request.get();
            Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
           //response.releaseConnection();
            ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
            executor.getHttpClient().getConnectionManager().shutdown();
//            request.getExecutor().close();
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
         }
      }
    
      {
         ClientRequest request = new ClientRequest(generateURL("/list"));
         request.header(HttpHeaderNames.ACCEPT, "application/" + type);
         request.header(type, value);
         request.header(type, value);
         request.header(type, value);
         ClientResponse<?> response;
         try
         {
            response = request.get();
            Assert.assertEquals(HttpResponseCodes.SC_OK, response.getStatus());
           //response.releaseConnection();
            ApacheHttpClient4Executor executor = (ApacheHttpClient4Executor) request.getExecutor();
            executor.getHttpClient().getConnectionManager().shutdown();
//            request.getExecutor().close();
         }
         catch (Exception e)
         {
            throw new RuntimeException(e);
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

   {
      log.info("starting testSessionScope()");

      // Need to supply each ClientRequest with a single ClientExecutor to maintain a single
      // cookie cache, which keeps the session alive.
      ClientExecutor executor = new ApacheHttpClient4Executor();

      // Create a book, which gets stored in the session scoped BookBag.
      ClientRequest request = new ClientRequest("http://localhost:8080/resteasy-cdi-ejb-test/rest/session/add/", executor);
      Book book1 = new Book(13, "Dead Man Napping");
      request.body(Constants.MEDIA_TYPE_TEST_XML, book1);
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

     * @return Client proxy used to interact with Candlepin via REST API.
     */
    public <T> T connect(Class<T> clazz, Credentials creds, String uri) {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
        ClientExecutor clientExecutor = new ApacheHttpClient4Executor(httpclient);
        return ProxyFactory.create(clazz, uri,
            clientExecutor);
    }
View Full Code Here

Examples of org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor

        }


        String adminUrl = ResourceAdminManager.getManagementUrl(uriInfo.getRequestUri(), app);

        ApacheHttpClient4Executor executor = ResourceAdminManager.createExecutor();


        try {
            ClientRequest request = executor.createRequest(adminUrl);
            request.formParameter(GeneralConstants.SAML_REQUEST_KEY, logoutRequestString);
            request.formParameter(SAML2LogOutHandler.BACK_CHANNEL_LOGOUT, SAML2LogOutHandler.BACK_CHANNEL_LOGOUT);
            ClientResponse response = null;
            try {
                response = request.post();
                response.releaseConnection();
                // Undertow will redirect root urls not ending in "/" to root url + "/".  Test for this weird behavior
                if (response.getStatus() == 302  && !adminUrl.endsWith("/")) {
                    String redirect = (String)response.getHeaders().getFirst(HttpHeaders.LOCATION);
                    String withSlash = adminUrl + "/";
                    if (withSlash.equals(redirect)) {
                        request = executor.createRequest(withSlash);
                        request.formParameter(GeneralConstants.SAML_REQUEST_KEY, logoutRequestString);
                        request.formParameter(SAML2LogOutHandler.BACK_CHANNEL_LOGOUT, SAML2LogOutHandler.BACK_CHANNEL_LOGOUT);
                        response = request.post();
                        response.releaseConnection();
                    }
                }
            } catch (Exception e) {
                logger.warn("failed to send saml logout", e);
            }

        } finally {
            executor.getHttpClient().getConnectionManager().shutdown();
        }

    }
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.