diff --git a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java index 9aa8a3be5f01b..b7acdf5948dd1 100644 --- a/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java +++ b/catalog/camel-catalog/src/test/java/org/apache/camel/catalog/CamelCatalogTest.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.stream.Stream; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -39,6 +40,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,6 +59,14 @@ public class CamelCatalogTest { private static final Logger LOG = LoggerFactory.getLogger(CamelCatalogTest.class); + private static Stream properties() { + return Stream.of( + Arguments.of("netty-http:http://localhost:8080/foo/bar?disconnect=true&keepAlive=false", "localhost", "8080"), + Arguments.of("netty-http:http://{{myhost}}:{{myport}}/foo/bar?disconnect=true&keepAlive=false", "{{myhost}}", + "{{myport}}"), + Arguments.of("netty-http:http://localhost:8080/foo/bar?disconnect=true&keepAlive=false", "localhost", "8080")); + } + @BeforeAll public static void createCamelCatalog() { catalog = new DefaultCamelCatalog(); @@ -429,16 +441,17 @@ public void testEndpointPropertiesPlaceholders() throws Exception { assertEquals("5", map.get("repeatCount")); } - @Test - public void testEndpointPropertiesNettyHttp() throws Exception { + @ParameterizedTest + @MethodSource("properties") + public void testEndpointPropertiesNettyHttp(String endpoint, String host, String port) throws Exception { Map map - = catalog.endpointProperties("netty-http:http://localhost:8080/foo/bar?disconnect=true&keepAlive=false"); + = catalog.endpointProperties(endpoint); assertNotNull(map); assertEquals(6, map.size()); assertEquals("http", map.get("protocol")); - assertEquals("localhost", map.get("host")); - assertEquals("8080", map.get("port")); + assertEquals(host, map.get("host")); + assertEquals(port, map.get("port")); assertEquals("foo/bar", map.get("path")); assertEquals("true", map.get("disconnect")); assertEquals("false", map.get("keepAlive")); @@ -458,36 +471,6 @@ public void testEndpointPropertiesNettyHttpDefaultPort() throws Exception { assertEquals("false", map.get("keepAlive")); } - @Test - public void testEndpointPropertiesNettyHttpPlaceholder() throws Exception { - Map map - = catalog.endpointProperties("netty-http:http://{{myhost}}:{{myport}}/foo/bar?disconnect=true&keepAlive=false"); - assertNotNull(map); - assertEquals(6, map.size()); - - assertEquals("http", map.get("protocol")); - assertEquals("{{myhost}}", map.get("host")); - assertEquals("{{myport}}", map.get("port")); - assertEquals("foo/bar", map.get("path")); - assertEquals("true", map.get("disconnect")); - assertEquals("false", map.get("keepAlive")); - } - - @Test - public void testEndpointPropertiesNettyHttpWithDoubleSlash() throws Exception { - Map map - = catalog.endpointProperties("netty-http:http://localhost:8080/foo/bar?disconnect=true&keepAlive=false"); - assertNotNull(map); - assertEquals(6, map.size()); - - assertEquals("http", map.get("protocol")); - assertEquals("localhost", map.get("host")); - assertEquals("8080", map.get("port")); - assertEquals("foo/bar", map.get("path")); - assertEquals("true", map.get("disconnect")); - assertEquals("false", map.get("keepAlive")); - } - @Test public void testAsEndpointUriLog() throws Exception { Map map = new HashMap<>();