Package org.apache.http.conn

Examples of org.apache.http.conn.HttpRoute


        // 3.x: TestHttpConnectionManager.testDroppedThread

        ThreadSafeClientConnManager mgr = createTSCCM(null, null);

        final HttpHost target = getServerHttp();
        final HttpRoute route = new HttpRoute(target, null, false);
        final int      rsplen = 8;
        final String      uri = "/random/" + rsplen;

        HttpRequest request =
            new BasicHttpRequest("GET", uri, HttpVersion.HTTP_1_1);
View Full Code Here


     * Obtains the default route to the local test server.
     *
     * @return the default route to the local test server
     */
    protected HttpRoute getDefaultRoute() {
        return new HttpRoute(new HttpHost("localhost", localServer.getServicePort()));
    }
View Full Code Here

        HttpRequest req = createRequest(target);
        HttpContext ctx = createContext();

        System.out.println("preparing route to " + target + " via " + proxy);
        HttpRoute route = new HttpRoute
            (target, null, proxy,
             supportedSchemes.getScheme(target).isLayered());

        System.out.println("requesting connection for " + route);
        ManagedClientConnection conn = clcm.getConnection(route);
View Full Code Here

    public void testGetConnection() throws InterruptedException {
        ThreadSafeClientConnManager mgr = createTSCCM(null, null);

        HttpHost target = new HttpHost("www.test.invalid", 80, "http");
        HttpRoute route = new HttpRoute(target, null, false);

        ManagedClientConnection conn = mgr.getConnection(route);
        assertNotNull(conn);
        assertNull(conn.getRoute());
        assertFalse(conn.isOpen());
View Full Code Here

        HttpConnectionManagerParams.setMaxTotalConnections(params, 2);

        ThreadSafeClientConnManager mgr = createTSCCM(params, null);

        HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
        HttpRoute route1 = new HttpRoute(target1, null, false);
        HttpHost target2 = new HttpHost("www.test2.invalid", 80, "http");
        HttpRoute route2 = new HttpRoute(target2, null, false);

        ManagedClientConnection conn1 = mgr.getConnection(route1);
        assertNotNull(conn1);
        ManagedClientConnection conn2 = mgr.getConnection(route2);
        assertNotNull(conn2);
View Full Code Here


    public void testMaxConnPerHost() throws Exception {

        HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
        HttpRoute route1 = new HttpRoute(target1, null, false);
        HttpHost target2 = new HttpHost("www.test2.invalid", 80, "http");
        HttpRoute route2 = new HttpRoute(target2, null, false);
        HttpHost target3 = new HttpHost("www.test3.invalid", 80, "http");
        HttpRoute route3 = new HttpRoute(target3, null, false);
       
        HttpParams params = createDefaultParams();
        HttpConnectionManagerParams.setMaxTotalConnections(params, 100);
        HttpConnectionManagerParams.setDefaultMaxConnectionsPerHost(params, 1);
        HttpConnectionManagerParams.setMaxConnectionsPerHost(params,route2, 2);
View Full Code Here

        HttpConnectionManagerParams.setMaxTotalConnections(params, 3);

        ThreadSafeClientConnManager mgr = createTSCCM(params, null);

        HttpHost target1 = new HttpHost("www.test1.invalid", 80, "http");
        HttpRoute route1 = new HttpRoute(target1, null, false);
        HttpHost target2 = new HttpHost("www.test2.invalid", 80, "http");
        HttpRoute route2 = new HttpRoute(target2, null, false);
        HttpHost target3 = new HttpHost("www.test3.invalid", 80, "http");
        HttpRoute route3 = new HttpRoute(target3, null, false);

        // the first three allocations should pass
        ManagedClientConnection conn1 = mgr.getConnection(route1, 10L);
        ManagedClientConnection conn2 = mgr.getConnection(route2, 10L);
        ManagedClientConnection conn3 = mgr.getConnection(route3, 10L);
View Full Code Here

    public void testDeleteClosedConnections() throws InterruptedException {
       
        ThreadSafeClientConnManager mgr = createTSCCM(null, null);

        HttpHost target = new HttpHost("www.test.invalid", 80, "http");
        HttpRoute route = new HttpRoute(target, null, false);

        ManagedClientConnection conn = mgr.getConnection(route);

        assertEquals("connectionsInPool",
                     mgr.getConnectionsInPool(), 1);
View Full Code Here

        HttpConnectionManagerParams.setMaxTotalConnections(params, 1);

        ThreadSafeClientConnManager mgr = createTSCCM(params, null);

        HttpHost target = new HttpHost("www.test.invalid", 80, "http");
        HttpRoute route = new HttpRoute(target, null, false);

        // get the only connection, then start an extra thread
        // on shutdown, the extra thread should get an exception

        ManagedClientConnection conn = mgr.getConnection(route, 1L);
View Full Code Here

        HttpConnectionManagerParams.setMaxTotalConnections(params, 1);

        ThreadSafeClientConnManager mgr = createTSCCM(params, null);

        HttpHost target = new HttpHost("www.test.invalid", 80, "http");
        HttpRoute route = new HttpRoute(target, null, false);

        // get the only connection, then start an extra thread
        ManagedClientConnection conn = mgr.getConnection(route, 1L);
        GetConnThread gct = new GetConnThread(mgr, route, 0L); // no timeout
        gct.start();
View Full Code Here

TOP

Related Classes of org.apache.http.conn.HttpRoute

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.