Package org.littleshoot.proxy

Examples of org.littleshoot.proxy.HttpProxyServer


        responseDeenrichmentFilter.initialize(serviceLoader().onlyOne(HttpResponseDeenrichmentService.class));

        String hostPort = realUrl.getHost() + ":" + realUrl.getPort();
        ResponseFilterMap responseFilterMap = new ResponseFilterMap(hostPort, responseDeenrichmentFilter);

        HttpProxyServer server = new DefaultHttpProxyServer(proxyUrl.getPort(), responseFilterMap, hostPort, null,
                requestFilter);

        server.start();

        return server;
    }
View Full Code Here


    public void destroyServer() {
        server.stop();
    }

    public HttpProxyServer initProxy() {
        HttpProxyServer proxyServer = new DefaultHttpProxyServer(PROXY_PORT);
        proxyServer.start(true, true);
        return proxyServer;
    }
View Full Code Here

        return proxyServer;
    }

    @Test
    public void testService1_httpProxy_defaultProxySetting() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        try {
            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("http://" + endpointUrl)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testService1_httpProxy_directProxy() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        try {
            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("http://" + endpointUrl)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testService1_httpProxy_noAuthentication() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        try {
            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("http://" + endpointUrl)
                            .proxyUri("http://127.0.0.1:" + PROXY_PORT)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testService1_httpProxy_basicAuthentication_success() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
            @Override
            public boolean authenticate(String user, String pass) {
                return user.equals("tom") && pass.equals("007");
            }
        });
        try {

            final Security security = Security.builder()
                    .authBasic("tom", "007")
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder()
                            .endpointUri("http://" + endpointUrl)
                            .proxyUri("http://127.0.0.1:" + PROXY_PORT)
                            .proxySecurity(security)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

    public void testService1_httpProxy_basicAuthentication_failure() throws Exception {

        exception.expect(TransmissionException.class);
        exception.expectMessage("[407]");

        HttpProxyServer proxyServer = initProxy();

        proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
            @Override
            public boolean authenticate(String user, String pass) {
                return user.equals("tom") && pass.equals("007");
            }
        });

        final Security props = Security.builder()
                .authBasic("james", "003")
                .build();

        try {
            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("http://" + endpointUrl)
                            .proxyUri("http://127.0.0.1:" + PROXY_PORT)
                            .proxySecurity(props)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

        }
    }

    public HttpProxyServer getProxy() {
        Map<String, HttpFilter> filters = new HashMap<String, HttpFilter>();
        HttpProxyServer proxyServer = new DefaultHttpProxyServer(PROXY_PORT, filters, null, null, null);
        return proxyServer;
    }
View Full Code Here

    public void destroyServer() {
        server.stop();
    }

    public HttpProxyServer initProxy() {
        HttpProxyServer proxyServer = new DefaultHttpProxyServer(PROXY_PORT);
        proxyServer.start(true, true);
        return proxyServer;
    }
View Full Code Here

        return proxyServer;
    }

    @Test
    public void testService1_httpProxy_defaultProxySetting() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        try {
            final Security securityContext = Security.builder()
                    .trustStoreUrl(getKeyStoreUrlOne())
                    .trustStorePassword(getKeyStorePassword())
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("https://" + endpointUrl)
                            .endpointSecurity(securityContext)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

TOP

Related Classes of org.littleshoot.proxy.HttpProxyServer

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.