This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-parent.git
The following commit(s) were added to refs/heads/master by this push:
new 6bc0d0e Use Mockito 5 on Java 11+ and test managed dependencies on
each Java version (#730)
6bc0d0e is described below
commit 6bc0d0ebc6520c3be16df09e5eabda70907bbe0b
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Sat Nov 28 15:43:37 2026 +0100
Use Mockito 5 on Java 11+ and test managed dependencies on each Java
version (#730)
* Use Mockito 5 on Java 11 and up
Mockito 4 creates mocks through Objenesis, which calls
`ReflectionFactory.newConstructorForSerialization`. Java 28 refuses
that call for classes that are not serializable, so tests mocking
concrete classes fail.
Mockito 5 requires Java 11, so keep Mockito 4.11.0, the last 4.x
release, in a new `java-1.8-10` profile and use Mockito 5 otherwise.
The Mockito 5 version is the top-level property on purpose: Dependabot
reads and updates the top-level property, not the profile one, so it
keeps updating Mockito 5 without touching the Java 8 pin.
Assisted-By: Claude Opus 5.5 <[email protected]>
* Remove the `java28-tests` profile
The profile passed `-Djdk.reflect.allowNonSerializableConstruction=true`
to Surefire and Failsafe so Mockito 4 could create mocks on Java 28.
Mockito 5, now used on Java 11 and up, does not need it.
The profile was never released, so its changelog entry is removed too.
Assisted-By: Claude Opus 5.5 <[email protected]>
* Test the managed dependencies on each supported Java version
The parent POM manages test dependencies (JUnit, JUnit Pioneer, Mockito)
but never uses them, so a Dependabot update to a version that needs a
newer Java (JUnit 6 needs Java 17, JUnit Pioneer 2 and Mockito 5 need
Java 11) would pass CI and only break components downstream.
Add a maven-invoker-plugin integration test, not inherited by
components, that builds a small project inheriting this POM and runs a
test using each managed dependency with the JDK running the build.
CI runs it on every Java version in the matrix.
Checked on Java 8: updating JUnit to 6.1.0, JUnit Pioneer to 2.3.0 or
the Java 8 Mockito pin to 5.25.0 fails the build with "class file has
wrong version".
Assisted-By: Claude Opus 5.5 <[email protected]>
* Fail the CI workflow when a non-experimental Java version fails
`continue-on-error: true` applied to every job, so a failure on, for
example, Java 8 did not fail the workflow. Restrict it to early-access
builds and disable `fail-fast` instead, so all Java versions still run.
Assisted-By: Claude Opus 5.5 <[email protected]>
* Reuse the `java-8-9` profile to pin Mockito 4
The existing `java-8-9` profile already covers Java 8 to 10, so the
dedicated `java-1.8-10` profile is not needed.
Assisted-By: Claude Opus 5.5 <[email protected]>
* Make only the Invoker execution non-inherited, with an explicit name
Move `<inherited>false</inherited>` and the configuration from the
plugin to the execution, and rename the execution to
`commons-parent-managed-dependencies-it`, so it is clear that it only
runs in the commons-parent build.
Assisted-By: Claude Opus 5.5 <[email protected]>
---
.github/workflows/maven.yml | 7 +-
pom.xml | 62 +++++++++--------
src/changes/changes.xml | 2 +-
src/it/managed-dependencies/invoker.properties | 17 +++++
src/it/managed-dependencies/pom.xml | 77 +++++++++++++++++++++
.../commons/parent/it/ManagedDependenciesTest.java | 80 ++++++++++++++++++++++
src/it/settings.xml | 56 +++++++++++++++
7 files changed, 271 insertions(+), 30 deletions(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 514ed55..d07d214 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -28,12 +28,15 @@ jobs:
build:
runs-on: ubuntu-latest
- # We want to try all Java versions here.
- continue-on-error: true
+ # Only early-access builds may fail without failing the workflow.
+ continue-on-error: ${{ matrix.experimental }}
strategy:
max-parallel: 20
+ # We want to try all Java versions here.
+ fail-fast: false
matrix:
java: [ 8, 11, 17, 21, 25, 27 ]
+ experimental: [ false ]
include:
- java: 28-ea
experimental: true
diff --git a/pom.xml b/pom.xml
index 6f05022..7cd5a4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -130,6 +130,7 @@
<commons.japicmp.version>0.28.0</commons.japicmp.version>
<commons.jar-plugin.version>3.5.1</commons.jar-plugin.version>
<commons.javadoc.version>3.12.0</commons.javadoc.version>
+ <commons.invoker.version>3.10.1</commons.invoker.version>
<commons.jxr.version>3.6.0</commons.jxr.version>
<commons.pmd.version>3.28.0</commons.pmd.version>
<commons.pmd-impl.version>7.30.0</commons.pmd-impl.version>
@@ -145,8 +146,7 @@
<commons.junit.version>5.14.4</commons.junit.version>
<!-- JUnit Pioneer 2 requires Java 11 -->
<commons.junit-pioneer.version>1.9.1</commons.junit-pioneer.version>
- <!-- Mockito 5 requires Java 11 -->
- <commons.mockito.version>4.11.0</commons.mockito.version>
+ <commons.mockito.version>5.25.0</commons.mockito.version>
<commons.jmh.version>1.37</commons.jmh.version>
<commons.asm.version>9.11.1</commons.asm.version>
<commons.taglist.version>3.3.0</commons.taglist.version>
@@ -1076,6 +1076,37 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>${commons.invoker.version}</version>
+ <executions>
+ <execution>
+ <!--
+ Only for commons-parent itself, not inherited by components:
+ builds the projects in src/it against this POM, with the JDK
running the build,
+ to check that the managed dependencies work on every JDK
supported by this POM.
+ -->
+ <id>commons-parent-managed-dependencies-it</id>
+ <inherited>false</inherited>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+
<localRepositoryPath>${project.build.directory}/it-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <showErrors>true</showErrors>
+ <streamLogsOnFailures>true</streamLogsOnFailures>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
<reporting>
@@ -1744,6 +1775,8 @@
<commons.checkstyle.version>9.3</commons.checkstyle.version>
<!-- Java EE Javadoc has been republished with Java > 8 and is no
longer compatible with Javadoc 8 -->
<commons.javadoc.javaee.link></commons.javadoc.javaee.link>
+ <!-- Mockito 5+ requires Java 11 -->
+ <commons.mockito.version>4.11.0</commons.mockito.version>
</properties>
</profile>
<profile>
@@ -1860,30 +1893,5 @@
</plugins>
</build>
</profile>
- <profile>
- <id>java28-tests</id>
- <activation>
- <jdk>[28,)</jdk>
- </activation>
- <build>
- <plugins>
- <!-- Temporarily allow Mockito/Objenesis to construct test doubles
on JDK 28 and later. -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <argLine>@{argLine}
-Djdk.reflect.allowNonSerializableConstruction=true</argLine>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <configuration>
- <argLine>@{argLine}
-Djdk.reflect.allowNonSerializableConstruction=true</argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
</project>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 54e0bd5..24a9ce0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -60,7 +60,6 @@ The <action> type attribute can be add, update, fix, or
remove.
<!-- FIX -->
<action type="fix" dev="aherbert" due-to="Alex Herbert">Document the
use of @{argLine} (not ${argLine}) to preserve the JaCoCo agent when a
component sets the maven-surefire-plugin argLine.</action>
<!-- ADD -->
- <action type="add" dev="ggregory" due-to="Gary Gregory">Add Maven
profile `java28-tests` to temporarily allow Mockito/Objenesis to construct test
doubles on JDK 28 and later.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump
com.puppycrawl.tools:checkstyle from 14.3.0 to 14.4.0 on Java 21 and
up.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump
commons.pmd-impl.version from 7.28.0 to 7.30.0.</action>
@@ -76,6 +75,7 @@ The <action> type attribute can be add, update, fix, or
remove.
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump
org.codehaus.mojo:exec-maven-plugin from 3.6.4 to 3.7.0.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump
org.codehaus.mojo:taglist-maven-plugin from 3.2.3 to 3.3.0.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump
org.codehaus.mojo:versions-maven-plugin from 2.24.0 to 2.25.2.</action>
+ <action type="update" dev="pkarwasz" due-to="Piotr P. Karwasz">Bump
org.mockito:mockito-bom from 4.11.0 to 5.25.0 on Java 11 and up; Mockito 4
fails on Java 28.</action>
</release>
<release version="107" date="2026-10-28" description="This is a feature
and maintenance release. Java 8 or later is required.">
<!-- FIX -->
diff --git a/src/it/managed-dependencies/invoker.properties
b/src/it/managed-dependencies/invoker.properties
new file mode 100644
index 0000000..ccdb439
--- /dev/null
+++ b/src/it/managed-dependencies/invoker.properties
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Compile and run the tests with the JDK running the build.
+invoker.goals = --batch-mode test
diff --git a/src/it/managed-dependencies/pom.xml
b/src/it/managed-dependencies/pom.xml
new file mode 100644
index 0000000..0b9a6ad
--- /dev/null
+++ b/src/it/managed-dependencies/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ https://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-parent</artifactId>
+ <version>@project.version@</version>
+ <relativePath />
+ </parent>
+ <groupId>org.apache.commons.parent.it</groupId>
+ <artifactId>managed-dependencies</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>Managed dependencies IT</name>
+ <description>
+ Checks that the dependency versions managed by the parent POM work on
every JDK the parent POM supports.
+ The test exercises at least one class of each managed dependency.
+ </description>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <commons.componentid>parent-it</commons.componentid>
+ <commons.module.name>org.apache.commons.parent.it</commons.module.name>
+ <commons.jira.id>COMMONSSITE</commons.jira.id>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit-pioneer</groupId>
+ <artifactId>junit-pioneer</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Fail if the test is not picked up, for example after a JUnit
engine change. -->
+ <failIfNoTests>true</failIfNoTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git
a/src/it/managed-dependencies/src/test/java/org/apache/commons/parent/it/ManagedDependenciesTest.java
b/src/it/managed-dependencies/src/test/java/org/apache/commons/parent/it/ManagedDependenciesTest.java
new file mode 100644
index 0000000..e20b522
--- /dev/null
+++
b/src/it/managed-dependencies/src/test/java/org/apache/commons/parent/it/ManagedDependenciesTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.parent.it;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Locale;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.junitpioneer.jupiter.DefaultLocale;
+import org.junitpioneer.jupiter.SetSystemProperty;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+/**
+ * Exercises each test dependency managed by the parent POM, on the JDK
running the build.
+ * <p>
+ * A managed version that requires a newer Java version than the JDK running
the build fails to compile or run here.
+ * </p>
+ */
+@ExtendWith(MockitoExtension.class)
+class ManagedDependenciesTest {
+
+ /**
+ * A concrete, non-final, non-serializable class, the hardest case for
mock creation.
+ */
+ static class Greeter {
+
+ String greet(final String name) {
+ return "Hello " + name;
+ }
+ }
+
+ @Mock
+ private Greeter greeter;
+
+ /** JUnit Pioneer. */
+ @Test
+ @DefaultLocale(language = "fr", country = "CA")
+ @SetSystemProperty(key = "commons.parent.it", value = "pioneer")
+ void testJUnitPioneer() {
+ assertEquals(Locale.CANADA_FRENCH, Locale.getDefault());
+ assertEquals("pioneer", System.getProperty("commons.parent.it"));
+ }
+
+ /** JUnit Jupiter params. */
+ @ParameterizedTest
+ @ValueSource(strings = { "a", "bb", "ccc" })
+ void testJUnitJupiterParams(final String value) {
+ assertEquals(value.length(), value.chars().filter(c -> c ==
value.charAt(0)).count());
+ }
+
+ /** Mockito core and Mockito JUnit Jupiter. */
+ @Test
+ void testMockito() {
+ when(greeter.greet("Commons")).thenReturn("Bonjour Commons");
+ assertEquals("Bonjour Commons", greeter.greet("Commons"));
+ verify(greeter).greet("Commons");
+ }
+}
diff --git a/src/it/settings.xml b/src/it/settings.xml
new file mode 100644
index 0000000..0da5cc6
--- /dev/null
+++ b/src/it/settings.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ https://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!--
+ Settings for the integration tests run by maven-invoker-plugin.
+ The ITs use an isolated local repository and resolve artifacts from the
user's local repository first.
+-->
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>