[Git][java-team/plexus-testing][master] 17 commits: New upstream version 1.2.0

Emmanuel Bourg (@ebourg) gitlab at salsa.debian.org
Sat Oct 24 23:29:49 BST 2026



Emmanuel Bourg pushed to branch master at Debian Java Maintainers / plexus-testing


Commits:
d65fec0e by Emmanuel Bourg at 2025-03-04T11:34:00+01:00
New upstream version 1.2.0
- - - - -
8bddbe28 by Emmanuel Bourg at 2025-03-04T11:35:03+01:00
New upstream version 1.3.0
- - - - -
3dc2695b by Emmanuel Bourg at 2025-03-04T11:36:05+01:00
New upstream version 1.4.0
- - - - -
29ccebf0 by Emmanuel Bourg at 2026-10-24T23:59:25+02:00
New upstream version 1.5.0
- - - - -
72d239b3 by Emmanuel Bourg at 2026-10-24T23:59:27+02:00
New upstream version 1.6.0
- - - - -
63c6a028 by Emmanuel Bourg at 2026-10-24T23:59:28+02:00
New upstream version 1.6.1
- - - - -
bf149849 by Emmanuel Bourg at 2026-10-24T23:59:29+02:00
New upstream version 1.7.0
- - - - -
a701c106 by Emmanuel Bourg at 2026-10-24T23:59:30+02:00
New upstream version 2.0.0
- - - - -
1d5abfa3 by Emmanuel Bourg at 2026-10-24T23:59:31+02:00
New upstream version 2.0.1
- - - - -
03ffb6b8 by Emmanuel Bourg at 2026-10-24T23:59:33+02:00
New upstream version 2.0.2
- - - - -
23e3ca9b by Emmanuel Bourg at 2026-10-24T23:59:34+02:00
New upstream version 2.1.0
- - - - -
7d80be82 by Emmanuel Bourg at 2026-10-24T23:59:35+02:00
Update upstream source from tag 'upstream/2.1.0'

Update to upstream version '2.1.0'
with Debian dir d2c4a4289987706edf49e2584914e0043e43a6a6
- - - - -
62d9b0e6 by Emmanuel Bourg at 2026-10-25T00:26:40+02:00
Updated the Maven rules

- - - - -
d53d074a by Emmanuel Bourg at 2026-10-25T00:26:48+02:00
Standards-Version updated to 4.7.4

- - - - -
c04c5372 by Emmanuel Bourg at 2026-10-25T00:26:48+02:00
Removed the Priority field

- - - - -
65658f17 by Emmanuel Bourg at 2026-10-25T00:26:48+02:00
Converted debian/watch to the version 5 format

- - - - -
16095a93 by Emmanuel Bourg at 2026-10-25T00:26:55+02:00
Upload to unstable

- - - - -


19 changed files:

- + .git-blame-ignore-revs
- .github/workflows/maven.yml
- .github/workflows/release-drafter.yml
- README.md
- debian/changelog
- debian/control
- debian/maven.ignoreRules
- debian/maven.rules
- debian/watch
- pom.xml
- src/main/java/org/codehaus/plexus/testing/PlexusExtension.java
- src/main/java/org/codehaus/plexus/testing/PlexusTest.java
- + src/main/java/org/codehaus/plexus/testing/PlexusTestConfiguration.java
- + src/site/markdown/index.md
- + src/site/site.xml
- + src/test/java/org/codehaus/plexus/testing/PlexusTestCustomizeTest.java
- src/test/java/org/codehaus/plexus/testing/PlexusTestTest.java → src/test/java/org/codehaus/plexus/testing/PlexusTestJavaxTest.java
- src/test/java/org/codehaus/plexus/testing/TestComponent.java → src/test/java/org/codehaus/plexus/testing/TestJavaxComponent.java
- src/test/java/org/codehaus/plexus/testing/TestComponent2.java → src/test/java/org/codehaus/plexus/testing/TestJavaxComponent2.java


Changes:

=====================================
.git-blame-ignore-revs
=====================================
@@ -0,0 +1,2 @@
+# Parent 13 - reformat
+92cd784be0351b6832af410fb373707270f12750


=====================================
.github/workflows/maven.yml
=====================================
@@ -21,26 +21,11 @@ on: [push, pull_request]
 
 jobs:
   build:
