Package org.apache.camel.component.http4.helper

Examples of org.apache.camel.component.http4.helper.HttpProducerHelperTest


    @Test
    public void httpPostWithImage() throws Exception {
        Map<String, String> expectedHeaders = new HashMap<String, String>();
        expectedHeaders.put("Content-Type", "image/jpeg");
        localServer.register("/", new HeaderValidationHandler("POST", null, null, getExpectedContent(), expectedHeaders));

        Exchange exchange = template.send(getProtocolString() + getHostName() + ":" + getPort() + "/", new Processor() {
            public void process(Exchange exchange) throws Exception {
                exchange.getIn().setBody(new File("src/test/data/logo.jpeg"));
                exchange.getIn().setHeader("Content-Type", "image/jpeg");
View Full Code Here


        }
    }

    @Test
    public void httpGetWithProxyAndWithUser() throws Exception {
        proxy.register("*", new ProxyAuthenticationValidationHandler("GET", null, null, getExpectedContent(), user, password));

        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort() + "?proxyHost="
                + getProxyHost() + "&proxyPort=" + getProxyPort() + "&proxyUsername=camel&proxyPassword=password", new Processor() {
                    public void process(Exchange exchange) throws Exception {
                    }
View Full Code Here

        }
    }

    @Test
    public void httpGetWithProxyAndWithUser() throws Exception {
        proxy.register("*", new ProxyAuthenticationValidationHandler("GET", null, null, getExpectedContent(), user, password));

        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort() + "?proxyHost="
                + getProxyHost() + "&proxyPort=" + getProxyPort() + "&proxyUsername=camel&proxyPassword=password", new Processor() {
                    public void process(Exchange exchange) throws Exception {
                    }
View Full Code Here

        }
    }

    @Test
    public void httpGetWithProxyAndWithUser() throws Exception {
        proxy.register("*", new ProxyAuthenticationValidationHandler("GET", null, null, getExpectedContent(), user, password));

        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort() + "?proxyAuthHost="
                + getProxyHost() + "&proxyAuthPort=" + getProxyPort() + "&proxyAuthUsername=camel&proxyAuthPassword=password", new Processor() {
                    public void process(Exchange exchange) throws Exception {
                    }
View Full Code Here

        assertExchange(exchange);
    }
   
    public void httpGetPullEndpointWithProxyAndWithUser() {
        proxy.register("*", new ProxyAuthenticationValidationHandler("GET", null, null, getExpectedContent(), user, password));

        Exchange exchange = consumer.receive("http4://" + getHostName() + ":" + getPort() + "?proxyAuthHost="
                + getProxyHost() + "&proxyAuthPort=" + getProxyPort() + "&proxyAuthUsername=camel&proxyAuthPassword=password");

        assertExchange(exchange);
View Full Code Here

        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            Object object = request.getAttribute(name);
            if (object instanceof File) {
                String fileName = request.getParameter(name);
                message.addAttachment(fileName, new DataHandler(new CamelFileDataSource((File) object, fileName)));
            }
        }
    }
View Full Code Here

        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            Object object = request.getAttribute(name);
            if (object instanceof File) {
                String fileName = request.getParameter(name);
                message.addAttachment(fileName, new DataHandler(new CamelFileDataSource((File) object, fileName)));
            }
        }
    }
View Full Code Here

        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            Object object = request.getAttribute(name);
            if (object instanceof File) {
                String fileName = request.getParameter(name);
                message.addAttachment(fileName, new DataHandler(new CamelFileDataSource((File) object, fileName)));
            }
        }
    }
View Full Code Here

        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            Object object = request.getAttribute(name);
            if (object instanceof File) {
                String fileName = request.getParameter(name);
                message.addAttachment(fileName, new DataHandler(new CamelFileDataSource((File) object, fileName)));
            }
        }
    }
View Full Code Here

        try {
            HttpResponse response = httpClient.execute(method);
            int responseCode = response.getStatusLine().getStatusCode();
            responeEntity = response.getEntity();
            // lets store the result in the output message.
            LoadingByteArrayOutputStream bos = new LoadingByteArrayOutputStream();
            InputStream is = responeEntity.getContent();

            try {
                IOHelper.copy(is, bos);
                bos.flush();
            } finally {
                ObjectHelper.close(is, "input stream", null);
            }
            Message message = exchange.getIn();
            message.setBody(bos.createInputStream());

            // lets set the headers
            Header[] headers = response.getAllHeaders();
            HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
            for (Header header : headers) {
View Full Code Here

TOP

Related Classes of org.apache.camel.component.http4.helper.HttpProducerHelperTest

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.