camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] git commit: CAMEL-6987: Fixed browse as xml not returning files if includeBody=true.
Date Wed, 20 Nov 2013 15:43:44 GMT
Updated Branches:
  refs/heads/camel-2.11.x 1fbee5b6d -> da43e9c71
  refs/heads/camel-2.12.x 8f9a4a022 -> dcaa5d782


CAMEL-6987: Fixed browse as xml not returning files if includeBody=true.


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

Branch: refs/heads/camel-2.11.x
Commit: da43e9c71384a37a218a90727920950e2e19c3eb
Parents: 1fbee5b
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Nov 20 16:44:05 2013 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Nov 20 16:45:18 2013 +0100

----------------------------------------------------------------------
 .../org/apache/camel/util/MessageHelper.java    |  4 +-
 .../ManagedBrowsableEndpointAsXmlFileTest.java  | 67 ++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/da43e9c7/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
index 61be0f0..ca9bcc2 100644
--- a/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/MessageHelper.java
@@ -212,7 +212,9 @@ public final class MessageHelper {
             } else if (obj instanceof Writer) {
                 return prepend + "[Body is instance of java.io.Writer]";
             } else if (obj instanceof WrappedFile || obj instanceof File) {
-                return prepend + "[Body is file based: " + obj + "]";
+                if (!allowFiles) {
+                    return prepend + "[Body is file based: " + obj + "]";
+                }
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/da43e9c7/camel-core/src/test/java/org/apache/camel/management/ManagedBrowsableEndpointAsXmlFileTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedBrowsableEndpointAsXmlFileTest.java
b/camel-core/src/test/java/org/apache/camel/management/ManagedBrowsableEndpointAsXmlFileTest.java
new file mode 100644
index 0000000..292bdb0
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/management/ManagedBrowsableEndpointAsXmlFileTest.java
@@ -0,0 +1,67 @@
+/**
+ * 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.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version 
+ */
+public class ManagedBrowsableEndpointAsXmlFileTest extends ManagementTestSupport {
+
+    @Override
+    protected void setUp() throws Exception {
+        deleteDirectory("target/files");
+        super.setUp();
+    }
+
+    public void testBrowseableEndpointAsXmlAllIncludeBody() throws Exception {
+        // JMX tests dont work well on AIX CI servers (hangs them)
+        if (isPlatform("aix")) {
+            return;
+        }
+
+        template.sendBodyAndHeader("direct:start", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+        MBeanServer mbeanServer = getMBeanServer();
+
+        ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"file://target/files\"");
+
+        String out = (String) mbeanServer.invoke(name, "browseAllMessagesAsXml", new Object[]{true},
new String[]{"java.lang.Boolean"});
+        assertNotNull(out);
+        log.info(out);
+
+        assertTrue("Should contain the body", out.contains("Hello World</body>"));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                context.setUseBreadcrumb(false);
+
+                from("direct:start").to("file:target/files");
+            }
+        };
+    }
+
+}


Mime
View raw message