You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/01/19 11:06:52 UTC
[12/17] camel git commit: CAMEL-10721: camel-connector example
CAMEL-10721: camel-connector example
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/219df166
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/219df166
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/219df166
Branch: refs/heads/master
Commit: 219df1664cceb21b0684f487cf469fe8d5b93c93
Parents: 1c50540
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Jan 18 16:59:18 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jan 19 11:00:00 2017 +0100
----------------------------------------------------------------------
connectors/camel-connector/pom.xml | 4 +-
.../examples/foo-bar-wine-example/pom.xml | 105 +++++++++++++++++++
.../src/main/java/org/foo/FooBarWineMain.java | 28 +++++
.../src/main/java/org/foo/FooBarWineRoute.java | 33 ++++++
.../src/main/resources/log4j2.properties | 23 ++++
.../src/test/java/io/fabric/FooBarTest.java | 48 +++++++++
.../src/test/resources/log4j2.properties | 28 +++++
connectors/examples/pom.xml | 1 +
8 files changed, 268 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/219df166/connectors/camel-connector/pom.xml
----------------------------------------------------------------------
diff --git a/connectors/camel-connector/pom.xml b/connectors/camel-connector/pom.xml
index c53b02c..8706635 100644
--- a/connectors/camel-connector/pom.xml
+++ b/connectors/camel-connector/pom.xml
@@ -27,8 +27,8 @@
<artifactId>camel-connector</artifactId>
<packaging>jar</packaging>
- <name>Camel :: Connector</name>
- <description>Camel Connector</description>
+ <name>Camel :: Connector Component</name>
+ <description>Camel Connector Component</description>
<properties>
<camel.osgi.export.pkg>org.apache.camel.component.connector.*</camel.osgi.export.pkg>
http://git-wip-us.apache.org/repos/asf/camel/blob/219df166/connectors/examples/foo-bar-wine-example/pom.xml
----------------------------------------------------------------------
diff --git a/connectors/examples/foo-bar-wine-example/pom.xml b/connectors/examples/foo-bar-wine-example/pom.xml
new file mode 100644
index 0000000..f603032
--- /dev/null
+++ b/connectors/examples/foo-bar-wine-example/pom.xml
@@ -0,0 +1,105 @@
+<?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.
+-->
+<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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>connectors-examples</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>foo-bar-wine-example</artifactId>
+ <name>Camel :: Connectors :: Examples :: Foo Bar and Wine Example</name>
+ <description>Foo Bar and Wine Example</description>
+ <packaging>jar</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Camel BOM -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>${project.version}</version>
+ <scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <!-- connectors used in this example -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>foo-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>bar-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>wine-connector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- Allows the example to be run via 'mvn camel:run' -->
+ <plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <configuration>
+ <mainClass>org.foo.FooBarWineMain</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/219df166/connectors/examples/foo-bar-wine-example/src/main/java/org/foo/FooBarWineMain.java
----------------------------------------------------------------------
diff --git a/connectors/examples/foo-bar-wine-example/src/main/java/org/foo/FooBarWineMain.java b/connectors/examples/foo-bar-wine-example/src/main/java/org/foo/FooBarWineMain.java
new file mode 100644
index 0000000..def8b04
--- /dev/null
+++ b/connectors/examples/foo-bar-wine-example/src/main/java/org/foo/FooBarWineMain.java
@@ -0,0 +1,28 @@
+/**
+ * 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.foo;
+
+import org.apache.camel.main.Main;
+
+public class FooBarWineMain {
+
+ public static void main(String[] args) throws Exception {
+ Main main = new Main();
+ main.addRouteBuilder(new FooBarWineRoute());
+ main.run();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/219df166/connectors/examples/foo-bar-wine-example/src/main/java/org/foo/FooBarWineRoute.java
----------------------------------------------------------------------
diff --git a/connectors/examples/foo-bar-wine-example/src/main/java/org/foo/FooBarWineRoute.java b/connectors/examples/foo-bar-wine-example/src/main/java/org/foo/FooBarWineRoute.java
new file mode 100644
index 0000000..7163ce2
--- /dev/null
+++ b/connectors/examples/foo-bar-wine-example/src/main/java/org/foo/FooBarWineRoute.java
@@ -0,0 +1,33 @@
+/**
+ * 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.foo;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class FooBarWineRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("foo:wine?period=3000")
+ .to("wine:wine?amount=2")
+ .log("Wine ordered ${body}");
+
+ from("foo:bar?period=5000")
+ .to("bar:GinTonic?amount=5")
+ .log("Bar ordered ${body}");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/219df166/connectors/examples/foo-bar-wine-example/src/main/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/connectors/examples/foo-bar-wine-example/src/main/resources/log4j2.properties b/connectors/examples/foo-bar-wine-example/src/main/resources/log4j2.properties
new file mode 100644
index 0000000..ed759af
--- /dev/null
+++ b/connectors/examples/foo-bar-wine-example/src/main/resources/log4j2.properties
@@ -0,0 +1,23 @@
+#
+# Copyright 2005-2015 Red Hat, Inc.
+#
+# Red Hat 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.
+#
+
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = out
http://git-wip-us.apache.org/repos/asf/camel/blob/219df166/connectors/examples/foo-bar-wine-example/src/test/java/io/fabric/FooBarTest.java
----------------------------------------------------------------------
diff --git a/connectors/examples/foo-bar-wine-example/src/test/java/io/fabric/FooBarTest.java b/connectors/examples/foo-bar-wine-example/src/test/java/io/fabric/FooBarTest.java
new file mode 100644
index 0000000..84e47fd
--- /dev/null
+++ b/connectors/examples/foo-bar-wine-example/src/test/java/io/fabric/FooBarTest.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2005-2015 Red Hat, Inc.
+ * <p>
+ * Red Hat 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 io.fabric;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class FooBarTest extends CamelTestSupport {
+
+ @Test
+ public void testFooBar() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+
+ mock.expectedMinimumMessageCount(2);
+ mock.setAssertPeriod(500);
+
+ assertMockEndpointsSatisfied();
+ }
+
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("foo:hello?period=100")
+ .to("bar:beer")
+ .to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/219df166/connectors/examples/foo-bar-wine-example/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/connectors/examples/foo-bar-wine-example/src/test/resources/log4j2.properties b/connectors/examples/foo-bar-wine-example/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..8910968
--- /dev/null
+++ b/connectors/examples/foo-bar-wine-example/src/test/resources/log4j2.properties
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
http://git-wip-us.apache.org/repos/asf/camel/blob/219df166/connectors/examples/pom.xml
----------------------------------------------------------------------
diff --git a/connectors/examples/pom.xml b/connectors/examples/pom.xml
index 5478431..9fbdb4d 100644
--- a/connectors/examples/pom.xml
+++ b/connectors/examples/pom.xml
@@ -36,6 +36,7 @@
<module>foo-connector</module>
<module>bar-connector</module>
<module>wine-connector</module>
+ <module>foo-bar-wine-example</module>
</modules>
</project>