This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 0956eb4 CAMEL-15015: Endpoint DSL - Add support for RAW() style for setting data unencoded 0956eb4 is described below commit 0956eb4fb69c2f5221848adacbf0f2c10d1f94a0 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu May 7 13:17:21 2020 +0200 CAMEL-15015: Endpoint DSL - Add support for RAW() style for setting data unencoded --- .../builder/endpoint/FtpRawParameterTest.java | 48 ++++++++++++++++++++++ .../org/apache/camel/support/DefaultComponent.java | 4 ++ 2 files changed, 52 insertions(+) diff --git a/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FtpRawParameterTest.java b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FtpRawParameterTest.java new file mode 100644 index 0000000..ad363bf --- /dev/null +++ b/core/camel-endpointdsl/src/test/java/org/apache/camel/builder/endpoint/FtpRawParameterTest.java @@ -0,0 +1,48 @@ +/* + * 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.builder.endpoint; + +import org.apache.camel.ContextTestSupport; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.file.remote.FtpEndpoint; +import org.junit.Test; + +public class FtpRawParameterTest extends ContextTestSupport { + + @Test + public void testRaw() throws Exception { + FtpEndpoint ftp = (FtpEndpoint) context.getEndpoints().stream().filter(e -> e.getEndpointUri().startsWith("ftp")).findFirst().get(); + assertNotNull(ftp); + assertEquals(5000L, ftp.getDelay()); + assertTrue(ftp.getConfiguration().isBinary()); + assertEquals("scott", ftp.getConfiguration().getUsername()); + assertEquals("sec+%ret", ftp.getConfiguration().getPassword()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new EndpointRouteBuilder() { + public void configure() throws Exception { + from(ftp("localhost:2121/inbox").username("scott").password("RAW(sec+%ret)").binary(true).delay(5000)) + .routeId("myroute").noAutoStartup() + .convertBodyTo(String.class) + .to(mock("result")); + } + }; + } + +} diff --git a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java index a531f97..dfcac31 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/DefaultComponent.java @@ -126,6 +126,10 @@ public abstract class DefaultComponent extends ServiceSupport implements Compone } // This special property is only to identify endpoints in a unique manner parameters.remove("hash"); + // parameters using raw syntax: RAW(value) + // should have the token removed, so its only the value we have in parameters, as we are about to create + // an endpoint and want to have the parameter values without the RAW tokens + URISupport.resolveRawParameterValues(parameters); validateURI(uri, path, parameters); if (LOG.isTraceEnabled()) {