You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2020/06/19 12:42:22 UTC
[camel] branch master updated (9cbf68e -> 0890893)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.
from 9cbf68e Regen
new 1807b2e [CAMEL-11807] Upgrade camel-spring-main to junit5
new af2d076 Fix typo: recieve -> receive
new e10ccef [CAMEL-15215] Simplify and homogenize spring testing
new ad299f2 [CAMEL-11807] Remove deprecated constructs from camelspring-javaconfig
new 578d866 [CAMEL-11807] Upgrade camel-spring-javaconfig to junit5
new 24ce10b [CAMEL-11807] Upgrade camel-servlet to junit5
new 0890893 [CAMEL-11807] Fix checkstyle
The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../camel/component/as2/api/AS2MessageTest.java | 2 +-
.../component/aws/swf/CamelWorkflowDefinition.java | 4 +-
.../component/aws/swf/SWFWorkflowConsumer.java | 4 +-
.../bindy/fixed/converter/BindyConverterTest.java | 18 +-
.../src/main/docs/browse-component.adoc | 2 +-
.../flatpack/FlatpackDelimitedDataFormatTest.java | 2 +-
.../mail/MailAttachmentDuplicateNamesTest.java | 2 +-
.../component/mail/MailHtmlAttachmentTest.java | 2 +-
.../apache/camel/component/mail/MailRouteTest.java | 4 +-
.../MinaTcpLineDelimiterUsingPlainSocketTest.java | 6 +-
.../mina/MinaTcpWithInOutUsingPlainSocketTest.java | 6 +-
.../NettyTcpWithInOutUsingPlainSocketTest.java | 6 +-
components/camel-servlet/pom.xml | 61 +---
.../src/main/docs/servlet-component.adoc | 6 +-
.../ExposedServletEndpointURIToJMXTest.java | 8 +-
.../servlet/HttpClientRouteExampleSpringTest.java | 50 ++--
.../servlet/HttpClientRouteSpringTest.java | 21 +-
.../component/servlet/HttpClientRouteTest.java | 111 ++++---
.../servlet/MultiServletConsumerTest.java | 34 ++-
.../servlet/ServletAsyncArquillianTest.java | 66 -----
.../camel/component/servlet/ServletAsyncTest.java | 58 ++++
.../servlet/ServletCamelRouterTestSupport.java | 284 ++++++++++++++++--
.../component/servlet/ServletChoiceBeanTest.java | 22 +-
.../servlet/ServletMuteExceptionTest.java | 23 +-
.../servlet/ServletNoSlashNeededTest.java | 17 +-
.../component/servlet/ServletRootPathTest.java | 17 +-
.../component/servlet/ServletSetBodyTest.java | 17 +-
.../ServletSetExchangePropertyBeanTest.java | 19 +-
.../servlet/ServletSwitchingStatusCode204Test.java | 23 +-
.../servlet/ServletTransferExceptionTest.java | 17 +-
.../servlet/rest/OptionsMethodWebRequest.java | 41 ---
.../servlet/rest/RestApiMatchUriServletTest.java | 14 +-
.../RestServletBindingModeAutoWithJsonTest.java | 16 +-
.../RestServletBindingModeAutoWithXmlTest.java | 16 +-
.../rest/RestServletBindingModeJsonTest.java | 23 +-
...RestServletBindingModeJsonWithContractTest.java | 21 +-
.../RestServletBindingModeOffWithContractTest.java | 21 +-
.../rest/RestServletBindingModeXmlTest.java | 23 +-
.../component/servlet/rest/RestServletGetTest.java | 14 +-
.../servlet/rest/RestServletGetWildcardsTest.java | 20 +-
.../rest/RestServletMethodNotAllowedTest.java | 14 +-
.../servlet/rest/RestServletOptionsTest.java | 23 +-
.../servlet/rest/RestServletPojoInOutTest.java | 29 +-
.../rest/RestServletPostJsonJaxbPojoTest.java | 16 +-
.../rest/RestServletPostJsonPojoListTest.java | 16 +-
.../servlet/rest/RestServletPostJsonPojoTest.java | 16 +-
.../rest/RestServletPostXmlJaxbPojoTest.java | 23 +-
.../servlet/rest/RestServletVerbTest.java | 46 ++-
.../camel/component/servlet/multiServletWeb.xml | 47 ---
.../apache/camel/component/servlet/web-example.xml | 55 ----
.../camel/component/servlet/web-spring-async.xml | 54 ----
.../apache/camel/component/servlet/web-spring.xml | 55 ----
.../org/apache/camel/component/servlet/web.xml | 38 ---
.../component/splunk/ConsumerStreamingTest.java | 6 +-
.../camel/component/splunk/ConsumerTest.java | 6 +-
.../splunk/integration/NormalSearchTest.java | 6 +-
.../splunk/integration/RealtimeSearchTest.java | 6 +-
.../splunk/integration/SavedSearchTest.java | 6 +-
.../splunk/integration/SplunkProducerTest.java | 2 +-
components/camel-spring-javaconfig/pom.xml | 6 +-
.../spring/javaconfig/BeanJavaConfigTest.java | 10 +-
.../apache/camel/spring/javaconfig/MainTest.java | 7 +-
.../autowire/AutodetectNoRoutesConfigTest.java | 16 +-
.../autowire/AutodetectingConfigTest.java | 15 +-
.../autowire/LoadingRawCamelConfigurationTest.java | 14 +-
.../spring/javaconfig/patterns/FilterTest.java | 15 +-
...CamelSpringDelegatingTestContextLoaderTest.java | 16 +-
.../test/JavaConfigWithNestedConfigClassTest.java | 25 +-
.../test/JavaConfigWithPostProcessorTest.java | 24 +-
components/camel-spring-main/pom.xml | 6 +-
.../org/apache/camel/spring/MainDummyTest.java | 10 +-
.../org/apache/camel/spring/MainExampleTest.java | 5 +-
.../java/org/apache/camel/spring/MainIoCTest.java | 5 +-
.../java/org/apache/camel/spring/MainTest.java | 5 +-
.../java/org/apache/camel/spring/MainVetoTest.java | 7 +-
.../camel/spring/MisspelledRouteRefTest.java | 9 +-
.../spring/SpringMainStartFailedIssueTest.java | 10 +-
.../apache/camel/spring/SpringCamelContext.java | 24 +-
.../org/apache/camel/spring/SpringTestSupport.java | 9 +
...teExclusionFromWithinSpringTestSupportTest.java | 2 +-
.../config/scan/SpringComponentScanTest.java | 2 +-
.../config/scan/route/MyExcludedRouteBuilder.java | 2 +-
.../spring/junit5/CamelAnnotationsHandler.java | 73 +++--
.../junit5/CamelSpringBootExecutionListener.java | 10 +-
.../test/spring/junit5/CamelSpringBootTest.java | 9 +-
.../camel/test/spring/junit5/CamelSpringTest.java | 8 +-
.../junit5/CamelSpringTestContextLoader.java | 321 +-------------------
.../test/spring/junit5/CamelSpringTestHelper.java | 11 +-
.../junit5/DisableJmxTestExecutionListener.java | 50 ----
.../junit5/SpringTestExecutionListenerSorter.java | 4 -
.../SpringTestExecutionListenerSorterTest.java | 4 -
.../camel/test/spring/CamelAnnotationsHandler.java | 73 +++--
.../spring/CamelSpringBootExecutionListener.java | 95 ------
.../camel/test/spring/CamelSpringBootRunner.java | 51 +---
.../CamelSpringDelegatingTestContextLoader.java | 21 +-
.../camel/test/spring/CamelSpringRunner.java | 18 +-
.../test/spring/CamelSpringTestContextLoader.java | 323 ++-------------------
.../camel/test/spring/CamelSpringTestHelper.java | 17 +-
.../spring/DisableJmxTestExecutionListener.java | 39 ---
.../apache/camel/component/undertow/undertow.json | 2 +-
.../src/main/docs/undertow-component.adoc | 2 +-
.../camel/component/undertow/UndertowConsumer.java | 8 +-
.../camel/component/undertow/UndertowEndpoint.java | 2 +-
.../operations/FutureEventDrivenOperation.java | 4 +-
.../dsl/UndertowEndpointBuilderFactory.java | 12 +-
.../modules/ROOT/pages/browse-component.adoc | 2 +-
.../modules/ROOT/pages/undertow-component.adoc | 2 +-
.../modules/ROOT/pages/exception-clause.adoc | 2 +-
108 files changed, 1052 insertions(+), 1940 deletions(-)
delete mode 100644 components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java
create mode 100644 components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncTest.java
delete mode 100644 components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/OptionsMethodWebRequest.java
delete mode 100644 components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/multiServletWeb.xml
delete mode 100644 components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-example.xml
delete mode 100644 components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring-async.xml
delete mode 100644 components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml
delete mode 100644 components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web.xml
delete mode 100644 components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/DisableJmxTestExecutionListener.java
delete mode 100644 components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootExecutionListener.java
delete mode 100644 components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
[camel] 06/07: [CAMEL-11807] Upgrade camel-servlet to junit5
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 24ce10b6da654b7d26692d66b5af0c5d08f980cd
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Jun 18 21:40:44 2020 +0200
[CAMEL-11807] Upgrade camel-servlet to junit5
---
components/camel-servlet/pom.xml | 61 +----
.../src/main/docs/servlet-component.adoc | 6 +-
.../ExposedServletEndpointURIToJMXTest.java | 8 +-
.../servlet/HttpClientRouteExampleSpringTest.java | 35 ++-
.../servlet/HttpClientRouteSpringTest.java | 21 +-
.../component/servlet/HttpClientRouteTest.java | 58 ++---
.../servlet/MultiServletConsumerTest.java | 29 ++-
.../servlet/ServletAsyncArquillianTest.java | 66 -----
.../camel/component/servlet/ServletAsyncTest.java | 58 +++++
.../servlet/ServletCamelRouterTestSupport.java | 284 +++++++++++++++++++--
.../component/servlet/ServletChoiceBeanTest.java | 12 +-
.../servlet/ServletMuteExceptionTest.java | 8 +-
.../servlet/ServletNoSlashNeededTest.java | 10 +-
.../component/servlet/ServletRootPathTest.java | 10 +-
.../component/servlet/ServletSetBodyTest.java | 10 +-
.../ServletSetExchangePropertyBeanTest.java | 12 +-
.../servlet/ServletSwitchingStatusCode204Test.java | 8 +-
.../servlet/ServletTransferExceptionTest.java | 10 +-
.../servlet/rest/OptionsMethodWebRequest.java | 41 ---
.../servlet/rest/RestApiMatchUriServletTest.java | 9 +-
.../RestServletBindingModeAutoWithJsonTest.java | 9 +-
.../RestServletBindingModeAutoWithXmlTest.java | 10 +-
.../rest/RestServletBindingModeJsonTest.java | 10 +-
...RestServletBindingModeJsonWithContractTest.java | 13 +-
.../RestServletBindingModeOffWithContractTest.java | 13 +-
.../rest/RestServletBindingModeXmlTest.java | 10 +-
.../component/servlet/rest/RestServletGetTest.java | 9 +-
.../servlet/rest/RestServletGetWildcardsTest.java | 9 +-
.../rest/RestServletMethodNotAllowedTest.java | 9 +-
.../servlet/rest/RestServletOptionsTest.java | 8 +-
.../servlet/rest/RestServletPojoInOutTest.java | 11 +-
.../rest/RestServletPostJsonJaxbPojoTest.java | 10 +-
.../rest/RestServletPostJsonPojoListTest.java | 10 +-
.../servlet/rest/RestServletPostJsonPojoTest.java | 10 +-
.../rest/RestServletPostXmlJaxbPojoTest.java | 10 +-
.../servlet/rest/RestServletVerbTest.java | 15 +-
.../camel/component/servlet/multiServletWeb.xml | 47 ----
.../apache/camel/component/servlet/web-example.xml | 55 ----
.../camel/component/servlet/web-spring-async.xml | 54 ----
.../apache/camel/component/servlet/web-spring.xml | 55 ----
.../org/apache/camel/component/servlet/web.xml | 38 ---
41 files changed, 533 insertions(+), 638 deletions(-)
diff --git a/components/camel-servlet/pom.xml b/components/camel-servlet/pom.xml
index 126fe9f..03d9957 100644
--- a/components/camel-servlet/pom.xml
+++ b/components/camel-servlet/pom.xml
@@ -37,22 +37,8 @@
javax.activation.*;version="${javax-activation-version-range}",
javax.servlet.*;version="${servlet-version-range}"
</camel.osgi.import.before.defaults>
-
- <!-- used for testing -->
- <tomcat.version>9.0.35</tomcat.version>
</properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.jboss.arquillian</groupId>
- <artifactId>arquillian-bom</artifactId>
- <version>${arquillian-version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
<dependencies>
<dependency>
@@ -83,7 +69,7 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -92,8 +78,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -102,22 +88,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>httpunit</groupId>
- <artifactId>httpunit</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>rhino</groupId>
- <artifactId>js</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<scope>test</scope>
@@ -139,28 +109,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>io.rest-assured</groupId>
- <artifactId>rest-assured</artifactId>
- <version>${rest-assured-version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <version>${arquillian-version}</version>
- <scope>test</scope>
- </dependency>
- <!--tomcat-->
- <dependency>
- <groupId>org.jboss.arquillian.container</groupId>
- <artifactId>arquillian-tomcat-embedded-9</artifactId>
- <version>1.1.0.Final</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tomcat.embed</groupId>
- <artifactId>tomcat-embed-core</artifactId>
- <version>${tomcat.version}</version>
+ <groupId>io.undertow</groupId>
+ <artifactId>undertow-servlet</artifactId>
+ <version>${undertow-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/components/camel-servlet/src/main/docs/servlet-component.adoc b/components/camel-servlet/src/main/docs/servlet-component.adoc
index e739d20..52d4894 100644
--- a/components/camel-servlet/src/main/docs/servlet-component.adoc
+++ b/components/camel-servlet/src/main/docs/servlet-component.adoc
@@ -245,12 +245,12 @@ from("servlet:hello?matchOnUriPrefix=true").process(new Processor() {
String path = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
path = path.substring(path.lastIndexOf("/"));
- assertEquals("Get a wrong content type", CONTENT_TYPE, contentType);
+ assertEquals(CONTENT_TYPE, contentType, "Get a wrong content type");
// assert camel http header
String charsetEncoding = exchange.getIn().getHeader(Exchange.HTTP_CHARACTER_ENCODING, String.class);
- assertEquals("Get a wrong charset name from the message heaer", "UTF-8", charsetEncoding);
+ assertEquals(charsetEncoding, "Get a wrong charset name from the message heaer", "UTF-8");
// assert exchange charset
- assertEquals("Get a wrong charset naem from the exchange property", "UTF-8", exchange.getProperty(Exchange.CHARSET_NAME));
+ assertEquals(exchange.getProperty(Exchange.CHARSET_NAME), "Get a wrong charset naem from the exchange property", "UTF-8");
exchange.getOut().setHeader(Exchange.CONTENT_TYPE, contentType + "; charset=UTF-8");
exchange.getOut().setHeader("PATH", path);
exchange.getOut().setBody("<b>Hello World</b>");
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ExposedServletEndpointURIToJMXTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ExposedServletEndpointURIToJMXTest.java
index 0aa7bed..fd9a506 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ExposedServletEndpointURIToJMXTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ExposedServletEndpointURIToJMXTest.java
@@ -22,8 +22,10 @@ import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ExposedServletEndpointURIToJMXTest extends CamelTestSupport {
@@ -43,7 +45,7 @@ public class ExposedServletEndpointURIToJMXTest extends CamelTestSupport {
MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
ObjectName name = new ObjectName("org.apache.camel:context=camel-1,type=endpoints,name=" + servletEndpointURI);
Set<ObjectName> objectNamesSet = mbeanServer.queryNames(name, null);
- assertEquals("Expect one MBean for the servlet endpoint", 1, objectNamesSet.size());
+ assertEquals(1, objectNamesSet.size(), "Expect one MBean for the servlet endpoint");
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
index de96e60..d6a5dff 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
@@ -16,12 +16,13 @@
*/
package org.apache.camel.component.servlet;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
-import org.junit.Before;
-import org.junit.Test;
+import io.undertow.servlet.Servlets;
+import io.undertow.servlet.api.DeploymentInfo;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.web.context.ContextLoaderListener;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class HttpClientRouteExampleSpringTest extends ServletCamelRouterTestSupport {
@Test
@@ -32,24 +33,32 @@ public class HttpClientRouteExampleSpringTest extends ServletCamelRouterTestSupp
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
WebResponse response = client.getResponse(req);
- assertEquals("Get a wrong response message.", "OK", response.getResponseMessage());
- assertEquals("Get a wrong response text.", "Add a name parameter to uri, eg ?name=foo", response.getText());
+ assertEquals("OK", response.getResponseMessage(), "Get a wrong response message.");
+ assertEquals("Add a name parameter to uri, eg ?name=foo", response.getText(), "Get a wrong response text.");
req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello?name=Willem");
response = client.getResponse(req);
- assertEquals("Get a wrong response text.", "Hello Willem how are you?", response.getText());
+ assertEquals("Hello Willem how are you?", response.getText(), "Get a wrong response text.");
}
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
startCamelContext = false;
super.setUp();
}
-
+
@Override
- protected String getConfiguration() {
- return "/org/apache/camel/component/servlet/web-example.xml";
+ protected DeploymentInfo getDeploymentInfo() {
+ return Servlets.deployment()
+ .setClassLoader(getClass().getClassLoader())
+ .setContextPath(CONTEXT)
+ .setDeploymentName(getClass().getName())
+ .addInitParameter("contextConfigLocation", "classpath:org/apache/camel/component/servlet/example-camelContext.xml")
+ .addListener(Servlets.listener(ContextLoaderListener.class))
+ .addServlet(Servlets.servlet("CamelServlet", CamelHttpTransportServlet.class)
+ .addInitParam("matchOnUriPrefix", "true")
+ .addMapping("/services/*"));
}
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteSpringTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteSpringTest.java
index 9418f8b..268d08e 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteSpringTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteSpringTest.java
@@ -16,20 +16,31 @@
*/
package org.apache.camel.component.servlet;
-import org.junit.Before;
+import io.undertow.servlet.Servlets;
+import io.undertow.servlet.api.DeploymentInfo;
+import org.junit.jupiter.api.BeforeEach;
+import org.springframework.web.context.ContextLoaderListener;
public class HttpClientRouteSpringTest extends HttpClientRouteTest {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
startCamelContext = false;
super.setUp();
}
-
+
@Override
- protected String getConfiguration() {
- return "/org/apache/camel/component/servlet/web-spring.xml";
+ protected DeploymentInfo getDeploymentInfo() {
+ return Servlets.deployment()
+ .setClassLoader(getClass().getClassLoader())
+ .setContextPath(CONTEXT)
+ .setDeploymentName(getClass().getName())
+ .addInitParameter("contextConfigLocation", "classpath:org/apache/camel/component/servlet/camelContext.xml")
+ .addListener(Servlets.listener(ContextLoaderListener.class))
+ .addServlet(Servlets.servlet("CamelServlet", CamelHttpTransportServlet.class)
+ .addInitParam("matchOnUriPrefix", "true")
+ .addMapping("/services/*"));
}
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
index b5a1678..64d2507 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
@@ -21,18 +21,18 @@ import java.io.ByteArrayInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpException;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.Exchange;
import org.apache.camel.FailedToStartRouteException;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
+
private static final String POST_DATA = "<request> hello world </request>";
private static final String CONTENT_TYPE = "text/xml; charset=UTF-8";
private static final String UNICODE_TEXT = "B\u00FCe W\u00F6rld";
@@ -43,18 +43,18 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
- assertEquals("Get wrong content type", "text/xml", response.getContentType());
+ assertEquals("text/xml", response.getContentType(), "Get wrong content type");
assertTrue("UTF-8".equalsIgnoreCase(response.getCharacterSet()));
- assertEquals("Get a wrong message header", "/hello", response.getHeaderField("PATH"));
- assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
+ assertEquals("/hello", response.getHeaderField("PATH"), "Get a wrong message header");
+ assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
req = new PostMethodWebRequest(CONTEXT_URL + "/services/helloworld", new ByteArrayInputStream(POST_DATA.getBytes()), CONTENT_TYPE);
response = client.getResponse(req);
- assertEquals("Get wrong content type", "text/xml", response.getContentType());
+ assertEquals("text/xml", response.getContentType(), "Get wrong content type");
assertTrue("UTF-8".equalsIgnoreCase(response.getCharacterSet()));
- assertEquals("Get a wrong message header", "/helloworld", response.getHeaderField("PATH"));
- assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
+ assertEquals("/helloworld", response.getHeaderField("PATH"), "Get a wrong message header");
+ assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
client.setExceptionsThrownOnErrorStatus(false);
}
@@ -63,8 +63,8 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/testHttpMethodRestrict", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
- assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
- assertEquals("The response body is wrong", POST_DATA, response.getText());
+ assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
+ assertEquals(POST_DATA, response.getText(), "The response body is wrong");
// Send other web method request
req = new GetMethodWebRequest(CONTEXT_URL + "/services/testHttpMethodRestrict");
@@ -73,7 +73,7 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
fail("Expect the exception here");
} catch (Exception ex) {
HttpException httpException = (HttpException)ex;
- assertEquals("Get a wrong response code", 405, httpException.getResponseCode());
+ assertEquals(405, httpException.getResponseCode(), "Get a wrong response code");
}
}
@@ -83,8 +83,8 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
- assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
- assertEquals("The response body is wrong", "Bye World", response.getText());
+ assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
+ assertEquals("Bye World", response.getText(), "The response body is wrong");
}
@Test
@@ -93,8 +93,8 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
- assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
- assertEquals("The response body is wrong", UNICODE_TEXT, response.getText());
+ assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
+ assertEquals(UNICODE_TEXT, response.getText(), "The response body is wrong");
}
@Test
@@ -103,8 +103,8 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
- assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
- assertEquals("The response body is wrong", UNICODE_TEXT, response.getText());
+ assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
+ assertEquals(UNICODE_TEXT, response.getText(), "The response body is wrong");
}
@Test
@@ -122,8 +122,8 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
});
fail("Excepts exception here");
} catch (Exception ex) {
- assertTrue("Get a wrong exception.", ex instanceof FailedToStartRouteException);
- assertTrue("Get a wrong cause of exception.", ex.getCause().getCause() instanceof UnsupportedOperationException);
+ assertTrue(ex instanceof FailedToStartRouteException, "Get a wrong exception.");
+ assertTrue(ex.getCause().getCause() instanceof UnsupportedOperationException, "Get a wrong cause of exception.");
}
}
@@ -138,12 +138,12 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
String path = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
path = path.substring(path.lastIndexOf('/'));
- assertEquals("Get a wrong content type", CONTENT_TYPE, contentType);
+ assertEquals(CONTENT_TYPE, contentType, "Get a wrong content type");
// assert camel http header
String charsetEncoding = exchange.getIn().getHeader(Exchange.HTTP_CHARACTER_ENCODING, String.class);
- assertEquals("Get a wrong charset name from the message heaer", "UTF-8", charsetEncoding);
+ assertEquals(charsetEncoding, "UTF-8", "Get a wrong charset name from the message header");
// assert exchange charset
- assertEquals("Get a wrong charset naem from the exchange property", "UTF-8", exchange.getProperty(Exchange.CHARSET_NAME));
+ assertEquals("UTF-8", exchange.getProperty(Exchange.CHARSET_NAME), "Get a wrong charset naem from the exchange property");
exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, contentType + "; charset=UTF-8");
exchange.getMessage().setHeader("PATH", path);
exchange.getMessage().setBody("<b>Hello World</b>");
@@ -159,9 +159,9 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
.convertBodyTo(String.class)
.process(exchange -> {
HttpServletRequest request = exchange.getIn(HttpServletRequest.class);
- assertNotNull("We should get request object here", request);
+ assertNotNull(request, "We should get request object here");
HttpServletResponse response = exchange.getIn(HttpServletResponse.class);
- assertNotNull("We should get response object here", response);
+ assertNotNull(response, "We should get response object here");
String s = exchange.getIn().getBody(String.class);
assertEquals("<request> hello world </request>", s);
}).transform(constant("Bye World"));
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/MultiServletConsumerTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/MultiServletConsumerTest.java
index 34ed941..5b5dc57 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/MultiServletConsumerTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/MultiServletConsumerTest.java
@@ -16,20 +16,15 @@
*/
package org.apache.camel.component.servlet;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpNotFoundException;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
+import io.undertow.servlet.Servlets;
+import io.undertow.servlet.api.DeploymentInfo;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MultiServletConsumerTest extends ServletCamelRouterTestSupport {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
- @Override
- protected String getConfiguration() {
- return "/org/apache/camel/component/servlet/multiServletWeb.xml";
- }
+public class MultiServletConsumerTest extends ServletCamelRouterTestSupport {
@Test
public void testMultiServletsConsumers() throws Exception {
@@ -76,4 +71,16 @@ public class MultiServletConsumerTest extends ServletCamelRouterTestSupport {
};
}
+ @Override
+ protected DeploymentInfo getDeploymentInfo() {
+ return Servlets.deployment()
+ .setClassLoader(getClass().getClassLoader())
+ .setContextPath(CONTEXT)
+ .setDeploymentName(getClass().getName())
+ .addServlet(Servlets.servlet("CamelServlet1", CamelHttpTransportServlet.class)
+ .addMapping("/services1/*"))
+ .addServlet(Servlets.servlet("CamelServlet2", CamelHttpTransportServlet.class)
+ .addMapping("/services2/*"));
+ }
+
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java
deleted file mode 100644
index e77fdff..0000000
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java
+++ /dev/null
@@ -1,66 +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.component.servlet;
-
-import java.net.URL;
-import java.nio.file.Paths;
-import java.text.MessageFormat;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.container.test.api.RunAsClient;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.arquillian.test.api.ArquillianResource;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static io.restassured.RestAssured.given;
-import static org.hamcrest.CoreMatchers.equalTo;
-
-@Ignore("TODO: Look at me later")
-@RunWith(Arquillian.class)
-public class ServletAsyncArquillianTest {
-
- @Deployment
- public static Archive<?> createTestArchive() {
- // this is a WAR project so use WebArchive
- return ShrinkWrap.create(WebArchive.class)
- // add the web.xml
- .setWebXML(Paths.get("src/test/resources/org/apache/camel/component/servlet/web-spring-async.xml").toFile());
- }
-
- /**
- *
- * @param url the URL is the URL to the web application that was deployed
- * @throws Exception
- */
- @Test
- @RunAsClient
- public void testHello(@ArquillianResource URL url) throws Exception {
- final String name = "Arnaud";
- given().
- baseUri(url.toString()).
- queryParam("name", name).
- when().
- get("/services/hello").
- then().
- body(equalTo(MessageFormat.format("Hello {0} how are you?", name)));
- }
-}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncTest.java
new file mode 100644
index 0000000..7b48da0
--- /dev/null
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.component.servlet;
+
+import java.text.MessageFormat;
+
+import io.undertow.servlet.Servlets;
+import io.undertow.servlet.api.DeploymentInfo;
+import org.junit.jupiter.api.Test;
+import org.springframework.web.context.ContextLoaderListener;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ServletAsyncTest extends ServletCamelRouterTestSupport {
+
+ @Test
+ public void testHello() throws Exception {
+ final String name = "Arnaud";
+
+ WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
+ req.setParameter("name", name);
+ ServletUnitClient client = newClient();
+ WebResponse response = client.getResponse(req);
+
+ assertEquals(200, response.getResponseCode());
+ assertEquals(MessageFormat.format("Hello {0} how are you?", name), response.getText(), "The response message is wrong");
+ }
+
+ @Override
+ protected DeploymentInfo getDeploymentInfo() {
+ return Servlets.deployment()
+ .setClassLoader(getClass().getClassLoader())
+ .setContextPath(CONTEXT)
+ .setDeploymentName(getClass().getName())
+ .addInitParameter("contextConfigLocation", "classpath:org/apache/camel/component/servlet/example-camelContext.xml")
+ .addListener(Servlets.listener(ContextLoaderListener.class))
+ .addServlet(Servlets.servlet("CamelServlet", CamelHttpTransportServlet.class)
+ .addInitParam("async", "true")
+ .setLoadOnStartup(1)
+ .setAsyncSupported(true)
+ .addMapping("/services/*"));
+ }
+
+}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java
index b16fcf7..c46ed46 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java
@@ -16,52 +16,286 @@
*/
package org.apache.camel.component.servlet;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
-import com.meterware.httpunit.HttpUnitOptions;
-import com.meterware.servletunit.ServletRunner;
-import com.meterware.servletunit.ServletUnitClient;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.After;
-import org.junit.Before;
+import io.undertow.Handlers;
+import io.undertow.Undertow;
+import io.undertow.server.handlers.PathHandler;
+import io.undertow.servlet.Servlets;
+import io.undertow.servlet.api.DeploymentInfo;
+import io.undertow.servlet.api.DeploymentManager;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.camel.util.IOHelper;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
public class ServletCamelRouterTestSupport extends CamelTestSupport {
+
public static final String CONTEXT = "/mycontext";
- public static final String CONTEXT_URL = "http://localhost/mycontext";
- protected ServletRunner sr;
+ protected String CONTEXT_URL;
protected boolean startCamelContext = true;
+ protected int port;
+ protected DeploymentManager manager;
+ protected Undertow server;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
- InputStream is = this.getClass().getResourceAsStream(getConfiguration());
- assertNotNull("The configuration input stream should not be null", is);
- sr = new ServletRunner(is, CONTEXT);
-
- HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
- if (startCamelContext) {
+ port = AvailablePortFinder.getNextAvailable();
+ DeploymentInfo servletBuilder = getDeploymentInfo();
+ manager = Servlets.newContainer().addDeployment(servletBuilder);
+ manager.deploy();
+ PathHandler path = Handlers.path(Handlers.redirect(CONTEXT))
+ .addPrefixPath(CONTEXT, manager.start());
+ server = Undertow.builder().addHttpListener(port, "localhost")
+ .setHandler(path).build();
+ server.start();
+ CONTEXT_URL = "http://localhost:" + port + CONTEXT;
+ if (startCamelContext) {
super.setUp();
}
}
-
+
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (startCamelContext) {
super.tearDown();
}
- sr.shutDown();
+ server.stop();
+ manager.stop();
+ manager.undeploy();
}
-
- /**
- * @return The web.xml to use for testing.
- */
- protected String getConfiguration() {
- return "/org/apache/camel/component/servlet/web.xml";
+
+ protected DeploymentInfo getDeploymentInfo() {
+ return Servlets.deployment()
+ .setClassLoader(getClass().getClassLoader())
+ .setContextPath(CONTEXT)
+ .setDeploymentName(getClass().getName())
+ .addServlet(Servlets.servlet("CamelServlet", CamelHttpTransportServlet.class)
+ .addMapping("/services/*"));
}
protected ServletUnitClient newClient() {
- return sr.newClient();
+ return new ServletUnitClient();
+ }
+
+ protected static abstract class WebRequest {
+ protected String url;
+ protected Map<String, String> headers = new HashMap<>();
+ protected Map<String, String> params = new HashMap<>();
+
+ public WebRequest(String url) {
+ this.url = url;
+ }
+
+ public abstract String getMethod();
+
+ public void setParameter(String key, String val) {
+ params.put(key, val);
+ }
+
+ public void setHeaderField(String key, String val) {
+ headers.put(key, val);
+ }
+ }
+
+ protected static class GetMethodWebRequest extends WebRequest {
+ public GetMethodWebRequest(String url) {
+ super(url);
+ headers.put("Content-Length", "0");
+ }
+ public String getMethod() {
+ return "GET";
+ }
+ }
+
+ protected static class PostMethodWebRequest extends WebRequest {
+ protected InputStream content;
+ public PostMethodWebRequest(String url) {
+ super(url);
+ }
+ public PostMethodWebRequest(String url, InputStream content, String contentType) {
+ super(url);
+ this.content = content;
+ headers.put("Content-Type", contentType);
+ }
+ public String getMethod() {
+ return "POST";
+ }
+ }
+
+ protected static class PutMethodWebRequest extends PostMethodWebRequest {
+ public PutMethodWebRequest(String url) {
+ super(url);
+ }
+ public PutMethodWebRequest(String url, InputStream content, String contentType) {
+ super(url, content, contentType);
+ }
+ public String getMethod() {
+ return "PUT";
+ }
+ }
+
+ protected static class OptionsMethodWebRequest extends WebRequest {
+ public OptionsMethodWebRequest(String url) {
+ super(url);
+ }
+ public String getMethod() {
+ return "OPTIONS";
+ }
+ }
+
+ protected static abstract class HeaderOnlyWebRequest extends WebRequest {
+ public HeaderOnlyWebRequest(String url) {
+ super(url);
+ }
+ }
+
+ protected static class WebResponse {
+
+ HttpURLConnection con;
+ String text;
+
+ public WebResponse(HttpURLConnection con) {
+ this.con = con;
+ }
+
+ public int getResponseCode() throws IOException {
+ return con.getResponseCode();
+ }
+
+ public String getText() throws IOException {
+ if (text == null) {
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ IOHelper.copy(con.getInputStream(), baos);
+ text = baos.toString();
+ } catch (IOException e) {
+ text = "Exception";
+ }
+ }
+ return text;
+ }
+
+ public String getContentType() {
+ String content = con.getContentType();
+ return content != null && content.contains(";")
+ ? content.substring(0, content.indexOf(";"))
+ : content;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ try {
+ return con.getInputStream();
+ } catch (IOException e) {
+ try {
+ Field f = con.getClass().getDeclaredField("inputStream");
+ f.setAccessible(true);
+ return (InputStream) f.get(con);
+ } catch (Throwable t) {
+ e.addSuppressed(t);
+ throw e;
+ }
+ }
+ }
+
+ public String getResponseMessage() throws IOException {
+ return con.getResponseMessage();
+ }
+
+ public String getCharacterSet() {
+ String content = con.getContentType();
+ return content != null && content.contains(";charset=")
+ ? content.substring(content.lastIndexOf(";charset=") + ";charset=".length())
+ : con.getContentEncoding();
+ }
+
+ public String getHeaderField(String key) {
+ return con.getHeaderField(key);
+ }
+ }
+
+ protected static class ServletUnitClient {
+
+ protected boolean exceptionsThrownOnErrorStatus = true;
+
+ public WebResponse getResponse(WebRequest req) throws IOException {
+ String params = req.params.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue())
+ .collect(Collectors.joining("&"));
+ String urlStr = params.isEmpty() ? req.url : req.url + "?" + params;
+ URL url = new URL(urlStr);
+ HttpURLConnection con = (HttpURLConnection) url.openConnection();
+ con.setUseCaches(false);
+ req.headers.forEach(con::addRequestProperty);
+ con.setRequestMethod(req.getMethod());
+ if (req instanceof PostMethodWebRequest) {
+ con.setDoOutput(true);
+ InputStream is = ((PostMethodWebRequest) req).content;
+ if (is != null) {
+ IOHelper.copy(is, con.getOutputStream());
+ }
+ }
+ int code = con.getResponseCode();
+ if (exceptionsThrownOnErrorStatus && code >= HttpURLConnection.HTTP_BAD_REQUEST) {
+ if (code == HttpURLConnection.HTTP_NOT_FOUND) {
+ throw new HttpNotFoundException(code, con.getResponseMessage(), url);
+ }
+ throw new HttpException(code, con.getResponseMessage(), url);
+ }
+ return new WebResponse(con);
+ }
+
+ public void setExceptionsThrownOnErrorStatus(boolean val) {
+ this.exceptionsThrownOnErrorStatus = val;
+ }
+ }
+
+ protected static class HttpException extends RuntimeException {
+ private int code;
+ private String message;
+ private URL url;
+
+ public HttpException(int code, String message, URL url) {
+ this.code = code;
+ this.message = message;
+ this.url = url;
+ }
+
+ public int getResponseCode() {
+ return code;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer(2048).append("Error on HTTP request: ");
+ sb.append(code);
+ if (message != null) {
+ sb.append(" ");
+ sb.append(message);
+ sb.append("");
+ }
+ if (url != null) {
+ sb.append(" [");
+ sb.append(url.toExternalForm());
+ sb.append("]");
+ }
+ return sb.toString();
+ }
+ }
+
+ protected static class HttpNotFoundException extends HttpException {
+ public HttpNotFoundException(int code, String message, URL url) {
+ super(code, message, url);
+ }
}
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletChoiceBeanTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletChoiceBeanTest.java
index 9d2217e..d95e50d 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletChoiceBeanTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletChoiceBeanTest.java
@@ -16,14 +16,12 @@
*/
package org.apache.camel.component.servlet;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HttpNotFoundException;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
public class ServletChoiceBeanTest extends ServletCamelRouterTestSupport {
@@ -37,7 +35,7 @@ public class ServletChoiceBeanTest extends ServletCamelRouterTestSupport {
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
- assertEquals("The response message is wrong ", "Client is Donald Duck", response.getText());
+ assertEquals("Client is Donald Duck", response.getText(), "The response message is wrong");
assertMockEndpointsSatisfied();
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletMuteExceptionTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletMuteExceptionTest.java
index 6a48a2b..298c0d8 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletMuteExceptionTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletMuteExceptionTest.java
@@ -18,12 +18,10 @@ package org.apache.camel.component.servlet;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServletMuteExceptionTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletNoSlashNeededTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletNoSlashNeededTest.java
index c1ee421..108f91d 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletNoSlashNeededTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletNoSlashNeededTest.java
@@ -16,12 +16,10 @@
*/
package org.apache.camel.component.servlet;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServletNoSlashNeededTest extends ServletCamelRouterTestSupport {
@@ -31,7 +29,7 @@ public class ServletNoSlashNeededTest extends ServletCamelRouterTestSupport {
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
- assertEquals("The response message is wrong ", "Bye World", response.getText());
+ assertEquals("Bye World", response.getText(), "The response message is wrong");
}
@Override
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletRootPathTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletRootPathTest.java
index 2b6dc91..c06d616 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletRootPathTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletRootPathTest.java
@@ -16,12 +16,10 @@
*/
package org.apache.camel.component.servlet;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServletRootPathTest extends ServletCamelRouterTestSupport {
@@ -31,7 +29,7 @@ public class ServletRootPathTest extends ServletCamelRouterTestSupport {
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
- assertEquals("The response message is wrong ", "Bye World", response.getText());
+ assertEquals("Bye World", response.getText(), "The response message is wrong");
}
@Override
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetBodyTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetBodyTest.java
index 847c5ad..1eb6c6a 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetBodyTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetBodyTest.java
@@ -16,12 +16,10 @@
*/
package org.apache.camel.component.servlet;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServletSetBodyTest extends ServletCamelRouterTestSupport {
@@ -31,7 +29,7 @@ public class ServletSetBodyTest extends ServletCamelRouterTestSupport {
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
- assertEquals("The response message is wrong ", "Bye World", response.getText());
+ assertEquals("Bye World", response.getText(), "The response message is wrong");
}
@Override
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetExchangePropertyBeanTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetExchangePropertyBeanTest.java
index 49e1f4f..73b73d8 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetExchangePropertyBeanTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetExchangePropertyBeanTest.java
@@ -16,12 +16,10 @@
*/
package org.apache.camel.component.servlet;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServletSetExchangePropertyBeanTest extends ServletCamelRouterTestSupport {
@@ -32,7 +30,7 @@ public class ServletSetExchangePropertyBeanTest extends ServletCamelRouterTestSu
WebResponse response = client.getResponse(req);
assertEquals(204, response.getResponseCode());
- assertEquals("The response message is wrong ", "", response.getText());
+ assertEquals("", response.getText(), "The response message is wrong");
}
@Override
@@ -43,7 +41,7 @@ public class ServletSetExchangePropertyBeanTest extends ServletCamelRouterTestSu
onException(Exception.class)
.handled(true);
- from("servlet:/hello")
+ from("servlet:/hello?httpBinding.eagerCheckContentAvailable=true")
.setProperty("myProperty").method(ServletSetExchangePropertyBeanTest.class, "throwException");
}
};
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSwitchingStatusCode204Test.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSwitchingStatusCode204Test.java
index fdd0da1..096cc76 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSwitchingStatusCode204Test.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSwitchingStatusCode204Test.java
@@ -16,13 +16,11 @@
*/
package org.apache.camel.component.servlet;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServletSwitchingStatusCode204Test extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
index 020873f..13bc15d 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
@@ -18,14 +18,14 @@ package org.apache.camel.component.servlet;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.http.common.HttpConstants;
import org.apache.camel.http.common.HttpHelper;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class ServletTransferExceptionTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/OptionsMethodWebRequest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/OptionsMethodWebRequest.java
deleted file mode 100644
index b428b57..0000000
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/OptionsMethodWebRequest.java
+++ /dev/null
@@ -1,41 +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.component.servlet.rest;
-
-import java.net.URL;
-
-import com.meterware.httpunit.GetMethodWebRequest;
-
-public class OptionsMethodWebRequest extends GetMethodWebRequest {
-
- public OptionsMethodWebRequest(String urlString) {
- super(urlString);
- }
-
- public OptionsMethodWebRequest(URL urlBase, String urlString) {
- super(urlBase, urlString);
- }
-
- public OptionsMethodWebRequest(URL urlBase, String urlString, String target) {
- super(urlBase, urlString, target);
- }
-
- @Override
- public String getMethod() {
- return "OPTIONS";
- }
-}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestApiMatchUriServletTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestApiMatchUriServletTest.java
index 003506f..34d893d 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestApiMatchUriServletTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestApiMatchUriServletTest.java
@@ -16,14 +16,13 @@
*/
package org.apache.camel.component.servlet.rest;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class RestApiMatchUriServletTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithJsonTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithJsonTest.java
index fd95d9b..586fbd0 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithJsonTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithJsonTest.java
@@ -18,15 +18,14 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class RestServletBindingModeAutoWithJsonTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithXmlTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithXmlTest.java
index 21d8fa0..b8c4b77 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithXmlTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithXmlTest.java
@@ -18,15 +18,15 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class RestServletBindingModeAutoWithXmlTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonTest.java
index ba25dcc..e102322 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonTest.java
@@ -18,15 +18,15 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class RestServletBindingModeJsonTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonWithContractTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonWithContractTest.java
index 0912f01..9946c9c 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonWithContractTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonWithContractTest.java
@@ -18,17 +18,18 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.Converter;
import org.apache.camel.TypeConverters;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class RestServletBindingModeJsonWithContractTest extends ServletCamelRouterTestSupport {
@@ -45,7 +46,7 @@ public class RestServletBindingModeJsonWithContractTest extends ServletCamelRout
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
String answer = response.getText();
- assertTrue("Unexpected response: " + answer, answer.contains("\"active\":true"));
+ assertTrue(answer.contains("\"active\":true"), "Unexpected response: " + answer);
assertMockEndpointsSatisfied();
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeOffWithContractTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeOffWithContractTest.java
index 0f78441..59a14e3 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeOffWithContractTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeOffWithContractTest.java
@@ -18,17 +18,18 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.dataformat.JsonDataFormat;
import org.apache.camel.model.dataformat.JsonLibrary;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class RestServletBindingModeOffWithContractTest extends ServletCamelRouterTestSupport {
@@ -45,7 +46,7 @@ public class RestServletBindingModeOffWithContractTest extends ServletCamelRoute
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
String answer = response.getText();
- assertTrue("Unexpected response: " + answer, answer.contains("\"active\":true"));
+ assertTrue(answer.contains("\"active\":true"), "Unexpected response: " + answer);
assertMockEndpointsSatisfied();
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeXmlTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeXmlTest.java
index ebac934..06d0d98 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeXmlTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeXmlTest.java
@@ -18,15 +18,15 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class RestServletBindingModeXmlTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetTest.java
index c9c9ead..62a5368 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetTest.java
@@ -16,15 +16,14 @@
*/
package org.apache.camel.component.servlet.rest;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.component.servlet.ServletRestHttpBinding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class RestServletGetTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetWildcardsTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetWildcardsTest.java
index 158ddbf..a23bd99 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetWildcardsTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetWildcardsTest.java
@@ -16,15 +16,14 @@
*/
package org.apache.camel.component.servlet.rest;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.component.servlet.ServletRestHttpBinding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class RestServletGetWildcardsTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletMethodNotAllowedTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletMethodNotAllowedTest.java
index 0a6a98e..83ac536 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletMethodNotAllowedTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletMethodNotAllowedTest.java
@@ -16,15 +16,14 @@
*/
package org.apache.camel.component.servlet.rest;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.component.servlet.ServletRestHttpBinding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class RestServletMethodNotAllowedTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletOptionsTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletOptionsTest.java
index 67177e6..2019c08 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletOptionsTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletOptionsTest.java
@@ -16,14 +16,14 @@
*/
package org.apache.camel.component.servlet.rest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.BindToRegistry;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.component.servlet.ServletRestHttpBinding;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class RestServletOptionsTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPojoInOutTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPojoInOutTest.java
index 36b558d..e7864e8 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPojoInOutTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPojoInOutTest.java
@@ -18,15 +18,14 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class RestServletPojoInOutTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonJaxbPojoTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonJaxbPojoTest.java
index 5af53c2..51e662d 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonJaxbPojoTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonJaxbPojoTest.java
@@ -18,15 +18,15 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class RestServletPostJsonJaxbPojoTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoListTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoListTest.java
index a14209e..3292caa 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoListTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoListTest.java
@@ -19,15 +19,15 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
import java.util.List;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class RestServletPostJsonPojoListTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoTest.java
index e37313e..e145171 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoTest.java
@@ -18,15 +18,15 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class RestServletPostJsonPojoTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostXmlJaxbPojoTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostXmlJaxbPojoTest.java
index e8ad4ff..a2299c4 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostXmlJaxbPojoTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostXmlJaxbPojoTest.java
@@ -18,15 +18,15 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
import org.apache.camel.model.rest.RestBindingMode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
public class RestServletPostXmlJaxbPojoTest extends ServletCamelRouterTestSupport {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletVerbTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletVerbTest.java
index 36b188d..f74b223 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletVerbTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletVerbTest.java
@@ -18,18 +18,14 @@ package org.apache.camel.component.servlet.rest;
import java.io.ByteArrayInputStream;
-import com.meterware.httpunit.GetMethodWebRequest;
-import com.meterware.httpunit.HeaderOnlyWebRequest;
-import com.meterware.httpunit.PostMethodWebRequest;
-import com.meterware.httpunit.PutMethodWebRequest;
-import com.meterware.httpunit.WebRequest;
-import com.meterware.httpunit.WebResponse;
-import com.meterware.servletunit.ServletUnitClient;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.component.servlet.ServletCamelRouterTestSupport;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class RestServletVerbTest extends ServletCamelRouterTestSupport {
@@ -118,7 +114,8 @@ public class RestServletVerbTest extends ServletCamelRouterTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- restConfiguration().component("servlet");
+ restConfiguration().component("servlet")
+ .endpointProperty("eagerCheckContentAvailable", "true");
rest()
.get("/users").route().transform().constant("[{ \"id\":\"1\", \"name\":\"Scott\" },{ \"id\":\"2\", \"name\":\"Claus\" }]").endRest()
diff --git a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/multiServletWeb.xml b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/multiServletWeb.xml
deleted file mode 100644
index 0b8c739..0000000
--- a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/multiServletWeb.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- 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.
-
--->
-<!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<web-app>
-
- <servlet>
- <servlet-name>CamelServlet1</servlet-name>
- <display-name>Camel Http Transport Servlet1</display-name>
- <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
- </servlet>
-
- <servlet>
- <servlet-name>CamelServlet2</servlet-name>
- <display-name>Camel Http Transport Servlet2</display-name>
- <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>CamelServlet1</servlet-name>
- <url-pattern>/services1/*</url-pattern>
- </servlet-mapping>
-
- <servlet-mapping>
- <servlet-name>CamelServlet2</servlet-name>
- <url-pattern>/services2/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
diff --git a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-example.xml b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-example.xml
deleted file mode 100644
index 09ed681..0000000
--- a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-example.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- 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.
-
--->
-<!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<!-- START SNIPPET: web -->
-<web-app>
-
- <!-- tell Spring where it should load the XML file -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:org/apache/camel/component/servlet/example-camelContext.xml</param-value>
- </context-param>
-
- <!-- spring context listener which loads the XML file -->
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
-
- <!-- Camel Servlet -->
- <servlet>
- <servlet-name>CamelServlet</servlet-name>
- <display-name>Camel Http Transport Servlet</display-name>
- <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
- <init-param>
- <param-name>matchOnUriPrefix</param-name>
- <param-value>true</param-value>
- </init-param>
- </servlet>
-
- <!-- Camel Servlet mappings -->
- <servlet-mapping>
- <servlet-name>CamelServlet</servlet-name>
- <url-pattern>/services/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
-<!-- END SNIPPET: web -->
diff --git a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring-async.xml b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring-async.xml
deleted file mode 100644
index a2a189f..0000000
--- a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring-async.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- 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.
-
--->
-<!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<!-- START SNIPPET: web -->
-<web-app>
- <!-- tell Spring where it should load the XML file -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:org/apache/camel/component/servlet/example-camelContext.xml</param-value>
- </context-param>
-
- <!-- spring context listener which loads the XML file -->
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
-
- <servlet>
- <servlet-name>CamelServlet</servlet-name>
- <display-name>Camel Http Transport Servlet</display-name>
- <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
- <init-param>
- <param-name>async</param-name>
- <param-value>true</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- <async-supported>true</async-supported>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>CamelServlet</servlet-name>
- <url-pattern>/services/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
-<!-- END SNIPPET: web -->
diff --git a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml
deleted file mode 100644
index 7f817d4..0000000
--- a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web-spring.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- 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.
-
--->
-<!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<!-- START SNIPPET: web -->
-<web-app>
-
- <!-- tell Spring where it should load the XML file -->
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:org/apache/camel/component/servlet/camelContext.xml</param-value>
- </context-param>
-
- <!-- spring context listener which loads the XML file -->
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
-
- <!-- Camel Servlet -->
- <servlet>
- <servlet-name>CamelServlet</servlet-name>
- <display-name>Camel Http Transport Servlet</display-name>
- <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
- <init-param>
- <param-name>matchOnUriPrefix</param-name>
- <param-value>true</param-value>
- </init-param>
- </servlet>
-
- <!-- Camel Servlet mappings -->
- <servlet-mapping>
- <servlet-name>CamelServlet</servlet-name>
- <url-pattern>/services/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
-<!-- END SNIPPET: web -->
diff --git a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web.xml b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web.xml
deleted file mode 100644
index a3408af..0000000
--- a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/web.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-
- 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.
-
--->
-<!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<!-- START SNIPPET: web -->
-<web-app>
-
- <servlet>
- <servlet-name>CamelServlet</servlet-name>
- <display-name>Camel Http Transport Servlet</display-name>
- <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>CamelServlet</servlet-name>
- <url-pattern>/services/*</url-pattern>
- </servlet-mapping>
-
-</web-app>
-<!-- END SNIPPET: web -->
[camel] 01/07: [CAMEL-11807] Upgrade camel-spring-main to junit5
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 1807b2eaf52c1526ef2d54ad753c00b077b1d6ca
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Jun 16 08:08:13 2020 +0200
[CAMEL-11807] Upgrade camel-spring-main to junit5
---
components/camel-spring-main/pom.xml | 6 +++---
.../src/test/java/org/apache/camel/spring/MainDummyTest.java | 10 ++++++----
.../src/test/java/org/apache/camel/spring/MainExampleTest.java | 5 ++---
.../src/test/java/org/apache/camel/spring/MainIoCTest.java | 5 ++---
.../src/test/java/org/apache/camel/spring/MainTest.java | 5 ++---
.../src/test/java/org/apache/camel/spring/MainVetoTest.java | 7 ++++---
.../java/org/apache/camel/spring/MisspelledRouteRefTest.java | 9 +++++----
.../apache/camel/spring/SpringMainStartFailedIssueTest.java | 10 +++++++---
8 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/components/camel-spring-main/pom.xml b/components/camel-spring-main/pom.xml
index b7d5402..22b234e 100644
--- a/components/camel-spring-main/pom.xml
+++ b/components/camel-spring-main/pom.xml
@@ -54,12 +54,12 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainDummyTest.java b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainDummyTest.java
index 6561798..e871a00 100644
--- a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainDummyTest.java
+++ b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainDummyTest.java
@@ -17,10 +17,12 @@
package org.apache.camel.spring;
import org.apache.camel.CamelContext;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MainDummyTest extends Assert {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class MainDummyTest {
@Test
public void testMain() throws Exception {
@@ -29,7 +31,7 @@ public class MainDummyTest extends Assert {
// should also be a Camel
CamelContext camel = main.getApplicationContext().getBean(CamelContext.class);
- assertNotNull("Camel should be in Spring", camel);
+ assertNotNull(camel, "Camel should be in Spring");
DummyBean dummy = (DummyBean) main.getApplicationContext().getBean("dummy");
assertNotNull(dummy);
diff --git a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainExampleTest.java b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainExampleTest.java
index 644adf7..3f4a4b8 100644
--- a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainExampleTest.java
+++ b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainExampleTest.java
@@ -17,10 +17,9 @@
package org.apache.camel.spring;
import org.apache.camel.builder.RouteBuilder;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MainExampleTest extends Assert {
+public class MainExampleTest {
@Test
public void testMain() throws Exception {
diff --git a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainIoCTest.java b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainIoCTest.java
index b5a8df1..3fb1348 100644
--- a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainIoCTest.java
+++ b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainIoCTest.java
@@ -18,10 +18,9 @@ package org.apache.camel.spring;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MainIoCTest extends Assert {
+public class MainIoCTest {
@Test
public void testMain() throws Exception {
diff --git a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainTest.java b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainTest.java
index 710839f..41bd1a8 100644
--- a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainTest.java
+++ b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainTest.java
@@ -22,12 +22,11 @@ import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class MainTest extends Assert {
+public class MainTest {
private static final Logger LOG = LoggerFactory.getLogger(MainTest.class);
@Test
diff --git a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainVetoTest.java b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainVetoTest.java
index f6f8add..5a2cdab 100644
--- a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainVetoTest.java
+++ b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MainVetoTest.java
@@ -16,10 +16,11 @@
*/
package org.apache.camel.spring;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class MainVetoTest extends Assert {
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class MainVetoTest {
@Test
public void testMain() throws Exception {
diff --git a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MisspelledRouteRefTest.java b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MisspelledRouteRefTest.java
index a93cf32..32d48a4 100644
--- a/components/camel-spring-main/src/test/java/org/apache/camel/spring/MisspelledRouteRefTest.java
+++ b/components/camel-spring-main/src/test/java/org/apache/camel/spring/MisspelledRouteRefTest.java
@@ -18,12 +18,13 @@ package org.apache.camel.spring;
import org.apache.camel.CamelException;
import org.apache.camel.RuntimeCamelException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.apache.camel.test.junit4.TestSupport.assertIsInstanceOf;
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
-public class MisspelledRouteRefTest extends Assert {
+public class MisspelledRouteRefTest {
@Test
public void testApplicationContextFailed() throws Exception {
diff --git a/components/camel-spring-main/src/test/java/org/apache/camel/spring/SpringMainStartFailedIssueTest.java b/components/camel-spring-main/src/test/java/org/apache/camel/spring/SpringMainStartFailedIssueTest.java
index 67f70f7..f10c5b6 100644
--- a/components/camel-spring-main/src/test/java/org/apache/camel/spring/SpringMainStartFailedIssueTest.java
+++ b/components/camel-spring-main/src/test/java/org/apache/camel/spring/SpringMainStartFailedIssueTest.java
@@ -17,8 +17,12 @@
package org.apache.camel.spring;
import org.apache.camel.FailedToCreateRouteException;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.junit.Test;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
public class SpringMainStartFailedIssueTest extends CamelTestSupport {
@@ -34,6 +38,6 @@ public class SpringMainStartFailedIssueTest extends CamelTestSupport {
assertIsInstanceOf(FailedToCreateRouteException.class, e);
}
- assertNull("Spring application context should NOT be created", main.getApplicationContext());
+ assertNull(main.getApplicationContext(), "Spring application context should NOT be created");
}
}
[camel] 03/07: [CAMEL-15215] Simplify and homogenize spring testing
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit e10ccef1e57277456c30aa843ba676eefbadebb8
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Jun 17 12:25:54 2020 +0200
[CAMEL-15215] Simplify and homogenize spring testing
---
.../apache/camel/spring/SpringCamelContext.java | 24 +-
.../org/apache/camel/spring/SpringTestSupport.java | 9 +
.../spring/junit5/CamelAnnotationsHandler.java | 73 +++--
.../junit5/CamelSpringBootExecutionListener.java | 10 +-
.../test/spring/junit5/CamelSpringBootTest.java | 9 +-
.../camel/test/spring/junit5/CamelSpringTest.java | 8 +-
.../junit5/CamelSpringTestContextLoader.java | 321 +-------------------
.../test/spring/junit5/CamelSpringTestHelper.java | 11 +-
.../junit5/DisableJmxTestExecutionListener.java | 50 ----
.../junit5/SpringTestExecutionListenerSorter.java | 4 -
.../SpringTestExecutionListenerSorterTest.java | 4 -
.../camel/test/spring/CamelAnnotationsHandler.java | 73 +++--
.../spring/CamelSpringBootExecutionListener.java | 95 ------
.../camel/test/spring/CamelSpringBootRunner.java | 51 +---
.../CamelSpringDelegatingTestContextLoader.java | 21 +-
.../camel/test/spring/CamelSpringRunner.java | 18 +-
.../test/spring/CamelSpringTestContextLoader.java | 323 ++-------------------
.../camel/test/spring/CamelSpringTestHelper.java | 17 +-
.../spring/DisableJmxTestExecutionListener.java | 39 ---
19 files changed, 229 insertions(+), 931 deletions(-)
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java b/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
index 100f857..baf7aa4 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
@@ -16,21 +16,28 @@
*/
package org.apache.camel.spring;
+import java.util.HashSet;
+import java.util.Set;
+
import org.apache.camel.Endpoint;
import org.apache.camel.api.management.JmxSystemPropertyKeys;
import org.apache.camel.component.bean.BeanProcessor;
import org.apache.camel.component.event.EventComponent;
import org.apache.camel.component.event.EventEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.scan.AssignableToPackageScanFilter;
+import org.apache.camel.impl.scan.InvertingPackageScanFilter;
import org.apache.camel.spi.BeanRepository;
import org.apache.camel.spi.Injector;
import org.apache.camel.spi.ModelJAXBContextFactory;
+import org.apache.camel.spi.PackageScanClassResolver;
import org.apache.camel.spi.Registry;
import org.apache.camel.spring.spi.ApplicationContextBeanRepository;
import org.apache.camel.spring.spi.SpringInjector;
import org.apache.camel.spring.spi.SpringManagementMBeanAssembler;
import org.apache.camel.support.DefaultRegistry;
import org.apache.camel.support.ProcessorEndpoint;
+import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,6 +65,8 @@ import static org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException;
public class SpringCamelContext extends DefaultCamelContext implements Lifecycle, ApplicationContextAware, Phased,
ApplicationListener<ApplicationEvent>, Ordered {
+ public static final String EXCLUDE_ROUTES = "CamelTestSpringExcludeRoutes";
+
private static final Logger LOG = LoggerFactory.getLogger(SpringCamelContext.class);
private static final ThreadLocal<Boolean> NO_START = new ThreadLocal<>();
private ApplicationContext applicationContext;
@@ -144,7 +153,7 @@ public class SpringCamelContext extends DefaultCamelContext implements Lifecycle
if (event instanceof ContextRefreshedEvent && ((ContextRefreshedEvent) event).getApplicationContext() == this.applicationContext) {
// nominally we would prefer to use Lifecycle interface that
- // would invoke start() method, but in order to do that
+ // would invoke start() method, but in order to do that
// SpringCamelContext needs to implement SmartLifecycle
// (look at DefaultLifecycleProcessor::startBeans), but it
// cannot implement it as it already implements
@@ -296,4 +305,17 @@ public class SpringCamelContext extends DefaultCamelContext implements Lifecycle
return !isStopping() && !isStopped();
}
+ protected PackageScanClassResolver createPackageScanClassResolver() {
+ PackageScanClassResolver resolver = super.createPackageScanClassResolver();
+ String excluded = System.getProperty(EXCLUDE_ROUTES);
+ if (ObjectHelper.isNotEmpty(excluded)) {
+ Set<Class<?>> excludedClasses = new HashSet<>();
+ for (String str : excluded.split(",")) {
+ excludedClasses.add(getClassResolver().resolveClass(str));
+ }
+ resolver.addFilter(new InvertingPackageScanFilter(new AssignableToPackageScanFilter(excludedClasses)));
+ }
+ return resolver;
+ }
+
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java b/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
index ebf87f1..1a94744 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
@@ -28,6 +28,7 @@ import org.apache.camel.api.management.JmxSystemPropertyKeys;
import org.apache.camel.impl.engine.DefaultPackageScanClassResolver;
import org.apache.camel.impl.scan.AssignableToPackageScanFilter;
import org.apache.camel.impl.scan.InvertingPackageScanFilter;
+import org.apache.camel.util.CollectionStringBuffer;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -48,6 +49,14 @@ public abstract class SpringTestSupport extends ContextTestSupport {
// we want SpringTestSupport to startup faster and not use JMX by default and should stop seda quicker
System.setProperty("CamelSedaPollTimeout", "10");
System.setProperty(JmxSystemPropertyKeys.DISABLED, Boolean.toString(!useJmx()));
+ Class<?>[] excluded = excludeRoutes();
+ if (excluded != null && excluded.length > 0) {
+ CollectionStringBuffer csb = new CollectionStringBuffer(",");
+ for (Class<?> clazz : excluded) {
+ csb.append(clazz.getName());
+ }
+ System.setProperty(SpringCamelContext.EXCLUDE_ROUTES, csb.toString());
+ }
applicationContext = createApplicationContext();
assertNotNull(applicationContext, "Should have created a valid spring context");
diff --git a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelAnnotationsHandler.java b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelAnnotationsHandler.java
index a06b946..23e2b6c 100644
--- a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelAnnotationsHandler.java
+++ b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelAnnotationsHandler.java
@@ -40,11 +40,10 @@ import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.util.CollectionStringBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
-import static org.apache.camel.test.spring.junit5.CamelSpringTestHelper.getAllMethods;
-
public final class CamelAnnotationsHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(CamelAnnotationsHandler.class);
@@ -53,11 +52,37 @@ public final class CamelAnnotationsHandler {
}
/**
- * Handles @ExcludeRoutes to make it easier to exclude other routes when testing with Spring Boot.
+ * Cleanup/restore global state to defaults / pre-test values after the test setup
+ * is complete.
+ *
+ * @param testClass the test class being executed
+ */
+ public static void cleanup(Class<?> testClass) {
+ SpringCamelContext.setNoStart(false);
+
+ if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
+ System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+ } else {
+ System.setProperty(JmxSystemPropertyKeys.DISABLED,
+ CamelSpringTestHelper.getOriginalJmxDisabled());
+ }
+ if (CamelSpringTestHelper.getOriginalExcludeRoutes() == null) {
+ System.clearProperty(SpringCamelContext.EXCLUDE_ROUTES);
+ } else {
+ System.setProperty(SpringCamelContext.EXCLUDE_ROUTES,
+ CamelSpringTestHelper.getOriginalExcludeRoutes());
+ }
+ }
+
+ /**
+ * Handles @ExcludeRoutes to make it easier to exclude other routes when testing with Spring.
*
+ * @param context the initialized Spring context
* @param testClass the test class being executed
*/
- public static void handleExcludeRoutesForSpringBoot(Class<?> testClass) {
+ public static void handleExcludeRoutes(ConfigurableApplicationContext context, Class<?> testClass) {
+ CamelSpringTestHelper.setOriginalExcludeRoutesValue(System.getProperty(SpringCamelContext.EXCLUDE_ROUTES));
+
if (testClass.isAnnotationPresent(ExcludeRoutes.class)) {
Class[] routes = testClass.getAnnotation(ExcludeRoutes.class).value();
// need to setup this as a JVM system property
@@ -65,7 +90,7 @@ public final class CamelAnnotationsHandler {
for (Class clazz : routes) {
csb.append(clazz.getName());
}
- String key = "CamelTestSpringExcludeRoutes";
+ String key = SpringCamelContext.EXCLUDE_ROUTES;
String value = csb.toString();
String exists = System.getProperty(key);
@@ -91,14 +116,17 @@ public final class CamelAnnotationsHandler {
if (testClass.getAnnotation(DisableJmx.class).value()) {
LOGGER.info("Disabling Camel JMX globally as DisableJmx annotation was found and disableJmx is set to true.");
System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
-
} else {
LOGGER.info("Enabling Camel JMX as DisableJmx annotation was found and disableJmx is set to false.");
System.clearProperty(JmxSystemPropertyKeys.DISABLED);
}
- } else {
- LOGGER.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
+ } else if (!testClass.isAnnotationPresent(EnableRouteCoverage.class)) {
+ // route coverage need JMX so do not disable it by default
+ LOGGER.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
+ } else {
+ LOGGER.info("Enabling Camel JMX as EnableRouteCoverage is used.");
+ System.setProperty(JmxSystemPropertyKeys.DISABLED, "false");
}
}
@@ -156,7 +184,7 @@ public final class CamelAnnotationsHandler {
}
public static void handleProvidesBreakpoint(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
+ Collection<Method> methods = CamelSpringTestHelper.getAllMethods(testClass);
final List<Breakpoint> breakpoints = new LinkedList<>();
for (Method method : methods) {
@@ -283,7 +311,7 @@ public final class CamelAnnotationsHandler {
* @param testClass the test class being executed
*/
public static void handleUseOverridePropertiesWithPropertiesComponent(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
+ Collection<Method> methods = CamelSpringTestHelper.getAllMethods(testClass);
final List<Properties> properties = new LinkedList<>();
for (Method method : methods) {
@@ -312,20 +340,23 @@ public final class CamelAnnotationsHandler {
}
}
- if (properties.size() != 0) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new CamelSpringTestHelper.DoToSpringCamelContextsStrategy() {
- public void execute(String contextName, SpringCamelContext camelContext) throws Exception {
- PropertiesComponent pc = camelContext.getPropertiesComponent();
- Properties extra = new Properties();
- for (Properties prop : properties) {
- extra.putAll(prop);
- }
- if (!extra.isEmpty()) {
- LOGGER.info("Using {} properties to override any existing properties on the PropertiesComponent on CamelContext with name [{}].", extra.size(), contextName);
+ Properties extra = new Properties();
+ for (Properties prop : properties) {
+ extra.putAll(prop);
+ }
+
+ if (!extra.isEmpty()) {
+ context.addBeanFactoryPostProcessor(beanFactory -> beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
+ @Override
+ public Object postProcessBeforeInitialization(Object bean, String beanName) {
+ if (bean instanceof PropertiesComponent) {
+ PropertiesComponent pc = (PropertiesComponent) bean;
+ LOGGER.info("Using {} properties to override any existing properties on the PropertiesComponent", extra.size());
pc.setOverrideProperties(extra);
}
+ return bean;
}
- });
+ }));
}
}
diff --git a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringBootExecutionListener.java b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringBootExecutionListener.java
index 898f058..187ec9e 100644
--- a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringBootExecutionListener.java
+++ b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringBootExecutionListener.java
@@ -32,7 +32,7 @@ public class CamelSpringBootExecutionListener extends AbstractTestExecutionListe
/**
* Returns the precedence that is used by Spring to choose the appropriate
* execution order of test listeners.
- *
+ *
* See {@link SpringTestExecutionListenerSorter#getPrecedence(Class)} for more.
*/
@Override
@@ -47,7 +47,8 @@ public class CamelSpringBootExecutionListener extends AbstractTestExecutionListe
Class<?> testClass = testContext.getTestClass();
// need to prepare this before we load spring application context
- CamelAnnotationsHandler.handleExcludeRoutesForSpringBoot(testClass);
+ CamelAnnotationsHandler.handleDisableJmx(null, testClass);
+ CamelAnnotationsHandler.handleExcludeRoutes(null, testClass);
// we are customizing the Camel context with
// CamelAnnotationsHandler so we do not want to start it
@@ -56,7 +57,9 @@ public class CamelSpringBootExecutionListener extends AbstractTestExecutionListe
// not to start it just yet
SpringCamelContext.setNoStart(true);
System.setProperty("skipStartingCamelContext", "true");
- ConfigurableApplicationContext context = (ConfigurableApplicationContext)testContext.getApplicationContext();
+ ConfigurableApplicationContext context = (ConfigurableApplicationContext) testContext.getApplicationContext();
+
+ CamelAnnotationsHandler.handleUseOverridePropertiesWithPropertiesComponent(context, testClass);
// Post CamelContext(s) instantiation but pre CamelContext(s) start
// setup
@@ -64,7 +67,6 @@ public class CamelSpringBootExecutionListener extends AbstractTestExecutionListe
CamelAnnotationsHandler.handleShutdownTimeout(context, testClass);
CamelAnnotationsHandler.handleMockEndpoints(context, testClass);
CamelAnnotationsHandler.handleMockEndpointsAndSkip(context, testClass);
- CamelAnnotationsHandler.handleUseOverridePropertiesWithPropertiesComponent(context, testClass);
System.clearProperty("skipStartingCamelContext");
SpringCamelContext.setNoStart(false);
diff --git a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringBootTest.java b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringBootTest.java
index c915c07..e5ee59c 100644
--- a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringBootTest.java
+++ b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringBootTest.java
@@ -30,8 +30,13 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@ExtendWith(SpringExtension.class)
-@TestExecutionListeners(value = {CamelSpringTestContextLoaderTestExecutionListener.class, DisableJmxTestExecutionListener.class, CamelSpringBootExecutionListener.class,
- StopWatchTestExecutionListener.class}, mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
+@TestExecutionListeners(
+ value = {
+ CamelSpringTestContextLoaderTestExecutionListener.class,
+ CamelSpringBootExecutionListener.class,
+ StopWatchTestExecutionListener.class
+ },
+ mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
public @interface CamelSpringBootTest {
}
diff --git a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTest.java b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTest.java
index 5049a57..5f9bc6e 100644
--- a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTest.java
+++ b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTest.java
@@ -32,8 +32,12 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
@Target({ElementType.TYPE})
@ExtendWith(SpringExtension.class)
@BootstrapWith(CamelTestContextBootstrapper.class)
-@TestExecutionListeners(value = {CamelSpringTestContextLoaderTestExecutionListener.class, DisableJmxTestExecutionListener.class,
- StopWatchTestExecutionListener.class}, mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
+@TestExecutionListeners(
+ value = {
+ CamelSpringTestContextLoaderTestExecutionListener.class,
+ StopWatchTestExecutionListener.class
+ },
+ mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS)
public @interface CamelSpringTest {
}
\ No newline at end of file
diff --git a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestContextLoader.java b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestContextLoader.java
index ff7e5c8..2a62194 100644
--- a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestContextLoader.java
+++ b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestContextLoader.java
@@ -38,6 +38,7 @@ import org.apache.camel.spring.SpringCamelContext;
import org.apache.camel.test.ExcludingPackageScanClassResolver;
import org.apache.camel.test.junit5.CamelTestSupport;
import org.apache.camel.test.spring.junit5.CamelSpringTestHelper.DoToSpringCamelContextsStrategy;
+import org.apache.camel.util.CollectionStringBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanPostProcessor;
@@ -45,6 +46,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
@@ -91,7 +93,7 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
loadBeanDefinitions(context, mergedConfig);
return loadContext(context, testClass);
} finally {
- cleanup(testClass);
+ CamelAnnotationsHandler.cleanup(testClass);
}
}
@@ -110,7 +112,6 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
*/
@Override
public ApplicationContext loadContext(String... locations) throws Exception {
-
Class<?> testClass = getTestClass();
if (LOG.isDebugEnabled()) {
@@ -122,7 +123,7 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
loadBeanDefinitions(context, locations);
return loadContext(context, testClass);
} finally {
- cleanup(testClass);
+ CamelAnnotationsHandler.cleanup(testClass);
}
}
@@ -148,8 +149,9 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
// Pre CamelContext(s) instantiation setup
- handleDisableJmx(context, testClass);
- handleUseOverridePropertiesWithPropertiesComponent(context, testClass);
+ CamelAnnotationsHandler.handleDisableJmx(context, testClass);
+ CamelAnnotationsHandler.handleExcludeRoutes(context, testClass);
+ CamelAnnotationsHandler.handleUseOverridePropertiesWithPropertiesComponent(context, testClass);
// Temporarily disable CamelContext start while the contexts are instantiated.
SpringCamelContext.setNoStart(true);
@@ -159,43 +161,25 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
SpringCamelContext.setNoStart(false);
// Post CamelContext(s) instantiation but pre CamelContext(s) start setup
- handleRouteCoverage(context, testClass);
- handleProvidesBreakpoint(context, testClass);
- handleShutdownTimeout(context, testClass);
- handleMockEndpoints(context, testClass);
- handleMockEndpointsAndSkip(context, testClass);
+ CamelAnnotationsHandler.handleRouteCoverage(context, testClass, s -> getTestMethod().getName());
+ CamelAnnotationsHandler.handleProvidesBreakpoint(context, testClass);
+ CamelAnnotationsHandler.handleShutdownTimeout(context, testClass);
+ CamelAnnotationsHandler.handleMockEndpoints(context, testClass);
+ CamelAnnotationsHandler.handleMockEndpointsAndSkip(context, testClass);
// CamelContext(s) startup
- handleCamelContextStartup(context, testClass);
+ CamelAnnotationsHandler.handleCamelContextStartup(context, testClass);
return context;
}
- /**
- * Cleanup/restore global state to defaults / pre-test values after the test setup
- * is complete.
- *
- * @param testClass the test class being executed
- */
- protected void cleanup(Class<?> testClass) {
- SpringCamelContext.setNoStart(false);
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- } else {
- System.setProperty(JmxSystemPropertyKeys.DISABLED,
- CamelSpringTestHelper.getOriginalJmxDisabled());
- }
- }
- }
-
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
- (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(mergedConfig.getLocations());
+ new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations());
+ new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
}
protected void loadBeanDefinitions(GenericApplicationContext context, String... locations) {
- (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(locations);
+ new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations);
}
/**
@@ -256,279 +240,6 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
}
/**
- * Handles disabling of JMX on Camel contexts based on {@link DisableJmx}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleDisableJmx(GenericApplicationContext context, Class<?> testClass) {
- CamelSpringTestHelper.setOriginalJmxDisabledValue(System.getProperty(JmxSystemPropertyKeys.DISABLED));
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (testClass.getAnnotation(DisableJmx.class).value()) {
- LOG.info("Disabling Camel JMX globally as DisableJmx annotation was found and disableJmx is set to true.");
- System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
- } else {
- LOG.info("Enabling Camel JMX as DisableJmx annotation was found and disableJmx is set to false.");
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- }
- } else if (!testClass.isAnnotationPresent(EnableRouteCoverage.class)) {
- LOG.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
- System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
- } else {
- LOG.info("Enabling Camel JMX as DisableJmx annotation was NOT found but EnableRouteCoverage annotation was found.");
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- }
- }
-
- /**
- * Handles disabling of JMX on Camel contexts based on {@link DisableJmx}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- private void handleRouteCoverage(GenericApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(EnableRouteCoverage.class)) {
- System.setProperty(CamelTestSupport.ROUTE_COVERAGE_ENABLED, "true");
-
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext) throws Exception {
- LOG.info("Enabling RouteCoverage");
- EventNotifier notifier = new RouteCoverageEventNotifier(testClass.getName(), s -> getTestMethod().getName());
- camelContext.addService(notifier, true);
- camelContext.getManagementStrategy().addEventNotifier(notifier);
- }
- });
- }
- }
-
- /**
- * Handles the processing of the {@link ProvidesBreakpoint} annotation on a test class. Exists here
- * as it is needed in
- *
- * @param context the initialized Spring context containing the Camel context(s) to insert breakpoints into
- * @param testClass the test class being processed
- *
- * @throws Exception if there is an error processing the class
- */
- protected void handleProvidesBreakpoint(GenericApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
- final List<Breakpoint> breakpoints = new LinkedList<>();
-
- for (Method method : methods) {
- if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) {
- Class<?>[] argTypes = method.getParameterTypes();
- if (argTypes.length != 0) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not a no-argument method.");
- } else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint.");
- } else if (!Modifier.isStatic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not static.");
- } else if (!Modifier.isPublic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not public.");
- }
-
- try {
- breakpoints.add((Breakpoint) method.invoke(null));
- } catch (Exception e) {
- throw new RuntimeException("Method [" + method.getName()
- + "] threw exception during evaluation.", e);
- }
- }
- }
-
- if (breakpoints.size() != 0) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- Debugger debugger = camelContext.getDebugger();
- if (debugger == null) {
- debugger = new DefaultDebugger();
- camelContext.setDebugger(debugger);
- }
-
- for (Breakpoint breakpoint : breakpoints) {
- LOG.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName);
- debugger.addBreakpoint(breakpoint);
- }
- }
- });
- }
- }
-
-
- /**
- * Handles updating shutdown timeouts on Camel contexts based on {@link ShutdownTimeout}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleShutdownTimeout(GenericApplicationContext context, Class<?> testClass) throws Exception {
- final int shutdownTimeout;
- final TimeUnit shutdownTimeUnit;
- if (testClass.isAnnotationPresent(ShutdownTimeout.class)) {
- shutdownTimeout = testClass.getAnnotation(ShutdownTimeout.class).value();
- shutdownTimeUnit = testClass.getAnnotation(ShutdownTimeout.class).timeUnit();
- } else {
- shutdownTimeout = 10;
- shutdownTimeUnit = TimeUnit.SECONDS;
- }
-
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- LOG.info("Setting shutdown timeout to [{} {}] on CamelContext with name [{}].", shutdownTimeout, shutdownTimeUnit, contextName);
- camelContext.getShutdownStrategy().setTimeout(shutdownTimeout);
- camelContext.getShutdownStrategy().setTimeUnit(shutdownTimeUnit);
- }
- });
- }
-
- /**
- * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpoints}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleMockEndpoints(GenericApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(MockEndpoints.class)) {
- final String mockEndpoints = testClass.getAnnotation(MockEndpoints.class).value();
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- LOG.info("Enabling auto mocking of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
- camelContext.adapt(ExtendedCamelContext.class).registerEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints));
- }
- });
- }
- }
-
- /**
- * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpointsAndSkip} and skipping the
- * original endpoint.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleMockEndpointsAndSkip(GenericApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(MockEndpointsAndSkip.class)) {
- final String mockEndpoints = testClass.getAnnotation(MockEndpointsAndSkip.class).value();
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- // resovle the property place holders of the mockEndpoints
- String mockEndpointsValue = camelContext.resolvePropertyPlaceholders(mockEndpoints);
- LOG.info("Enabling auto mocking and skipping of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpointsValue, contextName);
- camelContext.adapt(ExtendedCamelContext.class).registerEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpointsValue, true));
- }
- });
- }
- }
-
- /**
- * Sets property overrides for the Camel {@link org.apache.camel.component.properties.PropertiesComponent}.
- *
- * @param context the pre-refresh Spring context
- * @param testClass the test class being executed
- */
- protected void handleUseOverridePropertiesWithPropertiesComponent(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
- final List<Properties> properties = new LinkedList<>();
-
- for (Method method : methods) {
- if (AnnotationUtils.findAnnotation(method, UseOverridePropertiesWithPropertiesComponent.class) != null) {
- Class<?>[] argTypes = method.getParameterTypes();
- if (argTypes.length > 0) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with UseOverridePropertiesWithPropertiesComponent but is not a no-argument method.");
- } else if (!Properties.class.isAssignableFrom(method.getReturnType())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with UseOverridePropertiesWithPropertiesComponent but does not return a java.util.Properties.");
- } else if (!Modifier.isStatic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with UseOverridePropertiesWithPropertiesComponent but is not static.");
- } else if (!Modifier.isPublic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with UseOverridePropertiesWithPropertiesComponent but is not public.");
- }
-
- try {
- properties.add((Properties) method.invoke(null));
- } catch (Exception e) {
- throw new RuntimeException("Method [" + method.getName()
- + "] threw exception during evaluation.", e);
- }
- }
- }
-
- Properties extra = new Properties();
- for (Properties prop : properties) {
- extra.putAll(prop);
- }
-
- if (!extra.isEmpty()) {
- context.addBeanFactoryPostProcessor(beanFactory -> beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName) {
- if (bean instanceof PropertiesComponent) {
- PropertiesComponent pc = (PropertiesComponent) bean;
- LOG.info("Using {} properties to override any existing properties on the PropertiesComponent", extra.size());
- pc.setOverrideProperties(extra);
- }
- return bean;
- }
- }));
- }
- }
-
- /**
- * Handles starting of Camel contexts based on {@link UseAdviceWith} and other state in the JVM.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleCamelContextStartup(GenericApplicationContext context, Class<?> testClass) throws Exception {
- boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
- if (skip) {
- LOG.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
- } else if (testClass.isAnnotationPresent(UseAdviceWith.class)) {
- if (testClass.getAnnotation(UseAdviceWith.class).value()) {
- LOG.info("Skipping starting CamelContext(s) as UseAdviceWith annotation was found and isUseAdviceWith is set to true.");
- skip = true;
- } else {
- LOG.info("Starting CamelContext(s) as UseAdviceWith annotation was found, but isUseAdviceWith is set to false.");
- skip = false;
- }
- }
-
- if (!skip) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName,
- SpringCamelContext camelContext) throws Exception {
- LOG.info("Starting CamelContext with name [{}].", contextName);
- camelContext.start();
- }
- });
- }
- }
-
- /**
* Returns the class under test in order to enable inspection of annotations while the
* Spring context is being created.
*
diff --git a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestHelper.java b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestHelper.java
index 8d12f93..e990f41 100644
--- a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestHelper.java
+++ b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/CamelSpringTestHelper.java
@@ -40,6 +40,7 @@ import org.springframework.test.context.TestContext;
public final class CamelSpringTestHelper {
private static ThreadLocal<String> originalJmxDisabledValue = new ThreadLocal<>();
+ private static ThreadLocal<String> originalExcludeRoutesValue = new ThreadLocal<>();
private static ThreadLocal<Class<?>> testClazz = new ThreadLocal<>();
private static ThreadLocal<TestContext> testContext = new ThreadLocal<>();
@@ -53,7 +54,15 @@ public final class CamelSpringTestHelper {
public static void setOriginalJmxDisabledValue(String originalValue) {
originalJmxDisabledValue.set(originalValue);
}
-
+
+ public static String getOriginalExcludeRoutes() {
+ return originalExcludeRoutesValue.get();
+ }
+
+ public static void setOriginalExcludeRoutesValue(String originalValue) {
+ originalExcludeRoutesValue.set(originalValue);
+ }
+
public static Class<?> getTestClass() {
return testClazz.get();
}
diff --git a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/DisableJmxTestExecutionListener.java b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/DisableJmxTestExecutionListener.java
deleted file mode 100644
index 11f85b7..0000000
--- a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/DisableJmxTestExecutionListener.java
+++ /dev/null
@@ -1,50 +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.test.spring.junit5;
-
-import org.apache.camel.api.management.JmxSystemPropertyKeys;
-import org.springframework.test.context.TestContext;
-import org.springframework.test.context.support.AbstractTestExecutionListener;
-
-/**
- * Provides reset to pre-test state behavior for global enable/disable of JMX
- * support in Camel through the use of {@link DisableJmx}. Tries to ensure that
- * the pre-test value is restored.
- */
-public class DisableJmxTestExecutionListener extends AbstractTestExecutionListener {
-
- @Override
- public void afterTestClass(TestContext testContext) throws Exception {
- if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- } else {
- System.setProperty(JmxSystemPropertyKeys.DISABLED, CamelSpringTestHelper.getOriginalJmxDisabled());
- }
- }
-
- /**
- * Returns the precedence that is used by Spring to choose the appropriate
- * execution order of test listeners.
- *
- * See {@link SpringTestExecutionListenerSorter#getPrecedence(Class)} for more.
- */
- @Override
- public int getOrder() {
- return SpringTestExecutionListenerSorter.getPrecedence(getClass());
- }
-
-}
diff --git a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/SpringTestExecutionListenerSorter.java b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/SpringTestExecutionListenerSorter.java
index 94b2c75..cd4526c 100644
--- a/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/SpringTestExecutionListenerSorter.java
+++ b/components/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/SpringTestExecutionListenerSorter.java
@@ -22,8 +22,6 @@ import org.springframework.core.Ordered;
* This class centralizes the order of execution of spring test execution listeners:
* <ol>
* <li>{@link CamelSpringTestContextLoaderTestExecutionListener}</li>
- * <li>{@link DisableJmxTestExecutionListener}</li>
- * <li>{@link CamelSpringBootExecutionListener}</li>
* <li>{@link StopWatchTestExecutionListener}</li>
* <li>Spring default listeners</li>
* </ol>
@@ -38,8 +36,6 @@ public final class SpringTestExecutionListenerSorter {
return Ordered.HIGHEST_PRECEDENCE + 4000;
} else if (clazz == CamelSpringBootExecutionListener.class) {
return Ordered.HIGHEST_PRECEDENCE + 3000;
- } else if (clazz == DisableJmxTestExecutionListener.class) {
- return Ordered.HIGHEST_PRECEDENCE + 2000;
} else if (clazz == CamelSpringTestContextLoaderTestExecutionListener.class) {
return Ordered.HIGHEST_PRECEDENCE + 1000;
}
diff --git a/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/spring/SpringTestExecutionListenerSorterTest.java b/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/spring/SpringTestExecutionListenerSorterTest.java
index f39542d..b73f886 100644
--- a/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/spring/SpringTestExecutionListenerSorterTest.java
+++ b/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/spring/SpringTestExecutionListenerSorterTest.java
@@ -19,9 +19,7 @@ package org.apache.camel.test.spring;
import java.util.ArrayList;
import java.util.List;
-import org.apache.camel.test.spring.junit5.CamelSpringBootExecutionListener;
import org.apache.camel.test.spring.junit5.CamelSpringTestContextLoaderTestExecutionListener;
-import org.apache.camel.test.spring.junit5.DisableJmxTestExecutionListener;
import org.apache.camel.test.spring.junit5.StopWatchTestExecutionListener;
import org.junit.jupiter.api.Test;
@@ -36,8 +34,6 @@ public class SpringTestExecutionListenerSorterTest {
List<Class<?>> listenersInExpectedOrder = new ArrayList<>();
listenersInExpectedOrder.add(CamelSpringTestContextLoaderTestExecutionListener.class);
- listenersInExpectedOrder.add(DisableJmxTestExecutionListener.class);
- listenersInExpectedOrder.add(CamelSpringBootExecutionListener.class);
listenersInExpectedOrder.add(StopWatchTestExecutionListener.class);
List<Class<?>> listenersSortedByPrecedence = new ArrayList<>(listenersInExpectedOrder);
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelAnnotationsHandler.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelAnnotationsHandler.java
index 92bbc11..faf1a3b 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelAnnotationsHandler.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelAnnotationsHandler.java
@@ -40,11 +40,10 @@ import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.util.CollectionStringBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
-import static org.apache.camel.test.spring.CamelSpringTestHelper.getAllMethods;
-
public final class CamelAnnotationsHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(CamelAnnotationsHandler.class);
@@ -53,11 +52,37 @@ public final class CamelAnnotationsHandler {
}
/**
- * Handles @ExcludeRoutes to make it easier to exclude other routes when testing with Spring Boot.
+ * Cleanup/restore global state to defaults / pre-test values after the test setup
+ * is complete.
+ *
+ * @param testClass the test class being executed
+ */
+ public static void cleanup(Class<?> testClass) {
+ SpringCamelContext.setNoStart(false);
+
+ if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
+ System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+ } else {
+ System.setProperty(JmxSystemPropertyKeys.DISABLED,
+ CamelSpringTestHelper.getOriginalJmxDisabled());
+ }
+ if (CamelSpringTestHelper.getOriginalExcludeRoutes() == null) {
+ System.clearProperty(SpringCamelContext.EXCLUDE_ROUTES);
+ } else {
+ System.setProperty(SpringCamelContext.EXCLUDE_ROUTES,
+ CamelSpringTestHelper.getOriginalExcludeRoutes());
+ }
+ }
+
+ /**
+ * Handles @ExcludeRoutes to make it easier to exclude other routes when testing with Spring.
*
+ * @param context the initialized Spring context
* @param testClass the test class being executed
*/
- public static void handleExcludeRoutesForSpringBoot(Class<?> testClass) {
+ public static void handleExcludeRoutes(ConfigurableApplicationContext context, Class<?> testClass) {
+ CamelSpringTestHelper.setOriginalExcludeRoutesValue(System.getProperty(SpringCamelContext.EXCLUDE_ROUTES));
+
if (testClass.isAnnotationPresent(ExcludeRoutes.class)) {
Class[] routes = testClass.getAnnotation(ExcludeRoutes.class).value();
// need to setup this as a JVM system property
@@ -65,7 +90,7 @@ public final class CamelAnnotationsHandler {
for (Class clazz : routes) {
csb.append(clazz.getName());
}
- String key = "CamelTestSpringExcludeRoutes";
+ String key = SpringCamelContext.EXCLUDE_ROUTES;
String value = csb.toString();
String exists = System.getProperty(key);
@@ -91,14 +116,17 @@ public final class CamelAnnotationsHandler {
if (testClass.getAnnotation(DisableJmx.class).value()) {
LOGGER.info("Disabling Camel JMX globally as DisableJmx annotation was found and disableJmx is set to true.");
System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
-
} else {
LOGGER.info("Enabling Camel JMX as DisableJmx annotation was found and disableJmx is set to false.");
System.clearProperty(JmxSystemPropertyKeys.DISABLED);
}
- } else {
- LOGGER.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
+ } else if (!testClass.isAnnotationPresent(EnableRouteCoverage.class)) {
+ // route coverage need JMX so do not disable it by default
+ LOGGER.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
+ } else {
+ LOGGER.info("Enabling Camel JMX as EnableRouteCoverage is used.");
+ System.setProperty(JmxSystemPropertyKeys.DISABLED, "false");
}
}
@@ -156,7 +184,7 @@ public final class CamelAnnotationsHandler {
}
public static void handleProvidesBreakpoint(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
+ Collection<Method> methods = CamelSpringTestHelper.getAllMethods(testClass);
final List<Breakpoint> breakpoints = new LinkedList<>();
for (Method method : methods) {
@@ -283,7 +311,7 @@ public final class CamelAnnotationsHandler {
* @param testClass the test class being executed
*/
public static void handleUseOverridePropertiesWithPropertiesComponent(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
+ Collection<Method> methods = CamelSpringTestHelper.getAllMethods(testClass);
final List<Properties> properties = new LinkedList<>();
for (Method method : methods) {
@@ -312,20 +340,23 @@ public final class CamelAnnotationsHandler {
}
}
- if (properties.size() != 0) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new CamelSpringTestHelper.DoToSpringCamelContextsStrategy() {
- public void execute(String contextName, SpringCamelContext camelContext) throws Exception {
- PropertiesComponent pc = camelContext.getPropertiesComponent();
- Properties extra = new Properties();
- for (Properties prop : properties) {
- extra.putAll(prop);
- }
- if (!extra.isEmpty()) {
- LOGGER.info("Using {} properties to override any existing properties on the PropertiesComponent on CamelContext with name [{}].", extra.size(), contextName);
+ Properties extra = new Properties();
+ for (Properties prop : properties) {
+ extra.putAll(prop);
+ }
+
+ if (!extra.isEmpty()) {
+ context.addBeanFactoryPostProcessor(beanFactory -> beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
+ @Override
+ public Object postProcessBeforeInitialization(Object bean, String beanName) {
+ if (bean instanceof PropertiesComponent) {
+ PropertiesComponent pc = (PropertiesComponent) bean;
+ LOGGER.info("Using {} properties to override any existing properties on the PropertiesComponent", extra.size());
pc.setOverrideProperties(extra);
}
+ return bean;
}
- });
+ }));
}
}
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootExecutionListener.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootExecutionListener.java
deleted file mode 100644
index 9b59ba8..0000000
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootExecutionListener.java
+++ /dev/null
@@ -1,95 +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.test.spring;
-
-import org.apache.camel.spring.SpringCamelContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.test.context.TestContext;
-import org.springframework.test.context.support.AbstractTestExecutionListener;
-
-public class CamelSpringBootExecutionListener extends AbstractTestExecutionListener {
-
- protected static ThreadLocal<ConfigurableApplicationContext> threadApplicationContext = new ThreadLocal<>();
-
- private static final Logger LOG = LoggerFactory.getLogger(CamelSpringBootExecutionListener.class);
-
- @Override
- public void prepareTestInstance(TestContext testContext) throws Exception {
- LOG.info("@RunWith(CamelSpringBootRunner.class) preparing: {}", testContext.getTestClass());
-
- Class<?> testClass = testContext.getTestClass();
-
- // need to prepare this before we load spring application context
- CamelAnnotationsHandler.handleExcludeRoutesForSpringBoot(testClass);
-
- // we are customizing the Camel context with
- // CamelAnnotationsHandler so we do not want to start it
- // automatically, which would happen when SpringCamelContext
- // is added to Spring ApplicationContext, so we set the flag
- // not to start it just yet
- SpringCamelContext.setNoStart(true);
- System.setProperty("skipStartingCamelContext", "true");
- ConfigurableApplicationContext context = (ConfigurableApplicationContext) testContext.getApplicationContext();
-
- // Post CamelContext(s) instantiation but pre CamelContext(s) start setup
- CamelAnnotationsHandler.handleProvidesBreakpoint(context, testClass);
- CamelAnnotationsHandler.handleShutdownTimeout(context, testClass);
- CamelAnnotationsHandler.handleMockEndpoints(context, testClass);
- CamelAnnotationsHandler.handleMockEndpointsAndSkip(context, testClass);
- CamelAnnotationsHandler.handleUseOverridePropertiesWithPropertiesComponent(context, testClass);
-
- System.clearProperty("skipStartingCamelContext");
- SpringCamelContext.setNoStart(false);
- }
-
- @Override
- public void beforeTestMethod(TestContext testContext) throws Exception {
- LOG.info("@RunWith(CamelSpringBootRunner.class) before: {}.{}", testContext.getTestClass(), testContext.getTestMethod().getName());
-
- Class<?> testClass = testContext.getTestClass();
- String testName = testContext.getTestMethod().getName();
-
- ConfigurableApplicationContext context = (ConfigurableApplicationContext) testContext.getApplicationContext();
- threadApplicationContext.set(context);
-
- // mark Camel to be startable again and start Camel
- System.clearProperty("skipStartingCamelContext");
-
- // route coverage need to know the test method
- CamelAnnotationsHandler.handleRouteCoverage(context, testClass, s -> testName);
-
- LOG.info("Initialized CamelSpringBootRunner now ready to start CamelContext");
- CamelAnnotationsHandler.handleCamelContextStartup(context, testClass);
- }
-
- @Override
- public void afterTestMethod(TestContext testContext) throws Exception {
- LOG.info("@RunWith(CamelSpringBootRunner.class) after: {}.{}", testContext.getTestClass(), testContext.getTestMethod().getName());
-
- Class<?> testClass = testContext.getTestClass();
- String testName = testContext.getTestMethod().getName();
-
- ConfigurableApplicationContext context = threadApplicationContext.get();
- if (context != null && context.isRunning()) {
- // dump route coverage for each test method so its accurate statistics
- // even if spring application context is running (i.e. its not dirtied per test method)
- CamelAnnotationsHandler.handleRouteCoverageDump(context, testClass, s -> testName);
- }
- }
-}
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootRunner.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootRunner.java
index d499bb8..dd80e82 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootRunner.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringBootRunner.java
@@ -29,59 +29,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* for their Spring Boot based applications/routes using the typical Spring Test conventions
* for test development.
*/
-public class CamelSpringBootRunner extends SpringJUnit4ClassRunner {
+public class CamelSpringBootRunner extends CamelSpringRunner {
public CamelSpringBootRunner(Class<?> clazz) throws InitializationError {
super(clazz);
}
- /**
- * Returns the specialized manager instance that provides tight integration between Camel testing
- * features and Spring.
- *
- * @return a new instance of {@link CamelTestContextManager}.
- */
- @Override
- protected TestContextManager createTestContextManager(Class<?> clazz) {
- return new CamelTestContextManager(clazz);
- }
-
- /**
- * An implementation providing additional integration between Spring Test and Camel
- * testing features.
- */
- public static final class CamelTestContextManager extends TestContextManager {
-
- public CamelTestContextManager(Class<?> testClass) {
- super(testClass);
-
- // turn off auto starting spring as we need to do this later
- System.setProperty("skipStartingCamelContext", "true");
-
- // is Camel already registered
- if (!alreadyRegistered()) {
- // inject Camel first, and then disable jmx and add the stop-watch
- List<TestExecutionListener> list = getTestExecutionListeners();
- list.add(0, new CamelSpringTestContextLoaderTestExecutionListener());
- list.add(1, new DisableJmxTestExecutionListener());
- list.add(2, new CamelSpringBootExecutionListener());
- list.add(3, new StopWatchTestExecutionListener());
- }
- }
-
- private boolean alreadyRegistered() {
- List<TestExecutionListener> list = getTestExecutionListeners();
- if (list != null) {
- for (TestExecutionListener listener : list) {
- if (listener instanceof CamelSpringTestContextLoaderTestExecutionListener) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- }
-
}
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
index 3c22382..2fd7904 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringDelegatingTestContextLoader.java
@@ -63,7 +63,7 @@ public class CamelSpringDelegatingTestContextLoader extends DelegatingSmartConte
System.clearProperty("skipStartingCamelContext");
return loadContext(context, testClass);
} finally {
- cleanup(testClass);
+ CamelAnnotationsHandler.cleanup(testClass);
}
}
@@ -94,25 +94,6 @@ public class CamelSpringDelegatingTestContextLoader extends DelegatingSmartConte
return context;
}
-
- /**
- * Cleanup/restore global state to defaults / pre-test values after the test setup
- * is complete.
- *
- * @param testClass the test class being executed
- */
- protected void cleanup(Class<?> testClass) {
- SpringCamelContext.setNoStart(false);
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- } else {
- System.setProperty(JmxSystemPropertyKeys.DISABLED,
- CamelSpringTestHelper.getOriginalJmxDisabled());
- }
- }
- }
/**
* Returns the class under test in order to enable inspection of annotations while the
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringRunner.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringRunner.java
index 9f2569a..2753561 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringRunner.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringRunner.java
@@ -19,9 +19,14 @@ package org.apache.camel.test.spring;
import java.util.List;
import org.junit.runners.model.InitializationError;
+import org.springframework.test.context.BootstrapContext;
+import org.springframework.test.context.CacheAwareContextLoaderDelegate;
+import org.springframework.test.context.TestContextBootstrapper;
import org.springframework.test.context.TestContextManager;
import org.springframework.test.context.TestExecutionListener;
+import org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.DefaultBootstrapContext;
/**
* An implementation bringing the functionality of {@link org.apache.camel.test.spring.CamelSpringTestSupport} to
@@ -53,18 +58,25 @@ public class CamelSpringRunner extends SpringJUnit4ClassRunner {
public static final class CamelTestContextManager extends TestContextManager {
public CamelTestContextManager(Class<?> testClass) {
- super(testClass);
+ super(createTestContextBootstrapper(testClass));
// is Camel already registered
if (!alreadyRegistered()) {
// inject Camel first, and then disable jmx and add the stop-watch
List<TestExecutionListener> list = getTestExecutionListeners();
list.add(0, new CamelSpringTestContextLoaderTestExecutionListener());
- list.add(1, new DisableJmxTestExecutionListener());
- list.add(2, new StopWatchTestExecutionListener());
+ list.add(1, new StopWatchTestExecutionListener());
}
}
+ static TestContextBootstrapper createTestContextBootstrapper(Class<?> testClass) {
+ CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate = new DefaultCacheAwareContextLoaderDelegate();
+ BootstrapContext bootstrapContext = new DefaultBootstrapContext(testClass, cacheAwareContextLoaderDelegate);
+ TestContextBootstrapper testContextBootstrapper = new CamelTestContextBootstrapper();
+ testContextBootstrapper.setBootstrapContext(bootstrapContext);
+ return testContextBootstrapper;
+ }
+
private boolean alreadyRegistered() {
List<TestExecutionListener> list = getTestExecutionListeners();
if (list != null) {
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
index f408fd0..9ca04e3 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
@@ -38,6 +38,7 @@ import org.apache.camel.spring.SpringCamelContext;
import org.apache.camel.test.ExcludingPackageScanClassResolver;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.test.spring.CamelSpringTestHelper.DoToSpringCamelContextsStrategy;
+import org.apache.camel.util.CollectionStringBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanPostProcessor;
@@ -45,6 +46,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
@@ -91,7 +93,7 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
loadBeanDefinitions(context, mergedConfig);
return loadContext(context, testClass);
} finally {
- cleanup(testClass);
+ CamelAnnotationsHandler.cleanup(testClass);
}
}
@@ -110,7 +112,6 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
*/
@Override
public ApplicationContext loadContext(String... locations) throws Exception {
-
Class<?> testClass = getTestClass();
if (LOG.isDebugEnabled()) {
@@ -122,7 +123,7 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
loadBeanDefinitions(context, locations);
return loadContext(context, testClass);
} finally {
- cleanup(testClass);
+ CamelAnnotationsHandler.cleanup(testClass);
}
}
@@ -148,8 +149,9 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
// Pre CamelContext(s) instantiation setup
- handleDisableJmx(context, testClass);
- handleUseOverridePropertiesWithPropertiesComponent(context, testClass);
+ CamelAnnotationsHandler.handleDisableJmx(context, testClass);
+ CamelAnnotationsHandler.handleExcludeRoutes(context, testClass);
+ CamelAnnotationsHandler.handleUseOverridePropertiesWithPropertiesComponent(context, testClass);
// Temporarily disable CamelContext start while the contexts are instantiated.
SpringCamelContext.setNoStart(true);
@@ -159,43 +161,25 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
SpringCamelContext.setNoStart(false);
// Post CamelContext(s) instantiation but pre CamelContext(s) start setup
- handleRouteCoverage(context, testClass);
- handleProvidesBreakpoint(context, testClass);
- handleShutdownTimeout(context, testClass);
- handleMockEndpoints(context, testClass);
- handleMockEndpointsAndSkip(context, testClass);
+ CamelAnnotationsHandler.handleRouteCoverage(context, testClass, s -> getTestMethod().getName());
+ CamelAnnotationsHandler.handleProvidesBreakpoint(context, testClass);
+ CamelAnnotationsHandler.handleShutdownTimeout(context, testClass);
+ CamelAnnotationsHandler.handleMockEndpoints(context, testClass);
+ CamelAnnotationsHandler.handleMockEndpointsAndSkip(context, testClass);
// CamelContext(s) startup
- handleCamelContextStartup(context, testClass);
+ CamelAnnotationsHandler.handleCamelContextStartup(context, testClass);
return context;
}
-
- /**
- * Cleanup/restore global state to defaults / pre-test values after the test setup
- * is complete.
- *
- * @param testClass the test class being executed
- */
- protected void cleanup(Class<?> testClass) {
- SpringCamelContext.setNoStart(false);
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- } else {
- System.setProperty(JmxSystemPropertyKeys.DISABLED,
- CamelSpringTestHelper.getOriginalJmxDisabled());
- }
- }
- }
-
+
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
- (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(mergedConfig.getLocations());
+ new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations());
+ new AnnotatedBeanDefinitionReader(context).register(mergedConfig.getClasses());
}
protected void loadBeanDefinitions(GenericApplicationContext context, String... locations) {
- (new XmlBeanDefinitionReader(context)).loadBeanDefinitions(locations);
+ new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations);
}
/**
@@ -239,7 +223,7 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
}
}
}
-
+
GenericApplicationContext context;
if (routeExcludingContext != null) {
@@ -254,279 +238,8 @@ public class CamelSpringTestContextLoader extends AbstractContextLoader {
return context;
}
-
- /**
- * Handles disabling of JMX on Camel contexts based on {@link DisableJmx}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleDisableJmx(GenericApplicationContext context, Class<?> testClass) {
- CamelSpringTestHelper.setOriginalJmxDisabledValue(System.getProperty(JmxSystemPropertyKeys.DISABLED));
-
- if (testClass.isAnnotationPresent(DisableJmx.class)) {
- if (testClass.getAnnotation(DisableJmx.class).value()) {
- LOG.info("Disabling Camel JMX globally as DisableJmx annotation was found and disableJmx is set to true.");
- System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
- } else {
- LOG.info("Enabling Camel JMX as DisableJmx annotation was found and disableJmx is set to false.");
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- }
- } else if (!testClass.isAnnotationPresent(EnableRouteCoverage.class)) {
- // route coverage need JMX so do not disable it by default
- LOG.info("Disabling Camel JMX globally for tests by default. Use the DisableJMX annotation to override the default setting.");
- System.setProperty(JmxSystemPropertyKeys.DISABLED, "true");
- }
- }
-
- /**
- * Handles disabling of JMX on Camel contexts based on {@link DisableJmx}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- private void handleRouteCoverage(GenericApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(EnableRouteCoverage.class)) {
- System.setProperty(CamelTestSupport.ROUTE_COVERAGE_ENABLED, "true");
-
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext) throws Exception {
- LOG.info("Enabling RouteCoverage");
- EventNotifier notifier = new RouteCoverageEventNotifier(testClass.getName(), s -> getTestMethod().getName());
- camelContext.addService(notifier, true);
- camelContext.getManagementStrategy().addEventNotifier(notifier);
- }
- });
- }
- }
-
- /**
- * Handles the processing of the {@link ProvidesBreakpoint} annotation on a test class. Exists here
- * as it is needed in
- *
- * @param context the initialized Spring context containing the Camel context(s) to insert breakpoints into
- * @param testClass the test class being processed
- *
- * @throws Exception if there is an error processing the class
- */
- protected void handleProvidesBreakpoint(GenericApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
- final List<Breakpoint> breakpoints = new LinkedList<>();
-
- for (Method method : methods) {
- if (AnnotationUtils.findAnnotation(method, ProvidesBreakpoint.class) != null) {
- Class<?>[] argTypes = method.getParameterTypes();
- if (argTypes.length != 0) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not a no-argument method.");
- } else if (!Breakpoint.class.isAssignableFrom(method.getReturnType())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but does not return a Breakpoint.");
- } else if (!Modifier.isStatic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not static.");
- } else if (!Modifier.isPublic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with ProvidesBreakpoint but is not public.");
- }
-
- try {
- breakpoints.add((Breakpoint) method.invoke(null));
- } catch (Exception e) {
- throw new RuntimeException("Method [" + method.getName()
- + "] threw exception during evaluation.", e);
- }
- }
- }
-
- if (breakpoints.size() != 0) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- Debugger debugger = camelContext.getDebugger();
- if (debugger == null) {
- debugger = new DefaultDebugger();
- camelContext.setDebugger(debugger);
- }
-
- for (Breakpoint breakpoint : breakpoints) {
- LOG.info("Adding Breakpoint [{}] to CamelContext with name [{}].", breakpoint, contextName);
- debugger.addBreakpoint(breakpoint);
- }
- }
- });
- }
- }
-
-
- /**
- * Handles updating shutdown timeouts on Camel contexts based on {@link ShutdownTimeout}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleShutdownTimeout(GenericApplicationContext context, Class<?> testClass) throws Exception {
- final int shutdownTimeout;
- final TimeUnit shutdownTimeUnit;
- if (testClass.isAnnotationPresent(ShutdownTimeout.class)) {
- shutdownTimeout = testClass.getAnnotation(ShutdownTimeout.class).value();
- shutdownTimeUnit = testClass.getAnnotation(ShutdownTimeout.class).timeUnit();
- } else {
- shutdownTimeout = 10;
- shutdownTimeUnit = TimeUnit.SECONDS;
- }
-
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- LOG.info("Setting shutdown timeout to [{} {}] on CamelContext with name [{}].", shutdownTimeout, shutdownTimeUnit, contextName);
- camelContext.getShutdownStrategy().setTimeout(shutdownTimeout);
- camelContext.getShutdownStrategy().setTimeUnit(shutdownTimeUnit);
- }
- });
- }
-
- /**
- * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpoints}.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleMockEndpoints(GenericApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(MockEndpoints.class)) {
- final String mockEndpoints = testClass.getAnnotation(MockEndpoints.class).value();
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- LOG.info("Enabling auto mocking of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpoints, contextName);
- camelContext.adapt(ExtendedCamelContext.class).registerEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpoints));
- }
- });
- }
- }
-
- /**
- * Handles auto-intercepting of endpoints with mocks based on {@link MockEndpointsAndSkip} and skipping the
- * original endpoint.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleMockEndpointsAndSkip(GenericApplicationContext context, Class<?> testClass) throws Exception {
- if (testClass.isAnnotationPresent(MockEndpointsAndSkip.class)) {
- final String mockEndpoints = testClass.getAnnotation(MockEndpointsAndSkip.class).value();
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName, SpringCamelContext camelContext)
- throws Exception {
- // resovle the property place holders of the mockEndpoints
- String mockEndpointsValue = camelContext.resolvePropertyPlaceholders(mockEndpoints);
- LOG.info("Enabling auto mocking and skipping of endpoints matching pattern [{}] on CamelContext with name [{}].", mockEndpointsValue, contextName);
- camelContext.adapt(ExtendedCamelContext.class).registerEndpointCallback(new InterceptSendToMockEndpointStrategy(mockEndpointsValue, true));
- }
- });
- }
- }
-
- /**
- * Sets property overrides for the Camel {@link org.apache.camel.component.properties.PropertiesComponent}.
- *
- * @param context the pre-refresh Spring context
- * @param testClass the test class being executed
- */
- protected void handleUseOverridePropertiesWithPropertiesComponent(ConfigurableApplicationContext context, Class<?> testClass) throws Exception {
- Collection<Method> methods = getAllMethods(testClass);
- final List<Properties> properties = new LinkedList<>();
-
- for (Method method : methods) {
- if (AnnotationUtils.findAnnotation(method, UseOverridePropertiesWithPropertiesComponent.class) != null) {
- Class<?>[] argTypes = method.getParameterTypes();
- if (argTypes.length > 0) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with UseOverridePropertiesWithPropertiesComponent but is not a no-argument method.");
- } else if (!Properties.class.isAssignableFrom(method.getReturnType())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with UseOverridePropertiesWithPropertiesComponent but does not return a java.util.Properties.");
- } else if (!Modifier.isStatic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with UseOverridePropertiesWithPropertiesComponent but is not static.");
- } else if (!Modifier.isPublic(method.getModifiers())) {
- throw new IllegalArgumentException("Method [" + method.getName()
- + "] is annotated with UseOverridePropertiesWithPropertiesComponent but is not public.");
- }
-
- try {
- properties.add((Properties) method.invoke(null));
- } catch (Exception e) {
- throw new RuntimeException("Method [" + method.getName()
- + "] threw exception during evaluation.", e);
- }
- }
- }
-
- Properties extra = new Properties();
- for (Properties prop : properties) {
- extra.putAll(prop);
- }
-
- if (!extra.isEmpty()) {
- context.addBeanFactoryPostProcessor(beanFactory -> beanFactory.addBeanPostProcessor(new BeanPostProcessor() {
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName) {
- if (bean instanceof PropertiesComponent) {
- PropertiesComponent pc = (PropertiesComponent) bean;
- LOG.info("Using {} properties to override any existing properties on the PropertiesComponent", extra.size());
- pc.setOverrideProperties(extra);
- }
- return bean;
- }
- }));
- }
- }
/**
- * Handles starting of Camel contexts based on {@link UseAdviceWith} and other state in the JVM.
- *
- * @param context the initialized Spring context
- * @param testClass the test class being executed
- */
- protected void handleCamelContextStartup(GenericApplicationContext context, Class<?> testClass) throws Exception {
- boolean skip = "true".equalsIgnoreCase(System.getProperty("skipStartingCamelContext"));
- if (skip) {
- LOG.info("Skipping starting CamelContext(s) as system property skipStartingCamelContext is set to be true.");
- } else if (testClass.isAnnotationPresent(UseAdviceWith.class)) {
- if (testClass.getAnnotation(UseAdviceWith.class).value()) {
- LOG.info("Skipping starting CamelContext(s) as UseAdviceWith annotation was found and isUseAdviceWith is set to true.");
- skip = true;
- } else {
- LOG.info("Starting CamelContext(s) as UseAdviceWith annotation was found, but isUseAdviceWith is set to false.");
- skip = false;
- }
- }
-
- if (!skip) {
- CamelSpringTestHelper.doToSpringCamelContexts(context, new DoToSpringCamelContextsStrategy() {
-
- @Override
- public void execute(String contextName,
- SpringCamelContext camelContext) throws Exception {
- LOG.info("Starting CamelContext with name [{}].", contextName);
- camelContext.start();
- }
- });
- }
- }
-
- /**
* Returns the class under test in order to enable inspection of annotations while the
* Spring context is being created.
*
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
index 4418b15..b4db697 100644
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
+++ b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestHelper.java
@@ -38,22 +38,31 @@ import org.springframework.test.context.TestContext;
* for this class to work right.
*/
public final class CamelSpringTestHelper {
-
+
private static ThreadLocal<String> originalJmxDisabledValue = new ThreadLocal<>();
+ private static ThreadLocal<String> originalExcludeRoutesValue = new ThreadLocal<>();
private static ThreadLocal<Class<?>> testClazz = new ThreadLocal<>();
private static ThreadLocal<TestContext> testContext = new ThreadLocal<>();
private CamelSpringTestHelper() {
}
-
+
public static String getOriginalJmxDisabled() {
return originalJmxDisabledValue.get();
}
-
+
public static void setOriginalJmxDisabledValue(String originalValue) {
originalJmxDisabledValue.set(originalValue);
}
-
+
+ public static String getOriginalExcludeRoutes() {
+ return originalExcludeRoutesValue.get();
+ }
+
+ public static void setOriginalExcludeRoutesValue(String originalValue) {
+ originalExcludeRoutesValue.set(originalValue);
+ }
+
public static Class<?> getTestClass() {
return testClazz.get();
}
diff --git a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java b/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
deleted file mode 100644
index cc04c96..0000000
--- a/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/DisableJmxTestExecutionListener.java
+++ /dev/null
@@ -1,39 +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.test.spring;
-
-import org.apache.camel.api.management.JmxSystemPropertyKeys;
-import org.springframework.test.context.TestContext;
-import org.springframework.test.context.support.AbstractTestExecutionListener;
-
-/**
- * Provides reset to pre-test state behavior for global enable/disable of JMX
- * support in Camel through the use of {@link DisableJmx}.
- * Tries to ensure that the pre-test value is restored.
- */
-public class DisableJmxTestExecutionListener extends AbstractTestExecutionListener {
-
- @Override
- public void afterTestClass(TestContext testContext) throws Exception {
- if (CamelSpringTestHelper.getOriginalJmxDisabled() == null) {
- System.clearProperty(JmxSystemPropertyKeys.DISABLED);
- } else {
- System.setProperty(JmxSystemPropertyKeys.DISABLED, CamelSpringTestHelper.getOriginalJmxDisabled());
- }
- }
-
-}
[camel] 07/07: [CAMEL-11807] Fix checkstyle
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 089089397f2d18acdd448013b7ea0c3382cb441d
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Jun 19 09:48:29 2020 +0200
[CAMEL-11807] Fix checkstyle
---
.../servlet/HttpClientRouteExampleSpringTest.java | 15 ++--
.../component/servlet/HttpClientRouteTest.java | 57 +++++++-------
.../servlet/MultiServletConsumerTest.java | 5 +-
.../camel/component/servlet/ServletAsyncTest.java | 8 +-
.../servlet/ServletCamelRouterTestSupport.java | 88 +++++++++++-----------
.../component/servlet/ServletChoiceBeanTest.java | 10 +--
.../servlet/ServletMuteExceptionTest.java | 15 ++--
.../servlet/ServletNoSlashNeededTest.java | 7 +-
.../component/servlet/ServletRootPathTest.java | 7 +-
.../component/servlet/ServletSetBodyTest.java | 7 +-
.../ServletSetExchangePropertyBeanTest.java | 7 +-
.../servlet/ServletSwitchingStatusCode204Test.java | 15 ++--
.../servlet/ServletTransferExceptionTest.java | 7 +-
.../servlet/rest/RestApiMatchUriServletTest.java | 7 +-
.../RestServletBindingModeAutoWithJsonTest.java | 7 +-
.../RestServletBindingModeAutoWithXmlTest.java | 8 +-
.../rest/RestServletBindingModeJsonTest.java | 15 ++--
...RestServletBindingModeJsonWithContractTest.java | 10 +--
.../RestServletBindingModeOffWithContractTest.java | 10 +--
.../rest/RestServletBindingModeXmlTest.java | 15 ++--
.../component/servlet/rest/RestServletGetTest.java | 7 +-
.../servlet/rest/RestServletGetWildcardsTest.java | 13 +---
.../rest/RestServletMethodNotAllowedTest.java | 7 +-
.../servlet/rest/RestServletOptionsTest.java | 17 ++---
.../servlet/rest/RestServletPojoInOutTest.java | 20 ++---
.../rest/RestServletPostJsonJaxbPojoTest.java | 8 +-
.../rest/RestServletPostJsonPojoListTest.java | 8 +-
.../servlet/rest/RestServletPostJsonPojoTest.java | 8 +-
.../rest/RestServletPostXmlJaxbPojoTest.java | 15 ++--
.../servlet/rest/RestServletVerbTest.java | 33 +++-----
30 files changed, 192 insertions(+), 264 deletions(-)
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
index d6a5dff..b1fa756 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteExampleSpringTest.java
@@ -27,17 +27,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class HttpClientRouteExampleSpringTest extends ServletCamelRouterTestSupport {
@Test
public void testHttpRestricMethod() throws Exception {
-
- ServletUnitClient client = newClient();
+
// Send a web get method request
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
- WebResponse response = client.getResponse(req);
-
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/hello");
+ WebResponse response = query(req);
+
assertEquals("OK", response.getResponseMessage(), "Get a wrong response message.");
assertEquals("Add a name parameter to uri, eg ?name=foo", response.getText(), "Get a wrong response text.");
-
- req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello?name=Willem");
- response = client.getResponse(req);
+
+ req = new GetMethodWebRequest(contextUrl + "/services/hello?name=Willem");
+ response = query(req);
assertEquals("Hello Willem how are you?", response.getText(), "Get a wrong response text.");
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
index 64d2507..878390a 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/HttpClientRouteTest.java
@@ -39,70 +39,67 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
@Test
public void testHttpClient() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/hello", new ByteArrayInputStream(POST_DATA.getBytes()), CONTENT_TYPE);
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/hello",
+ new ByteArrayInputStream(POST_DATA.getBytes()), CONTENT_TYPE);
+ WebResponse response = query(req);
assertEquals("text/xml", response.getContentType(), "Get wrong content type");
assertTrue("UTF-8".equalsIgnoreCase(response.getCharacterSet()));
assertEquals("/hello", response.getHeaderField("PATH"), "Get a wrong message header");
assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
- req = new PostMethodWebRequest(CONTEXT_URL + "/services/helloworld", new ByteArrayInputStream(POST_DATA.getBytes()), CONTENT_TYPE);
- response = client.getResponse(req);
+ req = new PostMethodWebRequest(contextUrl + "/services/helloworld",
+ new ByteArrayInputStream(POST_DATA.getBytes()), CONTENT_TYPE);
+ response = query(req);
assertEquals("text/xml", response.getContentType(), "Get wrong content type");
assertTrue("UTF-8".equalsIgnoreCase(response.getCharacterSet()));
assertEquals("/helloworld", response.getHeaderField("PATH"), "Get a wrong message header");
assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
- client.setExceptionsThrownOnErrorStatus(false);
}
-
+
@Test
public void testHttpRestricMethod() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/testHttpMethodRestrict", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/testHttpMethodRestrict",
+ new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
+ WebResponse response = query(req);
assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
assertEquals(POST_DATA, response.getText(), "The response body is wrong");
-
+
// Send other web method request
- req = new GetMethodWebRequest(CONTEXT_URL + "/services/testHttpMethodRestrict");
+ req = new GetMethodWebRequest(contextUrl + "/services/testHttpMethodRestrict");
try {
- response = client.getResponse(req);
+ response = query(req);
fail("Expect the exception here");
} catch (Exception ex) {
- HttpException httpException = (HttpException)ex;
+ HttpException httpException = (HttpException) ex;
assertEquals(405, httpException.getResponseCode(), "Get a wrong response code");
}
}
@Test
public void testHttpConverter() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/testConverter", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/testConverter",
+ new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
+ WebResponse response = query(req, false);
assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
assertEquals("Bye World", response.getText(), "The response body is wrong");
}
@Test
public void testHttpUnicodeResponseWithStringResponse() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/testUnicodeWithStringResponse", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/testUnicodeWithStringResponse",
+ new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
+ WebResponse response = query(req, false);
assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
assertEquals(UNICODE_TEXT, response.getText(), "The response body is wrong");
}
@Test
public void testHttpUnicodeResponseWithObjectResponse() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/testUnicodeWithObjectResponse", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/testUnicodeWithObjectResponse",
+ new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
+ WebResponse response = query(req, false);
assertEquals("OK", response.getResponseMessage(), "The response message is wrong");
assertEquals(UNICODE_TEXT, response.getText(), "The response body is wrong");
}
@@ -123,7 +120,8 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
fail("Excepts exception here");
} catch (Exception ex) {
assertTrue(ex instanceof FailedToStartRouteException, "Get a wrong exception.");
- assertTrue(ex.getCause().getCause() instanceof UnsupportedOperationException, "Get a wrong cause of exception.");
+ assertTrue(ex.getCause().getCause() instanceof UnsupportedOperationException,
+ "Get a wrong cause of exception.");
}
}
@@ -143,13 +141,14 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport {
String charsetEncoding = exchange.getIn().getHeader(Exchange.HTTP_CHARACTER_ENCODING, String.class);
assertEquals(charsetEncoding, "UTF-8", "Get a wrong charset name from the message header");
// assert exchange charset
- assertEquals("UTF-8", exchange.getProperty(Exchange.CHARSET_NAME), "Get a wrong charset naem from the exchange property");
+ assertEquals("UTF-8", exchange.getProperty(Exchange.CHARSET_NAME),
+ "Get a wrong charset naem from the exchange property");
exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, contentType + "; charset=UTF-8");
exchange.getMessage().setHeader("PATH", path);
exchange.getMessage().setBody("<b>Hello World</b>");
});
// END SNIPPET: route
-
+
from("servlet:testHttpMethodRestrict?httpMethodRestrict=POST").process(exchange -> {
String request = exchange.getIn().getBody(String.class);
exchange.getMessage().setBody(request);
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/MultiServletConsumerTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/MultiServletConsumerTest.java
index 5b5dc57..1783788 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/MultiServletConsumerTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/MultiServletConsumerTest.java
@@ -53,9 +53,8 @@ public class MultiServletConsumerTest extends ServletCamelRouterTestSupport {
}
public String getService(String path) throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + path);
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + path);
+ WebResponse response = query(req);
return response.getText();
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncTest.java
index 7b48da0..7d19f5d 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncTest.java
@@ -31,13 +31,13 @@ public class ServletAsyncTest extends ServletCamelRouterTestSupport {
public void testHello() throws Exception {
final String name = "Arnaud";
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/hello");
req.setParameter("name", name);
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebResponse response = query(req);
assertEquals(200, response.getResponseCode());
- assertEquals(MessageFormat.format("Hello {0} how are you?", name), response.getText(), "The response message is wrong");
+ assertEquals(MessageFormat.format("Hello {0} how are you?", name), response.getText(),
+ "The response message is wrong");
}
@Override
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java
index c46ed46..c45a621 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletCamelRouterTestSupport.java
@@ -41,7 +41,7 @@ import org.junit.jupiter.api.BeforeEach;
public class ServletCamelRouterTestSupport extends CamelTestSupport {
public static final String CONTEXT = "/mycontext";
- protected String CONTEXT_URL;
+ protected String contextUrl;
protected boolean startCamelContext = true;
protected int port;
protected DeploymentManager manager;
@@ -59,7 +59,7 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport {
server = Undertow.builder().addHttpListener(port, "localhost")
.setHandler(path).build();
server.start();
- CONTEXT_URL = "http://localhost:" + port + CONTEXT;
+ contextUrl = "http://localhost:" + port + CONTEXT;
if (startCamelContext) {
super.setUp();
}
@@ -85,11 +85,37 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport {
.addMapping("/services/*"));
}
- protected ServletUnitClient newClient() {
- return new ServletUnitClient();
+ protected WebResponse query(WebRequest req) throws IOException {
+ return query(req, true);
}
- protected static abstract class WebRequest {
+ protected WebResponse query(WebRequest req, boolean exceptionsThrownOnErrorStatus) throws IOException {
+ String params = req.params.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue())
+ .collect(Collectors.joining("&"));
+ String urlStr = params.isEmpty() ? req.url : req.url + "?" + params;
+ URL url = new URL(urlStr);
+ HttpURLConnection con = (HttpURLConnection) url.openConnection();
+ con.setUseCaches(false);
+ req.headers.forEach(con::addRequestProperty);
+ con.setRequestMethod(req.getMethod());
+ if (req instanceof PostMethodWebRequest) {
+ con.setDoOutput(true);
+ InputStream is = ((PostMethodWebRequest) req).content;
+ if (is != null) {
+ IOHelper.copy(is, con.getOutputStream());
+ }
+ }
+ int code = con.getResponseCode();
+ if (exceptionsThrownOnErrorStatus && code >= HttpURLConnection.HTTP_BAD_REQUEST) {
+ if (code == HttpURLConnection.HTTP_NOT_FOUND) {
+ throw new HttpNotFoundException(code, con.getResponseMessage(), url);
+ }
+ throw new HttpException(code, con.getResponseMessage(), url);
+ }
+ return new WebResponse(con);
+ }
+
+ protected abstract static class WebRequest {
protected String url;
protected Map<String, String> headers = new HashMap<>();
protected Map<String, String> params = new HashMap<>();
@@ -114,6 +140,7 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport {
super(url);
headers.put("Content-Length", "0");
}
+
public String getMethod() {
return "GET";
}
@@ -121,14 +148,17 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport {
protected static class PostMethodWebRequest extends WebRequest {
protected InputStream content;
+
public PostMethodWebRequest(String url) {
super(url);
}
+
public PostMethodWebRequest(String url, InputStream content, String contentType) {
super(url);
this.content = content;
headers.put("Content-Type", contentType);
}
+
public String getMethod() {
return "POST";
}
@@ -138,9 +168,11 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport {
public PutMethodWebRequest(String url) {
super(url);
}
+
public PutMethodWebRequest(String url, InputStream content, String contentType) {
super(url, content, contentType);
}
+
public String getMethod() {
return "PUT";
}
@@ -150,12 +182,13 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport {
public OptionsMethodWebRequest(String url) {
super(url);
}
+
public String getMethod() {
return "OPTIONS";
}
}
- protected static abstract class HeaderOnlyWebRequest extends WebRequest {
+ protected abstract static class HeaderOnlyWebRequest extends WebRequest {
public HeaderOnlyWebRequest(String url) {
super(url);
}
@@ -215,7 +248,7 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport {
public String getCharacterSet() {
String content = con.getContentType();
- return content != null && content.contains(";charset=")
+ return content != null && content.contains(";charset=")
? content.substring(content.lastIndexOf(";charset=") + ";charset=".length())
: con.getContentEncoding();
}
@@ -225,45 +258,10 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport {
}
}
- protected static class ServletUnitClient {
-
- protected boolean exceptionsThrownOnErrorStatus = true;
-
- public WebResponse getResponse(WebRequest req) throws IOException {
- String params = req.params.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue())
- .collect(Collectors.joining("&"));
- String urlStr = params.isEmpty() ? req.url : req.url + "?" + params;
- URL url = new URL(urlStr);
- HttpURLConnection con = (HttpURLConnection) url.openConnection();
- con.setUseCaches(false);
- req.headers.forEach(con::addRequestProperty);
- con.setRequestMethod(req.getMethod());
- if (req instanceof PostMethodWebRequest) {
- con.setDoOutput(true);
- InputStream is = ((PostMethodWebRequest) req).content;
- if (is != null) {
- IOHelper.copy(is, con.getOutputStream());
- }
- }
- int code = con.getResponseCode();
- if (exceptionsThrownOnErrorStatus && code >= HttpURLConnection.HTTP_BAD_REQUEST) {
- if (code == HttpURLConnection.HTTP_NOT_FOUND) {
- throw new HttpNotFoundException(code, con.getResponseMessage(), url);
- }
- throw new HttpException(code, con.getResponseMessage(), url);
- }
- return new WebResponse(con);
- }
-
- public void setExceptionsThrownOnErrorStatus(boolean val) {
- this.exceptionsThrownOnErrorStatus = val;
- }
- }
-
protected static class HttpException extends RuntimeException {
- private int code;
- private String message;
- private URL url;
+ private final int code;
+ private final String message;
+ private final URL url;
public HttpException(int code, String message, URL url) {
this.code = code;
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletChoiceBeanTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletChoiceBeanTest.java
index d95e50d..e66564c 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletChoiceBeanTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletChoiceBeanTest.java
@@ -29,10 +29,9 @@ public class ServletChoiceBeanTest extends ServletCamelRouterTestSupport {
public void testClient() throws Exception {
getMockEndpoint("mock:bean").expectedMessageCount(1);
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/hello");
req.setParameter("id", "123");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebResponse response = query(req);
assertEquals(200, response.getResponseCode());
assertEquals("Client is Donald Duck", response.getText(), "The response message is wrong");
@@ -44,10 +43,9 @@ public class ServletChoiceBeanTest extends ServletCamelRouterTestSupport {
public void testNoClient() throws Exception {
getMockEndpoint("mock:bean").expectedMessageCount(1);
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
- ServletUnitClient client = newClient();
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/hello");
try {
- client.getResponse(req);
+ query(req);
fail("Should throw exception");
} catch (HttpNotFoundException e) {
assertEquals(404, e.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletMuteExceptionTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletMuteExceptionTest.java
index 298c0d8..b0b32d3 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletMuteExceptionTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletMuteExceptionTest.java
@@ -27,23 +27,20 @@ public class ServletMuteExceptionTest extends ServletCamelRouterTestSupport {
@Test
public void testMuteException() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/mute", new ByteArrayInputStream("".getBytes()), "text/plain");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/mute",
+ new ByteArrayInputStream("".getBytes()), "text/plain");
+ WebResponse response = query(req, false);
assertEquals(500, response.getResponseCode());
assertEquals("text/plain", response.getContentType());
assertEquals("Exception", response.getText());
}
-
@Test
public void testMuteWithTransferException() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/muteWithTransfer", new ByteArrayInputStream("".getBytes()), "text/plain");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/muteWithTransfer",
+ new ByteArrayInputStream("".getBytes()), "text/plain");
+ WebResponse response = query(req, false);
assertEquals(500, response.getResponseCode());
assertEquals("text/plain", response.getContentType());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletNoSlashNeededTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletNoSlashNeededTest.java
index 108f91d..fd279ff 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletNoSlashNeededTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletNoSlashNeededTest.java
@@ -25,13 +25,12 @@ public class ServletNoSlashNeededTest extends ServletCamelRouterTestSupport {
@Test
public void testNoSlashNeeded() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/hello");
+ WebResponse response = query(req);
assertEquals("Bye World", response.getText(), "The response message is wrong");
}
-
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletRootPathTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletRootPathTest.java
index c06d616..7bf7fd5 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletRootPathTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletRootPathTest.java
@@ -25,13 +25,12 @@ public class ServletRootPathTest extends ServletCamelRouterTestSupport {
@Test
public void testRootPath() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/");
+ WebResponse response = query(req);
assertEquals("Bye World", response.getText(), "The response message is wrong");
}
-
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetBodyTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetBodyTest.java
index 1eb6c6a..159c275 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetBodyTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetBodyTest.java
@@ -25,13 +25,12 @@ public class ServletSetBodyTest extends ServletCamelRouterTestSupport {
@Test
public void testSetBody() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/hello");
+ WebResponse response = query(req);
assertEquals("Bye World", response.getText(), "The response message is wrong");
}
-
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetExchangePropertyBeanTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetExchangePropertyBeanTest.java
index 73b73d8..b1e5277 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetExchangePropertyBeanTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSetExchangePropertyBeanTest.java
@@ -25,14 +25,13 @@ public class ServletSetExchangePropertyBeanTest extends ServletCamelRouterTestSu
@Test
public void testSetProperty() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/hello");
+ WebResponse response = query(req);
assertEquals(204, response.getResponseCode());
assertEquals("", response.getText(), "The response message is wrong");
}
-
+
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSwitchingStatusCode204Test.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSwitchingStatusCode204Test.java
index 096cc76..670a8cf 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSwitchingStatusCode204Test.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletSwitchingStatusCode204Test.java
@@ -26,9 +26,8 @@ public class ServletSwitchingStatusCode204Test extends ServletCamelRouterTestSup
@Test
public void testSwitchingNoBodyTo204() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/bar");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/bar");
+ WebResponse response = query(req);
assertEquals(204, response.getResponseCode());
assertEquals("", response.getText());
@@ -36,9 +35,8 @@ public class ServletSwitchingStatusCode204Test extends ServletCamelRouterTestSup
@Test
public void testNoSwitchingNoCode() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/foo");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/foo");
+ WebResponse response = query(req);
assertEquals(200, response.getResponseCode());
assertEquals("No Content", response.getText());
@@ -46,9 +44,8 @@ public class ServletSwitchingStatusCode204Test extends ServletCamelRouterTestSup
@Test
public void testNoSwitchingNoBody() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/foobar");
- ServletUnitClient client = newClient();
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/foobar");
+ WebResponse response = query(req);
assertEquals(200, response.getResponseCode());
assertEquals("", response.getText());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
index 13bc15d..325a573 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletTransferExceptionTest.java
@@ -31,10 +31,9 @@ public class ServletTransferExceptionTest extends ServletCamelRouterTestSupport
@Test
public void testTransferException() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/hello", new ByteArrayInputStream("".getBytes()), "text/plain");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/hello",
+ new ByteArrayInputStream("".getBytes()), "text/plain");
+ WebResponse response = query(req, false);
assertEquals(500, response.getResponseCode());
assertEquals(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, response.getContentType());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestApiMatchUriServletTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestApiMatchUriServletTest.java
index 34d893d..1f4d823 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestApiMatchUriServletTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestApiMatchUriServletTest.java
@@ -23,16 +23,13 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class RestApiMatchUriServletTest extends ServletCamelRouterTestSupport {
@Test
public void testApiDocGet() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/api-doc");
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/api-doc");
req.setHeaderField("Accept", "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithJsonTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithJsonTest.java
index 586fbd0..b06eeee 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithJsonTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithJsonTest.java
@@ -37,10 +37,9 @@ public class RestServletBindingModeAutoWithJsonTest extends ServletCamelRouterTe
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithXmlTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithXmlTest.java
index b8c4b77..fc34f90 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithXmlTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeAutoWithXmlTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-
public class RestServletBindingModeAutoWithXmlTest extends ServletCamelRouterTestSupport {
@Test
@@ -38,10 +37,9 @@ public class RestServletBindingModeAutoWithXmlTest extends ServletCamelRouterTes
String body = "<user name=\"Donald Duck\" id=\"123\"></user>";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/xml");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/xml");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonTest.java
index e102322..b4f7bc4 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-
public class RestServletBindingModeJsonTest extends ServletCamelRouterTestSupport {
@Test
@@ -37,10 +36,9 @@ public class RestServletBindingModeJsonTest extends ServletCamelRouterTestSuppor
mock.message(0).body().isInstanceOf(UserJaxbPojo.class);
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
@@ -58,10 +56,9 @@ public class RestServletBindingModeJsonTest extends ServletCamelRouterTestSuppor
mock.expectedMessageCount(0);
String body = "<user name=\"Donald Duck\" id=\"123\"></user>";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/xml");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/xml");
+ WebResponse response = query(req, false);
assertEquals(500, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonWithContractTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonWithContractTest.java
index 9946c9c..c1b6977 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonWithContractTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeJsonWithContractTest.java
@@ -30,7 +30,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class RestServletBindingModeJsonWithContractTest extends ServletCamelRouterTestSupport {
@Test
@@ -40,10 +39,9 @@ public class RestServletBindingModeJsonWithContractTest extends ServletCamelRout
mock.message(0).body().isInstanceOf(UserPojoEx.class);
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
String answer = response.getText();
assertTrue(answer.contains("\"active\":true"), "Unexpected response: " + answer);
@@ -52,7 +50,7 @@ public class RestServletBindingModeJsonWithContractTest extends ServletCamelRout
Object obj = mock.getReceivedExchanges().get(0).getIn().getBody();
assertEquals(UserPojoEx.class, obj.getClass());
- UserPojoEx user = (UserPojoEx)obj;
+ UserPojoEx user = (UserPojoEx) obj;
assertNotNull(user);
assertEquals(123, user.getId());
assertEquals("Donald Duck", user.getName());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeOffWithContractTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeOffWithContractTest.java
index 59a14e3..26068d9 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeOffWithContractTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeOffWithContractTest.java
@@ -30,7 +30,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-
public class RestServletBindingModeOffWithContractTest extends ServletCamelRouterTestSupport {
@Test
@@ -40,10 +39,9 @@ public class RestServletBindingModeOffWithContractTest extends ServletCamelRoute
mock.message(0).body().isInstanceOf(UserPojoEx.class);
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
String answer = response.getText();
assertTrue(answer.contains("\"active\":true"), "Unexpected response: " + answer);
@@ -52,7 +50,7 @@ public class RestServletBindingModeOffWithContractTest extends ServletCamelRoute
Object obj = mock.getReceivedExchanges().get(0).getIn().getBody();
assertEquals(UserPojoEx.class, obj.getClass());
- UserPojoEx user = (UserPojoEx)obj;
+ UserPojoEx user = (UserPojoEx) obj;
assertNotNull(user);
assertEquals(123, user.getId());
assertEquals("Donald Duck", user.getName());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeXmlTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeXmlTest.java
index 06d0d98..461a8bd 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeXmlTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletBindingModeXmlTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-
public class RestServletBindingModeXmlTest extends ServletCamelRouterTestSupport {
@Test
@@ -37,10 +36,9 @@ public class RestServletBindingModeXmlTest extends ServletCamelRouterTestSupport
mock.message(0).body().isInstanceOf(UserJaxbPojo.class);
String body = "<user name=\"Donald Duck\" id=\"123\"></user>";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/xml");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/xml");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
@@ -59,10 +57,9 @@ public class RestServletBindingModeXmlTest extends ServletCamelRouterTestSupport
// we bind to xml, but send in json, which is not possible
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(500, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetTest.java
index 62a5368..a8cbbf7 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetTest.java
@@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class RestServletGetTest extends ServletCamelRouterTestSupport {
@BindToRegistry("myBinding")
@@ -32,10 +31,8 @@ public class RestServletGetTest extends ServletCamelRouterTestSupport {
@Test
public void testServletProducerGet() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/123/basic");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/users/123/basic");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetWildcardsTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetWildcardsTest.java
index a23bd99..8e93c6a 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetWildcardsTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletGetWildcardsTest.java
@@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class RestServletGetWildcardsTest extends ServletCamelRouterTestSupport {
@BindToRegistry("myBinding")
@@ -32,10 +31,8 @@ public class RestServletGetWildcardsTest extends ServletCamelRouterTestSupport {
@Test
public void testServletProducerGet() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/123/basic");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/users/123/basic");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
@@ -44,10 +41,8 @@ public class RestServletGetWildcardsTest extends ServletCamelRouterTestSupport {
@Test
public void testServletProducerGetWildcards() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/456/name=g*");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/users/456/name=g*");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletMethodNotAllowedTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletMethodNotAllowedTest.java
index 83ac536..03f69aa 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletMethodNotAllowedTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletMethodNotAllowedTest.java
@@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class RestServletMethodNotAllowedTest extends ServletCamelRouterTestSupport {
@BindToRegistry("myBinding")
@@ -32,10 +31,8 @@ public class RestServletMethodNotAllowedTest extends ServletCamelRouterTestSuppo
@Test
public void testServletMethodNotAllowed() throws Exception {
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/123/basic");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/123/basic");
+ WebResponse response = query(req, false);
assertEquals(405, response.getResponseCode());
}
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletOptionsTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletOptionsTest.java
index 2019c08..0fad305 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletOptionsTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletOptionsTest.java
@@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class RestServletOptionsTest extends ServletCamelRouterTestSupport {
@BindToRegistry("myBinding")
@@ -32,17 +31,15 @@ public class RestServletOptionsTest extends ServletCamelRouterTestSupport {
@Test
public void testServletOptions() throws Exception {
- WebRequest req = new OptionsMethodWebRequest(CONTEXT_URL + "/services/users/v1/customers");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new OptionsMethodWebRequest(contextUrl + "/services/users/v1/customers");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
assertEquals("GET,OPTIONS", response.getHeaderField("ALLOW"));
assertEquals("", response.getText());
- req = new OptionsMethodWebRequest(CONTEXT_URL + "/services/users/v1/id/123");
- response = client.getResponse(req);
+ req = new OptionsMethodWebRequest(contextUrl + "/services/users/v1/id/123");
+ response = query(req, false);
assertEquals(200, response.getResponseCode());
assertEquals("PUT,OPTIONS", response.getHeaderField("ALLOW"));
@@ -51,10 +48,8 @@ public class RestServletOptionsTest extends ServletCamelRouterTestSupport {
@Test
public void testMultipleServletOptions() throws Exception {
- WebRequest req = new OptionsMethodWebRequest(CONTEXT_URL + "/services/users/v2/options");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new OptionsMethodWebRequest(contextUrl + "/services/users/v2/options");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
assertEquals("GET,POST,OPTIONS", response.getHeaderField("ALLOW"));
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPojoInOutTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPojoInOutTest.java
index e7864e8..839c700 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPojoInOutTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPojoInOutTest.java
@@ -26,16 +26,14 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-
public class RestServletPojoInOutTest extends ServletCamelRouterTestSupport {
@Test
public void testServletPojoInOut() throws Exception {
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/lives", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/lives",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
@@ -44,14 +42,12 @@ public class RestServletPojoInOutTest extends ServletCamelRouterTestSupport {
assertNotNull(out);
assertEquals("{\"iso\":\"EN\",\"country\":\"England\"}", out);
}
-
+
@Test
public void testServletPojoGet() throws Exception {
-
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/lives");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/users/lives");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
@@ -59,7 +55,7 @@ public class RestServletPojoInOutTest extends ServletCamelRouterTestSupport {
assertNotNull(out);
assertEquals("{\"iso\":\"EN\",\"country\":\"England\"}", out);
- }
+ }
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonJaxbPojoTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonJaxbPojoTest.java
index 51e662d..3572a90e 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonJaxbPojoTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonJaxbPojoTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-
public class RestServletPostJsonJaxbPojoTest extends ServletCamelRouterTestSupport {
@Test
@@ -37,10 +36,9 @@ public class RestServletPostJsonJaxbPojoTest extends ServletCamelRouterTestSuppo
mock.message(0).body().isInstanceOf(UserJaxbPojo.class);
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoListTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoListTest.java
index 3292caa..42c59e7 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoListTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoListTest.java
@@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-
public class RestServletPostJsonPojoListTest extends ServletCamelRouterTestSupport {
@Test
@@ -37,10 +36,9 @@ public class RestServletPostJsonPojoListTest extends ServletCamelRouterTestSuppo
mock.expectedMessageCount(1);
String body = "[ {\"id\": 123, \"name\": \"Donald Duck\"}, {\"id\": 456, \"name\": \"John Doe\"} ]";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
assertEquals("application/json", response.getContentType());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoTest.java
index e145171..46e7ddd 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostJsonPojoTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-
public class RestServletPostJsonPojoTest extends ServletCamelRouterTestSupport {
@Test
@@ -37,10 +36,9 @@ public class RestServletPostJsonPojoTest extends ServletCamelRouterTestSupport {
mock.message(0).body().isInstanceOf(UserPojo.class);
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostXmlJaxbPojoTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostXmlJaxbPojoTest.java
index a2299c4..7d48a11 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostXmlJaxbPojoTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletPostXmlJaxbPojoTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-
public class RestServletPostXmlJaxbPojoTest extends ServletCamelRouterTestSupport {
@Test
@@ -37,10 +36,9 @@ public class RestServletPostXmlJaxbPojoTest extends ServletCamelRouterTestSuppor
mock.message(0).body().isInstanceOf(UserJaxbPojo.class);
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
@@ -59,10 +57,9 @@ public class RestServletPostXmlJaxbPojoTest extends ServletCamelRouterTestSuppor
mock.message(0).body().isInstanceOf(UserJaxbPojo.class);
String body = "<user name=\"Donald Duck\" id=\"456\"></user>";
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "foo");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users/new",
+ new ByteArrayInputStream(body.getBytes()), "foo");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletVerbTest.java b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletVerbTest.java
index f74b223..d9ae401 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletVerbTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletVerbTest.java
@@ -26,15 +26,12 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class RestServletVerbTest extends ServletCamelRouterTestSupport {
@Test
public void testGetAll() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/users");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
assertEquals("[{ \"id\":\"1\", \"name\":\"Scott\" },{ \"id\":\"2\", \"name\":\"Claus\" }]", response.getText());
@@ -42,10 +39,8 @@ public class RestServletVerbTest extends ServletCamelRouterTestSupport {
@Test
public void testGetOne() throws Exception {
- WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/1");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new GetMethodWebRequest(contextUrl + "/services/users/1");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
assertEquals("{ \"id\":\"1\", \"name\":\"Scott\" }", response.getText());
@@ -59,10 +54,9 @@ public class RestServletVerbTest extends ServletCamelRouterTestSupport {
mock.expectedBodiesReceived(body);
mock.expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");
- WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PostMethodWebRequest(contextUrl + "/services/users",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
@@ -78,10 +72,9 @@ public class RestServletVerbTest extends ServletCamelRouterTestSupport {
mock.expectedHeaderReceived("id", "1");
mock.expectedHeaderReceived(Exchange.HTTP_METHOD, "PUT");
- WebRequest req = new PutMethodWebRequest(CONTEXT_URL + "/services/users/1", new ByteArrayInputStream(body.getBytes()), "application/json");
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebRequest req = new PutMethodWebRequest(contextUrl + "/services/users/1",
+ new ByteArrayInputStream(body.getBytes()), "application/json");
+ WebResponse response = query(req, false);
assertEquals(200, response.getResponseCode());
@@ -94,15 +87,13 @@ public class RestServletVerbTest extends ServletCamelRouterTestSupport {
mock.expectedHeaderReceived("id", "1");
mock.expectedHeaderReceived(Exchange.HTTP_METHOD, "DELETE");
- WebRequest req = new HeaderOnlyWebRequest(CONTEXT_URL + "/services/users/1") {
+ WebRequest req = new HeaderOnlyWebRequest(contextUrl + "/services/users/1") {
@Override
public String getMethod() {
return "DELETE";
}
};
- ServletUnitClient client = newClient();
- client.setExceptionsThrownOnErrorStatus(false);
- WebResponse response = client.getResponse(req);
+ WebResponse response = query(req, false);
assertEquals(204, response.getResponseCode());
[camel] 04/07: [CAMEL-11807] Remove deprecated constructs from
camelspring-javaconfig
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ad299f25c72232b755aa0a26dd249ec91d8daadc
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Jun 17 15:09:52 2020 +0200
[CAMEL-11807] Remove deprecated constructs from camelspring-javaconfig
---
.../java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java | 3 ++-
.../src/test/java/org/apache/camel/spring/javaconfig/MainTest.java | 3 +--
.../spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java | 3 ++-
.../camel/spring/javaconfig/autowire/AutodetectingConfigTest.java | 3 ++-
.../javaconfig/autowire/LoadingRawCamelConfigurationTest.java | 4 +---
.../javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java | 6 +-----
.../spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java | 3 ++-
.../spring/javaconfig/test/JavaConfigWithPostProcessorTest.java | 3 ++-
8 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java
index 1dab459..accaadf 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java
@@ -24,6 +24,7 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
+import org.apache.camel.test.spring.CamelSpringRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.annotation.Bean;
@@ -32,7 +33,7 @@ import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-@RunWith(CamelSpringJUnit4ClassRunner.class)
+@RunWith(CamelSpringRunner.class)
@ContextConfiguration(classes = {BeanJavaConfigTest.ContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
public class BeanJavaConfigTest extends AbstractJUnit4SpringContextTests {
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java
index 5f14ccf..d5fcf03 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java
@@ -19,11 +19,10 @@ package org.apache.camel.spring.javaconfig;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
-public class MainTest extends Assert {
+public class MainTest {
@Test
public void testOptions() throws Exception {
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java
index 8b8f122..93c3d75 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java
@@ -20,6 +20,7 @@ import org.apache.camel.CamelContext;
import org.apache.camel.spring.javaconfig.CamelConfiguration;
import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
+import org.apache.camel.test.spring.CamelSpringRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +30,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import static org.junit.Assert.assertEquals;
-@RunWith(CamelSpringJUnit4ClassRunner.class)
+@RunWith(CamelSpringRunner.class)
@ContextConfiguration(classes = {NoRoutesConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
public class AutodetectNoRoutesConfigTest extends AbstractJUnit4SpringContextTests {
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java
index 1eab026..0943f3d 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java
@@ -22,12 +22,13 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
+import org.apache.camel.test.spring.CamelSpringRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-@RunWith(CamelSpringJUnit4ClassRunner.class)
+@RunWith(CamelSpringRunner.class)
@ContextConfiguration(classes = {AutowiringContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
public class AutodetectingConfigTest extends AbstractJUnit4SpringContextTests {
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java
index 53964b0..9f828ea 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java
@@ -29,9 +29,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import static org.junit.Assert.assertNotNull;
-@ContextConfiguration(
- classes = {CamelConfiguration.class, AdditionalRouteConfiguration.class},
- loader = CamelSpringDelegatingTestContextLoader.class)
+@ContextConfiguration(classes = { CamelConfiguration.class, AdditionalRouteConfiguration.class })
public class LoadingRawCamelConfigurationTest extends AbstractJUnit4SpringContextTests {
@EndpointInject("mock:rawConfigTest")
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java
index 9fe6e40..748ce38 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java
@@ -37,11 +37,7 @@ import org.springframework.test.context.ContextConfiguration;
//START SNIPPET: example
// tag::example[]
@RunWith(CamelSpringRunner.class)
-@ContextConfiguration(
- classes = {CamelSpringDelegatingTestContextLoaderTest.TestConfig.class},
- // Since Camel 2.11.0
- loader = CamelSpringDelegatingTestContextLoader.class
- )
+@ContextConfiguration(classes = CamelSpringDelegatingTestContextLoaderTest.TestConfig.class)
@MockEndpoints
public class CamelSpringDelegatingTestContextLoaderTest {
@EndpointInject("mock:direct:end")
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java
index e8f9cad..c917892 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.spring.javaconfig.test;
import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
+import org.apache.camel.test.spring.CamelSpringRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.annotation.Bean;
@@ -28,7 +29,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import static org.junit.Assert.assertEquals;
-@RunWith(CamelSpringJUnit4ClassRunner.class)
+@RunWith(CamelSpringRunner.class)
@ContextConfiguration(classes = {JavaConfigWithNestedConfigClassTest.ContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
@Component
public class JavaConfigWithNestedConfigClassTest extends AbstractJUnit4SpringContextTests implements Cheese {
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java
index bd0d650..7dee3f4 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.spring.javaconfig.test;
import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
+import org.apache.camel.test.spring.CamelSpringRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.stereotype.Component;
@@ -26,7 +27,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import static org.junit.Assert.assertEquals;
-@RunWith(CamelSpringJUnit4ClassRunner.class)
+@RunWith(CamelSpringRunner.class)
@ContextConfiguration(classes = {MyConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
@Component
public class JavaConfigWithPostProcessorTest extends AbstractJUnit4SpringContextTests implements Cheese {
[camel] 05/07: [CAMEL-11807] Upgrade camel-spring-javaconfig to
junit5
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 578d8667da6310e87f42451af8d52e8d0bca2c79
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Jun 17 15:24:14 2020 +0200
[CAMEL-11807] Upgrade camel-spring-javaconfig to junit5
---
components/camel-spring-javaconfig/pom.xml | 6 ++---
.../spring/javaconfig/BeanJavaConfigTest.java | 11 ++++-----
.../apache/camel/spring/javaconfig/MainTest.java | 4 ++--
.../autowire/AutodetectNoRoutesConfigTest.java | 17 ++++++--------
.../autowire/AutodetectingConfigTest.java | 16 +++++--------
.../autowire/LoadingRawCamelConfigurationTest.java | 10 ++++-----
.../spring/javaconfig/patterns/FilterTest.java | 15 +++++--------
...CamelSpringDelegatingTestContextLoaderTest.java | 10 ++++-----
.../test/JavaConfigWithNestedConfigClassTest.java | 26 ++++++++++++----------
.../test/JavaConfigWithPostProcessorTest.java | 25 +++++++++++----------
10 files changed, 64 insertions(+), 76 deletions(-)
diff --git a/components/camel-spring-javaconfig/pom.xml b/components/camel-spring-javaconfig/pom.xml
index e8f2404..5b002c1 100644
--- a/components/camel-spring-javaconfig/pom.xml
+++ b/components/camel-spring-javaconfig/pom.xml
@@ -55,13 +55,13 @@
<!-- test dependencies -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-test-spring</artifactId>
+ <artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java
index accaadf..65b381e 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/BeanJavaConfigTest.java
@@ -22,19 +22,16 @@ import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
-import org.apache.camel.test.spring.CamelSpringRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
+import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-@RunWith(CamelSpringRunner.class)
-@ContextConfiguration(classes = {BeanJavaConfigTest.ContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
+@CamelSpringTest
+@ContextConfiguration(classes = BeanJavaConfigTest.ContextConfig.class)
public class BeanJavaConfigTest extends AbstractJUnit4SpringContextTests {
@EndpointInject("mock:end")
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java
index d5fcf03..4c0a553 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/MainTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.spring.javaconfig;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
public class MainTest {
@@ -32,7 +32,7 @@ public class MainTest {
context.stop();
}
- @Test
+ @org.junit.jupiter.api.Test
public void testOptionBP() throws Exception {
CamelContext context = createCamelContext(new String[]{"-bp", "org.apache.camel.spring.javaconfig.config"});
context.start();
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java
index 93c3d75..9184503 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectNoRoutesConfigTest.java
@@ -18,21 +18,18 @@ package org.apache.camel.spring.javaconfig.autowire;
import org.apache.camel.CamelContext;
import org.apache.camel.spring.javaconfig.CamelConfiguration;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
-import org.apache.camel.test.spring.CamelSpringRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(CamelSpringRunner.class)
-@ContextConfiguration(classes = {NoRoutesConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
-public class AutodetectNoRoutesConfigTest extends AbstractJUnit4SpringContextTests {
+
+@CamelSpringTest
+@ContextConfiguration(classes = NoRoutesConfig.class)
+public class AutodetectNoRoutesConfigTest {
@Autowired
CamelContext camelContext;
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java
index 0943f3d..f1f17b8 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/AutodetectingConfigTest.java
@@ -20,17 +20,13 @@ import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
-import org.apache.camel.test.spring.CamelSpringRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
+import org.junit.jupiter.api.Test;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-@RunWith(CamelSpringRunner.class)
-@ContextConfiguration(classes = {AutowiringContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
-public class AutodetectingConfigTest extends AbstractJUnit4SpringContextTests {
+@CamelSpringTest
+@ContextConfiguration(classes = AutowiringContextConfig.class)
+public class AutodetectingConfigTest {
@EndpointInject("mock:autowire")
MockEndpoint autowireMockEndpoint;
@@ -56,7 +52,7 @@ public class AutodetectingConfigTest extends AbstractJUnit4SpringContextTests {
autowireMockEndpoint.assertIsSatisfied();
}
- @Test
+ @org.junit.jupiter.api.Test
public void shouldWireRouteBuildersFromModule() throws InterruptedException {
// Given
moduleMockEndpoint.expectedMessageCount(1);
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java
index 9f828ea..dc34848 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/autowire/LoadingRawCamelConfigurationTest.java
@@ -20,17 +20,17 @@ import org.apache.camel.EndpointInject;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spring.javaconfig.CamelConfiguration;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.junit.Test;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
+import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+@CamelSpringTest
@ContextConfiguration(classes = { CamelConfiguration.class, AdditionalRouteConfiguration.class })
-public class LoadingRawCamelConfigurationTest extends AbstractJUnit4SpringContextTests {
+public class LoadingRawCamelConfigurationTest {
@EndpointInject("mock:rawConfigTest")
MockEndpoint moduleMockEndpoint;
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java
index 7dde0d9..180ebf6 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java
@@ -22,24 +22,21 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
+import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
/**
* Tests filtering using Spring Test and Java Config
*/
// START SNIPPET: example
// tag::example[]
-@RunWith(CamelSpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {FilterTest.ContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
-public class FilterTest extends AbstractJUnit4SpringContextTests {
+@CamelSpringTest
+@ContextConfiguration(classes = FilterTest.ContextConfig.class)
+public class FilterTest {
@EndpointInject("mock:result")
protected MockEndpoint resultEndpoint;
@@ -48,7 +45,7 @@ public class FilterTest extends AbstractJUnit4SpringContextTests {
protected ProducerTemplate template;
@DirtiesContext
- @Test
+ @org.junit.jupiter.api.Test
public void testSendMatchingMessage() throws Exception {
String expectedBody = "<matched/>";
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java
index 748ce38..e60fc33 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java
@@ -22,11 +22,9 @@ import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.apache.camel.test.spring.CamelSpringRunner;
-import org.apache.camel.test.spring.MockEndpoints;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
+import org.apache.camel.test.spring.junit5.MockEndpoints;
+import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
@@ -36,7 +34,7 @@ import org.springframework.test.context.ContextConfiguration;
*/
//START SNIPPET: example
// tag::example[]
-@RunWith(CamelSpringRunner.class)
+@CamelSpringTest
@ContextConfiguration(classes = CamelSpringDelegatingTestContextLoaderTest.TestConfig.class)
@MockEndpoints
public class CamelSpringDelegatingTestContextLoaderTest {
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java
index c917892..a55f042 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithNestedConfigClassTest.java
@@ -16,33 +16,35 @@
*/
package org.apache.camel.spring.javaconfig.test;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
-import org.apache.camel.test.spring.CamelSpringRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-@RunWith(CamelSpringRunner.class)
-@ContextConfiguration(classes = {JavaConfigWithNestedConfigClassTest.ContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
+
+@CamelSpringTest
+@ContextConfiguration(classes = JavaConfigWithNestedConfigClassTest.ContextConfig.class)
@Component
-public class JavaConfigWithNestedConfigClassTest extends AbstractJUnit4SpringContextTests implements Cheese {
+public class JavaConfigWithNestedConfigClassTest implements Cheese {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(JavaConfigWithPostProcessorTest.class);
+
private boolean doCheeseCalled;
@Test
public void testPostProcessorInjectsMe() throws Exception {
- assertEquals("doCheese() should be called", true, doCheeseCalled);
+ assertTrue(doCheeseCalled, "doCheese() should be called");
}
@Override
public void doCheese() {
- logger.info("doCheese called!");
+ LOGGER.info("doCheese called!");
doCheeseCalled = true;
}
diff --git a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java
index 7dee3f4..ce2491d 100644
--- a/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java
+++ b/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/JavaConfigWithPostProcessorTest.java
@@ -16,31 +16,32 @@
*/
package org.apache.camel.spring.javaconfig.test;
-import org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader;
-import org.apache.camel.test.spring.CamelSpringJUnit4ClassRunner;
-import org.apache.camel.test.spring.CamelSpringRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.apache.camel.test.spring.junit5.CamelSpringTest;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-@RunWith(CamelSpringRunner.class)
-@ContextConfiguration(classes = {MyConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
+@CamelSpringTest
+@ContextConfiguration(classes = MyConfig.class)
@Component
-public class JavaConfigWithPostProcessorTest extends AbstractJUnit4SpringContextTests implements Cheese {
+public class JavaConfigWithPostProcessorTest implements Cheese {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(JavaConfigWithPostProcessorTest.class);
+
private boolean doCheeseCalled;
@Test
public void testPostProcessorInjectsMe() throws Exception {
- assertEquals("doCheese() should be called", true, doCheeseCalled);
+ assertTrue(doCheeseCalled, "doCheese() should be called");
}
@Override
public void doCheese() {
- logger.info("doCheese called!");
+ LOGGER.info("doCheese called!");
doCheeseCalled = true;
}
}
[camel] 02/07: Fix typo: recieve -> receive
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit af2d076fc218d5dc0fe5be634e7c867bd13fff44
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Jun 16 15:32:45 2020 +0200
Fix typo: recieve -> receive
---
.../apache/camel/component/as2/api/AS2MessageTest.java | 2 +-
.../component/aws/swf/CamelWorkflowDefinition.java | 4 ++--
.../camel/component/aws/swf/SWFWorkflowConsumer.java | 4 ++--
.../bindy/fixed/converter/BindyConverterTest.java | 18 +++++++++---------
.../camel-browse/src/main/docs/browse-component.adoc | 2 +-
.../flatpack/FlatpackDelimitedDataFormatTest.java | 2 +-
.../mail/MailAttachmentDuplicateNamesTest.java | 2 +-
.../camel/component/mail/MailHtmlAttachmentTest.java | 2 +-
.../org/apache/camel/component/mail/MailRouteTest.java | 4 ++--
.../mina/MinaTcpLineDelimiterUsingPlainSocketTest.java | 6 +++---
.../mina/MinaTcpWithInOutUsingPlainSocketTest.java | 6 +++---
.../netty/NettyTcpWithInOutUsingPlainSocketTest.java | 6 +++---
.../camel/component/splunk/ConsumerStreamingTest.java | 6 +++---
.../apache/camel/component/splunk/ConsumerTest.java | 6 +++---
.../component/splunk/integration/NormalSearchTest.java | 6 +++---
.../splunk/integration/RealtimeSearchTest.java | 6 +++---
.../component/splunk/integration/SavedSearchTest.java | 6 +++---
.../splunk/integration/SplunkProducerTest.java | 2 +-
.../RouteExclusionFromWithinSpringTestSupportTest.java | 2 +-
.../spring/config/scan/SpringComponentScanTest.java | 2 +-
.../config/scan/route/MyExcludedRouteBuilder.java | 2 +-
.../org/apache/camel/component/undertow/undertow.json | 2 +-
.../src/main/docs/undertow-component.adoc | 2 +-
.../camel/component/undertow/UndertowConsumer.java | 8 ++++----
.../camel/component/undertow/UndertowEndpoint.java | 2 +-
.../operations/FutureEventDrivenOperation.java | 4 ++--
.../endpoint/dsl/UndertowEndpointBuilderFactory.java | 12 ++++++------
.../modules/ROOT/pages/browse-component.adoc | 2 +-
.../modules/ROOT/pages/undertow-component.adoc | 2 +-
.../modules/ROOT/pages/exception-clause.adoc | 2 +-
30 files changed, 66 insertions(+), 66 deletions(-)
diff --git a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/AS2MessageTest.java b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/AS2MessageTest.java
index 0480858..ea5412f 100644
--- a/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/AS2MessageTest.java
+++ b/components/camel-as2/camel-as2-api/src/test/java/org/apache/camel/component/as2/api/AS2MessageTest.java
@@ -662,7 +662,7 @@ public class AS2MessageTest {
assertEquals(extensionFields, mdnEntity.getExtensionFields(), "Unexpected value for Extension Fields");
ReceivedContentMic expectedMic = MicUtils.createReceivedContentMic(request, null);
ReceivedContentMic mdnMic = mdnEntity.getReceivedContentMic();
- assertEquals(expectedMic.getEncodedMessageDigest(), mdnMic.getEncodedMessageDigest(), "Unexpected value for Recieved Content Mic");
+ assertEquals(expectedMic.getEncodedMessageDigest(), mdnMic.getEncodedMessageDigest(), "Unexpected value for Received Content Mic");
LOG.debug("\r\n" + AS2Utils.printMessage(mndRequest));
}
diff --git a/components/camel-aws-swf/src/main/java/org/apache/camel/component/aws/swf/CamelWorkflowDefinition.java b/components/camel-aws-swf/src/main/java/org/apache/camel/component/aws/swf/CamelWorkflowDefinition.java
index a183191..a0ac64c 100644
--- a/components/camel-aws-swf/src/main/java/org/apache/camel/component/aws/swf/CamelWorkflowDefinition.java
+++ b/components/camel-aws-swf/src/main/java/org/apache/camel/component/aws/swf/CamelWorkflowDefinition.java
@@ -96,9 +96,9 @@ public class CamelWorkflowDefinition extends WorkflowDefinition {
public void signalRecieved(String signalName, String input) throws WorkflowException {
Object[] parameters = dataConverter.fromData(input, Object[].class);
try {
- LOGGER.debug("Processing workflow signalRecieved");
+ LOGGER.debug("Processing workflow signalReceived");
- swfWorkflowConsumer.signalRecieved(parameters);
+ swfWorkflowConsumer.signalReceived(parameters);
} catch (Throwable e) {
throwWorkflowException(dataConverter, e);
throw new IllegalStateException("Unreacheable");
diff --git a/components/camel-aws-swf/src/main/java/org/apache/camel/component/aws/swf/SWFWorkflowConsumer.java b/components/camel-aws-swf/src/main/java/org/apache/camel/component/aws/swf/SWFWorkflowConsumer.java
index 014dc0c..edc0c93 100644
--- a/components/camel-aws-swf/src/main/java/org/apache/camel/component/aws/swf/SWFWorkflowConsumer.java
+++ b/components/camel-aws-swf/src/main/java/org/apache/camel/component/aws/swf/SWFWorkflowConsumer.java
@@ -52,8 +52,8 @@ public class SWFWorkflowConsumer extends DefaultConsumer {
return endpoint.getResult(exchange);
}
- public void signalRecieved(Object[] parameters) throws Exception {
- LOGGER.debug("signalRecieved: " + Arrays.toString(parameters));
+ public void signalReceived(Object[] parameters) throws Exception {
+ LOGGER.debug("signalReceived: " + Arrays.toString(parameters));
Exchange exchange = endpoint.createExchange(parameters, SWFConstants.SIGNAL_RECEIVED_ACTION);
exchange.setPattern(InOnly);
diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/converter/BindyConverterTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/converter/BindyConverterTest.java
index f39368b..c238de2 100644
--- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/converter/BindyConverterTest.java
+++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/converter/BindyConverterTest.java
@@ -101,7 +101,7 @@ public class BindyConverterTest extends CamelTestSupport {
@Test
@DirtiesContext
public void testRightAlignedNotTrimmed() throws Exception {
- AllCombinations data = sendAndRecieveAllCombinations();
+ AllCombinations data = sendAndReceiveAllCombinations();
assertThat("Right aligned, padding not trimmed", data.field1, Is.is("!!!f1"));
}
@@ -109,7 +109,7 @@ public class BindyConverterTest extends CamelTestSupport {
@Test
@DirtiesContext
public void testLeftAlignedNotTrimmed() throws Exception {
- AllCombinations data = sendAndRecieveAllCombinations();
+ AllCombinations data = sendAndReceiveAllCombinations();
assertThat("Left aligned, padding not trimmed", data.field2, Is.is("f2!!!"));
}
@@ -117,7 +117,7 @@ public class BindyConverterTest extends CamelTestSupport {
@Test
@DirtiesContext
public void testRightAlignedTrimmed() throws Exception {
- AllCombinations data = sendAndRecieveAllCombinations();
+ AllCombinations data = sendAndReceiveAllCombinations();
assertThat("Right aligned, padding trimmed", data.field3, Is.is("f3"));
}
@@ -125,7 +125,7 @@ public class BindyConverterTest extends CamelTestSupport {
@Test
@DirtiesContext
public void testLeftAlignedTrimmed() throws Exception {
- AllCombinations data = sendAndRecieveAllCombinations();
+ AllCombinations data = sendAndReceiveAllCombinations();
assertThat("Left aligned, padding trimmed", data.field4, Is.is("f4"));
}
@@ -133,7 +133,7 @@ public class BindyConverterTest extends CamelTestSupport {
@Test
@DirtiesContext
public void testRightAlignedRecordPaddingNotTrimmed() throws Exception {
- AllCombinations data = sendAndRecieveAllCombinations();
+ AllCombinations data = sendAndReceiveAllCombinations();
assertThat("Right aligned, padding not trimmed", data.field5, Is.is("###f5"));
}
@@ -141,7 +141,7 @@ public class BindyConverterTest extends CamelTestSupport {
@Test
@DirtiesContext
public void testLeftAlignedRecordPaddingNotTrimmed() throws Exception {
- AllCombinations data = sendAndRecieveAllCombinations();
+ AllCombinations data = sendAndReceiveAllCombinations();
assertThat("Left aligned, padding not trimmed", data.field6, Is.is("f6###"));
}
@@ -149,7 +149,7 @@ public class BindyConverterTest extends CamelTestSupport {
@Test
@DirtiesContext
public void testRightAlignedRecordPaddingTrimmed() throws Exception {
- AllCombinations data = sendAndRecieveAllCombinations();
+ AllCombinations data = sendAndReceiveAllCombinations();
assertThat("Right aligned, padding trimmed", data.field7, Is.is("f7"));
}
@@ -157,12 +157,12 @@ public class BindyConverterTest extends CamelTestSupport {
@Test
@DirtiesContext
public void testLeftAlignedRecordPaddingTrimmed() throws Exception {
- AllCombinations data = sendAndRecieveAllCombinations();
+ AllCombinations data = sendAndReceiveAllCombinations();
assertThat("Left aligned, padding trimmed", data.field8, Is.is("f8"));
}
- private AllCombinations sendAndRecieveAllCombinations() throws InterruptedException {
+ private AllCombinations sendAndReceiveAllCombinations() throws InterruptedException {
AllCombinations all = new AllCombinations();
all.field1 = "f1";
all.field2 = "f2";
diff --git a/components/camel-browse/src/main/docs/browse-component.adoc b/components/camel-browse/src/main/docs/browse-component.adoc
index 2c44a46..4752ed1 100644
--- a/components/camel-browse/src/main/docs/browse-component.adoc
+++ b/components/camel-browse/src/main/docs/browse-component.adoc
@@ -97,7 +97,7 @@ We can now inspect the received exchanges from within the Java code:
----
private CamelContext context;
-public void inspectRecievedOrders() {
+public void inspectReceivedOrders() {
BrowsableEndpoint browse = context.getEndpoint("browse:orderReceived", BrowsableEndpoint.class);
List<Exchange> exchanges = browse.getExchanges();
diff --git a/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackDelimitedDataFormatTest.java b/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackDelimitedDataFormatTest.java
index b9ea96f..75e9f82 100644
--- a/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackDelimitedDataFormatTest.java
+++ b/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackDelimitedDataFormatTest.java
@@ -114,7 +114,7 @@ public class FlatpackDelimitedDataFormatTest extends CamelTestSupport {
// with the definition
from("direct:marshal").marshal(df).convertBodyTo(String.class).to("mock:marshal");
- // without the definition (will auto add column names from the recieved data)
+ // without the definition (will auto add column names from the received data)
FlatpackDataFormat df2 = new FlatpackDataFormat();
from("direct:marshal2").marshal(df2).convertBodyTo(String.class).to("mock:marshal2");
}
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentDuplicateNamesTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentDuplicateNamesTest.java
index 0a9b406..b25e5d2 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentDuplicateNamesTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentDuplicateNamesTest.java
@@ -37,7 +37,7 @@ import org.jvnet.mock_javamail.Mailbox;
public class MailAttachmentDuplicateNamesTest extends CamelTestSupport {
@Test
- public void testSendAndRecieveMailWithAttachmentsWithDuplicateNames() throws Exception {
+ public void testSendAndReceiveMailWithAttachmentsWithDuplicateNames() throws Exception {
// clear mailbox
Mailbox.clearAll();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHtmlAttachmentTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHtmlAttachmentTest.java
index 51fa0cd..2eaad5c 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHtmlAttachmentTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailHtmlAttachmentTest.java
@@ -37,7 +37,7 @@ import org.jvnet.mock_javamail.Mailbox;
public class MailHtmlAttachmentTest extends CamelTestSupport {
@Test
- public void testSendAndRecieveMailWithAttachments() throws Exception {
+ public void testSendAndReceiveMailWithAttachments() throws Exception {
// clear mailbox
Mailbox.clearAll();
diff --git a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
index 427c8f4..ff840a7 100644
--- a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
+++ b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailRouteTest.java
@@ -114,10 +114,10 @@ public class MailRouteTest extends CamelTestSupport {
from("pop3://route-test-james@localhost?initialDelay=100&delay=100").to("direct:a");
// must use fixed to option to send the mail to the given
- // reciever, as we have polled
+ // receiver, as we have polled
// a mail from a mailbox where it already has the 'old' To as
// header value
- // here we send the mail to 2 recievers. notice we can use a
+ // here we send the mail to 2 receivers. notice we can use a
// plain string with semi colon
// to seperate the mail addresses
from("direct:a")
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
index 75b57d3..5218cca 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpLineDelimiterUsingPlainSocketTest.java
@@ -53,16 +53,16 @@ public class MinaTcpLineDelimiterUsingPlainSocketTest extends BaseMinaTest {
@Test
public void testReceiveNoResponseSinceOutBodyIsNull() throws Exception {
String out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
}
@Test
public void testReceiveNoResponseSinceOutBodyIsNullTwice() throws Exception {
String out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
}
@Test
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
index 46f1b93..79522a1 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithInOutUsingPlainSocketTest.java
@@ -53,16 +53,16 @@ public class MinaTcpWithInOutUsingPlainSocketTest extends BaseMinaTest {
@Test
public void testReceiveNoResponseSinceOutBodyIsNull() throws Exception {
String out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
}
@Test
public void testReceiveNoResponseSinceOutBodyIsNullTwice() throws Exception {
String out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
}
@Test
diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTcpWithInOutUsingPlainSocketTest.java b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTcpWithInOutUsingPlainSocketTest.java
index aee89fe..299b963 100644
--- a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTcpWithInOutUsingPlainSocketTest.java
+++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTcpWithInOutUsingPlainSocketTest.java
@@ -51,16 +51,16 @@ public class NettyTcpWithInOutUsingPlainSocketTest extends BaseNettyTest {
@Test
public void testReceiveNoResponseSinceOutBodyIsNull() throws Exception {
String out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
}
@Test
public void testReceiveNoResponseSinceOutBodyIsNullTwice() throws Exception {
String out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
out = sendAndReceive("force-null-out-body");
- assertNull("no data should be recieved", out);
+ assertNull("no data should be received", out);
}
@Test
diff --git a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ConsumerStreamingTest.java b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ConsumerStreamingTest.java
index 086dd9f..d975024 100644
--- a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ConsumerStreamingTest.java
+++ b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ConsumerStreamingTest.java
@@ -54,9 +54,9 @@ public class ConsumerStreamingTest extends SplunkMockTestSupport {
when(jobMock.getResults(any())).thenReturn(stream);
assertMockEndpointsSatisfied();
- SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
- assertNotNull(recieved);
- Map<String, String> data = recieved.getEventData();
+ SplunkEvent received = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
+ assertNotNull(received);
+ Map<String, String> data = received.getEventData();
assertEquals("indexertpool", data.get("name"));
stream.close();
}
diff --git a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ConsumerTest.java b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ConsumerTest.java
index 3f635dc..d1f639e 100644
--- a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ConsumerTest.java
+++ b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/ConsumerTest.java
@@ -56,9 +56,9 @@ public class ConsumerTest extends SplunkMockTestSupport {
when(jobMock.getResults(any())).thenReturn(stream);
assertMockEndpointsSatisfied();
- SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
- assertNotNull(recieved);
- Map<String, String> data = recieved.getEventData();
+ SplunkEvent received = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
+ assertNotNull(received);
+ Map<String, String> data = received.getEventData();
assertEquals("indexertpool", data.get("name"));
assertEquals(true, searchMock.getReceivedExchanges().get(2).getProperty(Exchange.BATCH_COMPLETE, Boolean.class));
stream.close();
diff --git a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/NormalSearchTest.java b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/NormalSearchTest.java
index 9bd10b9..8745f64 100644
--- a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/NormalSearchTest.java
+++ b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/NormalSearchTest.java
@@ -35,9 +35,9 @@ public class NormalSearchTest extends SplunkTest {
getMockEndpoint("mock:submit-result").expectedMessageCount(1);
assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
- SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
- assertNotNull(recieved);
- Map<String, String> data = recieved.getEventData();
+ SplunkEvent received = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
+ assertNotNull(received);
+ Map<String, String> data = received.getEventData();
assertEquals("value1", data.get("key1"));
assertEquals("value2", data.get("key2"));
assertEquals("value3", data.get("key3"));
diff --git a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/RealtimeSearchTest.java b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/RealtimeSearchTest.java
index 80db504..c03395a 100644
--- a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/RealtimeSearchTest.java
+++ b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/RealtimeSearchTest.java
@@ -33,9 +33,9 @@ public class RealtimeSearchTest extends SplunkTest {
searchMock.expectedMessageCount(1);
assertMockEndpointsSatisfied();
- SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
- assertNotNull(recieved);
- Map<String, String> data = recieved.getEventData();
+ SplunkEvent received = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
+ assertNotNull(received);
+ Map<String, String> data = received.getEventData();
assertEquals("value1", data.get("key1"));
assertEquals("value2", data.get("key2"));
assertEquals("value3", data.get("key3"));
diff --git a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/SavedSearchTest.java b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/SavedSearchTest.java
index bebb7ee..4d0ce93 100644
--- a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/SavedSearchTest.java
+++ b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/SavedSearchTest.java
@@ -36,9 +36,9 @@ public class SavedSearchTest extends SplunkTest {
searchMock.expectedMessageCount(1);
assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
- SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
- assertNotNull(recieved);
- Map<String, String> data = recieved.getEventData();
+ SplunkEvent received = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
+ assertNotNull(received);
+ Map<String, String> data = received.getEventData();
assertEquals("value1", data.get("key1"));
assertEquals("value2", data.get("key2"));
assertEquals("value3", data.get("key3"));
diff --git a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/SplunkProducerTest.java b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/SplunkProducerTest.java
index c89644a..ae16e59 100644
--- a/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/SplunkProducerTest.java
+++ b/components/camel-splunk/src/test/java/org/apache/camel/component/splunk/integration/SplunkProducerTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
@Ignore("run manually since it requires a running local splunk server")
public class SplunkProducerTest extends SplunkTest {
- // Splunk tcp reciever port configured in Splunk
+ // Splunk tcp receiver port configured in Splunk
private static final String TCP_RECIEVER_PORT = "9997";
@Test
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/RouteExclusionFromWithinSpringTestSupportTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/RouteExclusionFromWithinSpringTestSupportTest.java
index 054ba53..f1bc4d4 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/RouteExclusionFromWithinSpringTestSupportTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/RouteExclusionFromWithinSpringTestSupportTest.java
@@ -40,7 +40,7 @@ public class RouteExclusionFromWithinSpringTestSupportTest extends SpringTestSup
MockEndpoint mock = getMockEndpoint("mock:definitelyShouldNeverReceiveExchange");
mock.expectedMessageCount(0);
- sendBody("seda:shouldNeverRecieveExchange", "dropped like a hot rock");
+ sendBody("seda:shouldNeverReceiveExchange", "dropped like a hot rock");
mock.await(500, TimeUnit.MILLISECONDS);
mock.assertIsSatisfied();
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
index fa08ca1..8eea42e 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
@@ -61,7 +61,7 @@ public class SpringComponentScanTest extends ContextTestSupport {
MockEndpoint mock = getMockEndpoint("mock:definitelyShouldNeverReceiveExchange");
mock.expectedMessageCount(0);
- sendBody("seda:shouldNeverRecieveExchange", "dropped like a hot rock");
+ sendBody("seda:shouldNeverReceiveExchange", "dropped like a hot rock");
mock.await(500, TimeUnit.MILLISECONDS);
mock.assertIsSatisfied();
}
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/route/MyExcludedRouteBuilder.java b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/route/MyExcludedRouteBuilder.java
index 411c495..af87b71 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/route/MyExcludedRouteBuilder.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/route/MyExcludedRouteBuilder.java
@@ -22,6 +22,6 @@ public class MyExcludedRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
- from("direct:shouldNeverRecieveExchange").to("mock:definitelyShouldNeverReceiveExchange");
+ from("direct:shouldNeverReceiveExchange").to("mock:definitelyShouldNeverReceiveExchange");
}
}
diff --git a/components/camel-undertow/src/generated/resources/org/apache/camel/component/undertow/undertow.json b/components/camel-undertow/src/generated/resources/org/apache/camel/component/undertow/undertow.json
index ec15c62..4c8cb9c 100644
--- a/components/camel-undertow/src/generated/resources/org/apache/camel/component/undertow/undertow.json
+++ b/components/camel-undertow/src/generated/resources/org/apache/camel/component/undertow/undertow.json
@@ -55,7 +55,7 @@
"tcpNoDelay": { "kind": "parameter", "displayName": "Tcp No Delay", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": "true", "description": "Setting to improve TCP protocol performance" },
"throwExceptionOnFailure": { "kind": "parameter", "displayName": "Throw Exception On Failure", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": "true", "description": "Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code." },
"transferException": { "kind": "parameter", "displayName": "Transfer Exception", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "secret": false, "defaultValue": "false", "description": "If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application\/x-java-serialized-object content type. On the producer side th [...]
- "accessLogReceiver": { "kind": "parameter", "displayName": "Access Log Receiver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "io.undertow.server.handlers.accesslog.AccessLogReceiver", "deprecated": false, "secret": false, "description": "Which Undertow AccessLogReciever should be used Will use JBossLoggingAccessLogReceiver if not specifid" },
+ "accessLogReceiver": { "kind": "parameter", "displayName": "Access Log Receiver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "io.undertow.server.handlers.accesslog.AccessLogReceiver", "deprecated": false, "secret": false, "description": "Which Undertow AccessLogReceiver should be used Will use JBossLoggingAccessLogReceiver if not specifid" },
"basicPropertyBinding": { "kind": "parameter", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" },
"headerFilterStrategy": { "kind": "parameter", "displayName": "Header Filter Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.HeaderFilterStrategy", "deprecated": false, "secret": false, "description": "To use a custom HeaderFilterStrategy to filter header to and from Camel message." },
"synchronous": { "kind": "parameter", "displayName": "Synchronous", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "description": "Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported)." },
diff --git a/components/camel-undertow/src/main/docs/undertow-component.adoc b/components/camel-undertow/src/main/docs/undertow-component.adoc
index 20db802..920dc1d 100644
--- a/components/camel-undertow/src/main/docs/undertow-component.adoc
+++ b/components/camel-undertow/src/main/docs/undertow-component.adoc
@@ -117,7 +117,7 @@ with the following path and query parameters:
| *tcpNoDelay* (producer) | Setting to improve TCP protocol performance | true | Boolean
| *throwExceptionOnFailure* (producer) | Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code. | true | Boolean
| *transferException* (producer) | If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type. On the producer side the exception will be deserialized and thrown as is instead of the HttpOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the in [...]
-| *accessLogReceiver* (advanced) | Which Undertow AccessLogReciever should be used Will use JBossLoggingAccessLogReceiver if not specifid | | AccessLogReceiver
+| *accessLogReceiver* (advanced) | Which Undertow AccessLogReceiver should be used Will use JBossLoggingAccessLogReceiver if not specifid | | AccessLogReceiver
| *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
| *headerFilterStrategy* (advanced) | To use a custom HeaderFilterStrategy to filter header to and from Camel message. | | HeaderFilterStrategy
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java
index 508cdc6..245b064 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowConsumer.java
@@ -108,14 +108,14 @@ public class UndertowConsumer extends DefaultConsumer implements HttpHandler, Su
// allow for HTTP 1.1 continue
HttpHandler httpHandler = new EagerFormParsingHandler().setNext(UndertowConsumer.this);
if (endpoint.getAccessLog()) {
- AccessLogReceiver accessLogReciever = null;
+ AccessLogReceiver accessLogReceiver = null;
if (endpoint.getAccessLogReceiver() != null) {
- accessLogReciever = endpoint.getAccessLogReceiver();
+ accessLogReceiver = endpoint.getAccessLogReceiver();
} else {
- accessLogReciever = new JBossLoggingAccessLogReceiver();
+ accessLogReceiver = new JBossLoggingAccessLogReceiver();
}
httpHandler = new AccessLogHandler(httpHandler,
- accessLogReciever,
+ accessLogReceiver,
"common",
AccessLogHandler.class.getClassLoader());
}
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
index 1973321..5d5b42e 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/UndertowEndpoint.java
@@ -604,7 +604,7 @@ public class UndertowEndpoint extends DefaultEndpoint implements AsyncEndpoint,
}
/**
- * Which Undertow AccessLogReciever should be used
+ * Which Undertow AccessLogReceiver should be used
* Will use JBossLoggingAccessLogReceiver if not specifid
*/
public void setAccessLogReceiver(AccessLogReceiver accessLogReceiver) {
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/operations/FutureEventDrivenOperation.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/operations/FutureEventDrivenOperation.java
index 88bc6e3..c46e31f 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/operations/FutureEventDrivenOperation.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/operations/FutureEventDrivenOperation.java
@@ -52,7 +52,7 @@ public abstract class FutureEventDrivenOperation<ResultType> extends ZooKeeperOp
this.event = event;
EventType received = event.getType();
if (LOG.isDebugEnabled()) {
- LOG.debug(format("Recieved event of type %s for node '%s'", received, event.getPath()));
+ LOG.debug(format("Received event of type %s for node '%s'", received, event.getPath()));
}
for (EventType watched : awaitedTypes) {
@@ -71,7 +71,7 @@ public abstract class FutureEventDrivenOperation<ResultType> extends ZooKeeperOp
if (b.length() > 0) {
b.setLength(b.length() - 2);
}
- LOG.trace(String.format("Recieved event of type %s did not match any watched types %s", received, Arrays.toString(awaitedTypes)));
+ LOG.trace(String.format("Received event of type %s did not match any watched types %s", received, Arrays.toString(awaitedTypes)));
}
}
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/UndertowEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/UndertowEndpointBuilderFactory.java
index b0ab71e..090e789 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/UndertowEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/UndertowEndpointBuilderFactory.java
@@ -478,7 +478,7 @@ public interface UndertowEndpointBuilderFactory {
return this;
}
/**
- * Which Undertow AccessLogReciever should be used Will use
+ * Which Undertow AccessLogReceiver should be used Will use
* JBossLoggingAccessLogReceiver if not specifid.
*
* The option is a:
@@ -493,7 +493,7 @@ public interface UndertowEndpointBuilderFactory {
return this;
}
/**
- * Which Undertow AccessLogReciever should be used Will use
+ * Which Undertow AccessLogReceiver should be used Will use
* JBossLoggingAccessLogReceiver if not specifid.
*
* The option will be converted to a
@@ -1122,7 +1122,7 @@ public interface UndertowEndpointBuilderFactory {
return (UndertowEndpointProducerBuilder) this;
}
/**
- * Which Undertow AccessLogReciever should be used Will use
+ * Which Undertow AccessLogReceiver should be used Will use
* JBossLoggingAccessLogReceiver if not specifid.
*
* The option is a:
@@ -1137,7 +1137,7 @@ public interface UndertowEndpointBuilderFactory {
return this;
}
/**
- * Which Undertow AccessLogReciever should be used Will use
+ * Which Undertow AccessLogReceiver should be used Will use
* JBossLoggingAccessLogReceiver if not specifid.
*
* The option will be converted to a
@@ -1422,7 +1422,7 @@ public interface UndertowEndpointBuilderFactory {
return (UndertowEndpointBuilder) this;
}
/**
- * Which Undertow AccessLogReciever should be used Will use
+ * Which Undertow AccessLogReceiver should be used Will use
* JBossLoggingAccessLogReceiver if not specifid.
*
* The option is a:
@@ -1437,7 +1437,7 @@ public interface UndertowEndpointBuilderFactory {
return this;
}
/**
- * Which Undertow AccessLogReciever should be used Will use
+ * Which Undertow AccessLogReceiver should be used Will use
* JBossLoggingAccessLogReceiver if not specifid.
*
* The option will be converted to a
diff --git a/docs/components/modules/ROOT/pages/browse-component.adoc b/docs/components/modules/ROOT/pages/browse-component.adoc
index c8fc72d..cb5bf0c 100644
--- a/docs/components/modules/ROOT/pages/browse-component.adoc
+++ b/docs/components/modules/ROOT/pages/browse-component.adoc
@@ -99,7 +99,7 @@ We can now inspect the received exchanges from within the Java code:
----
private CamelContext context;
-public void inspectRecievedOrders() {
+public void inspectReceivedOrders() {
BrowsableEndpoint browse = context.getEndpoint("browse:orderReceived", BrowsableEndpoint.class);
List<Exchange> exchanges = browse.getExchanges();
diff --git a/docs/components/modules/ROOT/pages/undertow-component.adoc b/docs/components/modules/ROOT/pages/undertow-component.adoc
index 282c603..aef7161 100644
--- a/docs/components/modules/ROOT/pages/undertow-component.adoc
+++ b/docs/components/modules/ROOT/pages/undertow-component.adoc
@@ -119,7 +119,7 @@ with the following path and query parameters:
| *tcpNoDelay* (producer) | Setting to improve TCP protocol performance | true | Boolean
| *throwExceptionOnFailure* (producer) | Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardless of the HTTP status code. | true | Boolean
| *transferException* (producer) | If enabled and an Exchange failed processing on the consumer side and if the caused Exception was send back serialized in the response as a application/x-java-serialized-object content type. On the producer side the exception will be deserialized and thrown as is instead of the HttpOperationFailedException. The caused exception is required to be serialized. This is by default turned off. If you enable this then be aware that Java will deserialize the in [...]
-| *accessLogReceiver* (advanced) | Which Undertow AccessLogReciever should be used Will use JBossLoggingAccessLogReceiver if not specifid | | AccessLogReceiver
+| *accessLogReceiver* (advanced) | Which Undertow AccessLogReceiver should be used Will use JBossLoggingAccessLogReceiver if not specifid | | AccessLogReceiver
| *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
| *headerFilterStrategy* (advanced) | To use a custom HeaderFilterStrategy to filter header to and from Camel message. | | HeaderFilterStrategy
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
diff --git a/docs/user-manual/modules/ROOT/pages/exception-clause.adoc b/docs/user-manual/modules/ROOT/pages/exception-clause.adoc
index 35474cb..2c52cff 100644
--- a/docs/user-manual/modules/ROOT/pages/exception-clause.adoc
+++ b/docs/user-manual/modules/ROOT/pages/exception-clause.adoc
@@ -747,7 +747,7 @@ from("jms:queue:order:input")
.to("bean:handleOrder");
----
-Then the message has been enriched with a header named application after the original message was recieved in the JMS endpoint. And in case of an error then the `onException`
+Then the message has been enriched with a header named application after the original message was received in the JMS endpoint. And in case of an error then the `onException`
will handle the exception and use the original message body and the headers from the current message as-is, which means the headers will include the application header.
[[ExceptionClause-AdvancedUsageofExceptionClause]]