Repository: camel Updated Branches: refs/heads/master feace21ab -> a749cefee
CAMEL-7575 Added a uni test to verify the bean processor of attachement Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a749cefe Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a749cefe Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a749cefe Branch: refs/heads/master Commit: a749cefee7f6a10565aa2e34ff79365a097c277c Parents: feace21 Author: Willem Jiang <willem.ji...@gmail.com> Authored: Fri Jul 4 11:19:35 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Fri Jul 4 11:19:59 2014 +0800 ---------------------------------------------------------------------- .../bean/BeanMethodWithExchangeTest.java | 68 ++++++++++++++++++++ 1 file changed, 68 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/a749cefe/camel-core/src/test/java/org/apache/camel/component/bean/BeanMethodWithExchangeTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanMethodWithExchangeTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanMethodWithExchangeTest.java new file mode 100644 index 0000000..01e022e --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanMethodWithExchangeTest.java @@ -0,0 +1,68 @@ +/** + * 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.bean; + +import javax.activation.DataHandler; +import javax.activation.FileDataSource; +import javax.naming.Context; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.Processor; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.util.jndi.JndiContext; + +public class BeanMethodWithExchangeTest extends ContextTestSupport { + + public void testBeanWithAnnotationAndExchangeTest() throws Exception { + Exchange result = template.request("direct:start1", new Processor() { + + public void process(Exchange exchange) throws Exception { + Message m = exchange.getIn(); + m.addAttachment("attachment", new DataHandler(new FileDataSource("src/test/org/apache/camel/component/bean/BeanWithAttachmentAnnotationTest.java"))); + } + + }); + + assertTrue(result.getOut().getAttachments().containsKey("attachment2")); + assertFalse(result.getOut().getAttachments().containsKey("attachment")); + + } + + protected Context createJndiContext() throws Exception { + JndiContext answer = new JndiContext(); + answer.bind("processor", new AttachmentProcessor()); + return answer; + } + + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + public void configure() throws Exception { + from("direct:start1").to("bean:processor"); + } + }; + } + + public static class AttachmentProcessor { + public void doSomething(Exchange exchange) { + exchange.getOut().addAttachment("attachment2", new DataHandler(new FileDataSource("src/test/org/apache/camel/component/bean/BeanMethodWithExchangeTest.java"))); + } + + } + +}