Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 8 additions & 35 deletions exist-ant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@
<groupId>org.exist-db</groupId>
<artifactId>exist-core</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>exist-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.exist-db</groupId>
Expand All @@ -77,35 +79,7 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<!-- needed for ant-testutil's BuildFileRule, which org.exist.ant.AntBuildFileExtension
extends to bridge it into JUnit 5; not detected by the dependency analyzer since
AntBuildFileExtension's own bytecode never references ExternalResource directly
(see ignoredUnusedDeclaredDependency below) -->
<exclusions>
<exclusion>
<!-- we ourselves have a test scoped dependency on a newer hamcrest... see below! -->
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-testutil</artifactId>
<version>${ant.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
Expand Down Expand Up @@ -156,7 +130,6 @@
<configuration>
<failOnWarning>true</failOnWarning>
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>junit:junit</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>
Expand Down
43 changes: 30 additions & 13 deletions exist-ant/src/test/java/org/exist/ant/AntBuildFileExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,43 @@
*/
package org.exist.ant;

import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import java.io.File;

/**
* JUnit 5 {@link org.junit.jupiter.api.extension.Extension} adapter for Ant's
* {@link BuildFileRule}, which ships only as a JUnit 4 {@code TestRule} with no
* upstream JUnit 5 equivalent.
*
* <p>{@code BuildFileRule} only overrides {@code after()} (its {@code before()} is
* the inherited no-op from {@link org.junit.rules.ExternalResource}; setup instead
* happens explicitly via {@link #configureProject(String)}), so exposing that one
* protected lifecycle hook as {@link AfterEachCallback} is sufficient to use it as
* an instance-level {@code @RegisterExtension} field without needing the JUnit 4
* migration-support shim.</p>
* Loads an Ant build file for a test and runs its targets.
* <p>
* Ant's own test helper, {@code BuildFileRule}, only exists as a JUnit 4 rule, so this does
* the part of it that the tests need: configure a {@link Project} from a build file, execute
* targets, and afterwards run the build file's {@code tearDown} target if it has one.
*/
public class AntBuildFileExtension extends BuildFileRule implements AfterEachCallback {
public class AntBuildFileExtension implements AfterEachCallback {
private Project project;

public void configureProject(final String buildFile) {
final File antFile = new File(buildFile);
project = new Project();
project.init();
project.setUserProperty("ant.file", antFile.getAbsolutePath());
ProjectHelper.configureProject(project, antFile);
}

public void executeTarget(final String target) {
project.executeTarget(target);
}

public Project getProject() {
return project;
}

@Override
public void afterEach(final ExtensionContext context) {
after();
if (project != null && project.getTargets().containsKey("tearDown")) {
project.executeTarget("tearDown");
}
}
}
16 changes: 15 additions & 1 deletion exist-core-jmh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
<artifactId>exist-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>exist-core</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>exist-index-lucene</artifactId>
Expand All @@ -82,9 +89,10 @@
<scope>provided</scope>
</dependency>
<dependency>
<!-- ExistEmbeddedServer, which the benchmarks use, implements the Jupiter extension callbacks,
so the Jupiter API has to be on the compile classpath of this main code -->
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -189,7 +197,13 @@
<failOnWarning>true</failOnWarning>
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>org.openjdk.jmh:jmh-generator-annprocess:jar:${jmh.version}</ignoredUnusedDeclaredDependency>
<!-- only needed by the compiler, for the supertypes of ExistEmbeddedServer -->
<ignoredUnusedDeclaredDependency>org.junit.jupiter:junit-jupiter-api:jar:${junit.jupiter.version}</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
<ignoredNonTestScopedDependencies>
<!-- compile scope on purpose, see the dependency; the analyzer only sees the tests using it -->
<ignoredNonTestScopedDependency>org.junit.jupiter:junit-jupiter-api:jar:${junit.jupiter.version}</ignoredNonTestScopedDependency>
</ignoredNonTestScopedDependencies>
</configuration>
</execution>
</executions>
Expand Down
84 changes: 56 additions & 28 deletions exist-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<exclusion> <!-- brings JUnit 4 at compile scope -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
Expand Down Expand Up @@ -519,19 +519,10 @@
<artifactId>jgrapht-opt</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<!-- scope>test</scope --> <!-- not just test scope, as needed for org.exist.test:
both for org.exist.test.runner's JUnit4 Runner-API-based custom test runner
(XSuite et al.), and org.exist.test.ExistEmbeddedServer/ExistXmldbEmbeddedServer/
ExistWebServer extending org.junit.rules.ExternalResource for JUnit 4 backward
compatibility alongside their JUnit 5 BeforeAllCallback/AfterAllCallback support. -->
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<!-- scope>test</scope --> <!-- not just test scope, as needed for org.exist.test -->
<scope>test</scope>
</dependency>

<!-- test dependencies -->
Expand All @@ -555,20 +546,33 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<!-- not just test scope, as needed for org.exist.test.ExistEmbeddedServer's
BeforeAllCallback/AfterAllCallback support, used by downstream modules' tests -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opentest4j</groupId>
<artifactId>opentest4j</artifactId>
<!-- not test scope: org.exist.test.runner.ExtTestFailureFunction (main source) throws
AssertionFailedError for rich IDE diff rendering of XQSuite test failures -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-testkit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand All @@ -587,6 +591,7 @@
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xmlunit</groupId>
Expand All @@ -597,12 +602,14 @@
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-legacy</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<!-- the one remaining use of JUnit 4: xmlunit-legacy's XMLAssert and XMLTestCase extend
junit.framework.Assert, so tests that use them need it to compile. Replace those
tests' XMLUnit 1 style assertions with XMLUnit 2 and this can go. -->
</dependency>

<!-- needed for starting up a jetty server -->
Expand Down Expand Up @@ -705,6 +712,30 @@
</testResources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>ban-junit4</id>
<configuration>
<rules combine.self="override">
<bannedDependencies>
<excludes>
<!-- test scope is allowed here only: xmlunit-legacy needs junit:junit to compile -->
<exclude>junit:junit:*:*:compile</exclude>
<exclude>junit:junit:*:*:provided</exclude>
<exclude>org.junit.vintage</exclude>
<exclude>com.googlecode.junit-toolbox</exclude>
</excludes>
<searchTransitive>true</searchTransitive>
<message>JUnit 4 must not be used outside the tests that need it for xmlunit-legacy; write tests with JUnit Jupiter.</message>
</bannedDependencies>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
Expand Down Expand Up @@ -784,7 +815,7 @@
<exclude>src/test/java/org/exist/storage/txn/ReusableTxnTest.java</exclude>
<exclude>src/test/java/org/exist/storage/txn/TransactionManagerTestHelper.java</exclude>
<exclude>src/test/java/org/exist/storage/txn/TxnTest.java</exclude>
<exclude>src/main/java/org/exist/test/DiffMatcher.java</exclude>
<exclude>src/test/java/org/exist/test/DiffMatcher.java</exclude>
<exclude>src/test/java/org/exist/test/Util.java</exclude>
<exclude>src/main/java/org/exist/util/CollectionOfArrayIterator.java</exclude>
<exclude>src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java</exclude>
Expand Down Expand Up @@ -951,7 +982,7 @@ The original license statement is also included below.]]></preamble>
<include>src/test/java/org/exist/storage/txn/ReusableTxnTest.java</include>
<include>src/test/java/org/exist/storage/txn/TransactionManagerTestHelper.java</include>
<include>src/test/java/org/exist/storage/txn/TxnTest.java</include>
<include>src/main/java/org/exist/test/DiffMatcher.java</include>
<include>src/test/java/org/exist/test/DiffMatcher.java</include>
<include>src/test/java/org/exist/test/Util.java</include>
<include>src/main/java/org/exist/util/CollectionOfArrayIterator.java</include>
<include>src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java</include>
Expand Down Expand Up @@ -1037,6 +1068,8 @@ The BaseX Team. The original license statement is also included below.]]></pream
<configuration>
<failOnWarning>true</failOnWarning>
<ignoredUnusedDeclaredDependencies>
<!-- only needed as the supertype of xmlunit-legacy's XMLAssert and XMLTestCase -->
<ignoredUnusedDeclaredDependency>junit:junit</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-core:jar:${log4j.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-jcl:jar:${log4j.version}</ignoredUnusedDeclaredDependency>
<ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-slf4j2-impl:jar:${log4j.version}</ignoredUnusedDeclaredDependency>
Expand Down Expand Up @@ -1352,11 +1385,6 @@ The BaseX Team. The original license statement is also included below.]]></pream
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion exist-core/src/main/java/org/exist/jetty/JettyStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ public synchronized boolean isWebAppStartedSuccessfully() {

/**
* When {@link #isWebAppStartedSuccessfully()} is {@code false}, holds the last startup failure
* message for test diagnostics (surfaced by {@link org.exist.test.ExistWebServer} in thrown
* message for test diagnostics (surfaced by {@code org.exist.test.ExistWebServer} in thrown
* {@link IllegalStateException}s).
*/
public synchronized Optional<String> getWebAppStartupFailureDetail() {
Expand Down
Loading
Loading