You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/03/24 14:05:07 UTC

[camel-karaf] 04/07: Camel-Karaf: Added tests/camel-blueprin-test

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-karaf.git

commit 2f87fe04783beac5e013b6d209f10ae3f02a2eba
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Mar 24 13:10:35 2020 +0100

    Camel-Karaf: Added tests/camel-blueprin-test
---
 tests/camel-blueprint-test/pom.xml                 | 64 ++++++++++++++++++++++
 ...eprintResolveComponentFromCamelContextTest.java | 43 +++++++++++++++
 .../builder/AddComponentInConfigureBuilder.java    | 30 ++++++++++
 .../test-resolve-component-from-camel-context.xml  | 28 ++++++++++
 tests/pom.xml                                      |  1 +
 5 files changed, 166 insertions(+)

diff --git a/tests/camel-blueprint-test/pom.xml b/tests/camel-blueprint-test/pom.xml
new file mode 100644
index 0000000..aab8365
--- /dev/null
+++ b/tests/camel-blueprint-test/pom.xml
@@ -0,0 +1,64 @@
+<?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.karaf</groupId>
+        <artifactId>tests</artifactId>
+        <version>3.2.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-blueprint-test</artifactId>
+    <name>Camel Karaf :: Integration Tests :: Blueprint</name>
+    <description>Tests the camel-blueprint features</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel.karaf</groupId>
+            <artifactId>camel-blueprint</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.karaf</groupId>
+            <artifactId>camel-test-blueprint</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- logging -->
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-slf4j-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+</project>
diff --git a/tests/camel-blueprint-test/src/test/java/org/apache/camel/blueprint/BlueprintResolveComponentFromCamelContextTest.java b/tests/camel-blueprint-test/src/test/java/org/apache/camel/blueprint/BlueprintResolveComponentFromCamelContextTest.java
new file mode 100644
index 0000000..8f8d7ba
--- /dev/null
+++ b/tests/camel-blueprint-test/src/test/java/org/apache/camel/blueprint/BlueprintResolveComponentFromCamelContextTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.camel.blueprint;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+public class BlueprintResolveComponentFromCamelContextTest extends CamelBlueprintTestSupport {
+
+    @EndpointInject("mock://result")
+    MockEndpoint result;
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "OSGI-INF/blueprint/test-resolve-component-from-camel-context.xml";
+    }
+
+    @Test
+    public void testResolveComponentFromCamelContext() throws Exception {
+        result.expectedMinimumMessageCount(1);
+
+        // The route is driven by a timer, so we should receive at least one message within 5 seconds
+        assertMockEndpointsSatisfied(5, TimeUnit.SECONDS);
+    }
+}
diff --git a/tests/camel-blueprint-test/src/test/java/org/apache/camel/blueprint/test/builder/AddComponentInConfigureBuilder.java b/tests/camel-blueprint-test/src/test/java/org/apache/camel/blueprint/test/builder/AddComponentInConfigureBuilder.java
new file mode 100644
index 0000000..4edd456
--- /dev/null
+++ b/tests/camel-blueprint-test/src/test/java/org/apache/camel/blueprint/test/builder/AddComponentInConfigureBuilder.java
@@ -0,0 +1,30 @@
+/*
+ * 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.camel.blueprint.test.builder;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.timer.TimerComponent;
+
+public class AddComponentInConfigureBuilder extends RouteBuilder {
+    @Override
+    public void configure() throws Exception {
+        getContext().addComponent("my-timer", new TimerComponent());
+
+        from("my-timer://test-timer?period=1000")
+                .to("mock://result");
+    }
+}
diff --git a/tests/camel-blueprint-test/src/test/resources/OSGI-INF/blueprint/test-resolve-component-from-camel-context.xml b/tests/camel-blueprint-test/src/test/resources/OSGI-INF/blueprint/test-resolve-component-from-camel-context.xml
new file mode 100644
index 0000000..ad7de52
--- /dev/null
+++ b/tests/camel-blueprint-test/src/test/resources/OSGI-INF/blueprint/test-resolve-component-from-camel-context.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+    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="test-builder" class="org.apache.camel.blueprint.test.builder.AddComponentInConfigureBuilder"/>
+
+    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
+        <routeBuilder ref="test-builder"/>
+    </camelContext>
+
+</blueprint>
diff --git a/tests/pom.xml b/tests/pom.xml
index 649e64f..873e96a 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -39,6 +39,7 @@
 
     <modules>
         <module>camel-blueprint-cxf-test</module>
+        <module>camel-blueprint-test</module>
     </modules>
 
     <build>