Skip to content

Commit

Permalink
[resolves #1402] Add support for component ahc
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Diesler committed May 16, 2017
1 parent 26f7a49 commit 1ca1fff
Show file tree
Hide file tree
Showing 14 changed files with 232 additions and 1 deletion.
2 changes: 1 addition & 1 deletion catalog/src/main/resources/component.roadmap
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[supported]
ahc
amqp
atom
avro
Expand Down Expand Up @@ -134,7 +135,6 @@ xslt
zookeeper

[planned]
ahc
ahc-ws
ahc-wss
azure-blob
Expand Down
3 changes: 3 additions & 0 deletions docs/guide/components/camel-ahc.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### camel-ahc

The http://camel.apache.org/ahc.html[ahc,window=_blank] component provides HTTP based endpoints for consuming external HTTP resources (as a client to call external servers using HTTP). The component uses the https://github.com/AsyncHttpClient/async-http-client[Async Http Client,window=_blank] library.
2 changes: 2 additions & 0 deletions docs/guide/components/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This chapter details information about supported camel components

include::camel-activemq.adoc[]

include::camel-ahc.adoc[]

include::camel-amqp.adoc[]

include::camel-atom.adoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<dependencies>
<module name="org.apache.camel.component.activemq" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.ahc" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.amqp" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.atom" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.avro" export="true" services="export" optional="true" />
Expand Down
14 changes: 14 additions & 0 deletions feature/etc/smartics/camel-modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@
</dependencies>
</module>

<module name="org.apache.camel.component.ahc">
<include artifact="org.apache.camel:camel-ahc" />
<apply-to-dependencies skip="true">
<include module="io.netty.skipped" />
<include module="org.apache.camel.apt" />
<include module="org.springframework.boot" />
</apply-to-dependencies>
<dependencies>
<module name="org.asynchttpclient" export="true"/>
<module name="io.netty" slot="4.1"/>
<module name="org.slf4j" />
</dependencies>
</module>

<module name="org.apache.camel.component.amqp">
<include artifact="org.apache.camel:camel-amqp" />
<apply-to-dependencies skip="true">
Expand Down
26 changes: 26 additions & 0 deletions feature/etc/smartics/other-modules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@

<module name="io.netty.skipped" skip="true">
<include artifact="io.netty:netty-all" />
<include artifact="io.netty:netty-transport-native-epoll" />
</module>

<module name="io.sundr">
Expand Down Expand Up @@ -806,6 +807,31 @@
</exports>
</module>

<module name="org.asynchttpclient">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<include artifact="com.typesafe.netty:netty-reactive-streams" />
<include artifact="org.asynchttpclient:async-http-client" />
<include artifact="org.asynchttpclient:async-http-client-netty-utils" />
<include artifact="org.asynchttpclient:netty-codec-dns" />
<include artifact="org.asynchttpclient:netty-resolver" />
<include artifact="org.asynchttpclient:netty-resolver-dns" />
<include artifact="org.reactivestreams:reactive-streams" />
<apply-to-dependencies skip="true">
<include module="io.netty.skipped" />
</apply-to-dependencies>
<dependencies>
<module name="javax.api" />
<module name="io.netty" slot="4.1"/>
</dependencies>
<exports>
<exclude path="io/netty**" />
<exclude path="com/typesafe**" />
<exclude path="org/reactivestreams" />
</exports>
</module>

<module name="org.beanshell">
<properties>
<property name="jboss.api" value="private"/>
Expand Down
4 changes: 4 additions & 0 deletions feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ahc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-amqp</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.apache.camel.component.ahc">
<resources>
<artifact name="${org.apache.camel:camel-ahc}" />
</resources>
<dependencies>
<module name="org.asynchttpclient" export="true" />
<module name="io.netty" slot="4.1" />
<module name="org.slf4j" />
<module name="javax.xml.bind.api" />
<module name="org.apache.camel.component.http.common" />
<module name="org.apache.camel.core" />
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<dependencies>
<module name="org.apache.camel.component.activemq" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.ahc" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.amqp" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.atom" export="true" services="export" optional="true" />
<module name="org.apache.camel.component.avro" export="true" services="export" optional="true" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.asynchttpclient">
<properties>
<property name="jboss.api" value="private" />
</properties>
<resources>
<artifact name="${org.asynchttpclient:async-http-client}" />
<artifact name="${org.asynchttpclient:async-http-client-netty-utils}" />
<artifact name="${org.asynchttpclient:netty-codec-dns}" />
<artifact name="${com.typesafe.netty:netty-reactive-streams}" />
<artifact name="${org.asynchttpclient:netty-resolver}" />
<artifact name="${org.asynchttpclient:netty-resolver-dns}" />
<artifact name="${org.reactivestreams:reactive-streams}" />
</resources>
<dependencies>
<module name="javax.api" />
<module name="io.netty" slot="4.1" />
<module name="org.slf4j" />
</dependencies>
<exports>
<exclude path="io/netty**" />
<exclude path="com/typesafe**" />
<exclude path="org/reactivestreams" />
</exports>
</module>
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/

package org.wildfly.camel.test.ahc;

import java.util.concurrent.Future;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
import org.asynchttpclient.AsyncHttpClient;
import org.asynchttpclient.DefaultAsyncHttpClient;
import org.asynchttpclient.Response;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.extension.camel.CamelAware;

@CamelAware
@RunWith(Arquillian.class)
public class AhcIntegrationTest {

private static final String HTTP_URL = "http://localhost:8080";

@Deployment
public static JavaArchive createdeployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "camel-ahc-test.jar");
return archive;
}