-
-    strategy:
-      matrix:
-        os: [ubuntu-latest,windows-latest, macOS-latest]
-        java: [8, 11, 16, 17]
-        jdk: [temurin,zulu]
-      fail-fast: false
-
-    runs-on: ${{ matrix.os }}
-
-    steps:
-      - name: Checkout
-        uses: actions/checkout at v2
-
-      - name: Set up JDK
-        uses: actions/setup-java at v2
-        with:
-          distribution: ${{ matrix.jdk }}
-          java-version: ${{ matrix.java }}
-          cache: 'maven'
-
-      - name: Build with Maven
-        run: mvn install javadoc:javadoc -e -B -V -Pno-tests-if-not-on-osx
+    name: Build it
+    uses: codehaus-plexus/.github/.github/workflows/maven.yml at master
+
+#   deploy:
+#     name: Deploy
+#     needs: build
+#     uses: codehaus-plexus/.github/.github/workflows/maven-deploy.yml at master
+#     secrets: inherit


=====================================
.github/workflows/release-drafter.yml
=====================================
@@ -7,6 +7,6 @@ jobs:
   update_release_draft:
     runs-on: ubuntu-latest
     steps:
-      - uses: release-drafter/release-drafter at v5.15.0
+      - uses: release-drafter/release-drafter at v6
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


=====================================
README.md
=====================================
@@ -1,3 +1,5 @@
 Plexus testing:
 
