This is an automated email from the ASF dual-hosted git repository. deki pushed a commit to branch CXF-7949_jakarta-servlet in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 4a56c1e3444b4c8dc51e2f919439c891c63bd903 Author: Alexey Markevich <buhhu...@gmail.com> AuthorDate: Mon Jan 20 15:25:08 2020 +0300 [CXF-7949] fix tests used embded Tomcat --- systests/cdi/base/pom.xml | 4 --- .../cdi/base/tomcat/AbstractTomcatServer.java | 30 +++++------------ systests/cdi/cdi-owb/pom.xml | 4 --- systests/cdi/pom.xml | 38 +--------------------- systests/rs-sse/pom.xml | 12 ------- .../jaxrs/sse/tomcat/AbstractTomcatServer.java | 37 +++++++-------------- systests/rs-sse/rs-sse-undertow/pom.xml | 5 +++ 7 files changed, 26 insertions(+), 104 deletions(-) diff --git a/systests/cdi/base/pom.xml b/systests/cdi/base/pom.xml index b6dd4c2..1e80cca 100644 --- a/systests/cdi/base/pom.xml +++ b/systests/cdi/base/pom.xml @@ -40,10 +40,6 @@ </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-plus</artifactId> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-webapp</artifactId> </dependency> <dependency> diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/tomcat/AbstractTomcatServer.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/tomcat/AbstractTomcatServer.java index bc45212..e992639 100644 --- a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/tomcat/AbstractTomcatServer.java +++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/tomcat/AbstractTomcatServer.java @@ -19,21 +19,22 @@ package org.apache.cxf.systests.cdi.base.tomcat; -import java.io.File; -import java.io.IOException; import java.nio.file.Files; +import java.nio.file.Path; import org.apache.catalina.startup.Tomcat; +import org.apache.cxf.helpers.FileUtils; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; import static org.junit.Assert.fail; public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { - private Tomcat server; private final String resourcePath; private final String contextPath; private final int port; + private Tomcat server; + private Path base; protected AbstractTomcatServer(final String resourcePath, final String contextPath, int portNumber) { this.resourcePath = resourcePath; @@ -47,12 +48,13 @@ public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { server = new Tomcat(); server.setPort(port); + server.getConnector(); try { - final File base = createTemporaryDirectory(); - server.setBaseDir(base.getAbsolutePath()); + base = Files.createTempDirectory("tmp-"); + server.setBaseDir(base.toString()); - server.getHost().setAppBase(base.getAbsolutePath()); + server.getHost().setAppBase(base.toString()); server.getHost().setAutoDeploy(true); server.getHost().setDeployOnStartup(true); @@ -64,21 +66,6 @@ public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { } } - private static File createTemporaryDirectory() throws IOException { - final File base = Files.createTempFile("tmp-", "").toFile(); - - if (!base.delete()) { - throw new IOException("Cannot (re)create base folder: " + base.getAbsolutePath()); - } - - if (!base.mkdir()) { - throw new IOException("Cannot create base folder: " + base.getAbsolutePath()); - } - - base.deleteOnExit(); - return base; - } - public void tearDown() throws Exception { super.tearDown(); @@ -86,6 +73,7 @@ public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { server.stop(); server.destroy(); server = null; + FileUtils.removeDir(base.toFile()); } } } diff --git a/systests/cdi/cdi-owb/pom.xml b/systests/cdi/cdi-owb/pom.xml index 6074890..866814c 100644 --- a/systests/cdi/cdi-owb/pom.xml +++ b/systests/cdi/cdi-owb/pom.xml @@ -86,10 +86,6 @@ </dependency> <dependency> <groupId>org.apache.cxf</groupId> - <artifactId>cxf-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-jetty</artifactId> </dependency> <dependency> diff --git a/systests/cdi/pom.xml b/systests/cdi/pom.xml index e8ac98a..9622dc6 100644 --- a/systests/cdi/pom.xml +++ b/systests/cdi/pom.xml @@ -33,7 +33,7 @@ <url>https://cxf.apache.org</url> <properties> <cxf.glassfish.el.version>3.0.1-b11</cxf.glassfish.el.version> - <cxf.openwebbeans.version>2.0.8</cxf.openwebbeans.version> + <cxf.openwebbeans.version>2.0.14</cxf.openwebbeans.version> </properties> <modules> <module>base</module> @@ -54,11 +54,6 @@ </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-plus</artifactId> - <version>${cxf.jetty.version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> <artifactId>apache-jsp</artifactId> <version>${cxf.jetty.version}</version> <exclusions> @@ -69,37 +64,6 @@ </exclusions> </dependency> <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-transports-http-jetty</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-frontend-jaxrs</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-rs-client</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-integration-cdi</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-testutils</artifactId> - <version>${project.version}</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>javax.annotation</groupId> <artifactId>jsr250-api</artifactId> <version>${cxf.jsr250.api.version}</version> diff --git a/systests/rs-sse/pom.xml b/systests/rs-sse/pom.xml index 802f43a..e23a480 100644 --- a/systests/rs-sse/pom.xml +++ b/systests/rs-sse/pom.xml @@ -40,23 +40,11 @@ </dependency> <dependency> <groupId>org.apache.cxf</groupId> - <artifactId>cxf-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-rt-transports-http-jetty</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxrs</artifactId> - <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-client</artifactId> - <version>${project.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> diff --git a/systests/rs-sse/rs-sse-tomcat/src/test/java/org/apache/cxf/systest/jaxrs/sse/tomcat/AbstractTomcatServer.java b/systests/rs-sse/rs-sse-tomcat/src/test/java/org/apache/cxf/systest/jaxrs/sse/tomcat/AbstractTomcatServer.java index 08e720a..d466e61 100644 --- a/systests/rs-sse/rs-sse-tomcat/src/test/java/org/apache/cxf/systest/jaxrs/sse/tomcat/AbstractTomcatServer.java +++ b/systests/rs-sse/rs-sse-tomcat/src/test/java/org/apache/cxf/systest/jaxrs/sse/tomcat/AbstractTomcatServer.java @@ -19,14 +19,15 @@ package org.apache.cxf.systest.jaxrs.sse.tomcat; -import java.io.File; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; import org.apache.catalina.Context; import org.apache.catalina.Wrapper; import org.apache.catalina.startup.Tomcat; +import org.apache.cxf.helpers.FileUtils; import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; import org.apache.cxf.systest.jaxrs.sse.BookStore; import org.apache.cxf.systest.jaxrs.sse.BookStoreResponseFilter; @@ -36,10 +37,11 @@ import static org.junit.Assert.fail; public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { - private Tomcat server; private final String resourcePath; private final String contextPath; private final int port; + private Tomcat server; + private Path base; protected AbstractTomcatServer(final String contextPath, int portNumber) { this(null, contextPath, portNumber); @@ -54,13 +56,14 @@ public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { protected void run() { server = new Tomcat(); server.setPort(port); + server.getConnector(); try { - final File base = createTemporaryDirectory(); - server.setBaseDir(base.getAbsolutePath()); + base = Files.createTempDirectory("tmp-"); + server.setBaseDir(base.toString()); if (resourcePath == null) { - final Context context = server.addContext("/", base.getAbsolutePath()); + final Context context = server.addContext("", base.toString()); final Wrapper cxfServlet = Tomcat.addServlet(context, "cxfServlet", new CXFNonSpringJaxrsServlet()); cxfServlet.addInitParameter("jaxrs.serviceClasses", BookStore.class.getName()); cxfServlet.addInitParameter("jaxrs.providers", String.join(",", @@ -70,7 +73,7 @@ public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { cxfServlet.setAsyncSupported(true); context.addServletMappingDecoded("/rest/*", "cxfServlet"); } else { - server.getHost().setAppBase(base.getAbsolutePath()); + server.getHost().setAppBase(base.toString()); server.getHost().setAutoDeploy(true); server.getHost().setDeployOnStartup(true); server.addWebapp(contextPath, getClass().getResource(resourcePath).toURI().getPath().toString()); @@ -83,25 +86,6 @@ public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { } } - protected void configureServer(org.eclipse.jetty.server.Server theserver) throws Exception { - - } - - private static File createTemporaryDirectory() throws IOException { - final File base = File.createTempFile("tmp-", ""); - - if (!base.delete()) { - throw new IOException("Cannot (re)create base folder: " + base.getAbsolutePath()); - } - - if (!base.mkdir()) { - throw new IOException("Cannot create base folder: " + base.getAbsolutePath()); - } - - base.deleteOnExit(); - return base; - } - public void tearDown() throws Exception { super.tearDown(); @@ -109,6 +93,7 @@ public abstract class AbstractTomcatServer extends AbstractBusTestServerBase { server.stop(); server.destroy(); server = null; + FileUtils.removeDir(base.toFile()); } } } diff --git a/systests/rs-sse/rs-sse-undertow/pom.xml b/systests/rs-sse/rs-sse-undertow/pom.xml index 7af5810..58229c3 100644 --- a/systests/rs-sse/rs-sse-undertow/pom.xml +++ b/systests/rs-sse/rs-sse-undertow/pom.xml @@ -51,5 +51,10 @@ <version>${project.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http-jetty</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project>