This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b57b72d0e85f2340cb2d55be44d2175c0caa7cc1
Author: Otavio Rodolfo Piske <angusyo...@gmail.com>
AuthorDate: Wed Mar 22 17:42:58 2023 +0100

    (chores) camel-jms: cleaned up duplicated test code
---
 .../camel/component/jms/JmsXMLRouteTest.java       | 120 +++------------------
 1 file changed, 14 insertions(+), 106 deletions(-)

diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsXMLRouteTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsXMLRouteTest.java
index a09b8b7d3f0..526f0b6c0a6 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsXMLRouteTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsXMLRouteTest.java
@@ -32,8 +32,9 @@ import 
org.apache.camel.test.infra.core.annotations.ContextFixture;
 import org.apache.camel.util.xml.StringSource;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Order;
-import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -52,8 +53,9 @@ public class JmsXMLRouteTest extends AbstractJMSTest {
     protected ProducerTemplate template;
     protected ConsumerTemplate consumer;
 
-    @Test
-    public void testLondonWithFileStreamAsObject() throws Exception {
+    @ParameterizedTest
+    @ValueSource(strings = { "direct:object", "direct:bytes", "direct:default" 
})
+    public void testLondonWithFileStream(String endpointUri) throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:london");
         mock.expectedMessageCount(1);
         mock.message(0).body(String.class).contains("James");
@@ -61,69 +63,14 @@ public class JmsXMLRouteTest extends AbstractJMSTest {
         Source source = new StreamSource(new FileInputStream(TEST_LONDON));
         assertNotNull(source);
 
-        template.sendBody("direct:object", source);
+        template.sendBody(endpointUri, source);
 
         MockEndpoint.assertIsSatisfied(context);
     }
 
-    @Test
-    public void testLondonWithFileStreamAsBytes() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:london");
-        mock.expectedMessageCount(1);
-        mock.message(0).body(String.class).contains("James");
-
-        Source source = new StreamSource(new FileInputStream(TEST_LONDON));
-        assertNotNull(source);
-
-        template.sendBody("direct:bytes", source);
-
-        MockEndpoint.assertIsSatisfied(context);
-    }
-
-    @Test
-    public void testLondonWithFileStreamAsDefault() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:london");
-        mock.expectedMessageCount(1);
-        mock.message(0).body(String.class).contains("James");
-
-        Source source = new StreamSource(new FileInputStream(TEST_LONDON));
-        assertNotNull(source);
-
-        template.sendBody("direct:default", source);
-
-        MockEndpoint.assertIsSatisfied(context);
-    }
-
-    @Test
-    public void testTampaWithFileStreamAsObject() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:tampa");
-        mock.expectedMessageCount(1);
-        mock.message(0).body(String.class).contains("Hiram");
-
-        Source source = new StreamSource(new FileInputStream(TEST_TAMPA));
-        assertNotNull(source);
-
-        template.sendBody("direct:object", source);
-
-        MockEndpoint.assertIsSatisfied(context);
-    }
-
-    @Test
-    public void testTampaWithFileStreamAsBytes() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:tampa");
-        mock.expectedMessageCount(1);
-        mock.message(0).body(String.class).contains("Hiram");
-
-        Source source = new StreamSource(new FileInputStream(TEST_TAMPA));
-        assertNotNull(source);
-
-        template.sendBody("direct:bytes", source);
-
-        MockEndpoint.assertIsSatisfied(context);
-    }
-
-    @Test
-    public void testTampaWithFileStreamAsDefault() throws Exception {
+    @ParameterizedTest
+    @ValueSource(strings = { "direct:object", "direct:bytes", "direct:default" 
})
+    public void testTampaWithFileStream(String endpointUri) throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:tampa");
         mock.expectedMessageCount(1);
         mock.message(0).body(String.class).contains("Hiram");
@@ -131,53 +78,14 @@ public class JmsXMLRouteTest extends AbstractJMSTest {
         Source source = new StreamSource(new FileInputStream(TEST_TAMPA));
         assertNotNull(source);
 
-        template.sendBody("direct:default", source);
-
-        MockEndpoint.assertIsSatisfied(context);
-    }
-
-    @Test
-    public void testLondonWithStringSourceAsObject() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:london");
-        mock.expectedMessageCount(1);
-        mock.message(0).body(String.class).contains("James");
-
-        Source source = new StringSource(
-                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-                                         + "<person user=\"james\">\n"
-                                         + "  <firstName>James</firstName>\n"
-                                         + "  <lastName>Strachan</lastName>\n"
-                                         + "  <city>London</city>\n"
-                                         + "</person>");
-        assertNotNull(source);
-
-        template.sendBody("direct:object", source);
-
-        MockEndpoint.assertIsSatisfied(context);
-    }
-
-    @Test
-    public void testLondonWithStringSourceAsBytes() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:london");
-        mock.expectedMessageCount(1);
-        mock.message(0).body(String.class).contains("James");
-
-        Source source = new StringSource(
-                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-                                         + "<person user=\"james\">\n"
-                                         + "  <firstName>James</firstName>\n"
-                                         + "  <lastName>Strachan</lastName>\n"
-                                         + "  <city>London</city>\n"
-                                         + "</person>");
-        assertNotNull(source);
-
-        template.sendBody("direct:bytes", source);
+        template.sendBody(endpointUri, source);
 
         MockEndpoint.assertIsSatisfied(context);
     }
 
-    @Test
-    public void testLondonWithStringSourceAsDefault() throws Exception {
+    @ParameterizedTest
+    @ValueSource(strings = { "direct:object", "direct:bytes", "direct:default" 
})
+    public void testLondonWithStringSourceAsObject(String endpointUri) throws 
Exception {
         MockEndpoint mock = getMockEndpoint("mock:london");
         mock.expectedMessageCount(1);
         mock.message(0).body(String.class).contains("James");
@@ -191,7 +99,7 @@ public class JmsXMLRouteTest extends AbstractJMSTest {
                                          + "</person>");
         assertNotNull(source);
 
-        template.sendBody("direct:default", source);
+        template.sendBody(endpointUri, source);
 
         MockEndpoint.assertIsSatisfied(context);
     }

Reply via email to