You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/12/09 07:24:58 UTC

[1/4] camel git commit: Polish the index.html of camel-example-servlet-tomcat-no-spring

Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x cf9212221 -> 2f7523140
  refs/heads/camel-2.14.x 4cbee5f11 -> 0a252ecd7


Polish the index.html of camel-example-servlet-tomcat-no-spring


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

Branch: refs/heads/camel-2.14.x
Commit: fedd88db5a46ab6edfefd4f6e0e177d3f8c8b6e5
Parents: 4cbee5f
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Dec 8 11:44:08 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Dec 9 14:23:00 2014 +0800

----------------------------------------------------------------------
 .../src/main/webapp/index.html                                | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fedd88db/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html b/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html
index cb3ce63..833d67d 100644
--- a/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html
+++ b/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html
@@ -27,7 +27,12 @@ To get started click <a href="camel/hello">this link</a>.
 <br/>
 <br/>
 This example is documented at
-<a href="http://camel.apache.org/servlet-tomcat-example-no-spring.html">servlet tomcat no spring example</a>
+<a href="http://camel.apache.org/servlet-tomcat-no-spring-example.html">servlet tomcat no spring example</a>
+
+<br/>
+<br/>
+You can find more information about the camel servletlistener component
+<a href="https://camel.apache.org/servletlistener-component.html">here</a>
 
 <br/>
 If you hit any problems please let us know on the


[3/4] camel git commit: CAMEL-8091 DefaultExchangeFormatter should consider Exchange.LOG_DEBUG_BODY_MAX_CHARS with thanks to Stephan

Posted by ni...@apache.org.
CAMEL-8091 DefaultExchangeFormatter should consider Exchange.LOG_DEBUG_BODY_MAX_CHARS with thanks to Stephan


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

Branch: refs/heads/camel-2.13.x
Commit: 42da7161007bb198d64ec55656d1303e1c826807
Parents: cf92122
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Dec 9 14:15:58 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Dec 9 14:24:13 2014 +0800

----------------------------------------------------------------------
 .../processor/DefaultExchangeFormatter.java     | 13 ++-
 .../processor/DefaultExchangeFormatterTest.java | 91 ++++++++++++++++++++
 2 files changed, 103 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/42da7161/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java b/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
index 19ee87a..138c6cf 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
@@ -389,7 +389,18 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
             }
         }
 
