Package org.apache.http.impl.conn

Examples of org.apache.http.impl.conn.PoolingClientConnectionManager


    @ArquillianResource
    private URL url;

    @Test
    public void testValidRequest() throws Exception {
        DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());

        HttpGet get = new HttpGet(url + "myjaxrs/validate/5");
        HttpResponse result = client.execute(get);

        Assert.assertEquals(200, result.getStatusLine().getStatusCode());
View Full Code Here


        Assert.assertEquals("ValidatorModel{id=5}", EntityUtils.toString(result.getEntity()));
    }

    @Test
    public void testInvalidRequest() throws Exception {
        DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());

        HttpGet get = new HttpGet(url + "myjaxrs/validate/3");
        HttpResponse result = client.execute(get);

        Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode());
View Full Code Here

        Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode());
    }

    @Test
    public void testInvalidRequestCausingPropertyConstraintViolation() throws Exception {
        DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());

        HttpGet get = new HttpGet(url + "myjaxrs/another-validate/3");
        HttpResponse result = client.execute(get);

        Assert.assertEquals("Property constraint violated", 400, result.getStatusLine().getStatusCode());
View Full Code Here

        Assert.assertEquals("Property constraint violated", 400, result.getStatusLine().getStatusCode());
    }

    @Test
    public void testInvalidRequestsAreAcceptedDependingOnValidationConfiguration() throws Exception {
        DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());

        HttpGet get = new HttpGet(url + "myjaxrs/yet-another-validate/3/disabled");
        HttpResponse result = client.execute(get);

        Assert.assertEquals("No constraint violated", 200, result.getStatusLine().getStatusCode());
View Full Code Here

        Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode());
    }

    @Test
    public void testInvalidResponse() throws Exception {
        DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());

        HttpGet get = new HttpGet(url + "myjaxrs/validate/11");
        HttpResponse result = client.execute(get);

        Assert.assertEquals("Return value constraint violated", 500, result.getStatusLine().getStatusCode());
View Full Code Here

    private static final String AGENT = "detectlanguage-java";

    private final HttpClient httpClient;

    public Client() {
        PoolingClientConnectionManager connMgr = new PoolingClientConnectionManager();
        connMgr.setDefaultMaxPerRoute(MAX_CONNECTIONS_PER_ROUTE);
        connMgr.setMaxTotal(MAX_TOTAL_CONNECTIONS);

        this.httpClient = new DefaultHttpClient(connMgr);
        this.httpClient.getParams().setParameter("http.protocol.version",
                HttpVersion.HTTP_1_1);
        this.httpClient.getParams().setParameter("http.socket.timeout",
View Full Code Here

    public Client(String location, String key) {
        this.key = key;
        this.root = location;

        PoolingClientConnectionManager connMgr = new PoolingClientConnectionManager();
        this.httpClient = new DefaultHttpClient(connMgr);

        this.httpClient.getParams().setParameter("http.protocol.version", HttpVersion.HTTP_1_1);
        this.httpClient.getParams().setParameter("http.socket.timeout", new Integer(CONNECTION_TIMEOUT));
        this.httpClient.getParams().setParameter("http.connection.timeout", new Integer(CONNECTION_TIMEOUT));
View Full Code Here

  private synchronized HttpClient getHttpClient () throws Exception
  {
    if (httpClient == null)
    {
      PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
      cm.closeIdleConnections(1, TimeUnit.SECONDS);
      httpClient = new DefaultHttpClient(cm);
      HttpParams params = httpClient.getParams();
      params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000);
      params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000);
      if (skipValidation)
View Full Code Here

  private static final String AGENT = "detectlanguage-java";

  private final HttpClient httpClient;

  public Client() {
    PoolingClientConnectionManager connMgr = new PoolingClientConnectionManager();
    this.httpClient = new DefaultHttpClient(connMgr);

    this.httpClient.getParams().setParameter("http.protocol.version",
        HttpVersion.HTTP_1_1);
    this.httpClient.getParams().setParameter("http.socket.timeout",
View Full Code Here

  {
    getSessionParameters();
    if (hasConnected == false)
    {
      // Set up connection manager
      PoolingClientConnectionManager localConnectionManager = new PoolingClientConnectionManager();
      localConnectionManager.setMaxTotal(1);

      // Set up ingest ssl if indicated
      if (ingestKeystoreManager != null)
      {
        SSLSocketFactory myFactory = new SSLSocketFactory(ingestKeystoreManager.getSecureSocketFactory(),
          new BrowserCompatHostnameVerifier());
        Scheme myHttpsProtocol = new Scheme("https", 443, myFactory);
        localConnectionManager.getSchemeRegistry().register(myHttpsProtocol);
      }
      connectionManager = localConnectionManager;

      // Create the httpclient
      BasicHttpParams params = new BasicHttpParams();
View Full Code Here

TOP

Related Classes of org.apache.http.impl.conn.PoolingClientConnectionManager

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.