This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit ae20425c86e08ed01c6eac8a87cbf31ce6da48c0 Author: Claus Ibsen <[email protected]> AuthorDate: Fri May 10 10:31:31 2024 +0200 CAMEL-20609: Added unit test --- .../camel/processor/ToVariableReceiveTest.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/ToVariableReceiveTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/ToVariableReceiveTest.java new file mode 100644 index 00000000000..7558c937d38 --- /dev/null +++ b/core/camel-core/src/test/java/org/apache/camel/processor/ToVariableReceiveTest.java @@ -0,0 +1,55 @@ +/* + * 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.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; +import org.junit.jupiter.api.Test; + +public class ToVariableReceiveTest extends ContextTestSupport { + + @Test + public void testReceive() throws Exception { + getMockEndpoint("mock:after").expectedBodiesReceived("World"); + getMockEndpoint("mock:after").expectedVariableReceived("bye", "Bye World"); + getMockEndpoint("mock:result").expectedBodiesReceived("Bye World"); + getMockEndpoint("mock:result").expectedVariableReceived("bye", "Bye World"); + getMockEndpoint("mock:result").message(0).header("foo").isNull(); + + template.sendBody("direct:receive", "World"); + + assertMockEndpointsSatisfied(); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + from("direct:receive") + .toV("direct:foo", null, "bye") + .to("mock:after") + .setBody(variable("bye")) + .to("mock:result"); + + from("direct:foo") + .setHeader("foo", constant("Foo was here")) + .transform().simple("Bye ${body}"); + } + }; + } +}
