camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: Added test based on user forum issue
Date Wed, 29 Jan 2014 07:55:54 GMT
Updated Branches:
  refs/heads/master 9542d07c8 -> 8cd86620d


Added test based on user forum issue


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

Branch: refs/heads/master
Commit: 8cd86620d09f9641f4d29c5a131f162fd48ec547
Parents: 9542d07
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jan 29 08:56:38 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jan 29 08:56:38 2014 +0100

----------------------------------------------------------------------
 .../NoClassDefFoundErrorWrapExceptionTest.java  | 55 +++++++++++++++
 .../java/org/apache/camel/util/ProcessorA.java  | 28 ++++++++
 .../java/org/apache/camel/util/ProcessorB.java  | 28 ++++++++
 .../org/apache/camel/util/ProcessorFail.java    | 28 ++++++++
 .../NoClassDefFoundErrorWrapExceptionTest.java  | 70 ++++++++++++++++++++
 .../camel/component/jms/issues/ProcessorA.java  | 29 ++++++++
 .../camel/component/jms/issues/ProcessorB.java  | 29 ++++++++
 .../component/jms/issues/ProcessorFail.java     | 29 ++++++++
 8 files changed, 296 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8cd86620/camel-core/src/test/java/org/apache/camel/util/NoClassDefFoundErrorWrapExceptionTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/NoClassDefFoundErrorWrapExceptionTest.java
b/camel-core/src/test/java/org/apache/camel/util/NoClassDefFoundErrorWrapExceptionTest.java
new file mode 100644
index 0000000..7569443
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/NoClassDefFoundErrorWrapExceptionTest.java
@@ -0,0 +1,55 @@
+/**
+ * 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.util;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+public class NoClassDefFoundErrorWrapExceptionTest extends ContextTestSupport {
+
+    public void testNoClassDef() throws Exception {
+        try {
+            template.requestBody("seda:start", "Hello World");
+            fail("Should throw exception");
+        } catch (Exception e) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            e.printStackTrace(pw);
+
+            String s = sw.toString();
+            assertTrue(s.contains("java.lang.LinkageError"));
+            assertTrue(s.contains("Cannot do this"));
+            assertTrue(s.contains("org.apache.camel.util.ProcessorFail.process"));
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:start")
+                    .process(new ProcessorA())
+                    .process(new ProcessorB())
+                    .process(new ProcessorFail());
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8cd86620/camel-core/src/test/java/org/apache/camel/util/ProcessorA.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/ProcessorA.java b/camel-core/src/test/java/org/apache/camel/util/ProcessorA.java
new file mode 100644
index 0000000..4f6b7c3
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/ProcessorA.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.apache.camel.util;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class ProcessorA implements Processor {
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        exchange.getIn().setHeader("a", "a");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8cd86620/camel-core/src/test/java/org/apache/camel/util/ProcessorB.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/ProcessorB.java b/camel-core/src/test/java/org/apache/camel/util/ProcessorB.java
new file mode 100644
index 0000000..8720af6
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/ProcessorB.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.apache.camel.util;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class ProcessorB implements Processor {
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        exchange.getIn().setHeader("b", "b");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8cd86620/camel-core/src/test/java/org/apache/camel/util/ProcessorFail.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/ProcessorFail.java b/camel-core/src/test/java/org/apache/camel/util/ProcessorFail.java
new file mode 100644
index 0000000..3ef32e7
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/ProcessorFail.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.apache.camel.util;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class ProcessorFail implements Processor {
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        throw new LinkageError("Cannot do this");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8cd86620/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/NoClassDefFoundErrorWrapExceptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/NoClassDefFoundErrorWrapExceptionTest.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/NoClassDefFoundErrorWrapExceptionTest.java
new file mode 100644
index 0000000..f647b66
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/NoClassDefFoundErrorWrapExceptionTest.java
@@ -0,0 +1,70 @@
+/**
+ * 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.component.jms.issues;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import javax.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.CamelJmsTestHelper;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+public class NoClassDefFoundErrorWrapExceptionTest extends CamelTestSupport {
+
+    @Test
+    public void testNoClassDef() throws Exception {
+        try {
+            template.requestBody("activemq:start?transferException=true", "Hello World");
+            fail("Should throw exception");
+        } catch (Exception e) {
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            e.printStackTrace(pw);
+
+            String s = sw.toString();
+            assertTrue(s.contains("java.lang.LinkageError"));
+            assertTrue(s.contains("Cannot do this"));
+            assertTrue(s.contains("org.apache.camel.component.jms.issues.ProcessorFail.process"));
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("activemq:start?transferException=true")
+                        .process(new ProcessorA())
+                        .process(new ProcessorB())
+                        .process(new ProcessorFail());
+            }
+        };
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+        return camelContext;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8cd86620/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorA.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorA.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorA.java
new file mode 100644
index 0000000..aea1dd9
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorA.java
@@ -0,0 +1,29 @@
+/**
+ * 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.component.jms.issues;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class ProcessorA implements Processor {
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        exchange.getIn().setHeader("a", "a");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8cd86620/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorB.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorB.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorB.java
new file mode 100644
index 0000000..5a4bd7e
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorB.java
@@ -0,0 +1,29 @@
+/**
+ * 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.component.jms.issues;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class ProcessorB implements Processor {
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        exchange.getIn().setHeader("b", "b");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8cd86620/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorFail.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorFail.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorFail.java
new file mode 100644
index 0000000..f41181c
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/ProcessorFail.java
@@ -0,0 +1,29 @@
+/**
+ * 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.component.jms.issues;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+public class ProcessorFail implements Processor {
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        throw new LinkageError("Cannot do this");
+    }
+
+}


Mime
View raw message