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 2019/10/16 17:25:49 UTC

[camel] branch master updated: CAMEL-14025: add muteException option to camel-jetty component (#3253)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9bd871b  CAMEL-14025: add muteException option to camel-jetty component (#3253)
9bd871b is described below

commit 9bd871b541f2367103e81f454c556cdca9c1994b
Author: mschnitzler <sc...@gmail.com>
AuthorDate: Wed Oct 16 19:25:32 2019 +0200

    CAMEL-14025: add muteException option to camel-jetty component (#3253)
---
 .../camel/component/jetty9/JettyHttpEndpoint9.java |  1 +
 .../component/jetty/JettyMuteExceptionTest.java    | 55 ++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
index 3425065..bd65238 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
@@ -48,6 +48,7 @@ public class JettyHttpEndpoint9 extends JettyHttpEndpoint implements AsyncEndpoi
         if (this.binding == null) {
             this.binding = new AttachmentHttpBinding();
             this.binding.setTransferException(isTransferException());
+            this.binding.setMuteException(isMuteException());
             if (getComponent() != null) {
                 this.binding.setAllowJavaSerializedObject(getComponent().isAllowJavaSerializedObject());
             }
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMuteExceptionTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMuteExceptionTest.java
new file mode 100644
index 0000000..899243f
--- /dev/null
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyMuteExceptionTest.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.component.jetty;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class JettyMuteExceptionTest extends BaseJettyTest {
+
+    @Test
+    public void testMuteException() throws Exception {
+
+        HttpClient client = new HttpClient();
+        GetMethod get = new GetMethod("http://localhost:" + getPort() + "/foo");
+        get.setRequestHeader("Accept", "application/text");
+        client.executeMethod(get);
+
+        String body = get.getResponseBodyAsString();
+        Assert.assertNotNull(body);
+        Assert.assertEquals("Exception", body);
+        Assert.assertEquals(500, get.getStatusCode());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("jetty:http://localhost:{{port}}/foo?muteException=true")
+                        .to("mock:destination")
+                        .throwException(new IllegalArgumentException("Camel cannot do this"));
+            }
+        };
+    }
+
+
+}