Package ru.decipher.proxy.impl

Examples of ru.decipher.proxy.impl.HttpProxyConfig


    protected boolean buildProxy(String host, int port) {
        return buildProxy(host, port, Proxy.Type.HTTP);
    }

    protected synchronized boolean buildProxy(String host, int port, Proxy.Type type) {
        return proxyConfigs.add(new HttpProxyConfig(host.replaceAll("\\s+|\\xA0", ""), port, type));
    }
View Full Code Here


        assertEquals(expected, actual);
    }

    @Test
    public void testThatProxyBroughtBackWell() throws Exception {
        final HttpProxyConfig proxy = manager.take();
        for (int i = 0; i < 2; i++) {
            manager.take();
        }
        manager.compliment(proxy);
        assertEquals(PROXY1, manager.take());
View Full Code Here

        assertEquals(PROXY1, manager.take());
    }

    @Test(expected = IllegalStateException.class)
    public void testThatCanNotBackUnknownProxy() throws Exception {
        manager.compliment(new HttpProxyConfig("testX.host", 31337));
    }
View Full Code Here

    }

    @Test
    public void testThatUsageRatePerProxyWorksWell() throws Exception {
        long time = System.currentTimeMillis();
        final HttpProxyConfig proxy = manager.take();
        for (int i = 0; i < 2; i++) {
            manager.take();
        }
        manager.compliment(proxy);
        manager.take();
View Full Code Here

                new DefaultProxyManager(new Mock3GoodHttpProxyNoDelayLoader(), 0, 1000, 10, 0);
        class Task implements Runnable {
            @Override
            public void run() {
                try {
                    final HttpProxyConfig proxy = manager.take();
                    //do something
                    manager.compliment(proxy);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new RuntimeException(e);
View Full Code Here

    @Test
    public void testThatNewProxyWillBeLoadedFromSourceWhenAllProxiesAreDropped() throws Exception {
        int blameTimes = 0;
        while (blameTimes < 30) {
            final HttpProxyConfig proxy = manager.take();
            manager.blame(proxy);
            blameTimes++;
        }
        assertEquals(PROXY1, manager.take());
    }
View Full Code Here

    @Test
    public void testThatBadProxyWillBeGoneWhenFailedRequestsLimitHit() throws Exception {
        int blameTimes = 0;
        while (blameTimes < 10) {
            final HttpProxyConfig proxy = manager.take();
            if (proxy.equals(PROXY1)) {
                blameTimes++;
            }
            manager.blame(proxy);
        }
        Set<HttpProxyConfig> expected = new HashSet<HttpProxyConfig>() {{
View Full Code Here

    @Test
    public void testThatBadProxyWillBeForgivenOnSuccessRequest() throws Exception {
        int blameTimes = 0;
        boolean back = false;
        while (blameTimes < 10) {
            final HttpProxyConfig proxy = manager.take();
            if (proxy.equals(PROXY1)) {
                if (blameTimes == 1 && !back) {
                    manager.compliment(proxy);
                    back = true;
                }
                blameTimes++;
View Full Code Here

    @Test(expected = IllegalStateException.class)
    public void testThatDroppedProxyCanNotBeBroughtBack() throws Exception {
        int blameTimes = 0;
        while (blameTimes < 10) {
            final HttpProxyConfig proxy = manager.take();
            if (proxy.equals(PROXY1)) {
                blameTimes++;
            }
            manager.blame(proxy);
        }
        manager.compliment(PROXY1);
View Full Code Here

    @Test(expected = IllegalStateException.class)
    public void testThatDroppedProxyCanNotBeBlamed() throws Exception {
        int blameTimes = 0;
        while (blameTimes < 10) {
            final HttpProxyConfig proxy = manager.take();
            if (proxy.equals(PROXY1)) {
                blameTimes++;
            }
            manager.blame(proxy);
        }
        manager.blame(PROXY1);
View Full Code Here

TOP

Related Classes of ru.decipher.proxy.impl.HttpProxyConfig

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.