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 <gno...@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 -->