Repository: camel Updated Branches: refs/heads/master 80ff59200 -> 7f0f97a8e
CAMEL-7897: Added unit test Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7f0f97a8 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7f0f97a8 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7f0f97a8 Branch: refs/heads/master Commit: 7f0f97a8eed922e61674a86d5ca6d30f712fab8e Parents: 80ff592 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue May 26 18:46:56 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue May 26 18:46:56 2015 +0200 ---------------------------------------------------------------------- .../component/bean/BeanByteArrayBodyTest.java | 47 ++++++++++++++++++++ .../camel/language/simple/SimpleTest.java | 8 ++++ 2 files changed, 55 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/7f0f97a8/camel-core/src/test/java/org/apache/camel/component/bean/BeanByteArrayBodyTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanByteArrayBodyTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanByteArrayBodyTest.java new file mode 100644 index 0000000..d206bc2 --- /dev/null +++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanByteArrayBodyTest.java @@ -0,0 +1,47 @@ +/** + * 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 org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; + +public class BeanByteArrayBodyTest extends ContextTestSupport { + + public void testByteArray() throws Exception { + byte[] bytes = new byte[]{65, 66, 67}; + + getMockEndpoint("mock:result").expectedMessageCount(1); + getMockEndpoint("mock:result").expectedHeaderReceived("foo", 3); + + template.sendBody("direct:start", bytes); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:start") + .log("Body is ${body} and of type ${in.body.getClass.getCanonicalName}") + .setHeader("foo", simple("${in.body.length}")) + .to("mock:result"); + } + }; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/7f0f97a8/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java index dfcaf4e..5545dc2 100644 --- a/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java +++ b/camel-core/src/test/java/org/apache/camel/language/simple/SimpleTest.java @@ -1394,6 +1394,14 @@ public class SimpleTest extends LanguageTestSupport { assertExpression("${body.length}", 3); } + public void testByteArrayLength() throws Exception { + exchange.getIn().setBody(new byte[]{65, 66, 67}); + assertExpression("${body[0]}", 65); + assertExpression("${body[1]}", 66); + assertExpression("${body[2]}", 67); + assertExpression("${body.length}", 3); + } + public void testSimpleMapBoolean() throws Exception { Map<String, Object> map = new HashMap<String, Object>(); exchange.getIn().setBody(map);