Package ru.decipher.proxy.impl

Examples of ru.decipher.proxy.impl.HttpProxyConfig


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


        final Random random = new Random();
        for (int i = 0; i < 100; i++) {
            tasks.add(Executors.callable(new Runnable() {
                @Override
                public void run() {
                    HttpProxyConfig take = manager.take();
                    try {
                        sleep(100);
                    } catch (InterruptedException ignored) {
                    }
                    manager.compliment(take);
View Full Code Here

    }

    @Test
    public void testThatManagerDoesNotBlockQueueDuringProxiesUpdate() throws Exception {
        manager = new DefaultProxyManager(new Mock3GoodHttpProxySlowLoader(), 1, 100, 10, 0);
        final HttpProxyConfig firstProxy = manager.take();
        final HttpProxyConfig secondProxy = manager.take();
        manager.ban(secondProxy);
        new Thread(new Runnable() {
            @Override
            public void run() {
                manager.take();
            }
        }).start();
        manager.compliment(firstProxy);
        final HttpProxyConfig actual = manager.take();
        assertNotNull(actual);
    }
View Full Code Here

    }

    @Test
    public void testThatCheckedProxiesGoFirst() throws Exception {
        manager = new DefaultProxyManager(new MockIncrementalGoodHttpProxyNoDelayLoader(), 10, 100, 10, 0);
        final HttpProxyConfig firstProxy = manager.take();
        final HttpProxyConfig secondProxy = manager.take();
        final HttpProxyConfig third = manager.take();
        final HttpProxyConfig fourth = manager.take();

        manager.blame(firstProxy);
        manager.blame(secondProxy);
        manager.compliment(fourth);
        manager.compliment(third);
View Full Code Here

    }

    @Test
    public void testThatUpdateRateLimitWorksWell() throws Exception {
        final DefaultProxyManager manager = new DefaultProxyManager(new LocalhostNoProxyLoader(), 0, 0, 0, 1000);
        final HttpProxyConfig config = manager.take();
        manager.ban(config);
        long time = System.currentTimeMillis();
        manager.take();
        time = System.currentTimeMillis() - time;
        assertTrue("update rate limits failed", time >= 1000);
View Full Code Here

        add(new HttpProxyConfig("test2.host", 31337));
    }};

    @Override
    public Collection<HttpProxyConfig> load() throws Exception {
        configs.add(new HttpProxyConfig("test" + (configs.size() + 1) + ".host", 31337));
        log.debug("returned mocked proxy configs on demand");
        return configs;
    }
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

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.