@Test
public void testAsyncHttpClient() throws Exception {

try (AsyncHttpClient client = new DefaultAsyncHttpClient()) {
Future<Response> f = client.prepareGet(HTTP_URL).execute();
Response res = f.get();
Assert.assertEquals(200, res.getStatusCode());
Assert.assertTrue(res.getResponseBody().contains("Welcome to WildFly 10"));
}
}

@Test
public void testAsyncHttpRoute() throws Exception {

CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.to("ahc:" + HTTP_URL)
.to("mock:results");
}
});

MockEndpoint mockep = camelctx.getEndpoint("mock:results", MockEndpoint.class);
mockep.setExpectedCount(1);

camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
producer.sendBody("direct:start", null);

mockep.assertIsSatisfied();
Message message = mockep.getExchanges().get(0).getIn();
Assert.assertEquals(200, (int) message.getHeader(Exchange.HTTP_RESPONSE_CODE, Integer.class));
Assert.assertTrue(message.getBody(String.class).contains("Welcome to WildFly 10"));

} finally {
camelctx.stop();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
^org/apache/xmlbeans/impl/schema
^org/apache/xmlbeans/impl/values
^org/apache/zookeeper(.*)
^org/asynchttpclient(.*)
^org/codehaus/groovy(.*)
^org/dozer(.*)
^org/eclipse/egit/github/core(.*)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,8 @@ org/apache/camel/builder
org/apache/camel/builder/script
org/apache/camel/coap
org/apache/camel/component
org/apache/camel/component/ahc
org/apache/camel/component/ahc/helper
org/apache/camel/component/amqp
org/apache/camel/component/atom
org/apache/camel/component/avro
Expand Down Expand Up @@ -1335,6 +1337,39 @@ org/apache/zookeeper/txn
org/apache/zookeeper/util
org/apache/zookeeper/version
org/apache/zookeeper/version/util
org/asynchttpclient
org/asynchttpclient/channel
org/asynchttpclient/config
org/asynchttpclient/cookie
org/asynchttpclient/exception
org/asynchttpclient/filter
org/asynchttpclient/handler
org/asynchttpclient/handler/resumable
org/asynchttpclient/netty
org/asynchttpclient/netty/channel
org/asynchttpclient/netty/future
org/asynchttpclient/netty/handler
org/asynchttpclient/netty/handler/intercept
org/asynchttpclient/netty/request
org/asynchttpclient/netty/request/body
org/asynchttpclient/netty/ssl
org/asynchttpclient/netty/timeout
org/asynchttpclient/netty/util
org/asynchttpclient/netty/ws
org/asynchttpclient/ntlm
org/asynchttpclient/oauth
org/asynchttpclient/proxy
org/asynchttpclient/request
org/asynchttpclient/request/body
org/asynchttpclient/request/body/generator
org/asynchttpclient/request/body/multipart
org/asynchttpclient/request/body/multipart/part
org/asynchttpclient/resolver
org/asynchttpclient/spnego
org/asynchttpclient/uri
org/asynchttpclient/util
org/asynchttpclient/webdav
org/asynchttpclient/ws
org/codehaus/groovy
org/codehaus/groovy/ant
org/codehaus/groovy/antlr
Expand Down
8 changes: 8 additions & 0 deletions patch/etc/baseline/module-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
/org/apache/activemq/main/activemq-pool-5.14.5.jar
/org/apache/activemq/main/activemq-spring-5.14.5.jar
/org/apache/camel/component/activemq/main/activemq-camel-5.14.5.jar
/org/apache/camel/component/ahc/main/camel-ahc-2.19.1-SNAPSHOT.jar
/org/apache/camel/component/amqp/main/camel-amqp-2.19.1-SNAPSHOT.jar
/org/apache/camel/component/atom/main/camel-atom-2.19.1-SNAPSHOT.jar
/org/apache/camel/component/avro/main/camel-avro-2.19.1-SNAPSHOT.jar
Expand Down Expand Up @@ -319,6 +320,13 @@
/org/apache/zookeeper/main/curator-framework-2.11.1.jar
/org/apache/zookeeper/main/curator-recipes-2.11.1.jar
/org/apache/zookeeper/main/zookeeper-3.4.10.jar
/org/asynchttpclient/main/async-http-client-2.0.32.jar
/org/asynchttpclient/main/async-http-client-netty-utils-2.0.32.jar
/org/asynchttpclient/main/netty-codec-dns-2.0.32.jar
/org/asynchttpclient/main/netty-reactive-streams-1.0.8.jar
/org/asynchttpclient/main/netty-resolver-2.0.32.jar
/org/asynchttpclient/main/netty-resolver-dns-2.0.32.jar
/org/asynchttpclient/main/reactive-streams-1.0.0.jar
/org/beanshell/main/bsh-2.0b6.jar
/org/bitbucket/jose4j/main/jose4j-0.4.4.jar
/org/bouncycastle/ext/main/bcpg-jdk15on-1.55.jar
Expand Down

0 comments on commit 1ca1fff

Please sign in to comment.