Skip to content
Advertisement

Integration test fails when upgrading failsafe but passes within intellij

I have a multi maven module project. The project runs fine and everything passes, but if I upgrade failsafe plugin from 2.22.2 to the latest version 3.0.0-M5 the integration test within two of the maven modules(client and server-with-jersey) fails. I have tried different configuration, but I am not quite sure what to do anymore… So I am hoping that the someone can explain me what I am maybe doing wrong…

The project can be found here: https://github.com/Hakky54/mutual-tls-ssl

It is just a tutorial of setting up ssl/tls for different clients and servers, so I need to warn you if you run it locally it will pull a-lot dependencies…

The plugin configuration is:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>3.0.0-M5</version>
    <executions>
        <execution>
            <id>integration-test</id>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
        <execution>
            <id>verify</id>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The pom of the failing module is:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <parent>
        <artifactId>mutual-tls-ssl</artifactId>
        <groupId>nl.altindag</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>server-with-jersey</artifactId>
    <packaging>jar</packaging>

    <properties>
        <main-class-server>nl.altindag.server.App</main-class-server>
    </properties>

    <dependencies>
        <dependency>
            <groupId>nl.altindag</groupId>
            <artifactId>shared-server-resources</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>io.github.hakky54</groupId>
            <artifactId>sslcontext-kickstart</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-grizzly2-http</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.inject</groupId>
            <artifactId>jersey-hk2</artifactId>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.hakky54</groupId>
            <artifactId>logcaptor</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${version.maven-surefire-plugin}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${version.maven-fail-safe}</version>
                <configuration>
                    <classpathDependencyExcludes>
                        <classpathDependencyExclude>org.slf4j:slf4j-simple</classpathDependencyExclude>
                    </classpathDependencyExcludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${version.exec-maven-plugin}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>${version.maven-shade-plugin}</mainClass>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${version.maven-shade-plugin}</version>
                <configuration>
                    <finalName>server</finalName>
                    <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>${main-class-server}</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jacoco</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>${version.jacoco-maven-plugin}</version>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

And the following integration test is failing: AppIT. But if I run this within intellij idea it passes, but with mvn clean install it gives me the following exception:

[ERROR] Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 1.971 s <<< FAILURE! - in nl.altindag.server.AppIT
[ERROR] nl.altindag.server.AppIT.startServerWithTwoWayAuthentication  Time elapsed: 1.555 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:

Expecting:
 <"">
to be equal to:
 <"Hello">
but was not.
    at server.with.jersey@1.0-SNAPSHOT/nl.altindag.server.AppIT.startServerWithTwoWayAuthentication(AppIT.java:109)

[ERROR] nl.altindag.server.AppIT.startServerWithoutSecurity  Time elapsed: 0.086 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:

Expecting:
 <"">
to be equal to:
 <"Hello">
but was not.
    at server.with.jersey@1.0-SNAPSHOT/nl.altindag.server.AppIT.startServerWithoutSecurity(AppIT.java:40)

[ERROR] nl.altindag.server.AppIT.startServerWithOneWayAuthentication  Time elapsed: 0.207 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:

Expecting:
 <"">
to be equal to:
 <"Hello">
but was not.
    at server.with.jersey@1.0-SNAPSHOT/nl.altindag.server.AppIT.startServerWithOneWayAuthentication(AppIT.java:74)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   AppIT.startServerWithOneWayAuthentication:74
Expecting:
 <"">
to be equal to:
 <"Hello">
but was not.
[ERROR]   AppIT.startServerWithTwoWayAuthentication:109
Expecting:
 <"">
to be equal to:
 <"Hello">
but was not.
[ERROR]   AppIT.startServerWithoutSecurity:40
Expecting:
 <"">
to be equal to:
 <"Hello">
but was not.
[INFO]
[ERROR] Tests run: 3, Failures: 3, Errors: 0, Skipped: 0

Advertisement

Answer

Maybe you should give it a try with a temporal workaround.

Let’s start with investigating the problem. Enable the debug log and run the tests

mvn -X verify

and investigate the classpath printed on the console.

I have noticed that you are using the maven-shade-plugin which modifies the content of JAR file. I think the problem might be with classpath. We changed the maven-failsafe-plugin so that the classpath contains the path pointing to the attached main JAR. On the opposite site the maven-surefire-plugin uses target/classes instead. The Failsafe plugin is used for the integration tests and uses the JAR file which is more realistic approach of testing the application.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement