[ 
https://issues.apache.org/jira/browse/KARAF-5893?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16719802#comment-16719802
 ] 

ASF GitHub Bot commented on KARAF-5893:
---------------------------------------

jbonofre closed pull request #696: [KARAF-5893] Add camel example
URL: https://github.com/apache/karaf/pull/696
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/examples/karaf-camel-example/README.md 
b/examples/karaf-camel-example/README.md
new file mode 100644
index 0000000000..b35113d19f
--- /dev/null
+++ b/examples/karaf-camel-example/README.md
@@ -0,0 +1,106 @@
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you 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.
+-->
+# Apache Karaf Camel Example
+
+## Abstract
+
+This example shows how to use Apache Camel in Karaf. Apache Camel is a 
integration framework, allowing you to integrate several systems and 
applications all together.
+
+Apache Camel supports several DSL. This example shows how to use the Camel 
Java DSL and the Camel Blueprint DSL.
+
+It creates several Camel routes, exposing a HTTP endpoint and using a Content 
Based Router EIP (Enterprise Integration Pattern).
+
+## Artifacts
+
+* **karaf-camel-example-java** is a bundle containing routes described using 
the Camel Java DSL.
+* **karaf-camel-example-blueprint** is just a wrapper containing routes 
described using Blueprint. Karaf supports deployment of this DSL directly (in 
the deploy folder for instance) or packaged as a bundle.
+* **karaf-camel-example-features** provides a Karaf features repository used 
for the deployment.
+
+## Build
+
+The build uses Apache Maven. Simply use:
+
+```
+mvn clean install
+```
+
+## Feature and Deployment
+
+On a running Karaf instance, register the features repository using:
+
+```
+karaf@root()> feature:repo-add 
mvn:org.apache.karaf.examples/karaf-camel-example-features/4.2.2-SNAPSHOT/xml
+```
+
+Then, you can install either Camel Java or Blueprint features:
+
+```
+karaf@root()> feature:install karaf-camel-example-java
+```
+
+```
+karaf@root()> feature:install karaf-camel-example-blueprint
+```
+
+## Usage
+
+Once you have install a Camel feature, the main route is started and bind a 
HTTP endpoint on `http://localhost:9090/example`.
+
+We can test payloads testing different paths of the content based router.
+
+First, let's try an e-mail request:
+
+```
+curl -X POST -H "Content-Type: application/json" http://localhost:9090/example 
-d '{ "notification": { "type": "email", "to": "f...@bar.com", "message": "This 
is a test" }}'
+```
+
+You can see in the log that the e-mail route has been called in the log:
+
+```
+karaf@root()> log:display
+10:24:22.453 INFO [qtp1790923892-140] [EXAMPLE INBOUND] Received: { 
"notification": { "type": "email", "to": "f...@bar.com", "message": "This is a 
test" }}
+10:24:22.465 INFO [qtp1790923892-140] [EXAMPLE INBOUND] Received email 
notification
+10:24:22.466 INFO [qtp1790923892-140] [EXAMPLE EMAIL] Sending notification 
email
+```
+
+And we have the curl response confirming it:
+
+```
+{ "status": "email sent", "to": "f...@bar.com", "subject": "Notification"}
+```
+
+We can also test the `http` path of the content based router:
+
+```
+curl -X POST -H "Content-Type: application/json" http://localhost:9090/example 
-d '{ "notification": { "type": "http", "service": "http://foo"; }}'
+```
+
+We can see the response confirming the call to the http route path:
+
+```
+{ "status": "http requested", "service": "http://foo"; }
+```
+
+and the corresponding log messages:
+
+```
+11:17:28.372 INFO [qtp1790923892-138] [EXAMPLE INBOUND] Received: { 
"notification": { "type": "http", "service": "http://foo"; }}
+11:17:28.374 INFO [qtp1790923892-138] [EXAMPLE INBOUND] Received http 
notification
+11:17:28.374 INFO [qtp1790923892-138] [EXAMPLE HTTP] Sending http notification
+```
\ No newline at end of file
diff --git a/examples/karaf-camel-example/karaf-camel-example-blueprint/pom.xml 
b/examples/karaf-camel-example/karaf-camel-example-blueprint/pom.xml
new file mode 100644
index 0000000000..ec8bb9b68f
--- /dev/null
+++ b/examples/karaf-camel-example/karaf-camel-example-blueprint/pom.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.examples</groupId>
+        <artifactId>karaf-camel-example</artifactId>
+        <version>4.2.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>karaf-camel-example-blueprint</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Karaf :: Examples :: Camel :: Blueprint DSL</name>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifact</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    
<file>src/main/resources/OSGI-INF/blueprint/route.xml</file>
+                                    <classifier>route</classifier>
+                                    <type>xml</type>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git 
a/examples/karaf-camel-example/karaf-camel-example-blueprint/src/main/resources/OSGI-INF/blueprint/route.xml
 
