Class PlexusExtension

  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension

    public class PlexusExtension
    extends java.lang.Object
    implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
    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 5.
    Author:
    Jason van Zyl, Trygve Laugstøl, Michal Maczka, Guillaume Nodet
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BASEDIR_KEY  
    • Constructor Summary

      Constructors 
      Constructor Description
      PlexusExtension()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)  
      void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)  
      protected void customizeContainerConfiguration​(org.codehaus.plexus.ContainerConfiguration containerConfiguration)
      Allow custom test case implementations do augment the default container configuration before executing tests.
      protected void customizeContext​(org.codehaus.plexus.context.Context context)  
      static java.lang.String getBasedir()  
      protected java.lang.String getConfigurationName​(org.junit.jupiter.api.extension.ExtensionContext context)
      Allow the retrieval of a container configuration that is based on the name of the test class being run.
      org.codehaus.plexus.PlexusContainer getContainer​(org.junit.jupiter.api.extension.ExtensionContext context)  
      protected java.lang.String getCustomConfigurationName()  
      protected java.lang.String getTestBasedir​(org.junit.jupiter.api.extension.ExtensionContext context)
      The base directory for the test instance.
      static java.lang.String getTestConfiguration​(java.lang.Class<?> clazz)  
      static java.io.File getTestFile​(java.lang.String path)  
      static java.io.File getTestFile​(java.lang.String basedir, java.lang.String path)  
      static java.lang.String getTestPath​(java.lang.String path)  
      static java.lang.String getTestPath​(java.lang.String basedir, java.lang.String path)  
      protected void setTestBasedir​(java.lang.String testBasedir, org.junit.jupiter.api.extension.ExtensionContext context)
      Set the base directory for the test instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PlexusExtension

        public PlexusExtension()
    • Method Detail

      • beforeEach

        public void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                        throws java.lang.Exception
        Specified by:
        beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
        Throws:
        java.lang.Exception
      • customizeContainerConfiguration

        protected void customizeContainerConfiguration​(org.codehaus.plexus.ContainerConfiguration containerConfiguration)
        Allow custom test case implementations do augment the default container configuration before executing tests.
        Parameters:
        containerConfiguration - ContainerConfiguration.
      • customizeContext

        protected void customizeContext​(org.codehaus.plexus.context.Context context)
      • afterEach

        public void afterEach​(org.junit.jupiter.api.extension.ExtensionContext context)
                       throws java.lang.Exception
        Specified by:
        afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
        Throws:
        java.lang.Exception
      • getTestBasedir

        protected java.lang.String getTestBasedir​(org.junit.jupiter.api.extension.ExtensionContext context)
        The base directory for the test instance. By default, this is the same as the basedir.
        Parameters:
        context - the test execution context
        Returns:
        the testBasedir
        Since:
        1.7.0
      • setTestBasedir

        protected void setTestBasedir​(java.lang.String testBasedir,
                                      org.junit.jupiter.api.extension.ExtensionContext context)
        Set the base directory for the test instance. By default, this is the same as the basedir.
        Parameters:
        testBasedir - the testBasedir for the test instance
        context - the test execution context
        Since:
        1.7.0
      • getContainer

        public org.codehaus.plexus.PlexusContainer getContainer​(org.junit.jupiter.api.extension.ExtensionContext context)
      • getCustomConfigurationName

        protected java.lang.String getCustomConfigurationName()
      • getConfigurationName

        protected java.lang.String getConfigurationName​(org.junit.jupiter.api.extension.ExtensionContext context)
        Allow the retrieval of a container configuration that is based on the name of the test class being run. So if you have a test class called org.foo.FunTest, then this will produce a resource name of org/foo/FunTest.xml which would be used to configure the Plexus container before running your test.
        Returns:
        A configruation name
      • getTestFile

        public static java.io.File getTestFile​(java.lang.String path)
      • getTestFile

        public static java.io.File getTestFile​(java.lang.String basedir,
                                               java.lang.String path)
      • getTestPath

        public static java.lang.String getTestPath​(java.lang.String path)
      • getTestPath

        public static java.lang.String getTestPath​(java.lang.String basedir,
                                                   java.lang.String path)
      • getBasedir

        public static java.lang.String getBasedir()
      • getTestConfiguration

        public static java.lang.String getTestConfiguration​(java.lang.Class<?> clazz)