Skip to content
Permalink
Browse files
drop surefire forks
  • Loading branch information
rmannibucau committed Oct 26, 2018
1 parent 998e179 commit 652533d1bc9540223108c3632156d4f24ade2c41
Showing 3 changed files with 28 additions and 3 deletions.
@@ -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>
@@ -18,28 +18,40 @@

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;
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 @@ protected void startInternal() throws LifecycleException {
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");
12 pom.xml
@@ -161,7 +161,7 @@
<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>
@@ -170,6 +170,16 @@
</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>

0 comments on commit 652533d

Please sign in to comment.