This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit ddc3990c5cbb9379ea406f0bc4ff98650ef7c505 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Fri Jun 7 11:03:42 2024 +0200 CAMEL-20838: use appropriate methods for setting up/cleaning up resources (camel-servlet) --- .../camel/component/servlet/HttpClientRouteExampleSpringTest.java | 7 ++++--- .../apache/camel/component/servlet/HttpClientRouteSpringTest.java | 5 +++-- .../org/apache/camel/component/servlet/HttpClientRouteTest.java | 2 +- .../camel/component/servlet/ServletCamelRouterTestSupport.java | 7 +++---- 4 files changed, 11 insertions(+), 10 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 39f68dab879..712bdf9eeaa 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 @@ -40,9 +40,10 @@ public class HttpClientRouteExampleSpringTest extends ServletCamelRouterTestSupp } @Override - public void doPreSetup() { - startCamelContext = false; - testConfiguration().withAutoStartContext(startCamelContext); + public void setupResources() throws Exception { + super.setupResources(); + + testConfiguration().withAutoStartContext(false); } @Override 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 9b3f6476bad..20375d120fb 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 @@ -23,8 +23,9 @@ import org.springframework.web.context.ContextLoaderListener; public class HttpClientRouteSpringTest extends HttpClientRouteTest { @Override - public void doPreSetup() { - startCamelContext = false; + public void setupResources() throws Exception { + super.setupResources(); + testConfiguration().withAutoStartContext(false); } @Override 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 bdfc5ab2608..4b4fa7cdb0d 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 @@ -115,7 +115,7 @@ public class HttpClientRouteTest extends ServletCamelRouterTestSupport { @Test public void testCreateSerlvetEndpointProducer() throws Exception { - assumeTrue(startCamelContext, "don't test it with web.xml configure"); + assumeTrue(testConfiguration().autoStartContext(), "don't test it with web.xml configure"); try { context.addRoutes(new RouteBuilder() { @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 38810272d92..7096b81bb7c 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 @@ -45,13 +45,12 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport { public static final String CONTEXT = "/mycontext"; protected String contextUrl; - protected boolean startCamelContext = true; protected int port; protected DeploymentManager manager; protected Undertow server; @Override - public void doPreSetup() throws Exception { + public void setupResources() throws Exception { port = AvailablePortFinder.getNextAvailable(); DeploymentInfo servletBuilder = getDeploymentInfo(); manager = Servlets.newContainer().addDeployment(servletBuilder); @@ -63,11 +62,11 @@ public class ServletCamelRouterTestSupport extends CamelTestSupport { server.start(); contextUrl = "http://localhost:" + port + CONTEXT; - testConfiguration().withAutoStartContext(startCamelContext); + testConfiguration().withAutoStartContext(true); } @Override - public void doPostTearDown() throws ServletException { + public void cleanupResources() throws ServletException { server.stop(); manager.stop(); manager.undeploy();