b/examples/karaf-camel-example/karaf-camel-example-blueprint/src/main/resources/OSGI-INF/blueprint/route.xml
new file mode 100644
index 0000000000..00fa7bb6d6
--- /dev/null
+++ 
b/examples/karaf-camel-example/karaf-camel-example-blueprint/src/main/resources/OSGI-INF/blueprint/route.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
+
+    <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
+        <route id="example-http-inbound">
+            <from uri="jetty:http://0.0.0.0:9090/example"/>
+            <convertBodyTo type="java.lang.String"/>
+            <log message="[EXAMPLE INBOUND] Received: ${body}"/>
+            <choice>
+                <when>
+                    <simple>${headers.CamelHttpMethod} == 'POST'</simple>
+                    <setHeader headerName="type">
+                        <jsonpath>$.notification.type</jsonpath>
+                    </setHeader>
+                    <choice>
+                        <when>
+                            <simple>${header.type} == 'email'</simple>
+                            <log message="[EXAMPLE INBOUND] Received email 
notification"/>
+                            <to uri="direct:email"/>
+                            <setHeader 
headerName="Exchange.HTTP_RESPONSE_CODE"><constant>200</constant></setHeader>
+                        </when>
+                        <when>
+                            <simple>${header.type} == 'http'</simple>
+                            <log message="[EXAMPLE INBOUND] Received http 
notification"/>
+                            <to uri="direct:http"/>
+                            <setHeader 
headerName="Exchange.HTTP_RESPONSE_CODE"><constant>200</constant></setHeader>
+                        </when>
+                        <otherwise>
+                            <log message="[EXAMPLE INBOUND] Unknown 
notification"/>
+                            <setBody><constant>{ "status": "reject", "type": 
"unknown" }</constant></setBody>
+                            <setHeader 
headerName="Exchange.HTTP_RESPONSE_CODE"><constant>400</constant></setHeader>
+                        </otherwise>
+                    </choice>
+                </when>
+                <otherwise>
+                    <log message="[EXAMPLE INBOUND] only POST is accepted 
(${headers.CamelHttpMethod})"/>
+                    <setBody><constant>{ "error": "only POST is accepted" 
}</constant></setBody>
+                    <setHeader 
headerName="Exchange.HTTP_RESPONSE_CODE"><constant>500</constant></setHeader>
+                </otherwise>
+            </choice>
+        </route>
+        <route id="example-email">
+            <from uri="direct:email"/>
+            <log message="[EXAMPLE EMAIL] Sending notification email"/>
+            <setHeader 
headerName="to"><jsonpath>$.notification.to</jsonpath></setHeader>
+            <setHeader 
headerName="subject"><constant>Notification</constant></setHeader>
+            <setBody><jsonpath>$.notification.message</jsonpath></setBody>
+            <!-- <to uri="smtp://localhost"/> -->
+            <setBody><simple>{ "status": "email sent", "to": "${header.to}", 
"subject": "${header.subject}" }</simple></setBody>
+        </route>
+        <route id="example-http">
+            <from uri="direct:http"/>
+            <log message="[EXAMPLE HTTP] Sending http notification"/>
+            <setHeader 
headerName="service"><jsonpath>$.notification.service</jsonpath></setHeader>
+            <!-- <to uri="jetty:..." /> -->
+            <setBody><simple>{ "status": "http requested", "service": 
"${header.service}" }</simple></setBody>
+        </route>
+    </camelContext>
+
+
+</blueprint>
\ No newline at end of file
diff --git a/examples/karaf-camel-example/karaf-camel-example-features/pom.xml 
b/examples/karaf-camel-example/karaf-camel-example-features/pom.xml
new file mode 100644
index 0000000000..957008a627
--- /dev/null
+++ b/examples/karaf-camel-example/karaf-camel-example-features/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.examples</groupId>
+        <artifactId>karaf-camel-example</artifactId>
+        <version>4.2.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>karaf-camel-example-features</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Karaf :: Examples :: Camel :: Features</name>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/feature</directory>
+                <filtering>true</filtering>
+                <targetPath>${project.build.directory}/feature</targetPath>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>resources</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!--
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>verify</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>verify</goal>
+                        </goals>
+                        <configuration>
+                            <descriptors>
+                                
<descriptor>file:${project.build.directory}/feature/feature.xml</descriptor>
+                            </descriptors>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            -->
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>target/feature/feature.xml</file>
+                                    <type>xml</type>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git 
a/examples/karaf-camel-example/karaf-camel-example-features/src/main/feature/feature.xml
 
