use of org.apache.camel.http.common.HttpConfiguration in project camel by apache.
the class HttpQueryGoogleProxyTest method testQueryGoogleProxy.
@Test
@Ignore("Run manually")
public void testQueryGoogleProxy() throws Exception {
HttpConfiguration config = new HttpConfiguration();
config.setProxyHost("myProxyHost");
config.setProxyPort(8877);
config.setProxyAuthMethod("Basic");
config.setAuthMethodPriority("Digest,Basic");
config.setProxyAuthUsername("myProxyUsername");
config.setProxyAuthPassword("myProxyPassword");
HttpComponent http = context.getComponent("http", HttpComponent.class);
http.setHttpConfiguration(config);
Object out = template.requestBody("http://google.com/search?q=Camel", "");
assertNotNull(out);
String data = context.getTypeConverter().convertTo(String.class, out);
assertTrue("Camel should be in search result from Google", data.indexOf("Camel") > -1);
}
use of org.apache.camel.http.common.HttpConfiguration in project camel by apache.
the class HttpBasicAuthComponentConfiguredTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
HttpConfiguration config = new HttpConfiguration();
config.setAuthMethod("Basic");
config.setAuthUsername("donald");
config.setAuthPassword("duck");
HttpComponent http = context.getComponent("http", HttpComponent.class);
http.setHttpConfiguration(config);
from("jetty://http://localhost:{{port}}/test?handlers=myAuthHandler").process(new Processor() {
public void process(Exchange exchange) throws Exception {
HttpServletRequest req = exchange.getIn().getBody(HttpServletRequest.class);
assertNotNull(req);
Principal user = req.getUserPrincipal();
assertNotNull(user);
assertEquals("donald", user.getName());
}
}).transform(constant("Bye World"));
from("jetty://http://localhost:{{port}}/anotherTest?handlers=myAuthHandler").transform(constant("See you later"));
}
};
}
Aggregations