-        return MessageHelper.extractBodyForLogging(message, "", isShowStreams(), isShowFiles(), getMaxChars());
+        return MessageHelper.extractBodyForLogging(message, "", isShowStreams(), isShowFiles(), getMaxChars(message));
+    }
+
+    private int getMaxChars(Message message) {
+        int maxChars = getMaxChars();
+        if (message.getExchange() != null) {
+            String property = message.getExchange().getContext().getProperty(Exchange.LOG_DEBUG_BODY_MAX_CHARS);
+            if (property != null) {
+                maxChars = message.getExchange().getContext().getTypeConverter().convertTo(Integer.class, property);
+            }
+        }
+        return maxChars;
     }
 
     protected String getBodyTypeAsString(Message message) {

http://git-wip-us.apache.org/repos/asf/camel/blob/42da7161/camel-core/src/test/java/org/apache/camel/processor/DefaultExchangeFormatterTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/DefaultExchangeFormatterTest.java b/camel-core/src/test/java/org/apache/camel/processor/DefaultExchangeFormatterTest.java
new file mode 100644
index 0000000..69ee665
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/DefaultExchangeFormatterTest.java
@@ -0,0 +1,91 @@
+/**
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.impl.DefaultMessage;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class DefaultExchangeFormatterTest {
+    private DefaultCamelContext camelContext;
+    private Exchange exchange;
+    private DefaultExchangeFormatter exchangeFormatter;
+
+    @Before
+    public void setUp() {
+        camelContext = new DefaultCamelContext();
+        Message message = new DefaultMessage();
+        message.setBody("This is the message body");
+        exchange = new DefaultExchange(camelContext);
+        exchange.setIn(message);
+        exchangeFormatter = new DefaultExchangeFormatter();
+    }
+
+    @Test
+    public void testDefaultFormat() {
+        String formattedExchange = exchangeFormatter.format(exchange);
+        assertTrue(formattedExchange.contains("This is the message body"));
+    }
+
+    @Test
+    /*
+     * The formatted exchange without limitation is 
+     * Exchange[ExchangePattern: InOnly, BodyType: String, Body: This is the message body]
+     * The "Exchange[", the "...", and the "]" do not count here, but the 
+     * leading ", " that is removed later does count...
+     */
+    public void testFormatWithMaxCharsParameter() {
+        exchangeFormatter.setMaxChars(60);
+        String formattedExchange = exchangeFormatter.format(exchange);
+        assertEquals(60 + "Exchange[...]".length() - ", ".length(), formattedExchange.length());
+    }
+
+    @Test
+    /*
+     * This limitation is really the length of the printed message body, not the
+     * one of the message
+     */
+    public void testFormatWithBodyMaxChars() {
+        camelContext.getProperties().put(Exchange.LOG_DEBUG_BODY_MAX_CHARS, "7");
+        String formattedExchange = exchangeFormatter.format(exchange);
+        assertFalse(formattedExchange.contains("This is "));
+        assertTrue(formattedExchange.contains("This is"));
+        camelContext.getProperties().remove(Exchange.LOG_DEBUG_BODY_MAX_CHARS);
+    }
+
+    @Test
+    /*
+     * These two limitations will first truncate the message body and then the
+     * total message.
+     */
+    public void testFormatWithBoth() {
+        camelContext.getProperties().put(Exchange.LOG_DEBUG_BODY_MAX_CHARS, "7");
+        exchangeFormatter.setMaxChars(60);
+        String formattedExchange = exchangeFormatter.format(exchange);
+        assertEquals(60 + "Exchange[...]".length() - ", ".length(), formattedExchange.length());
+        assertFalse(formattedExchange.contains("This is "));
+        camelContext.getProperties().remove(Exchange.LOG_DEBUG_BODY_MAX_CHARS);
+    }
+}


[4/4] camel git commit: Polish the index.html of camel-example-servlet-tomcat-no-spring

Posted by ni...@apache.org.
Polish the index.html of camel-example-servlet-tomcat-no-spring


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

Branch: refs/heads/camel-2.13.x
Commit: 2f75231408b987a908d5ccc5e02b8d2286dd123c
Parents: 42da716
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Dec 8 11:44:08 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Dec 9 14:24:32 2014 +0800

----------------------------------------------------------------------
 .../src/main/webapp/index.html                                | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2f752314/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html b/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html
index cb3ce63..833d67d 100644
--- a/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html
+++ b/examples/camel-example-servlet-tomcat-no-spring/src/main/webapp/index.html
@@ -27,7 +27,12 @@ To get started click <a href="camel/hello">this link</a>.
 <br/>
 <br/>
 This example is documented at
-<a href="http://camel.apache.org/servlet-tomcat-example-no-spring.html">servlet tomcat no spring example</a>
+<a href="http://camel.apache.org/servlet-tomcat-no-spring-example.html">servlet tomcat no spring example</a>
+
+<br/>
+<br/>
+You can find more information about the camel servletlistener component
+<a href="https://camel.apache.org/servletlistener-component.html">here</a>
 
 <br/>
 If you hit any problems please let us know on the


[2/4] camel git commit: CAMEL-8091 DefaultExchangeFormatter should consider Exchange.LOG_DEBUG_BODY_MAX_CHARS with thanks to Stephan

Posted by ni...@apache.org.
CAMEL-8091 DefaultExchangeFormatter should consider Exchange.LOG_DEBUG_BODY_MAX_CHARS with thanks to Stephan


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

Branch: refs/heads/camel-2.14.x
Commit: 0a252ecd7ea5fe29e19595351fb52dcaf56c626f
Parents: fedd88d
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Dec 9 14:15:58 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Dec 9 14:23:49 2014 +0800

----------------------------------------------------------------------
 .../processor/DefaultExchangeFormatter.java     | 13 ++-
 .../processor/DefaultExchangeFormatterTest.java | 91 ++++++++++++++++++++
 2 files changed, 103 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0a252ecd/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java b/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
