Class PlexusJUnit4TestCase

  • Direct Known Subclasses:
    ScmTestCase

    public class PlexusJUnit4TestCase
    extends java.lang.Object
    Based on PlexusTestCase from org.sonatype.sisu:sisu-inject-plexus. Note: this class is copied from maven-release.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String basedir  
      private org.codehaus.plexus.PlexusContainer container  
      org.junit.rules.TestName testName  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.codehaus.plexus.configuration.PlexusConfiguration customizeComponentConfiguration()  
      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.ClassLoader getClassLoader()  
      protected java.io.InputStream getConfiguration()  
      protected java.io.InputStream getConfiguration​(java.lang.String subname)  
      protected java.lang.String getConfigurationName​(java.lang.String subname)
      Allow the retrieval of a container configuration that is based on the name of the test class being run.
      protected org.codehaus.plexus.PlexusContainer getContainer()  
      protected java.lang.String getCustomConfigurationName()  
      com.google.inject.Module[] getCustomModules()
      Allows test to define custom modules.
      java.lang.String getName()  
      protected java.io.InputStream getResourceAsStream​(java.lang.String resource)  
      java.lang.String getTestConfiguration()  
      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 <T> T lookup​(java.lang.Class<T> componentClass)  
      protected <T> T lookup​(java.lang.Class<T> componentClass, java.lang.String roleHint)  
      protected java.lang.Object lookup​(java.lang.String componentKey)  
      protected java.lang.Object lookup​(java.lang.String role, java.lang.String roleHint)  
      protected <T> java.util.Map<java.lang.String,​T> lookupMap​(java.lang.Class<T> componentClass)  
      protected void release​(java.lang.Object component)  
      void setUp()  
      protected void setupContainer()  
      void tearDown()  
      • Methods inherited from class java.lang.Object

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

      • container

        private org.codehaus.plexus.PlexusContainer container
      • basedir

        private static java.lang.String basedir
      • testName

        public org.junit.rules.TestName testName
    • Constructor Detail

      • PlexusJUnit4TestCase

        public PlexusJUnit4TestCase()
    • Method Detail

      • setUp

        public void setUp()
                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getName

        public java.lang.String getName()
      • setupContainer

        protected void setupContainer()
      • getCustomModules

        public com.google.inject.Module[] getCustomModules()
        Allows test to define custom modules.
      • 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 -
      • customizeContext

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

        protected org.codehaus.plexus.configuration.PlexusConfiguration customizeComponentConfiguration()
      • tearDown

        public void tearDown()
                      throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getContainer

        protected org.codehaus.plexus.PlexusContainer getContainer()
      • getConfiguration

        protected java.io.InputStream getConfiguration()
                                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getConfiguration

        protected java.io.InputStream getConfiguration​(java.lang.String subname)
                                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getCustomConfigurationName

        protected java.lang.String getCustomConfigurationName()
      • getConfigurationName

        protected java.lang.String getConfigurationName​(java.lang.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 -
        Returns:
      • getResourceAsStream

        protected java.io.InputStream getResourceAsStream​(java.lang.String resource)
      • getClassLoader

        protected java.lang.ClassLoader getClassLoader()
      • lookup

        protected java.lang.Object lookup​(java.lang.String componentKey)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • lookup

        protected java.lang.Object lookup​(java.lang.String role,
                                          java.lang.String roleHint)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • lookup

        protected <T> T lookup​(java.lang.Class<T> componentClass)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • lookup

        protected <T> T lookup​(java.lang.Class<T> componentClass,
                               java.lang.String roleHint)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • lookupMap

        protected <T> java.util.Map<java.lang.String,​T> lookupMap​(java.lang.Class<T> componentClass)
                                                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • release

        protected void release​(java.lang.Object component)
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • 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 java.lang.String getTestConfiguration()
      • getTestConfiguration

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