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 ecfd3425d91e735e010c53f709faf811925be1c5
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Tue Sep 13 13:22:47 2022 +0200

    CAMEL-18456: converted camel-olingo2 to camel-test-infra-jetty
---
 .../camel-olingo2/camel-olingo2-component/pom.xml  | 28 +++++---------
 .../olingo2/AbstractOlingo2AppAPITestSupport.java  | 17 ++++++++
 .../olingo2/AbstractOlingo2TestSupport.java        | 16 ++++++++
 .../camel/component/olingo2/Olingo2AppAPITest.java | 32 ++++++++-------
 .../olingo2/Olingo2ComponentConsumerTest.java      | 28 ++++++--------
 .../olingo2/Olingo2ComponentProducerTest.java      | 26 +++++--------
 .../camel/component/olingo2/Olingo2RouteTest.java  | 24 ++++++------
 ...ingo2SampleServer.java => Olingo2TestUtil.java} | 45 ++--------------------
 .../infra/jetty/services/JettyConfiguration.java   |  9 +++++
 .../jetty/services/JettyConfigurationBuilder.java  | 10 ++++-
 .../infra/jetty/services/JettyEmbeddedService.java | 12 +++++-
 11 files changed, 122 insertions(+), 125 deletions(-)

diff --git a/components/camel-olingo2/camel-olingo2-component/pom.xml 
b/components/camel-olingo2/camel-olingo2-component/pom.xml
index 8634e93401d..7930d4b9c74 100644
--- a/components/camel-olingo2/camel-olingo2-component/pom.xml
+++ b/components/camel-olingo2/camel-olingo2-component/pom.xml
@@ -107,28 +107,20 @@
             <scope>test</scope>
         </dependency>
 
+        <!-- test infra -->
         <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-servlet</artifactId>
