Class MojoRule

java.lang.Object
org.apache.maven.plugin.testing.MojoRule
All Implemented Interfaces:
org.junit.rules.TestRule

@Deprecated public class MojoRule extends Object implements org.junit.rules.TestRule
Deprecated.
As of version 3.4.0, it is advised to work with JUnit5 tests which do not use rules but extensions MojoExtension instead.
TestRule for usage with Junit-4.10ff. This is just a wrapper for an embedded AbstractMojoTestCase, so all protected methods of the TestCase are exhibited as public in the rule. You may annotate single tests methods with WithoutMojo to prevent the rule from firing.
Since:
2.2
Author:
Mirko Friedenhagen
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
     
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Deprecated.
    May be overridden in the implementation to do stuff after the current test was run.
    org.junit.runners.model.Statement
    apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
    Deprecated.
     
    protected void
    Deprecated.
    May be overridden in the implementation to do stuff after the embedded test case is set up but before the current test is actually run.
    <T extends org.apache.maven.plugin.Mojo>
    T
    configureMojo(T mojo, String artifactId, File pom)
    Deprecated.
     
    <T extends org.apache.maven.plugin.Mojo>
    T
    configureMojo(T mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration)
    Deprecated.
     
    void
    executeMojo(File basedir, String goal)
    Deprecated.
     
    void
    executeMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters)
    Deprecated.
     
    void
    executeMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, org.apache.maven.plugin.MojoExecution execution)
    Deprecated.
     
    void
    executeMojo(org.apache.maven.project.MavenProject project, String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters)
    Deprecated.
     
    org.codehaus.plexus.configuration.PlexusConfiguration
    Deprecated.
     
    org.codehaus.plexus.configuration.PlexusConfiguration
    extractPluginConfiguration(String artifactId, org.codehaus.plexus.util.xml.Xpp3Dom pomDom)
    Deprecated.
     
    org.codehaus.plexus.PlexusContainer
    Deprecated.
     
    Deprecated.
     
    Deprecated.
     
    Deprecated.
     
    Deprecated.
    Convenience method to obtain all variables and values from the mojo (including its superclasses) Note: the values in the map are of type Object so the caller is responsible for casting to desired types.
    Deprecated.
    Convenience method to obtain all variables and values from the mojo (including its superclasses) Note: the values in the map are of type Object so the caller is responsible for casting to desired types.
    <T> T
    Deprecated.
    Convenience method to obtain the value of a variable on a mojo that might not have a getter.
    final <T> T
    lookup(Class<T> role)
    Deprecated.
     
    <T extends org.apache.maven.plugin.Mojo>
    T
    Deprecated.
     
    <T extends org.apache.maven.plugin.Mojo>
    T
    lookupConfiguredMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.MojoExecution execution)
    Deprecated.
     
    <T extends org.apache.maven.plugin.Mojo>
    T
    lookupConfiguredMojo(org.apache.maven.project.MavenProject project, String goal)
    Deprecated.
     
    <T extends org.apache.maven.plugin.Mojo>
    T
    Deprecated.
    Lookup the mojo leveraging the actual subprojects pom
    <T extends org.apache.maven.plugin.Mojo>
    T
    lookupEmptyMojo(String goal, String pluginPom)
    Deprecated.
    Lookup an empty mojo
    <T extends org.apache.maven.plugin.Mojo>
    T
    lookupMojo(String goal, File pom)
    Deprecated.
    Lookup the mojo leveraging the actual subprojects pom
    <T extends org.apache.maven.plugin.Mojo>
    T
    lookupMojo(String goal, String pluginPom)
    Deprecated.
    Lookup the mojo leveraging the subproject pom
    <T extends org.apache.maven.plugin.Mojo>
    T
    lookupMojo(String groupId, String artifactId, String version, String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration)
    Deprecated.
     
    org.apache.maven.execution.MavenSession
    newMavenSession(org.apache.maven.project.MavenProject project)
    Deprecated.
     
    org.apache.maven.plugin.MojoExecution
    Deprecated.
     
    org.apache.maven.project.MavenProject
    Deprecated.
     
    void
    Deprecated.
     
    org.codehaus.plexus.ContainerConfiguration
    Deprecated.
     
    <T> void
    setVariableValueToObject(Object object, String variable, T value)
    Deprecated.
    Convenience method to set values to variables in objects that don't have setters

    Methods inherited from class java.lang.Object

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

    • MojoRule

      public MojoRule()
      Deprecated.
    • MojoRule

      public MojoRule(AbstractMojoTestCase testCase)
      Deprecated.
  • Method Details

    • before

      protected void before() throws Throwable
      Deprecated.
      May be overridden in the implementation to do stuff after the embedded test case is set up but before the current test is actually run.
      Throws:
      Throwable
    • after

      protected void after()
      Deprecated.
      May be overridden in the implementation to do stuff after the current test was run.
    • getPublicDescriptorStream

      public InputStream getPublicDescriptorStream() throws Exception
      Deprecated.
      Throws:
      Exception
    • getPluginDescriptorPath

      public String getPluginDescriptorPath()
      Deprecated.
    • getPluginDescriptorLocation

      public String getPluginDescriptorLocation()
      Deprecated.
    • setupContainer

      public void setupContainer()
      Deprecated.
    • setupContainerConfiguration

      public org.codehaus.plexus.ContainerConfiguration setupContainerConfiguration()
      Deprecated.
    • getContainer

      public org.codehaus.plexus.PlexusContainer getContainer()
      Deprecated.
    • lookupMojo

      public <T extends org.apache.maven.plugin.Mojo> T lookupMojo(String goal, String pluginPom) throws Exception
      Deprecated.
      Lookup the mojo leveraging the subproject pom
      Parameters:
      goal -
      pluginPom -
      Returns:
      a Mojo instance
      Throws:
      Exception
    • lookupEmptyMojo

      public <T extends org.apache.maven.plugin.Mojo> T lookupEmptyMojo(String goal, String pluginPom) throws Exception
      Deprecated.
      Lookup an empty mojo
      Parameters:
      goal -
      pluginPom -
      Returns:
      a Mojo instance
      Throws:
      Exception
    • lookupMojo

      public <T extends org.apache.maven.plugin.Mojo> T lookupMojo(String goal, File pom) throws Exception
      Deprecated.
      Lookup the mojo leveraging the actual subprojects pom
      Parameters:
      goal -
      pom -
      Returns:
      a Mojo instance
      Throws:
      Exception
    • lookupEmptyMojo

      public <T extends org.apache.maven.plugin.Mojo> T lookupEmptyMojo(String goal, File pom) throws Exception
      Deprecated.
      Lookup the mojo leveraging the actual subprojects pom
      Parameters:
      goal -
      pom -
      Returns:
      a Mojo instance
      Throws:
      Exception
    • lookupMojo

      public <T extends org.apache.maven.plugin.Mojo> T lookupMojo(String groupId, String artifactId, String version, String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws Exception
      Deprecated.
      Throws:
      Exception
    • lookupConfiguredMojo

      public <T extends org.apache.maven.plugin.Mojo> T lookupConfiguredMojo(org.apache.maven.project.MavenProject project, String goal) throws Exception
      Deprecated.
      Throws:
      Exception
    • lookupConfiguredMojo

      public <T extends org.apache.maven.plugin.Mojo> T lookupConfiguredMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.MojoExecution execution) throws Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException
      Deprecated.
      Throws:
      Exception
      org.codehaus.plexus.component.configurator.ComponentConfigurationException
    • newMavenSession

      public org.apache.maven.execution.MavenSession newMavenSession(org.apache.maven.project.MavenProject project)
      Deprecated.
    • newMojoExecution

      public org.apache.maven.plugin.MojoExecution newMojoExecution(String goal)
      Deprecated.
    • extractPluginConfiguration

      public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId, File pom) throws Exception
      Deprecated.
      Throws:
      Exception
    • extractPluginConfiguration

      public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId, org.codehaus.plexus.util.xml.Xpp3Dom pomDom) throws Exception
      Deprecated.
      Throws:
      Exception
    • configureMojo

      public <T extends org.apache.maven.plugin.Mojo> T configureMojo(T mojo, String artifactId, File pom) throws Exception
      Deprecated.
      Throws:
      Exception
    • configureMojo

      public <T extends org.apache.maven.plugin.Mojo> T configureMojo(T mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws Exception
      Deprecated.
      Throws:
      Exception
    • getVariableValueFromObject

      public <T> T getVariableValueFromObject(Object object, String variable) throws IllegalAccessException
      Deprecated.
      Convenience method to obtain the value of a variable on a mojo that might not have a getter. NOTE: the caller is responsible for casting to to what the desired type is.
      Parameters:
      object -
      variable -
      Returns:
      object value of variable
      Throws:
      IllegalArgumentException
      IllegalAccessException
    • getVariablesAndValuesFromObject

      public Map<String,Object> getVariablesAndValuesFromObject(Object object) throws IllegalAccessException
      Deprecated.
      Convenience method to obtain all variables and values from the mojo (including its superclasses) Note: the values in the map are of type Object so the caller is responsible for casting to desired types.
      Parameters:
      object -
      Returns:
      map of variable names and values
      Throws:
      IllegalAccessException
    • getVariablesAndValuesFromObject

      public Map<String,Object> getVariablesAndValuesFromObject(Class<?> clazz, Object object) throws IllegalAccessException
      Deprecated.
      Convenience method to obtain all variables and values from the mojo (including its superclasses) Note: the values in the map are of type Object so the caller is responsible for casting to desired types.
      Parameters:
      clazz -
      object -
      Returns:
      map of variable names and values
      Throws:
      IllegalAccessException
    • setVariableValueToObject

      public <T> void setVariableValueToObject(Object object, String variable, T value) throws IllegalAccessException
      Deprecated.
      Convenience method to set values to variables in objects that don't have setters
      Parameters:
      object -
      variable -
      value -
      Throws:
      IllegalAccessException
    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      Deprecated.
      Specified by:
      apply in interface org.junit.rules.TestRule
    • readMavenProject

      public org.apache.maven.project.MavenProject readMavenProject(File basedir) throws Exception
      Deprecated.
      Throws:
      Exception
      Since:
      3.1.0
    • executeMojo

      public void executeMojo(File basedir, String goal) throws Exception
      Deprecated.
      Throws:
      Exception
      Since:
      3.1.0
    • lookupConfiguredMojo

      public <T extends org.apache.maven.plugin.Mojo> T lookupConfiguredMojo(File basedir, String goal) throws Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException
      Deprecated.
      Throws:
      Exception
      org.codehaus.plexus.component.configurator.ComponentConfigurationException
      Since:
      3.1.0
    • lookup

      public final <T> T lookup(Class<T> role) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
      Deprecated.
      Throws:
      org.codehaus.plexus.component.repository.exception.ComponentLookupException
      Since:
      3.1.0
    • executeMojo

      public void executeMojo(org.apache.maven.project.MavenProject project, String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters) throws Exception
      Deprecated.
      Throws:
      Exception
      Since:
      3.2.0
    • executeMojo

      public void executeMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters) throws Exception
      Deprecated.
      Throws:
      Exception
      Since:
      3.2.0
    • executeMojo

      public void executeMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, org.apache.maven.plugin.MojoExecution execution) throws Exception
      Deprecated.
      Throws:
      Exception
      Since:
      3.2.0