Package org.codehaus.plexus.testing
Class PlexusExtension
- java.lang.Object
-
- org.codehaus.plexus.testing.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 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 4.- Author:
- Jason van Zyl, Trygve Laugstøl, Michal Maczka, Guillaume Nodet
-
-
Constructor Summary
Constructors Constructor Description PlexusExtension()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterEach(org.junit.jupiter.api.extension.ExtensionContext context)voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context)protected org.codehaus.plexus.configuration.PlexusConfigurationcustomizeComponentConfiguration()protected voidcustomizeContainerConfiguration(org.codehaus.plexus.ContainerConfiguration containerConfiguration)Allow custom test case implementations do augment the default container configuration before executing tests.protected voidcustomizeContext(org.codehaus.plexus.context.Context context)static StringgetBasedir()protected ClassLoadergetClassLoader()protected InputStreamgetConfiguration()protected InputStreamgetConfiguration(String subname)protected StringgetConfigurationName(String subname)Allow the retrieval of a container configuration that is based on the name of the test class being run.org.codehaus.plexus.PlexusContainergetContainer()protected StringgetCustomConfigurationName()protected InputStreamgetResourceAsStream(String resource)StringgetTestConfiguration()static StringgetTestConfiguration(Class<?> clazz)static FilegetTestFile(String path)static FilegetTestFile(String basedir, String path)static StringgetTestPath(String path)static StringgetTestPath(String basedir, String path)protected <T> Tlookup(Class<T> componentClass)protected <T> Tlookup(Class<T> componentClass, String roleHint)protected <T> Tlookup(String componentKey)protected <T> Tlookup(String role, String roleHint)protected voidrelease(Object component)protected voidsetupContainer()
-
-
-
Method Detail
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception- Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback- Throws:
Exception
-
setupContainer
protected void setupContainer()
-
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)
-
customizeComponentConfiguration
protected org.codehaus.plexus.configuration.PlexusConfiguration customizeComponentConfiguration()
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
Exception
-
getContainer
public org.codehaus.plexus.PlexusContainer getContainer()
-
getConfiguration
protected InputStream getConfiguration() throws Exception
- Throws:
Exception
-
getConfiguration
protected InputStream getConfiguration(String subname) throws Exception
- Throws:
Exception
-
getCustomConfigurationName
protected String getCustomConfigurationName()
-
getConfigurationName
protected String getConfigurationName(String subname)
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.- Parameters:
subname- the subname- Returns:
- A configruation name
-
getResourceAsStream
protected InputStream getResourceAsStream(String resource)
-
getClassLoader
protected ClassLoader getClassLoader()
-
lookup
protected <T> T lookup(String componentKey) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
-
lookup
protected <T> T lookup(String role, String roleHint) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
-
lookup
protected <T> T lookup(Class<T> componentClass) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
-
lookup
protected <T> T lookup(Class<T> componentClass, String roleHint) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException
-
release
protected void release(Object component) throws org.codehaus.plexus.component.repository.exception.ComponentLifecycleException
- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLifecycleException
-
getBasedir
public static String getBasedir()
-
getTestConfiguration
public String getTestConfiguration()
-
-