index 19ee87a..138c6cf 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/DefaultExchangeFormatter.java
@@ -389,7 +389,18 @@ public class DefaultExchangeFormatter implements ExchangeFormatter {
             }
         }
 
-        return MessageHelper.extractBodyForLogging(message, "", isShowStreams(), isShowFiles(), getMaxChars());
+        return MessageHelper.extractBodyForLogging(message, "", isShowStreams(), isShowFiles(), getMaxChars(message));
+    }
+
+    private int getMaxChars(Message message) {
+        int maxChars = getMaxChars();
+        if (message.getExchange() != null) {
+            String property = message.getExchange().getContext().getProperty(Exchange.LOG_DEBUG_BODY_MAX_CHARS);
+            if (property != null) {
+                maxChars = message.getExchange().getContext().getTypeConverter().convertTo(Integer.class, property);
+            }
+        }
+        return maxChars;
     }
 
     protected String getBodyTypeAsString(Message message) {

http://git-wip-us.apache.org/repos/asf/camel/blob/0a252ecd/camel-core/src/test/java/org/apache/camel/processor/DefaultExchangeFormatterTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/DefaultExchangeFormatterTest.java b/camel-core/src/test/java/org/apache/camel/processor/DefaultExchangeFormatterTest.java
new file mode 100644
index 0000000..69ee665
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/DefaultExchangeFormatterTest.java
@@ -0,0 +1,91 @@
+/**
+ * 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;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.impl.DefaultMessage;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class DefaultExchangeFormatterTest {
+    private DefaultCamelContext camelContext;
+    private Exchange exchange;
+    private DefaultExchangeFormatter exchangeFormatter;
+
+    @Before
+    public void setUp() {
+        camelContext = new DefaultCamelContext();
+        Message message = new DefaultMessage();
+        message.setBody("This is the message body");
+        exchange = new DefaultExchange(camelContext);
+        exchange.setIn(message);
+        exchangeFormatter = new DefaultExchangeFormatter();
+    }
+
+    @Test
+    public void testDefaultFormat() {
+        String formattedExchange = exchangeFormatter.format(exchange);
+        assertTrue(formattedExchange.contains("This is the message body"));
+    }
+
+    @Test
+    /*
+     * The formatted exchange without limitation is 
+     * Exchange[ExchangePattern: InOnly, BodyType: String, Body: This is the message body]
+     * The "Exchange[", the "...", and the "]" do not count here, but the 
+     * leading ", " that is removed later does count...
+     */
+    public void testFormatWithMaxCharsParameter() {
+        exchangeFormatter.setMaxChars(60);
+        String formattedExchange = exchangeFormatter.format(exchange);
+        assertEquals(60 + "Exchange[...]".length() - ", ".length(), formattedExchange.length());
+    }
+
+    @Test
+    /*
+     * This limitation is really the length of the printed message body, not the
+     * one of the message
+     */
+    public void testFormatWithBodyMaxChars() {
+        camelContext.getProperties().put(Exchange.LOG_DEBUG_BODY_MAX_CHARS, "7");
+        String formattedExchange = exchangeFormatter.format(exchange);
+        assertFalse(formattedExchange.contains("This is "));
+        assertTrue(formattedExchange.contains("This is"));
+        camelContext.getProperties().remove(Exchange.LOG_DEBUG_BODY_MAX_CHARS);
+    }
+
+    @Test
+    /*
+     * These two limitations will first truncate the message body and then the
+     * total message.
+     */
+    public void testFormatWithBoth() {
+        camelContext.getProperties().put(Exchange.LOG_DEBUG_BODY_MAX_CHARS, "7");
+        exchangeFormatter.setMaxChars(60);
+        String formattedExchange = exchangeFormatter.format(exchange);
+        assertEquals(60 + "Exchange[...]".length() - ", ".length(), formattedExchange.length());
+        assertFalse(formattedExchange.contains("This is "));
+        camelContext.getProperties().remove(Exchange.LOG_DEBUG_BODY_MAX_CHARS);
+    }
+}