-            <version>${jetty-version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-server</artifactId>
-            <version>${jetty-version}</version>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-common</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
             <scope>test</scope>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.eclipse.jetty.orbit</groupId>
-                    <artifactId>javax.servlet</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
+
         <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-webapp</artifactId>
-            <version>${jetty-version}</version>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-infra-jetty</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2AppAPITestSupport.java
 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2AppAPITestSupport.java
index c7f65214772..fdd1a805e25 100644
--- 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2AppAPITestSupport.java
+++ 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2AppAPITestSupport.java
@@ -28,6 +28,8 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.component.olingo2.api.Olingo2ResponseHandler;
 import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.infra.jetty.services.JettyConfiguration;
+import org.apache.camel.test.infra.jetty.services.JettyConfigurationBuilder;
 import org.apache.http.entity.ContentType;
 import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
 import org.apache.olingo.odata2.api.ep.feed.ODataDeltaFeed;
@@ -140,6 +142,21 @@ public class AbstractOlingo2AppAPITestSupport {
         return b.toString();
     }
 
+    protected static JettyConfiguration createConfiguration() {
+        return createConfiguration(PORT);
+    }
+
+    protected static JettyConfiguration createConfiguration(int port) {
+        return JettyConfigurationBuilder
+                .emptyTemplate()
+                .withPort(port)
+                .withContextPath(JettyConfiguration.ROOT_CONTEXT_PATH)
+                .withWebAppContextConfiguration()
+                .withWebApp(AbstractOlingo2TestSupport.getWebResource())
+                .build()
+                .build();
+    }
+
     protected static final class TestOlingo2ResponseHandler<T> implements 
Olingo2ResponseHandler<T> {
 
         private T response;
diff --git 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2TestSupport.java
 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2TestSupport.java
index a915dfd7865..42bc0d979f7 100644
--- 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2TestSupport.java
+++ 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/AbstractOlingo2TestSupport.java
@@ -17,12 +17,15 @@
 package org.apache.camel.component.olingo2;
 
 import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
 import java.util.Map;
 import java.util.Properties;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Assumptions;
 
 /**
  * Abstract base class for Olingo Integration tests generated by Camel API 
component maven plugin.
@@ -32,6 +35,19 @@ public class AbstractOlingo2TestSupport extends 
CamelTestSupport {
     private static final String TEST_OPTIONS_PROPERTIES = 
"/test-options.properties";
     private Properties properties = new Properties();
 
+    protected static String getWebResource() {
+        final URL resource = 
AbstractOlingo2TestSupport.class.getResource("/olingo2_ref");
+
+        Assumptions.assumeTrue(resource != null, "The web app cannot be 
found");
+        try {
+            return resource.toURI().getPath();
+        } catch (URISyntaxException e) {
+            Assumptions.abort("Unable to convert the resource to URI");
+        }
+
+        return null;
+    }
+
     protected void setDefaultTestProperty(String key, String value) {
         properties.setProperty(key, value);
     }
diff --git 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppAPITest.java
 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppAPITest.java
index 65a8471474c..f309642844d 100644
--- 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppAPITest.java
+++ 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2AppAPITest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.olingo2;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -33,6 +34,8 @@ import 
org.apache.camel.component.olingo2.api.batch.Olingo2BatchResponse;
 import org.apache.camel.component.olingo2.api.batch.Operation;
 import org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl;
 import org.apache.camel.component.olingo2.api.impl.SystemQueryOption;
+import org.apache.camel.test.infra.jetty.services.JettyConfiguration;
+import org.apache.camel.test.infra.jetty.services.JettyEmbeddedService;
 import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.edm.EdmEntitySet;
@@ -47,6 +50,7 @@ import 
org.apache.olingo.odata2.api.servicedocument.ServiceDocument;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -64,29 +68,29 @@ public class Olingo2AppAPITest extends 
AbstractOlingo2AppAPITestSupport {
     private static Edm edm;
     private static Map<String, EdmEntitySet> edmEntitySetMap;
 
-    private static Olingo2SampleServer server;
+    private static final JettyConfiguration JETTY_CONFIGURATION = 
createConfiguration();
+
+    @RegisterExtension
+    public static JettyEmbeddedService service = new 
JettyEmbeddedService(JETTY_CONFIGURATION);
 
     @BeforeAll
-    public static void beforeClass() throws Exception {
-        startServers(PORT);
-        Olingo2SampleServer.generateSampleData(TEST_SERVICE_URL);
-        setupClient();
+    public static void beforeClass() {
+        try {
+            Olingo2TestUtil.generateSampleData(TEST_SERVICE_URL);
+            setupClient();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
     }
 
     @AfterAll
-    public static void afterClass() throws Exception {
+    public static void afterClass() {
         if (olingoApp != null) {
             olingoApp.close();
         }
-        if (server != null) {
-            server.stop();
-            server.destroy();
-        }
-    }
 
-    protected static void startServers(int port) throws Exception {
-        server = new Olingo2SampleServer(port, "/olingo2_ref");
-        server.start();
     }
 
     protected static void setupClient() throws Exception {
diff --git 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentConsumerTest.java
 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentConsumerTest.java
index f8b1bdde661..725294c3627 100644
--- 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentConsumerTest.java
+++ 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentConsumerTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.olingo2;
 
+import java.io.IOException;
 import java.util.Map;
 
 import org.apache.camel.CamelContext;
@@ -24,12 +25,15 @@ import org.apache.camel.LoggingLevel;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.infra.jetty.services.JettyConfiguration;
+import org.apache.camel.test.infra.jetty.services.JettyEmbeddedService;
 import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
 import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
-import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
+import static 
org.apache.camel.component.olingo2.AbstractOlingo2AppAPITestSupport.createConfiguration;
 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;
@@ -48,7 +52,10 @@ public class Olingo2ComponentConsumerTest extends 
AbstractOlingo2TestSupport {
     private static final int PORT = AvailablePortFinder.getNextAvailable();
     private static final String TEST_SERVICE_URL = "http://localhost:"; + PORT 
+ "/MyFormula.svc";
 
-    private static Olingo2SampleServer server;
+    private static final JettyConfiguration JETTY_CONFIGURATION = 
createConfiguration(PORT);
+
+    @RegisterExtension
+    public static JettyEmbeddedService service = new 
JettyEmbeddedService(JETTY_CONFIGURATION);
 
     public Olingo2ComponentConsumerTest() {
         setDefaultTestProperty("serviceUri", "http://localhost:"; + PORT + 
"/MyFormula.svc");
@@ -63,22 +70,9 @@ public class Olingo2ComponentConsumerTest extends 
AbstractOlingo2TestSupport {
     }
 
     @BeforeAll
-    public static void beforeClass() throws Exception {
-        startServers(PORT);
-        Olingo2SampleServer.generateSampleData(TEST_SERVICE_URL);
-    }
-
-    @AfterAll
-    public static void afterClass() throws Exception {
-        if (server != null) {
-            server.stop();
-            server.destroy();
-        }
-    }
+    public static void beforeClass() throws IOException {
+        Olingo2TestUtil.generateSampleData(TEST_SERVICE_URL);
 
-    protected static void startServers(int port) throws Exception {
-        server = new Olingo2SampleServer(port, "/olingo2_ref");
-        server.start();
     }
 
     private void addRouteAndStartContext(RouteBuilder builder) throws 
Exception {
diff --git 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentProducerTest.java
 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentProducerTest.java
index d90055eabea..44c4fe7bd62 100644
--- 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentProducerTest.java
+++ 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2ComponentProducerTest.java
@@ -33,17 +33,20 @@ import 
org.apache.camel.component.olingo2.api.impl.Olingo2AppImpl;
 import org.apache.camel.component.olingo2.api.impl.SystemQueryOption;
 import org.apache.camel.component.olingo2.internal.Olingo2Constants;
 import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.infra.jetty.services.JettyConfiguration;
+import org.apache.camel.test.infra.jetty.services.JettyEmbeddedService;
 import org.apache.olingo.odata2.api.commons.HttpStatusCodes;
 import org.apache.olingo.odata2.api.edm.Edm;
 import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
 import org.apache.olingo.odata2.api.ep.feed.ODataFeed;
 import org.apache.olingo.odata2.api.servicedocument.ServiceDocument;
-import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static 
org.apache.camel.component.olingo2.AbstractOlingo2AppAPITestSupport.createConfiguration;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -74,7 +77,10 @@ public class Olingo2ComponentProducerTest extends 
AbstractOlingo2TestSupport {
             = String.format("DefaultContainer.Manufacturers('%s')", 
TEST_CREATE_MANUFACTURER_ID);
     private static final String TEST_SERVICE_URL = "http://localhost:"; + PORT 
+ "/MyFormula.svc";
 
-    private static Olingo2SampleServer server;
+    private static final JettyConfiguration JETTY_CONFIGURATION = 
createConfiguration(PORT);
+
+    @RegisterExtension
+    public static JettyEmbeddedService service = new 
JettyEmbeddedService(JETTY_CONFIGURATION);
 
     public Olingo2ComponentProducerTest() {
         setDefaultTestProperty("serviceUri", "http://localhost:"; + PORT + 
"/MyFormula.svc");
@@ -82,21 +88,7 @@ public class Olingo2ComponentProducerTest extends 
AbstractOlingo2TestSupport {
 
     @BeforeAll
     public static void beforeClass() throws Exception {
-        startServers(PORT);
-        Olingo2SampleServer.generateSampleData(TEST_SERVICE_URL);
-    }
-
-    @AfterAll
-    public static void afterClass() throws Exception {
-        if (server != null) {
-            server.stop();
-            server.destroy();
-        }
-    }
-
-    protected static void startServers(int port) throws Exception {
-        server = new Olingo2SampleServer(port, "/olingo2_ref");
-        server.start();
+        Olingo2TestUtil.generateSampleData(TEST_SERVICE_URL);
     }
 
     @Test
diff --git 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2RouteTest.java
 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2RouteTest.java
index 208e7d94c05..9a056ef1b16 100644
--- 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2RouteTest.java
+++ 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2RouteTest.java
@@ -24,12 +24,16 @@ import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.olingo2.api.Olingo2App;
 import org.apache.camel.component.olingo2.internal.Olingo2Constants;
 import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.infra.jetty.services.JettyConfiguration;
+import org.apache.camel.test.infra.jetty.services.JettyEmbeddedService;
 import org.apache.camel.test.junit5.CamelTestSupport;
 import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
+import static 
org.apache.camel.component.olingo2.AbstractOlingo2AppAPITestSupport.createConfiguration;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
@@ -39,28 +43,22 @@ public class Olingo2RouteTest extends CamelTestSupport {
     private static final String ID_PROPERTY = "Id";
 
     private static Olingo2App olingoApp;
-    private static Olingo2SampleServer server;
+
+    private static final JettyConfiguration JETTY_CONFIGURATION = 
createConfiguration(PORT);
+
+    @RegisterExtension
+    public static JettyEmbeddedService service = new 
JettyEmbeddedService(JETTY_CONFIGURATION);
 
     @BeforeAll
     public static void beforeClass() throws Exception {
-        startServers(PORT);
-        Olingo2SampleServer.generateSampleData(TEST_SERVICE_URL);
+        Olingo2TestUtil.generateSampleData(TEST_SERVICE_URL);
     }
 
     @AfterAll
-    public static void afterClass() throws Exception {
+    public static void afterClass() {
         if (olingoApp != null) {
             olingoApp.close();
         }
-        if (server != null) {
-            server.stop();
-            server.destroy();
-        }
-    }
-
-    protected static void startServers(int port) throws Exception {
-        server = new Olingo2SampleServer(port, "/olingo2_ref");
-        server.start();
     }
 
     @SuppressWarnings("unchecked")
diff --git 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2SampleServer.java
 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2TestUtil.java
similarity index 57%
rename from 
components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2SampleServer.java
rename to 
components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2TestUtil.java
index 3bb49b22973..eef9dd8fc4b 100644
--- 
a/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2SampleServer.java
+++ 
b/components/camel-olingo2/camel-olingo2-component/src/test/java/org/apache/camel/component/olingo2/Olingo2TestUtil.java
@@ -18,57 +18,18 @@ package org.apache.camel.component.olingo2;
 
 import java.io.IOException;
 import java.lang.reflect.Method;
-import java.net.URISyntaxException;
 
-import org.eclipse.jetty.server.Handler;
-import org.eclipse.jetty.server.handler.DefaultHandler;
-import org.eclipse.jetty.server.handler.HandlerCollection;
-import org.eclipse.jetty.webapp.WebAppContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * The embedded server for hosting the olingo2 sample service during the tests
  */
-public class Olingo2SampleServer {
-    private static final Logger LOG = 
LoggerFactory.getLogger(Olingo2SampleServer.class);
+public final class Olingo2TestUtil {
+    private static final Logger LOG = 
LoggerFactory.getLogger(Olingo2TestUtil.class);
 
-    private org.eclipse.jetty.server.Server server;
-    private int port;
+    private Olingo2TestUtil() {
 
-    /**
-     * @param port
-     * @param resourcePath
-     */
-    public Olingo2SampleServer(int port, String resourcePath) {
-        this.port = port;
-        server = new org.eclipse.jetty.server.Server(port);
-
-        WebAppContext webappcontext = new WebAppContext();
-        String contextPath = null;
-        try {
-            contextPath = 
Olingo2SampleServer.class.getResource(resourcePath).toURI().getPath();
-        } catch (URISyntaxException e) {
-            LOG.error("Unable to read the resource at {}", resourcePath, e);
-        }
-        webappcontext.setContextPath("/");
-
-        webappcontext.setWar(contextPath);
-
-        server.setHandler(webappcontext);
-    }
-
-    public void start() throws Exception {
-        server.start();
-        LOG.debug("Olingo sample server started at port {}", port);
-    }
-
-    public void stop() throws Exception {
-        server.stop();
-    }
-
-    public void destroy() {
-        server.destroy();
     }
 
     static void generateSampleData(String serviceUrl) throws IOException {
diff --git 
a/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfiguration.java
 
b/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfiguration.java
index 0390d02dade..16fb864ec4b 100644
--- 
a/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfiguration.java
+++ 
b/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfiguration.java
@@ -38,6 +38,7 @@ import 
org.eclipse.jetty.security.authentication.BasicAuthenticator;
 import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.handler.ContextHandler;
 import org.eclipse.jetty.server.handler.ErrorHandler;
+import org.eclipse.jetty.server.handler.HandlerCollection;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 import org.eclipse.jetty.util.security.Constraint;
@@ -288,6 +289,14 @@ public class JettyConfiguration {
         }
     }
 
+    public static class HandlerCollectionConfiguration {
+        private final HandlerCollection handlers = new HandlerCollection();
+
+        public void setHandlers(Handler[] handlers) {
+            this.handlers.setHandlers(handlers);
+        }
+    }
+
     private int port;
     private SSLContext sslContext;
 
diff --git 
a/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfigurationBuilder.java
 
b/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfigurationBuilder.java
index 9edad30fbd9..ee47da7cae4 100644
--- 
a/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfigurationBuilder.java
+++ 
b/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyConfigurationBuilder.java
@@ -96,8 +96,10 @@ public final class JettyConfigurationBuilder {
             this.webContextConfiguration = new 
JettyConfiguration.WebContextConfiguration(jettyConfiguration.getContextPath());
         }
 
-        public String getContextPath() {
-            return webContextConfiguration.getContextPath();
+        public WebAppContextConfigurationBuilder withWebApp(String webApp) {
+            webContextConfiguration.setWebApp(webApp);
+
+            return this;
         }
 
         @Override
@@ -149,6 +151,10 @@ public final class JettyConfigurationBuilder {
         }
     }
 
+    public static class HandlerContextConfigurationBuilder {
+
+    }
+
     private JettyConfiguration jettyConfiguration = new JettyConfiguration();
 
     private JettyConfigurationBuilder() {
diff --git 
a/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyEmbeddedService.java
 
b/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyEmbeddedService.java
index 567fc9207eb..db2eb902dd7 100644
--- 
a/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyEmbeddedService.java
+++ 
b/test-infra/camel-test-infra-jetty/src/test/java/org/apache/camel/test/infra/jetty/services/JettyEmbeddedService.java
@@ -92,6 +92,10 @@ public class JettyEmbeddedService implements JettyService, 
BeforeEachCallback, A
 
     @Override
     public void shutdown() {
+        if (server == null) {
+            return;
+        }
+
         try {
             server.stop();
 
@@ -106,12 +110,16 @@ public class JettyEmbeddedService implements 
JettyService, BeforeEachCallback, A
 
     @Override
     public void afterEach(ExtensionContext extensionContext) throws Exception {
-        shutdown();
+        if (server != null && server.isStarted()) {
+            shutdown();
+        }
     }
 
     @Override
     public void beforeEach(ExtensionContext extensionContext) throws Exception 
{
-        initialize();
+        if (server == null || server.isStopped()) {
+            initialize();
+        }
     }
 
     @Override

Reply via email to