You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Hadrian Zbarcea <hz...@gmail.com> on 2013/11/22 18:14:56 UTC

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

For some reason, the context for me is localhost/camel-1.
I fixed the test, but I am curious how this works for others now.
This is I think/hope the last failing test and now I can cut the release.


Hadrian


On 11/20/2013 10:42 AM, davsclaus@apache.org wrote:
> Updated Branches:
>    refs/heads/master f29888779 -> 37e0e6bb8
>
>
> 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/37e0e6bb
> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/37e0e6bb
> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/37e0e6bb
>
> Branch: refs/heads/master
> Commit: 37e0e6bb8371f313db3d5d2642288acfa645b8db
> Parents: f298887
> Author: Claus Ibsen <da...@apache.org>
> Authored: Wed Nov 20 16:44:05 2013 +0100
> Committer: Claus Ibsen <da...@apache.org>
> Committed: Wed Nov 20 16:44:05 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/37e0e6bb/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 3e38d23..c81b53b 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
> @@ -223,7 +223,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/37e0e6bb/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");
> +            }
> +        };
> +    }
> +
> +}
>

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

Posted by Babak Vahdat <ba...@swissonline.ch>.
Ah this is a side effect of
https://issues.apache.org/jira/browse/CAMEL-6938

Through which we do NOT append the host name for the JMX names on the
master branch anymore however this ³new behaviour² does not apply for
other branches (2.12.x 2.11.x). The backported fix for CAMEL-6987 did not
count with this behaviour divergence of the master and 2.12 branch. As
you¹re going to cut 2.11.3 as well you would need to backport your fix to
that branch as well.

Babak

Am 22.11.13 18:14 schrieb "Hadrian Zbarcea" unter <hz...@gmail.com>:

>For some reason, the context for me is localhost/camel-1.
>I fixed the test, but I am curious how this works for others now.
>This is I think/hope the last failing test and now I can cut the release.
>
>
>Hadrian
>
>
>On 11/20/2013 10:42 AM, davsclaus@apache.org wrote:
>> Updated Branches:
>>    refs/heads/master f29888779 -> 37e0e6bb8
>>
>>
>> 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/37e0e6bb
>> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/37e0e6bb
>> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/37e0e6bb
>>
>> Branch: refs/heads/master
>> Commit: 37e0e6bb8371f313db3d5d2642288acfa645b8db
>> Parents: f298887
>> Author: Claus Ibsen <da...@apache.org>
>> Authored: Wed Nov 20 16:44:05 2013 +0100
>> Committer: Claus Ibsen <da...@apache.org>
>> Committed: Wed Nov 20 16:44:05 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/37e0e6bb/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 3e38d23..c81b53b 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
>> @@ -223,7 +223,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/37e0e6bb/camel-core/src
>>/test/java/org/apache/camel/management/ManagedBrowsableEndpointAsXmlFileT
>>est.java
>> ----------------------------------------------------------------------
>> diff --git 
>>a/camel-core/src/test/java/org/apache/camel/management/ManagedBrowsableEn
>>dpointAsXmlFileTest.java
>>b/camel-core/src/test/java/org/apache/camel/management/ManagedBrowsableEn
>>dpointAsXmlFileTest.java
>> new file mode 100644
>> index 0000000..292bdb0
>> --- /dev/null
>> +++ 
>>b/camel-core/src/test/java/org/apache/camel/management/ManagedBrowsableEn
>>dpointAsXmlFileTest.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,n
>>ame=\"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");
>> +            }
>> +        };
>> +    }
>> +
>> +}
>>