This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit f87e6c155274cee1ccd438921926316fcf896c07 Author: Craig Ziesman <[email protected]> AuthorDate: Thu Sep 7 17:32:26 2023 -0500 Working on unit tests --- components/camel-thymeleaf/pom.xml | 72 +--------------------- .../src/main/docs/thymeleaf-component.adoc | 24 ++++---- .../thymeleaf/ThymeleafAbstractBaseTest.java | 18 +++--- .../thymeleaf/ThymeleafBodyAsDomainObjectTest.java | 10 +-- .../thymeleaf/ThymeleafComponentTest.java | 8 +-- .../thymeleaf/ThymeleafConcurrentTest.java | 6 +- .../thymeleaf/ThymeleafContentCacheTest.java | 15 +++-- .../ThymeleafFileResolverAllParamsTest.java | 1 - ...ymeleafWebApplicationResolverAllParamsTest.java | 9 +-- .../ThymeleafWebApplicationResolverTest.java | 7 ++- .../src/test/resources/log4j2.properties | 2 +- 11 files changed, 51 insertions(+), 121 deletions(-) diff --git a/components/camel-thymeleaf/pom.xml b/components/camel-thymeleaf/pom.xml index 736f9e36fb2..e0c503f3ae8 100644 --- a/components/camel-thymeleaf/pom.xml +++ b/components/camel-thymeleaf/pom.xml @@ -32,15 +32,6 @@ <name>Camel :: Thymeleaf</name> <description>Camel Thymeleaf support</description> - <properties> - <thymeleaf-version>3.1.2.RELEASE</thymeleaf-version> - <jakarta-servlet-api-version>6.0.0</jakarta-servlet-api-version> - <wiremock-version>3.0.0-beta-15</wiremock-version> - <pitest-maven-version>1.14.4</pitest-maven-version> - <pitest-junit5-plugin-version>1.2.0</pitest-junit5-plugin-version> - <jacoco-maven-plugin-version>0.8.10</jacoco-maven-plugin-version> - </properties> - <dependencies> <dependency> <groupId>org.apache.camel</groupId> @@ -76,7 +67,7 @@ </dependency> <dependency> - <groupId>org.wiremock</groupId> + <groupId>com.github.tomakehurst</groupId> <artifactId>wiremock</artifactId> <version>${wiremock-version}</version> <scope>test</scope> @@ -97,65 +88,4 @@ </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <argLine>${argLine}</argLine> - </configuration> - </plugin> - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - <version>${jacoco-maven-plugin-version}</version> - <executions> - <execution> - <goals> - <goal>prepare-agent</goal> - </goals> - </execution> - <execution> - <id>generate-code-coverage-report</id> - <goals> - <goal>report</goal> - </goals> - </execution> - </executions> - <configuration> - <excludes> - <exclude>**/*Configurer.class</exclude> - <exclude>**/*Factory.class</exclude> - </excludes> - </configuration> - </plugin> - - <plugin> - <groupId>org.pitest</groupId> - <artifactId>pitest-maven</artifactId> - <version>${pitest-maven-version}</version> - <dependencies> - <dependency> - <groupId>org.pitest</groupId> - <artifactId>pitest-junit5-plugin</artifactId> - <version>${pitest-junit5-plugin-version}</version> - </dependency> - </dependencies> - <configuration> - <targetClasses> - <param>org.apache.camel.component.thymeleaf.*</param> - </targetClasses> -<!-- <targetTests>--> -<!-- <param>org.apache.camel.component.thymeleaf.*</param>--> -<!-- </targetTests>--> - <excludedClasses> - <param>org.apache.camel.component.thymeleaf.*Configurer*</param> - <param>org.apache.camel.component.thymeleaf.*Factory*</param> - </excludedClasses> - </configuration> - </plugin> - - </plugins> - </build> - </project> diff --git a/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc b/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc index a35288f720a..4694bb40f1b 100644 --- a/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc +++ b/components/camel-thymeleaf/src/main/docs/thymeleaf-component.adoc @@ -39,7 +39,7 @@ thymeleaf:templateName[?options] Where *templateName* is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: -\file://folder/myfile.txt). +\file://folder/myfile.html). @@ -66,7 +66,7 @@ and added as headers, thus making it possible to return values from Thymeleaf to the Message. For example, to set the header value of `fruit` in the Thymeleaf template -`fruit-template.txt`: +`fruit-template.html`: ------------------------------- $in.setHeader("fruit", "Apple") @@ -143,7 +143,7 @@ For a simple use case, you could use something like: [source,java] ---------------------------------------- from("activemq:My.Queue"). - to("thymeleaf:com/acme/MyResponse.txt"); + to("thymeleaf:com/acme/MyResponse.html"); ---------------------------------------- To use a Thymeleaf template to formulate a response to a message for @@ -155,17 +155,17 @@ destination, you could use the following route: [source,java] ---------------------------------------- from("activemq:My.Queue") - .to("thymeleaf:com/acme/MyResponse.txt") + .to("thymeleaf:com/acme/MyResponse.html") .to("activemq:Another.Queue"); ---------------------------------------- And to use the content cache, e.g. for use in production, where the -`.txt` template never changes: +`.html` template never changes: [source,java] ---------------------------------------------------------- from("activemq:My.Queue") - .to("thymeleaf:com/acme/MyResponse.txt?contentCache=true") + .to("thymeleaf:com/acme/MyResponse.html?contentCache=true") .to("activemq:Another.Queue"); ---------------------------------------------------------- @@ -174,7 +174,7 @@ And a file based resource: [source,java] ----------------------------------------------------------------- from("activemq:My.Queue") - .to("thymeleaf:file://myfolder/MyResponse.txt?contentCache=true") + .to("thymeleaf:file://myfolder/MyResponse.html?contentCache=true") .to("activemq:Another.Queue"); ----------------------------------------------------------------- @@ -184,7 +184,7 @@ should use dynamically via a header, so for example: [source,java] --------------------------------------------------------------------------- from("direct:in") - .setHeader("CamelThymeleafResourceUri").constant("path/to/my/template.txt") + .setHeader("CamelThymeleafResourceUri").constant("path/to/my/template.html") .to("thymeleaf:dummy?allowTemplateFromHeader=true""); --------------------------------------------------------------------------- @@ -203,15 +203,15 @@ from("direct:in") In this sample we want to use Thymeleaf templating for an order confirmation email. The email template is laid out in Thymeleaf as: -.letter.txt +.letter.html [source,text] ---------------------------------------------- -Dear ${headers.lastName}, ${headers.firstName} +Dear [(${headers.lastName})], [(${headers.firstName})] -Thanks for the order of ${headers.item}. +Thanks for the order of [(${headers.item})]. Regards Camel Riders Bookstore -${body} +[(${body})] ---------------------------------------------- And the java code (from an unit test): diff --git a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafAbstractBaseTest.java b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafAbstractBaseTest.java index f80064448a9..525a949a8a7 100644 --- a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafAbstractBaseTest.java +++ b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafAbstractBaseTest.java @@ -16,14 +16,14 @@ */ package org.apache.camel.component.thymeleaf; +import java.util.HashMap; +import java.util.Map; + import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; -import java.util.HashMap; -import java.util.Map; - import static java.util.Map.entry; public abstract class ThymeleafAbstractBaseTest extends CamelTestSupport { @@ -147,12 +147,12 @@ public abstract class ThymeleafAbstractBaseTest extends CamelTestSupport { protected String expected() { return "\n\n" + - "Dear Doe, Jane\n" + - "\n" + - "Thank you for your order number 7 of Widgets for Dummies.\n" + - "\n" + - "Regards Camel Riders Bookstore\n" + - "Spazz Testing Service"; + "Dear Doe, Jane\n" + + "\n" + + "Thank you for your order number 7 of Widgets for Dummies.\n" + + "\n" + + "Regards Camel Riders Bookstore\n" + + "Spazz Testing Service"; } @Override diff --git a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafBodyAsDomainObjectTest.java b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafBodyAsDomainObjectTest.java index b7d6447382b..8dfac7e68b3 100644 --- a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafBodyAsDomainObjectTest.java +++ b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafBodyAsDomainObjectTest.java @@ -121,11 +121,11 @@ public class ThymeleafBodyAsDomainObjectTest extends ThymeleafAbstractBaseTest { public String toString() { return "Letter{" + - "firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - ", item='" + item + '\'' + - ", closing='" + closing + '\'' + - '}'; + "firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", item='" + item + '\'' + + ", closing='" + closing + '\'' + + '}'; } } diff --git a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafComponentTest.java b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafComponentTest.java index e2578b165a6..efdb1b993b1 100644 --- a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafComponentTest.java +++ b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafComponentTest.java @@ -16,6 +16,10 @@ */ package org.apache.camel.component.thymeleaf; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + import org.apache.camel.support.PropertyBindingListener; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Test; @@ -23,10 +27,6 @@ import org.thymeleaf.templatemode.TemplateMode; import org.thymeleaf.templateresolver.ITemplateResolver; import org.thymeleaf.templateresolver.StringTemplateResolver; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - import static java.util.Map.entry; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; diff --git a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafConcurrentTest.java b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafConcurrentTest.java index 220939065d3..d38f6796379 100644 --- a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafConcurrentTest.java +++ b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafConcurrentTest.java @@ -16,13 +16,13 @@ */ package org.apache.camel.component.thymeleaf; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.junit.jupiter.api.Test; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - import static org.apache.camel.test.junit5.TestSupport.body; public class ThymeleafConcurrentTest extends ThymeleafAbstractBaseTest { diff --git a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafContentCacheTest.java b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafContentCacheTest.java index 42039d7194c..6469b06d2d9 100644 --- a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafContentCacheTest.java +++ b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafContentCacheTest.java @@ -16,6 +16,13 @@ */ package org.apache.camel.component.thymeleaf; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.management.MBeanServer; +import javax.management.ObjectName; + import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; @@ -23,12 +30,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import javax.management.MBeanServer; -import javax.management.ObjectName; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - import static java.util.Map.entry; @TestInstance(TestInstance.Lifecycle.PER_METHOD) @@ -200,8 +201,6 @@ public class ThymeleafContentCacheTest extends ThymeleafAbstractBaseTest { public void configure() { - context.setTracing(true); - from(DIRECT_START_NO_CACHE) .setProperty(ORDER_NUMBER, simple("7")) .to("thymeleaf://org/apache/camel/component/thymeleaf/letter-cached.html?cacheable=false&allowContextMapAll=true") diff --git a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafFileResolverAllParamsTest.java b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafFileResolverAllParamsTest.java index 612c84bd962..7b38c49c34b 100644 --- a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafFileResolverAllParamsTest.java +++ b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafFileResolverAllParamsTest.java @@ -89,7 +89,6 @@ public class ThymeleafFileResolverAllParamsTest extends ThymeleafAbstractBaseTes public void configure() { - context.setTracing(true); from(DIRECT_START) .setBody(simple(SPAZZ_TESTING_SERVICE)) .to("thymeleaf:org/apache/camel/component/thymeleaf/letter?allowContextMapAll=true&cacheTimeToLive=500&cacheable=false&checkExistence=true&encoding=UTF-8&order=1&prefix=src/test/resources/&templateMode=HTML&resolver=FILE&suffix=.html") diff --git a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafWebApplicationResolverAllParamsTest.java b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafWebApplicationResolverAllParamsTest.java index 2c35934fc66..9be2eeb6179 100644 --- a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafWebApplicationResolverAllParamsTest.java +++ b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafWebApplicationResolverAllParamsTest.java @@ -16,7 +16,12 @@ */ package org.apache.camel.component.thymeleaf; +import java.io.File; +import java.io.InputStream; +import java.net.URL; + import jakarta.servlet.ServletContext; + import org.apache.camel.ExchangePattern; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; @@ -29,10 +34,6 @@ import org.thymeleaf.templateresolver.ITemplateResolver; import org.thymeleaf.templateresolver.WebApplicationTemplateResolver; import org.thymeleaf.web.servlet.JakartaServletWebApplication; -import java.io.File; -import java.io.InputStream; -import java.net.URL; - import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; diff --git a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafWebApplicationResolverTest.java b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafWebApplicationResolverTest.java index d75768e8aa0..e16270a2962 100644 --- a/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafWebApplicationResolverTest.java +++ b/components/camel-thymeleaf/src/test/java/org/apache/camel/component/thymeleaf/ThymeleafWebApplicationResolverTest.java @@ -16,7 +16,11 @@ */ package org.apache.camel.component.thymeleaf; +import java.io.File; +import java.io.InputStream; + import jakarta.servlet.ServletContext; + import org.apache.camel.ExchangePattern; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; @@ -29,9 +33,6 @@ import org.thymeleaf.templateresolver.ITemplateResolver; import org.thymeleaf.templateresolver.WebApplicationTemplateResolver; import org.thymeleaf.web.servlet.JakartaServletWebApplication; -import java.io.File; -import java.io.InputStream; - import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/components/camel-thymeleaf/src/test/resources/log4j2.properties b/components/camel-thymeleaf/src/test/resources/log4j2.properties index 4aafcbf3eed..3ee03fc4552 100644 --- a/components/camel-thymeleaf/src/test/resources/log4j2.properties +++ b/components/camel-thymeleaf/src/test/resources/log4j2.properties @@ -30,7 +30,7 @@ rootLogger.appenderRef.stdout.ref = stdout #logger.thymeleaf.name = org.apache.camel.component.thymeleaf #logger.thymeleaf.level = INFO logger.camel.name = org.apache.camel -logger.camel.level = DEBUG +logger.camel.level = INFO logger.springframework.name = org.springframework logger.springframework.level = INFO
