drop surefire forks
authorRomain Manni-Bucau <rmannibucau@gmail.com>
Fri, 26 Oct 2018 14:13:04 +0000 (16:13 +0200)
committerRomain Manni-Bucau <rmannibucau@gmail.com>
Fri, 26 Oct 2018 14:13:04 +0000 (16:13 +0200)
geronimo-metrics/pom.xml
geronimo-metrics/src/test/java/org/apache/geronimo/microprofile/metrics/test/TckContainer.java
pom.xml

index ba2dc2b..a29b50a 100644 (file)
@@ -99,9 +99,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.22.1</version>
         <configuration>
-          <reuseForks>false</reuseForks>
           <dependenciesToScan>
             <dependency>org.eclipse.microprofile.metrics:microprofile-metrics-api-tck</dependency>
             <dependency>org.eclipse.microprofile.metrics:microprofile-metrics-rest-tck</dependency>
index 70e8447..3079ceb 100644 (file)
@@ -18,16 +18,21 @@ package org.apache.geronimo.microprofile.metrics.test;
 
 import static java.lang.ClassLoader.getSystemClassLoader;
 import static java.lang.String.format;
+import static java.util.Optional.of;
+import static java.util.Optional.ofNullable;
 
 import java.io.File;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.loader.WebappClassLoaderBase;
 import org.apache.catalina.loader.WebappLoader;
 import org.apache.meecrowave.Meecrowave;
 import org.apache.meecrowave.arquillian.MeecrowaveContainer;
+import org.apache.meecrowave.io.IO;
 import org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext;
 import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData;
 import org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet;
@@ -35,11 +40,18 @@ import org.jboss.shrinkwrap.api.Archive;
 import org.jboss.shrinkwrap.api.exporter.ZipExporter;
 
 public class TckContainer extends MeecrowaveContainer {
+    private final Map<Archive<?>, Runnable> onUnDeploy = new HashMap<>();
+
     @Override
     public ProtocolMetaData deploy(final Archive<?> archive) {
         final File dump = toArchiveDump(archive);
         archive.as(ZipExporter.class).exportTo(dump, true);
         final String context = ""; // forced by tcks :(
+        onUnDeploy.put(archive, () -> {
+            getContainer().undeploy(""); // cause we forced the context name
+            IO.delete(dump);
+            of(new File(getContainer().getBase(), "webapps/ROOT")).filter(File::exists).ifPresent(IO::delete);
+        });
         final Meecrowave container = getContainer();
         container.deployWebapp(new Meecrowave.DeploymentMeta(context, dump, c -> {
             c.setLoader(new WebappLoader() {
@@ -63,6 +75,11 @@ public class TckContainer extends MeecrowaveContainer {
         return new ProtocolMetaData().addContext(new HTTPContext(configuration.getHost(), port).add(new Servlet("arquillian", context)));
     }
 
+    @Override
+    public void undeploy(final Archive<?> archive) { // we rename the archive so the context so we must align the undeploy
+        ofNullable(onUnDeploy.remove(archive)).ifPresent(Runnable::run);
+    }
+
     private Meecrowave getContainer() {
         try {
             final Field field = getClass().getSuperclass().getDeclaredField("container");
diff --git a/pom.xml b/pom.xml
index e31b473..d735d9b 100644 (file)
--- a/pom.xml
+++ b/pom.xml
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
-        <version>3.0.2</version>
+        <version>3.1.0</version>
         <configuration>
           <archive combine.children="append">
             <manifestEntries>
           </archive>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.22.1</version>
+        <configuration>
+          <reuseForks>true</reuseForks>
+          <forkCount>1</forkCount>
+          <trimStackTrace>false</trimStackTrace>
+        </configuration>
+      </plugin>
     </plugins>
   </build>