Repository: camel
Updated Branches:
  refs/heads/master 2e9bce8a0 -> ad44b7211


CAMEL-10247: Added unit test


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ad44b721
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ad44b721
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ad44b721

Branch: refs/heads/master
Commit: ad44b72112d4cb468d6462728fa6570170f39e33
Parents: 2e9bce8
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Aug 17 10:07:23 2016 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Aug 17 10:11:27 2016 +0200

----------------------------------------------------------------------
 .../onexception/OnExceptionRouteIdTest.java     | 56 ++++++++++++++++++++
 .../OnExceptionRouteIdRouteBuilder.java         | 36 +++++++++++++
 .../test/blueprint/OnExceptionRouteIdTest.java  | 43 +++++++++++++++
 .../test/blueprint/OnExceptionRouteIdTest.xml   | 29 ++++++++++
 4 files changed, 164 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ad44b721/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRouteIdTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRouteIdTest.java
 
b/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRouteIdTest.java
new file mode 100644
index 0000000..e39b7c8
--- /dev/null
+++ 
b/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRouteIdTest.java
@@ -0,0 +1,56 @@
+/**
+ * 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.processor.onexception;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+
+public class OnExceptionRouteIdTest extends ContextTestSupport {
+
+    public void testOnExceptionRouteId() throws Exception {
+        getMockEndpoint("mock:error").expectedMessageCount(0);
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        RouteDefinition route = context.getRouteDefinition("foo");
+        assertNotNull(route);
+        assertEquals("foo", route.getId());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                onException(Exception.class).id("myError")
+                    .maximumRedeliveries(0)
+                    .handled(true)
+                    .setHeader("error", constant("true"))
+                    .end()
+                    .stop();
+
+                from("direct:foo").routeId("foo")
+                    .to("mock:foo")
+                    .end();
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ad44b721/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/OnExceptionRouteIdRouteBuilder.java
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/OnExceptionRouteIdRouteBuilder.java
 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/OnExceptionRouteIdRouteBuilder.java
new file mode 100644
index 0000000..ba1e40b
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/OnExceptionRouteIdRouteBuilder.java
@@ -0,0 +1,36 @@
+/**
+ * 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.test.blueprint;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class OnExceptionRouteIdRouteBuilder extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        onException(Exception.class).id("myError")
+                .maximumRedeliveries(0)
+                .handled(true)
+                .setHeader("error", constant("true"))
+                .end()
+                .stop();
+
+        from("direct:foo").routeId("foo")
+                .to("mock:foo")
+                .end();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ad44b721/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/OnExceptionRouteIdTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/OnExceptionRouteIdTest.java
 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/OnExceptionRouteIdTest.java
new file mode 100644
index 0000000..438a080
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/OnExceptionRouteIdTest.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.test.blueprint;
+
+import org.apache.camel.model.RouteDefinition;
+import org.junit.Test;
+
+public class OnExceptionRouteIdTest extends CamelBlueprintTestSupport {
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/OnExceptionRouteIdTest.xml";
+    }
+
+    @Test
+    public void testOnExceptionRouteId() throws Exception {
+        getMockEndpoint("mock:error").expectedMessageCount(0);
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        RouteDefinition route = context.getRouteDefinition("foo");
+        assertNotNull(route);
+        assertEquals("foo", route.getId());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/ad44b721/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/OnExceptionRouteIdTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/OnExceptionRouteIdTest.xml
 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/OnExceptionRouteIdTest.xml
new file mode 100644
index 0000000..55a5359
--- /dev/null
+++ 
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/OnExceptionRouteIdTest.xml
@@ -0,0 +1,29 @@
+<?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";
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>
+
+  <bean id="myRoute" 
class="org.apache.camel.test.blueprint.OnExceptionRouteIdRouteBuilder"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/blueprint";>
+    <routeBuilder ref="myRoute"/>
+  </camelContext>
+
+</blueprint>

Reply via email to