This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch uri-assembler in repository https://gitbox.apache.org/repos/asf/camel.git
commit fe0b8542a0e614915bdd94d1d1ca20cd15d2426d Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Sep 25 11:45:18 2020 +0200 CAMEL-15567: components - Generate source code for creating endpoint uri via a map of properties. WIP --- .../runtime-camelcatalog-endpointuriassembler | 2 - .../impl/CamelCatalogEndpointUriAssembler.java | 40 -------------------- ...untimeCamelCatalogEndpointUriAssemblerTest.java | 13 ------- .../apache/camel/impl/AssembleResolverTest.java | 43 ---------------------- 4 files changed, 98 deletions(-) diff --git a/core/camel-core-catalog/src/generated/resources/META-INF/services/org/apache/camel/runtime-camelcatalog-endpointuriassembler b/core/camel-core-catalog/src/generated/resources/META-INF/services/org/apache/camel/runtime-camelcatalog-endpointuriassembler deleted file mode 100644 index ec29104..0000000 --- a/core/camel-core-catalog/src/generated/resources/META-INF/services/org/apache/camel/runtime-camelcatalog-endpointuriassembler +++ /dev/null @@ -1,2 +0,0 @@ -# Generated by camel build tools - do NOT edit this file! -class=org.apache.camel.catalog.impl.CamelCatalogEndpointUriAssembler diff --git a/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/CamelCatalogEndpointUriAssembler.java b/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/CamelCatalogEndpointUriAssembler.java deleted file mode 100644 index 13aaba1..0000000 --- a/core/camel-core-catalog/src/main/java/org/apache/camel/catalog/impl/CamelCatalogEndpointUriAssembler.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.camel.catalog.impl; - -import java.net.URISyntaxException; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.catalog.RuntimeCamelCatalog; -import org.apache.camel.spi.EndpointUriAssembler; -import org.apache.camel.spi.annotations.JdkService; - -import static org.apache.camel.catalog.RuntimeCamelCatalog.ENDPOINT_URI_ASSEMBLER_FACTORY; - -/** - * Uses {@link RuntimeCamelCatalog} to assemble the endpoint uri. - */ -@JdkService(ENDPOINT_URI_ASSEMBLER_FACTORY) -@Deprecated -public class CamelCatalogEndpointUriAssembler implements EndpointUriAssembler { - - @Override - public boolean isEnabled(String scheme) { - // as its a fallback then assume it can handle this - return true; - } - - @Override - public String buildUri(CamelContext camelContext, String scheme, Map<String, Object> parameters) { - try { - Map<String, String> copy = new LinkedHashMap<>(); - parameters.forEach((k, v) -> copy.put(k, v != null ? v.toString() : null)); - return camelContext.adapt(ExtendedCamelContext.class).getRuntimeCamelCatalog().asEndpointUri(scheme, copy, - false); - } catch (URISyntaxException e) { - throw RuntimeCamelException.wrapRuntimeException(e); - } - } -} diff --git a/core/camel-core/src/test/java/org/apache/camel/catalog/RuntimeCamelCatalogEndpointUriAssemblerTest.java b/core/camel-core/src/test/java/org/apache/camel/catalog/RuntimeCamelCatalogEndpointUriAssemblerTest.java index a3cf85b..f52d4a7 100644 --- a/core/camel-core/src/test/java/org/apache/camel/catalog/RuntimeCamelCatalogEndpointUriAssemblerTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/catalog/RuntimeCamelCatalogEndpointUriAssemblerTest.java @@ -21,7 +21,6 @@ import java.util.Map; import org.apache.camel.ContextTestSupport; import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.catalog.impl.CamelCatalogEndpointUriAssembler; import org.apache.camel.spi.EndpointUriAssembler; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -41,16 +40,4 @@ public class RuntimeCamelCatalogEndpointUriAssemblerTest extends ContextTestSupp Assertions.assertEquals("timer:foo?period=123&repeatCount=5", uri); } - @Test - public void testRuntimeAssemble() throws Exception { - EndpointUriAssembler assembler = new CamelCatalogEndpointUriAssembler(); - - Map<String, Object> params = new HashMap<>(); - params.put("timerName", "foo"); - params.put("period", "123"); - params.put("repeatCount", "5"); - - String uri = assembler.buildUri(context, "timer", params); - Assertions.assertEquals("timer:foo?period=123&repeatCount=5", uri); - } } diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/AssembleResolverTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/AssembleResolverTest.java deleted file mode 100644 index f4225d9..0000000 --- a/core/camel-core/src/test/java/org/apache/camel/impl/AssembleResolverTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.impl; - -import org.apache.camel.ContextTestSupport; -import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.catalog.impl.CamelCatalogEndpointUriAssembler; -import org.apache.camel.spi.EndpointUriAssembler; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -public class AssembleResolverTest extends ContextTestSupport { - - @Test - public void testAssembleResolver() throws Exception { - // will use source code generated - EndpointUriAssembler assembler = context.adapt(ExtendedCamelContext.class).getAssemblerResolver() - .resolveAssembler("log", context); - Assertions.assertNotNull(assembler); - // TODO: check classname - - // will then use fallback that is catalog based - assembler = context.adapt(ExtendedCamelContext.class).getAssemblerResolver() - .resolveAssembler("unknown", context); - Assertions.assertNotNull(assembler); - boolean catalog = assembler instanceof CamelCatalogEndpointUriAssembler; - Assertions.assertTrue(catalog); - } -}