b/examples/karaf-camel-example/karaf-camel-example-features/src/main/feature/feature.xml
new file mode 100644
index 0000000000..92f485c4df
--- /dev/null
+++ 
b/examples/karaf-camel-example/karaf-camel-example-features/src/main/feature/feature.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<features name="karaf-camel-example-${project.version}" 
xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0";>
+
+    
<repository>mvn:org.apache.camel.karaf/apache-camel/${camel.version}/xml/features</repository>
+
+    <feature name="karaf-camel-example-common" version="${project.version}">
+        <feature prerequisite="true">aries-blueprint</feature>
+        <feature>camel-blueprint</feature>
+        <feature>camel-jetty</feature>
+        <feature>camel-jsonpath</feature>
+        <feature>camel-mail</feature>
+        <capability>
+            
osgi.service;objectClass=org.apache.aries.blueprint.NamespaceHandler;osgi.service.blueprint.namespace=http://camel.apache.org/schema/blueprint;effective:=active;
+        </capability>
+    </feature>
+
+    <feature name="karaf-camel-example-java" version="${project.version}">
+        <feature 
version="${project.version}">karaf-camel-example-common</feature>
+        
<bundle>mvn:org.apache.karaf.examples/karaf-camel-example-java/${project.version}</bundle>
+    </feature>
+
+    <feature name="karaf-camel-example-blueprint" version="${project.version}">
+        <feature 
version="${project.version}">karaf-camel-example-common</feature>
+        
<bundle>blueprint:mvn:org.apache.karaf.examples/karaf-camel-example-blueprint/${project.version}/xml/route</bundle>
+    </feature>
+
+</features>
diff --git a/examples/karaf-camel-example/karaf-camel-example-java/pom.xml 
b/examples/karaf-camel-example/karaf-camel-example-java/pom.xml
new file mode 100644
index 0000000000..bc80dda88e
--- /dev/null
+++ b/examples/karaf-camel-example/karaf-camel-example-java/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.examples</groupId>
+        <artifactId>karaf-camel-example</artifactId>
+        <version>4.2.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>karaf-camel-example-java</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Karaf :: Examples :: Camel :: Java DSL</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+            <version>${camel.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file
diff --git 
a/examples/karaf-camel-example/karaf-camel-example-java/src/main/java/org/apache/karaf/examples/camel/java/ExampleCamelRouteBuilder.java
 
b/examples/karaf-camel-example/karaf-camel-example-java/src/main/java/org/apache/karaf/examples/camel/java/ExampleCamelRouteBuilder.java
new file mode 100644
index 0000000000..9d21e66165
--- /dev/null
+++ 
b/examples/karaf-camel-example/karaf-camel-example-java/src/main/java/org/apache/karaf/examples/camel/java/ExampleCamelRouteBuilder.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.examples.camel.java;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class ExampleCamelRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        from("jetty:http://0.0.0.0:9090/example";)
+                .id("example-http-inbound")
+                .convertBodyTo(String.class)
+                .log("[EXAMPLE INBOUND] Received: ${body}")
+                .choice()
+                    .when().simple("${headers.CamelHttpMethod} == 'POST'")
+                        .setHeader("type").jsonpath("$.notification.type")
+                        .choice()
+                            .when().simple("${header.type} == 'email'")
+                                .log("[EXAMPLE INBOUND] Received email 
notification")
+                                .to("direct:email")
+                                .setHeader("Exchange.HTTP_RESPONSE_CODE", 
constant(200))
+                            .when().simple("${header.type} == 'http'")
+                                .log("[EXAMPLE INBOUND] Received http 
notification")
+                                .to("direct:http")
+                                .setHeader("Exchange.HTTP_RESPONSE_CODE", 
constant(200))
+                            .otherwise()
+                                .log("[EXAMPLE INBOUND] Unknown notification")
+                                .setBody(constant("{ \"status\": \"reject\", 
\"type\": \"unknown\" }"))
+                                .setHeader("Exchange.HTTP_RESPONSE_CODE", 
constant(400))
+                    .otherwise()
+                        .log("[EXAMPLE INBOUND] only POST is accepted 
(${headers.CamelHttpMethod})")
+                        .setBody(constant("{ \"error\": \"only POST is 
accepted\" }"))
+                        .setHeader("Exchange.HTTP_RESPONSE_CODE", 
constant(500));
+
+        from("direct:email")
+                .id("example-email")
+                .log("[EXAMPLE EMAIL] Sending notification email")
+                .setHeader("to").jsonpath("$.notification.to")
+                .setHeader("subject", constant("Notification"))
+                .setHeader("payload").jsonpath("$.notification.message")
+                //.to("smtp://localhost");
+                .setBody(simple("{ \"status\": \"email sent\", \"to\": 
\"${header.to}\", \"subject\": \"${header.subject}\" }"));
+
+        from("direct:http")
+                .id("example-http")
+                .log("[EXAMPLE HTTP] Sending http notification")
+                .setHeader("service").jsonpath("$.notification.service")
+                // send to HTTP service
+                .setBody(simple("{ \"status\": \"http requested\", 
\"service\": \"${header.service}\" }"));
+    }
+    
+}
diff --git 
a/examples/karaf-camel-example/karaf-camel-example-java/src/main/resources/OSGI-INF/blueprint/route.xml
 
b/examples/karaf-camel-example/karaf-camel-example-java/src/main/resources/OSGI-INF/blueprint/route.xml
new file mode 100644
index 0000000000..3adb646130
--- /dev/null
+++ 
b/examples/karaf-camel-example/karaf-camel-example-java/src/main/resources/OSGI-INF/blueprint/route.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
+
+    <bean id="routeBuilder" 
class="org.apache.karaf.examples.camel.java.ExampleCamelRouteBuilder"/>
+
+    <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
+        <routeBuilder ref="routeBuilder"/>
+    </camelContext>
+
+</blueprint>
\ No newline at end of file
diff --git a/examples/karaf-camel-example/pom.xml 
b/examples/karaf-camel-example/pom.xml
new file mode 100644
index 0000000000..df66653b62
--- /dev/null
+++ b/examples/karaf-camel-example/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.examples</groupId>
+        <artifactId>apache-karaf-examples</artifactId>
+        <version>4.2.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>karaf-camel-example</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Karaf :: Examples :: Camel</name>
+
+    <properties>
+        <camel.version>2.23.0</camel.version>
+    </properties>
+
+    <modules>
+        <module>karaf-camel-example-java</module>
+        <module>karaf-camel-example-blueprint</module>
+        <module>karaf-camel-example-features</module>
+    </modules>
+
+</project>
\ No newline at end of file
diff --git a/examples/pom.xml b/examples/pom.xml
index 786ccc931f..f7cf1a5af8 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -37,7 +37,7 @@
         <module>karaf-blueprint-example</module>
         <module>karaf-branding-example</module>
         <module>karaf-bundle-example</module>
-        <!-- <module>karaf-camel-example</module> -->
+        <module>karaf-camel-example</module>
         <!-- <module>karaf-cdi-example</module> -->
         <module>karaf-command-example</module>
         <module>karaf-deployer-example</module>
diff --git 
a/itests/test/src/test/java/org/apache/karaf/itests/examples/CamelExampleTest.java
 
b/itests/test/src/test/java/org/apache/karaf/itests/examples/CamelExampleTest.java
new file mode 100644
index 0000000000..145b3ea3d8
--- /dev/null
+++ 
b/itests/test/src/test/java/org/apache/karaf/itests/examples/CamelExampleTest.java
@@ -0,0 +1,113 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.itests.examples;
+
+import org.apache.karaf.itests.KarafTestSupport;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class CamelExampleTest extends KarafTestSupport {
+
+    public void setup() throws Exception {
+        
addFeaturesRepository("mvn:org.apache.karaf.examples/karaf-camel-example-features/"
 + System.getProperty("karaf.version") + "/xml");
+    }
+
+    @Test
+    public void testJavaDSL() throws Exception {
+        setup();
+        installAndAssertFeature("karaf-camel-example-java");
+        verify();
+    }
+
+    @Test
+    public void testBlueprintDSL() throws Exception {
+        setup();
+        installAndAssertFeature("karaf-camel-example-blueprint");
+        verify();
+    }
+
+    public void verify() throws Exception {
+        String output = executeCommand("camel:route-list");
+        while (true) {
+            if (!output.contains("Started")) {
+                Thread.sleep(500);
+                output = executeCommand("camel:route-list");
+            } else {
+                break;
+            }
+        }
+        System.out.println(output);
+
+        URL url = new URL("http://localhost:9090/example";);
+        HttpURLConnection connection = (HttpURLConnection) 
url.openConnection();
+        connection.setRequestMethod("POST");
+        connection.setRequestProperty("Content-Type", "application/json");
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+
+        PrintWriter writer = new PrintWriter(new 
OutputStreamWriter(connection.getOutputStream()));
+        writer.println("{ \"notification\": { \"type\": \"email\", \"to\": 
\"f...@bar.com\", \"message\": \"this is a test\" }}");
+        writer.flush();
+        writer.close();
+
+        BufferedReader reader = new BufferedReader(new 
InputStreamReader(connection.getInputStream()));
+        String line;
+        StringBuffer buffer = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+            buffer.append(line);
+        }
+        reader.close();
+
+        output = buffer.toString();
+        System.out.println(output);
+        assertEquals("{ \"status\": \"email sent\", \"to\": \"f...@bar.com\", 
\"subject\": \"Notification\" }", output);
+
+        connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestMethod("POST");
+        connection.setRequestProperty("Content-Type", "application/json");
+        connection.setDoOutput(true);
+        connection.setDoInput(true);
+
+        writer = new PrintWriter(new 
OutputStreamWriter(connection.getOutputStream()));
+        writer.println("{ \"notification\": { \"type\": \"http\", \"service\": 
\"http://foo\"; }}");
+        writer.flush();
+        writer.close();
+
+        reader = new BufferedReader(new 
InputStreamReader(connection.getInputStream()));
+        buffer = new StringBuffer();
+        while ((line = reader.readLine()) != null) {
+            buffer.append(line);
+        }
+        reader.close();
+
+        output = buffer.toString();
+        System.out.println(output);
+        assertEquals("{ \"status\": \"http requested\", \"service\": 
\"http://foo\"; }", output);
+    }
+
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add Camel examples
> ------------------
>
>                 Key: KARAF-5893
>                 URL: https://issues.apache.org/jira/browse/KARAF-5893
>             Project: Karaf
>          Issue Type: Task
>          Components: karaf
>            Reporter: Francois Papon
>            Assignee: Jean-Baptiste Onofré
>            Priority: Minor
>             Fix For: 4.2.2
>
>
> Add a Camel examples using Blueprint and a Camel custom processor.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to