Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAMEL-20093 : Replaced 3 test cases with a single parameterized one. #13904

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -55,6 +59,14 @@ public class CamelCatalogTest {

private static final Logger LOG = LoggerFactory.getLogger(CamelCatalogTest.class);

private static Stream<Arguments> 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();
Expand Down Expand Up @@ -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<String, String> 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"));
Expand All @@ -458,36 +471,6 @@ public void testEndpointPropertiesNettyHttpDefaultPort() throws Exception {
assertEquals("false", map.get("keepAlive"));
}

@Test
public void testEndpointPropertiesNettyHttpPlaceholder() throws Exception {
Map<String, String> 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<String, String> 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<String, String> map = new HashMap<>();
Expand Down
Loading