Package org.apache.http.conn.scheme

Examples of org.apache.http.conn.scheme.SchemeRegistry


     */
    private final static void setup() {

        // Register the "http" protocol scheme, it is required
        // by the default operator to look up socket factories.
        supportedSchemes = new SchemeRegistry();
        SocketFactory sf = PlainSocketFactory.getSocketFactory();
        supportedSchemes.register(new Scheme("http", sf, 80));

        // Prepare parameters.
        // Since this example doesn't use the full core framework,
View Full Code Here


        public HttpParams getParams() {
            throw new UnsupportedOperationException("just a mockup");
        }

        public SchemeRegistry getSchemeRegistry() {
            SchemeRegistry registry = new SchemeRegistry();
            registry.register(new Scheme("http", new SocketFactoryMockup(null), 80));
            return registry;
        }
View Full Code Here

        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
       
        final CountDownLatch connectLatch = new CountDownLatch(1);       
        final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(connectLatch, WaitPolicy.BEFORE_CONNECT, PlainSocketFactory.getSocketFactory());
        Scheme scheme = new Scheme("http", stallingSocketFactory, 80);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(scheme);

        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, registry);

        final HttpHost target = getServerHttp();
        final HttpRoute route = new HttpRoute(target, null, false);
View Full Code Here

        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
       
        final CountDownLatch connectLatch = new CountDownLatch(1);       
        final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(connectLatch, WaitPolicy.BEFORE_CREATE, PlainSocketFactory.getSocketFactory());
        Scheme scheme = new Scheme("http", stallingSocketFactory, 80);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(scheme);

        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, registry);

        final HttpHost target = getServerHttp();
        final HttpRoute route = new HttpRoute(target, null, false);
View Full Code Here

        public HttpParams getParams() {
            throw new UnsupportedOperationException("just a mockup");
        }

        public SchemeRegistry getSchemeRegistry() {
            SchemeRegistry registry = new SchemeRegistry();
            registry.register(new Scheme("http", new SocketFactoryMockup(null), 80));
            return registry;
        }
View Full Code Here

        ConnManagerParams.setMaxTotalConnections(mgrpar, 1);
       
        final CountDownLatch connectLatch = new CountDownLatch(1);       
        final StallingSocketFactory stallingSocketFactory = new StallingSocketFactory(connectLatch, WaitPolicy.AFTER_CONNECT, PlainSocketFactory.getSocketFactory());
        Scheme scheme = new Scheme("http", stallingSocketFactory, 80);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(scheme);

        ThreadSafeClientConnManager mgr = createTSCCM(mgrpar, registry);

        final HttpHost target = getServerHttp();
        final HttpRoute route = new HttpRoute(target, null, false);
View Full Code Here

            // expected
        }
    }

    public void testRegisterUnregister() {
        SchemeRegistry schmreg = new SchemeRegistry();

        Scheme http = new Scheme
            ("http", PlainSocketFactory.getSocketFactory(), 80);
        Scheme https = new Scheme
            ("https", SecureSocketFactoryMockup.INSTANCE, 443);
        //  ("https", SSLSocketFactory.getSocketFactory(), 443);
        Scheme myhttp = new Scheme
            ("http", PlainSocketFactory.getSocketFactory(), 80);

        HttpHost host  = new HttpHost("www.test.invalid", -1, "http");
        HttpHost hosts = new HttpHost("www.test.invalid", -1, "https");

        assertNull(schmreg.register(myhttp));
        assertNull(schmreg.register(https));
        assertSame(myhttp, schmreg.register(http));
        assertSame(http, schmreg.getScheme("http"));
        assertSame(http, schmreg.getScheme(host));
        assertSame(https, schmreg.getScheme("https"));
        assertSame(https, schmreg.getScheme(hosts));

        schmreg.unregister("http");
        schmreg.unregister("https");

        assertNull(schmreg.get("http")); // get() does not throw exception
        try {
            schmreg.getScheme("http"); // getScheme() does throw exception
            fail("IllegalStateException should have been thrown");
        } catch (IllegalStateException ex) {
            // expected
        }
    }
View Full Code Here

     *
     * @return the default scheme registry
     */
    public SchemeRegistry createSchemeRegistry() {

        SchemeRegistry schreg = new SchemeRegistry();
        SocketFactory sf = PlainSocketFactory.getSocketFactory();
        schreg.register(new Scheme("http", sf, 80));

        return schreg;
    }
View Full Code Here

        }
    }


    public void testIterator() {
        SchemeRegistry schmreg = new SchemeRegistry();

        List<String> names = schmreg.getSchemeNames();
        assertNotNull(names);
        assertTrue(names.isEmpty());

        Scheme http = new Scheme
            ("http", PlainSocketFactory.getSocketFactory(), 80);
        Scheme https = new Scheme
            ("https", SecureSocketFactoryMockup.INSTANCE, 443);
        //  ("https", SSLSocketFactory.getSocketFactory(), 443);

        schmreg.register(http);
        schmreg.register(https);

        names = schmreg.getSchemeNames();
        assertNotNull(names);
        assertFalse(names.isEmpty());

        boolean flaghttp  = false;
        boolean flaghttps = false;
        String name = names.get(0);

        if ("http".equals(name))
            flaghttp = true;
        else if ("https".equals(name))
            flaghttps = true;
        else
            fail("unexpected name in iterator: " + name);

        assertNotNull(schmreg.get(name));
        schmreg.unregister(name);
        assertNull(schmreg.get(name));

        name = names.get(1);

        if ("http".equals(name)) {
            if (flaghttp) fail("name 'http' found twice");
        } else if ("https".equals(name)) {
            if (flaghttps) fail("name 'https' found twice");
        } else {
            fail("unexpected name in iterator: " + name);
        }

        assertNotNull(schmreg.get(name));
    }
View Full Code Here

        assertNotNull(schmreg.get(name));
    }

    public void testIllegalRegisterUnregister() {
        SchemeRegistry schmreg = new SchemeRegistry();
        try {
            schmreg.register(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            schmreg.unregister(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            schmreg.get(null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            schmreg.getScheme((String)null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        try {
            schmreg.getScheme((HttpHost)null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.http.conn.scheme.SchemeRegistry

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.