- * [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-testing.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.codehaus.plexus%22%20a%3A%22plexus-testing%22)
+* [![Maven Central](https://img.shields.io/maven-central/v/org.codehaus.plexus/plexus-testing.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.codehaus.plexus%22%20a%3A%22plexus-testing%22)
+  [![Reproducible Builds](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jvm-repo-rebuild/reproducible-central/master/content/org/codehaus/plexus/plexus-testing/badge.json)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/codehaus/plexus/plexus-testing/README.md)
+


=====================================
debian/changelog
=====================================
@@ -1,3 +1,13 @@
+plexus-testing (2.1.0-1) unstable; urgency=medium
+
+  * New upstream release
+    - Updated the Maven rules
+  * Standards-Version updated to 4.7.4
+  * Removed the Priority field
+  * Converted debian/watch to the version 5 format
+
+ -- Emmanuel Bourg <ebourg at apache.org>  Sun, 25 Oct 2026 00:26:55 +0200
+
 plexus-testing (1.1.0-1) unstable; urgency=medium
 
   * Initial release (Closes: #1020843)


=====================================
debian/control
=====================================
@@ -1,6 +1,5 @@
 Source: plexus-testing
 Section: java
-Priority: optional
 Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
 Uploaders: Emmanuel Bourg <ebourg at apache.org>
 Build-Depends:
@@ -10,7 +9,7 @@ Build-Depends:
  libguice-java,
  libsisu-plexus-java (>= 0.3.4),
  maven-debian-helper (>= 2.6)
-Standards-Version: 4.6.1
+Standards-Version: 4.7.4
 Vcs-Git: https://salsa.debian.org/java-team/plexus-testing.git
 Vcs-Browser: https://salsa.debian.org/java-team/plexus-testing
 Homepage: https://github.com/codehaus-plexus/plexus-testing


=====================================
debian/maven.ignoreRules
=====================================
@@ -2,3 +2,6 @@
 org.apache.maven.plugins maven-checkstyle-plugin * * * *
 org.apache.maven.shared maven-shared-resources * * * *
 org.junit.jupiter junit-jupiter-engine * * * *
+org.mockito * * * * *
+javax.inject javax.inject * * * *
+org.apache.maven.plugins maven-scm-publish-plugin * * * *


=====================================
debian/maven.rules
=====================================
@@ -1,2 +1,3 @@
 
 org.codehaus.plexus plexus-testing jar s/.*/debian/ * *
+com.google.inject guice * s/.*/debian/ s/classes// *


=====================================
debian/watch
=====================================
@@ -1,3 +1,5 @@
-version=4
-opts="repack,compression=xz" \
-https://github.com/codehaus-plexus/plexus-testing/tags .*/(?:.*?)([\d\.]+)\.tar\.gz
+Version: 5
+Mode: git
+Source: https://github.com/codehaus-plexus/plexus-testing.git
+Matching-Pattern: refs/tags/plexus-testing-([\d.]+)
+Compression: xz


=====================================
pom.xml
=====================================
@@ -1,29 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
 <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.codehaus.plexus</groupId>
     <artifactId>plexus</artifactId>
-    <version>8</version>
+    <version>25</version>
   </parent>
 
   <artifactId>plexus-testing</artifactId>
-  <version>1.1.0</version>
+  <version>2.1.0</version>
 
   <name>Plexus Testing</name>
+  <description>Library to help testing plexus components</description>
+  <url>https://codehaus-plexus.github.io/plexus-testing/</url>
 
   <scm>
-    <connection>scm:git:git at github.com:codehaus-plexus/plexus-testing.git</connection>
-    <developerConnection>scm:git:git at github.com:codehaus-plexus/plexus-testing.git</developerConnection>
-    <url>http://github.com/codehaus-plexus/plexus-testing</url>
-    <tag>plexus-testing-1.1.0</tag>
+    <connection>scm:git:https://github.com/codehaus-plexus/plexus-testing.git</connection>
+    <developerConnection>${project.scm.connection}</developerConnection>
+    <tag>plexus-testing-2.1.0</tag>
+    <url>https://github.com/codehaus-plexus/plexus-testing</url>
   </scm>
+
   <issueManagement>
     <system>github</system>
     <url>https://github.com/codehaus-plexus/plexus-testing/issues</url>
   </issueManagement>
+
   <distributionManagement>
     <site>
       <id>github:gh-pages</id>
@@ -32,50 +35,73 @@
   </distributionManagement>
 
   <properties>
-    <cobertura.skip>true</cobertura.skip>
-    <javaVersion>8</javaVersion>
-    <project.build.outputTimestamp>2021-09-21T23:44:57Z</project.build.outputTimestamp>
+    <project.build.outputTimestamp>2026-01-05T12:37:48Z</project.build.outputTimestamp>
   </properties>
-  
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-checkstyle-plugin</artifactId>
-        <dependencies>
-          <dependency>
-            <groupId>org.apache.maven.shared</groupId>
-            <artifactId>maven-shared-resources</artifactId>
-            <version>3</version>
-          </dependency>
-        </dependencies>
-      </plugin>
-    </plugins>
-  </build>
 
   <dependencies>
+    <!-- use direct dependency to override version such dependencyManagement are not transitive in Maven 3.x -->
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <!-- overwrite due to CVE-2023-2976 in Guice transitive dependencies -->
+      <version>33.5.0-jre</version>
+    </dependency>
     <dependency>
       <groupId>org.eclipse.sisu</groupId>
       <artifactId>org.eclipse.sisu.plexus</artifactId>
-      <version>0.3.4</version>
+      <version>0.9.0.M4</version>
     </dependency>
     <dependency>
       <groupId>com.google.inject</groupId>
       <artifactId>guice</artifactId>
-      <classifier>no_aop</classifier>
-      <version>4.2.3</version>
+      <version>5.1.0</version>
+      <classifier>classes</classifier>
     </dependency>
     <dependency>
       <groupId>org.junit.jupiter</groupId>
       <artifactId>junit-jupiter-api</artifactId>
-      <version>5.8.0</version>
     </dependency>
+
     <dependency>
-      <groupId>org.junit.jupiter</groupId>
-      <artifactId>junit-jupiter-engine</artifactId>
-      <version>5.8.0</version>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <version>4.11.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-junit-jupiter</artifactId>
+      <version>4.11.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-scm-publish-plugin</artifactId>
+        <configuration>
+          <content>${project.reporting.outputDirectory}</content>
+          <!-- mono-module doesn't require site:stage -->
+        </configuration>
+        <executions>
+          <execution>
+            <id>scm-publish</id>
+            <!-- deploy site with maven-scm-publish-plugin -->
+            <goals>
+              <goal>publish-scm</goal>
+            </goals>
+            <phase>site-deploy</phase>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>


=====================================
src/main/java/org/codehaus/plexus/testing/PlexusExtension.java
=====================================
@@ -36,8 +36,8 @@ package org.codehaus.plexus.testing;
  */
 
 import java.io.File;
-import java.io.InputStream;
 import java.util.Collections;
+import java.util.Optional;
 
 import org.codehaus.plexus.ContainerConfiguration;
 import org.codehaus.plexus.DefaultContainerConfiguration;
@@ -45,9 +45,6 @@ import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.PlexusContainerException;
-import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.DefaultContext;
 import org.junit.jupiter.api.extension.AfterEachCallback;
@@ -58,58 +55,79 @@ import org.junit.jupiter.api.extension.ExtensionContext;
  * This is a slightly modified version of the original plexus class
  * available at https://raw.githubusercontent.com/codehaus-plexus/plexus-containers/master/plexus-container-default/
  *              src/main/java/org/codehaus/plexus/PlexusTestCase.java
- * in order to migrate the tests to JUnit 4.
+ * in order to migrate the tests to JUnit 5.
  *
  * @author Jason van Zyl
  * @author <a href="mailto:trygvis at inamo.no">Trygve Laugstøl</a>
  * @author <a href="mailto:michal at codehaus.org">Michal Maczka</a>
  * @author Guillaume Nodet
  */
-public class PlexusExtension implements BeforeEachCallback, AfterEachCallback
-{
-    private ExtensionContext context;
-    private PlexusContainer container;
+public class PlexusExtension implements BeforeEachCallback, AfterEachCallback {
 
-    private static String basedir;
+    private static class PlexusClosableWrapper implements AutoCloseable {
+        private final PlexusContainer container;
 
-    @Override
-    public void beforeEach( ExtensionContext context )
-            throws Exception
-    {
-        basedir = getBasedir();
-        this.context = context;
+        PlexusClosableWrapper(PlexusContainer container) {
+            this.container = container;
+        }
+
+        @Override
+        public void close() {
+            container.dispose();
+        }
+
+        public PlexusContainer get() {
+            return container;
+        }
+    }
 
-        getContainer().addComponent( getContainer(), PlexusContainer.class.getName() );
+    private static final ExtensionContext.Namespace PLEXUS_EXTENSION =
+            ExtensionContext.Namespace.create("PlexusExtension");
+
+    public static final String BASEDIR_KEY = "basedir";
+
+    private static final ThreadLocal<ExtensionContext> extensionContextThreadLocal = new ThreadLocal<>();
+
+    static {
+        if (System.getProperty("guice_custom_class_loading", "").trim().isEmpty()) {
+            System.setProperty("guice_custom_class_loading", "CHILD");
+        }
+    }
+
+    @Override
+    public void beforeEach(ExtensionContext context) throws Exception {
+        setTestBasedir(getDefaultBasedir(), context);
 
-        ( (DefaultPlexusContainer) getContainer() ).addPlexusInjector( Collections.emptyList(),
-                binder -> binder.requestInjection( context.getRequiredTestInstance() ) );
+        context.getRequiredTestInstances().getAllInstances().forEach(testInstance -> ((DefaultPlexusContainer)
+                        getContainer(context))
+                .addPlexusInjector(Collections.emptyList(), binder -> binder.requestInjection(testInstance)));
     }
 
-    @SuppressWarnings( "ResultOfMethodCallIgnored" )
-    protected void setupContainer()
-    {
+    private PlexusContainer setupContainer(ExtensionContext context) {
+        // Store the context in a thread local for static access
+        // must be done hear as this method is always executed
+        extensionContextThreadLocal.set(context);
+        context.getStore(PLEXUS_EXTENSION)
+                .put("threadLocalCloseable", (AutoCloseable) extensionContextThreadLocal::remove);
+
         // ----------------------------------------------------------------------------
         // Context Setup
         // ----------------------------------------------------------------------------
 
-        DefaultContext context = new DefaultContext();
-
-        context.put( "basedir", getBasedir() );
+        DefaultContext plexusContext = new DefaultContext();
+        plexusContext.put("basedir", getTestBasedir(context));
+        customizeContext(plexusContext);
 
-        customizeContext( context );
+        boolean hasPlexusHome = plexusContext.contains("plexus.home");
 
-        boolean hasPlexusHome = context.contains( "plexus.home" );
+        if (!hasPlexusHome) {
+            File f = new File(getTestBasedir(context), "target/plexus-home");
 
-        if ( !hasPlexusHome )
-        {
-            File f = getTestFile( "target/plexus-home" );
-
-            if ( !f.isDirectory() )
-            {
+            if (!f.isDirectory()) {
                 f.mkdir();
             }
 
-            context.put( "plexus.home", f.getAbsolutePath() );
+            plexusContext.put("plexus.home", f.getAbsolutePath());
         }
 
         // ----------------------------------------------------------------------------
@@ -118,31 +136,30 @@ public class PlexusExtension implements BeforeEachCallback, AfterEachCallback
 
         String config = getCustomConfigurationName();
 
-        ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration()
-                .setName( "test" )
-                .setContext( context.getContextData() );
-
-        if ( config != null )
-        {
-            containerConfiguration.setContainerConfiguration( config );
-        }
-        else
-        {
-            String resource = getConfigurationName( null );
+        ContainerConfiguration containerConfiguration =
+                new DefaultContainerConfiguration().setName("test").setContext(plexusContext.getContextData());
 
-            containerConfiguration.setContainerConfiguration( resource );
+        if (config != null) {
+            containerConfiguration.setContainerConfiguration(config);
+        } else {
+            String resource = getConfigurationName(context);
+            containerConfiguration.setContainerConfiguration(resource);
         }
 
-        customizeContainerConfiguration( containerConfiguration );
+        customizeContainerConfiguration(containerConfiguration);
+        testInstanceCustomizeContainerConfiguration(containerConfiguration, context);
 
-        try
-        {
-            container = new DefaultPlexusContainer( containerConfiguration );
-        }
-        catch ( PlexusContainerException e )
-        {
-            throw new IllegalArgumentException( "Failed to create plexus container.", e );
+        PlexusContainer container;
+        try {
+            container = new DefaultPlexusContainer(containerConfiguration);
+            container.addComponent(container, PlexusContainer.class.getName());
+        } catch (PlexusContainerException e) {
+            throw new IllegalArgumentException("Failed to create plexus container.", e);
         }
+        testInstanceCustomizeContainer(container, context);
+        context.getStore(PLEXUS_EXTENSION).put(PlexusClosableWrapper.class, new PlexusClosableWrapper(container));
+
+        return container;
     }
 
     /**
@@ -151,57 +168,73 @@ public class PlexusExtension implements BeforeEachCallback, AfterEachCallback
      *
      * @param containerConfiguration {@link ContainerConfiguration}.
      */
-    protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration )
-    {
-        containerConfiguration.setAutoWiring( true );
-        containerConfiguration.setClassPathScanning( PlexusConstants.SCANNING_INDEX );
+    protected void customizeContainerConfiguration(ContainerConfiguration containerConfiguration) {
+        containerConfiguration.setAutoWiring(true);
+        containerConfiguration.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
     }
 
-    protected void customizeContext( Context context )
-    {
+    private void testInstanceCustomizeContainerConfiguration(
+            ContainerConfiguration containerConfiguration, ExtensionContext context) {
+        context.getRequiredTestInstances().getAllInstances().forEach(testInstance -> {
+            if (testInstance instanceof PlexusTestConfiguration) {
+                ((PlexusTestConfiguration) testInstance).customizeConfiguration(containerConfiguration);
+            }
+        });
     }
 
-    protected PlexusConfiguration customizeComponentConfiguration()
-    {
-        return null;
+    private void testInstanceCustomizeContainer(PlexusContainer container, ExtensionContext context) {
+        context.getRequiredTestInstances().getAllInstances().forEach(testInstance -> {
+            if (testInstance instanceof PlexusTestConfiguration) {
+                ((PlexusTestConfiguration) testInstance).customizeContainer(container);
+            }
+        });
     }
 
-    @Override
-    public void afterEach( ExtensionContext context )
-            throws Exception
-    {
-        if ( container != null )
-        {
-            container.dispose();
+    protected void customizeContext(Context context) {}
 
-            container = null;
-        }
+    @Override
+    public void afterEach(ExtensionContext context) throws Exception {
+        // empty method, not used
     }
 
-    public PlexusContainer getContainer()
-    {
-        if ( container == null )
-        {
-            setupContainer();
+    /**
+     * The base directory for the test instance. By default, this is the same as the basedir.
+     *
+     * @param context  the test execution context
+     *
+     * @return the testBasedir
+     * @since 1.7.0
+     */
+    protected String getTestBasedir(ExtensionContext context) {
+        String testBasedir = context.getStore(PLEXUS_EXTENSION).get(BASEDIR_KEY, String.class);
+        if (testBasedir == null) {
+            testBasedir = getDefaultBasedir();
+            context.getStore(PLEXUS_EXTENSION).put(BASEDIR_KEY, testBasedir);
         }
-
-        return container;
+        return testBasedir;
     }
 
-    protected InputStream getConfiguration()
-            throws Exception
-    {
-        return getConfiguration( null );
+    /**
+     * Set the base directory for the test instance. By default, this is the same as the basedir.
+     *
+     * @param testBasedir the testBasedir for the test instance
+     * @param context  the test execution context
+     * @since 1.7.0
+     */
+    protected void setTestBasedir(String testBasedir, ExtensionContext context) {
+        context.getStore(PLEXUS_EXTENSION).put(BASEDIR_KEY, testBasedir);
     }
 
-    protected InputStream getConfiguration( String subname )
-            throws Exception
-    {
-        return getResourceAsStream( getConfigurationName( subname ) );
+    public PlexusContainer getContainer(ExtensionContext context) {
+        PlexusClosableWrapper container =
+                context.getStore(PLEXUS_EXTENSION).get(PlexusClosableWrapper.class, PlexusClosableWrapper.class);
+        if (container == null) {
+            return setupContainer(context);
+        }
+        return container.get();
     }
 
-    protected String getCustomConfigurationName()
-    {
+    protected String getCustomConfigurationName() {
         return null;
     }
 
@@ -211,131 +244,64 @@ public class PlexusExtension implements BeforeEachCallback, AfterEachCallback
      * this will produce a resource name of org/foo/FunTest.xml which would be used to
      * configure the Plexus container before running your test.
      *
-     * @param subname the subname
      * @return A configruation name
      */
-    protected String getConfigurationName( String subname )
-    {
+    protected String getConfigurationName(ExtensionContext context) {
         Class<?> testClass = context.getRequiredTestClass();
-        for ( Class<?> clazz = testClass;
-              clazz != null;
-              clazz = clazz.getSuperclass() )
-        {
-            String name = clazz.getName().replace( '.', '/' ) + ".xml";
-            if ( testClass.getClassLoader().getResource( name ) != null )
-            {
+        for (Class<?> clazz = testClass; clazz != null; clazz = clazz.getSuperclass()) {
+            String name = clazz.getName().replace('.', '/') + ".xml";
+            if (testClass.getClassLoader().getResource(name) != null) {
                 return name;
             }
         }
         return null;
     }
 
-    protected InputStream getResourceAsStream( String resource )
-    {
-        return context.getRequiredTestClass().getResourceAsStream( resource );
-    }
-
-    protected ClassLoader getClassLoader()
-    {
-        return context.getRequiredTestClass().getClassLoader();
-    }
-
-    // ----------------------------------------------------------------------
-    // Container access
-    // ----------------------------------------------------------------------
-
-    @SuppressWarnings( "unchecked" )
-    protected <T> T lookup( String componentKey )
-            throws ComponentLookupException
-    {
-        return (T) getContainer().lookup( componentKey );
-    }
-
-    @SuppressWarnings( "unchecked" )
-    protected <T> T lookup( String role,
-                            String roleHint )
-            throws ComponentLookupException
-    {
-        return (T) getContainer().lookup( role, roleHint );
-    }
-
-    protected <T> T lookup( Class<T> componentClass )
-            throws ComponentLookupException
-    {
-        return getContainer().lookup( componentClass );
-    }
-
-    protected <T> T lookup( Class<T> componentClass, String roleHint )
-            throws ComponentLookupException
-    {
-        return getContainer().lookup( componentClass, roleHint );
-    }
-
-    protected void release( Object component )
-            throws ComponentLifecycleException
-    {
-        getContainer().release( component );
-    }
-
     // ----------------------------------------------------------------------
     // Helper methods for sub classes
     // ----------------------------------------------------------------------
 
-    public static File getTestFile( String path )
-    {
-        return new File( getBasedir(), path );
+    public static File getTestFile(String path) {
+        return new File(getBasedir(), path);
     }
 
-    public static File getTestFile( String basedir,
-                                    String path )
-    {
-        File basedirFile = new File( basedir );
+    public static File getTestFile(String basedir, String path) {
+        File basedirFile = new File(basedir);
 
-        if ( !basedirFile.isAbsolute() )
-        {
-            basedirFile = getTestFile( basedir );
+        if (!basedirFile.isAbsolute()) {
+            basedirFile = getTestFile(basedir);
         }
 
-        return new File( basedirFile, path );
+        return new File(basedirFile, path);
     }
 
-    public static String getTestPath( String path )
-    {
-        return getTestFile( path ).getAbsolutePath();
+    public static String getTestPath(String path) {
+        return getTestFile(path).getAbsolutePath();
     }
 
-    public static String getTestPath( String basedir,
-                                      String path )
-    {
-        return getTestFile( basedir, path ).getAbsolutePath();
+    public static String getTestPath(String basedir, String path) {
+        return getTestFile(basedir, path).getAbsolutePath();
     }
 
-    public static String getBasedir()
-    {
-        if ( basedir != null )
-        {
-            return basedir;
-        }
-
-        basedir = System.getProperty( "basedir" );
+    private static String getDefaultBasedir() {
+        String basedir = System.getProperty("basedir");
 
-        if ( basedir == null )
-        {
-            basedir = new File( "" ).getAbsolutePath();
+        if (basedir == null) {
+            basedir = new File("").getAbsolutePath();
         }
 
         return basedir;
     }
 
-    public String getTestConfiguration()
-    {
-        return getTestConfiguration( context.getRequiredTestClass() );
+    public static String getBasedir() {
+        return Optional.ofNullable(extensionContextThreadLocal.get())
+                .map(ec -> ec.getStore(PLEXUS_EXTENSION).get(BASEDIR_KEY, String.class))
+                .orElseGet(PlexusExtension::getDefaultBasedir);
     }
 
-    public static String getTestConfiguration( Class<?> clazz )
-    {
-        String s = clazz.getName().replace( '.', '/' );
+    public static String getTestConfiguration(Class<?> clazz) {
+        String s = clazz.getName().replace('.', '/');
 
-        return s.substring( 0, s.indexOf( "$" ) ) + ".xml";
+        return s.substring(0, s.indexOf("$")) + ".xml";
     }
 }


=====================================
src/main/java/org/codehaus/plexus/testing/PlexusTest.java
=====================================
@@ -29,10 +29,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
 /**
  * Plexus test
  */
- at Retention( RetentionPolicy.RUNTIME )
- at ExtendWith( PlexusExtension.class )
- at Target( ElementType.TYPE )
-public @interface PlexusTest
-{
-
-}
+ at Retention(RetentionPolicy.RUNTIME)
+ at ExtendWith(PlexusExtension.class)
+ at Target(ElementType.TYPE)
+public @interface PlexusTest {}


=====================================
src/main/java/org/codehaus/plexus/testing/PlexusTestConfiguration.java
=====================================
@@ -0,0 +1,28 @@
+package org.codehaus.plexus.testing;
+
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.PlexusContainer;
+
+/**
+ * Allow to customize the Plexus container by test class.
+ *
+ * @since 1.7.0
+ */
+public interface PlexusTestConfiguration {
+
+    /**
+     * Customize the container configuration before the container is created.
+     *
+     * @param containerConfiguration the container configuration to customize
+     * @since 1.7.0
+     */
+    default void customizeConfiguration(ContainerConfiguration containerConfiguration) {}
+
+    /**
+     * Customize the container after it has been created.
+     *
+     * @param container the container to customize
+     * @since 1.7.0
+     */
+    default void customizeContainer(PlexusContainer container) {}
+}


=====================================
src/site/markdown/index.md
=====================================
@@ -0,0 +1,22 @@
+# Plexus Testing
+
+Library to help testing plexus components
+
+## Example usage
+
+### Test class
+
+<!-- MACRO{snippet|id=test-class|file=src/test/java/org/codehaus/plexus/testing/PlexusTestJavaxTest.java} -->
+
+### Customization of the Plexus Container
+
+Test class can customize the Plexus Container used for testing by implementing
+the [`PlexusTestConfiguration`](apidocs/org/codehaus/plexus/testing/PlexusTestConfiguration.html).
+All methods have default empty implementations so you can implement only the ones you need.
+
+<!-- MACRO{snippet|id=test-customize-class|file=src/test/java/org/codehaus/plexus/testing/PlexusTestCustomizeTest.java} -->
+
+### Used classes in test
+
+<!-- MACRO{snippet|id=test-component|file=src/test/java/org/codehaus/plexus/testing/TestJavaxComponent.java} -->
+<!-- MACRO{snippet|id=test-component2|file=src/test/java/org/codehaus/plexus/testing/TestJavaxComponent2.java} -->


=====================================
src/site/site.xml
=====================================
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<site xmlns="http://maven.apache.org/SITE/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xsi:schemaLocation="http://maven.apache.org/SITE/2.0.0 https://maven.apache.org/xsd/site-2.0.0.xsd">
+
+  <body>
+    <menu name="Overview">
+      <item name="Introduction" href="index.html"/>
+      <item name="Javadoc" href="apidocs/index.html"/>
+    </menu>
+
+    <menu ref="parent"/>
+    <menu ref="reports"/>
+  </body>
+</site>


=====================================
src/test/java/org/codehaus/plexus/testing/PlexusTestCustomizeTest.java
=====================================
@@ -0,0 +1,76 @@
+package org.codehaus.plexus.testing;
+
+/*
+ * 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
+ *
+ *   http://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.
+ */
+// START SNIPPET: test-customize-class
+import javax.inject.Inject;
+
+import org.codehaus.plexus.PlexusContainer;
+import org.junit.jupiter.api.Nested;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
+// MockitoExtension must be first
+ at ExtendWith(MockitoExtension.class)
+ at PlexusTest
+class PlexusTestCustomizeTest implements PlexusTestConfiguration {
+
+    @Mock
+    private TestJavaxComponent2 mockComponent2;
+
+    /*
+    Customize the container configuration before it is used to create the container.
+
+    Method has default empty implementation so not need to implement if not used.
+
+    @Override
+    public void customizeConfiguration(ContainerConfiguration containerConfiguration) {
+
+    }
+    */
+
+    @Override
+    public void customizeContainer(PlexusContainer container) {
+        container.addComponent(mockComponent2, TestJavaxComponent2.class.getName());
+    }
+
+    @Inject
+    private TestJavaxComponent testJavaxComponent;
+
+    @Test
+    void dependencyShouldBeInjected() {
+        assertNotNull(testJavaxComponent);
+        assertSame(testJavaxComponent.getTestComponent2(), mockComponent2);
+    }
+
+    @Nested
+    class NestedTest {
+        @Test
+        void nestedDependencyShouldAlsoBeInjected() {
+            assertNotNull(testJavaxComponent);
+            assertSame(testJavaxComponent.getTestComponent2(), mockComponent2);
+        }
+    }
+}
+// END SNIPPET: test-customize-class


=====================================
src/test/java/org/codehaus/plexus/testing/PlexusTestTest.java → src/test/java/org/codehaus/plexus/testing/PlexusTestJavaxTest.java
=====================================
@@ -18,24 +18,33 @@ package org.codehaus.plexus.testing;
  * specific language governing permissions and limitations
  * under the License.
  */
+// START SNIPPET: test-class
+import javax.inject.Inject;
 
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
+import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
 
-import javax.inject.Inject;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 @PlexusTest
-class PlexusTestTest
-{
+class PlexusTestJavaxTest {
 
     @Inject
-    private TestComponent testComponent;
+    private TestJavaxComponent testJavaxComponent;
 
     @Test
-    void dependencyShouldBeInjected()
-    {
-        assertNotNull( testComponent );
-        assertNotNull( testComponent.getTestComponent2() );
+    void dependencyShouldBeInjected() {
+        assertNotNull(testJavaxComponent);
+        assertNotNull(testJavaxComponent.getTestComponent2());
+    }
+
+    @Nested
+    class NestedTest {
+        @Test
+        void nestedDependencyShouldAlsoBeInjected() {
+            assertNotNull(testJavaxComponent);
+            assertNotNull(testJavaxComponent.getTestComponent2());
+        }
     }
 }
+// END SNIPPET: test-class


=====================================
src/test/java/org/codehaus/plexus/testing/TestComponent.java → src/test/java/org/codehaus/plexus/testing/TestJavaxComponent.java
=====================================
@@ -19,17 +19,17 @@ package org.codehaus.plexus.testing;
  * under the License.
  */
 
+// START SNIPPET: test-component
 import javax.inject.Inject;
 import javax.inject.Named;
 
 @Named
-public class TestComponent
-{
+public class TestJavaxComponent {
     @Inject
-    private TestComponent2 testComponent2;
+    private TestJavaxComponent2 testJavaxComponent2;
 
-    public TestComponent2 getTestComponent2()
-    {
-        return testComponent2;
+    public TestJavaxComponent2 getTestComponent2() {
+        return testJavaxComponent2;
     }
 }
+// END SNIPPET: test-component


=====================================
src/test/java/org/codehaus/plexus/testing/TestComponent2.java → src/test/java/org/codehaus/plexus/testing/TestJavaxComponent2.java
=====================================
@@ -19,9 +19,9 @@ package org.codehaus.plexus.testing;
  * under the License.
  */
 
+// START SNIPPET: test-component2
 import javax.inject.Named;
 
 @Named
-public class TestComponent2
-{
-}
+public class TestJavaxComponent2 {}
+// END SNIPPET: test-component2



View it on GitLab: https://salsa.debian.org/java-team/plexus-testing/-/compare/1f47b323b770b9e552d2bea1837ed20379d93402...16095a93688aa941ec7da8f8c3086ae7e5d28b6a

-- 
View it on GitLab: https://salsa.debian.org/java-team/plexus-testing/-/compare/1f47b323b770b9e552d2bea1837ed20379d93402...16095a93688aa941ec7da8f8c3086ae7e5d28b6a
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20261024/b6b29e9a/attachment.htm>


More information about the pkg-java-commits mailing list