Package org.apache.maven.plugin.testing
Class MojoRule
- java.lang.Object
-
- org.apache.maven.plugin.testing.MojoRule
-
- All Implemented Interfaces:
org.junit.rules.TestRule
@Deprecated public class MojoRule extends java.lang.Object implements org.junit.rules.TestRuleDeprecated.As of version 3.4.0, it is advised to work with JUnit5 tests which do not use rules but extensionsMojoExtensioninstead.TestRulefor usage with Junit-4.10ff. This is just a wrapper for an embeddedAbstractMojoTestCase, so allprotectedmethods of the TestCase are exhibited aspublicin the rule. You may annotate single tests methods withWithoutMojoto prevent the rule from firing.- Since:
- 2.2
- Author:
- Mirko Friedenhagen
-
-
Constructor Summary
Constructors Constructor Description MojoRule()Deprecated.MojoRule(AbstractMojoTestCase testCase)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidafter()Deprecated.May be overridden in the implementation to do stuff after the current test was run.org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description)Deprecated.protected voidbefore()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>
TconfigureMojo(T mojo, java.lang.String artifactId, java.io.File pom)Deprecated.<T extends org.apache.maven.plugin.Mojo>
TconfigureMojo(T mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration)Deprecated.voidexecuteMojo(java.io.File basedir, java.lang.String goal)Deprecated.voidexecuteMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, java.lang.String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters)Deprecated.voidexecuteMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, org.apache.maven.plugin.MojoExecution execution)Deprecated.voidexecuteMojo(org.apache.maven.project.MavenProject project, java.lang.String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters)Deprecated.org.codehaus.plexus.configuration.PlexusConfigurationextractPluginConfiguration(java.lang.String artifactId, java.io.File pom)Deprecated.org.codehaus.plexus.configuration.PlexusConfigurationextractPluginConfiguration(java.lang.String artifactId, org.codehaus.plexus.util.xml.Xpp3Dom pomDom)Deprecated.org.codehaus.plexus.PlexusContainergetContainer()Deprecated.java.lang.StringgetPluginDescriptorLocation()Deprecated.java.lang.StringgetPluginDescriptorPath()Deprecated.java.io.InputStreamgetPublicDescriptorStream()Deprecated.java.util.Map<java.lang.String,java.lang.Object>getVariablesAndValuesFromObject(java.lang.Class<?> clazz, java.lang.Object object)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.java.util.Map<java.lang.String,java.lang.Object>getVariablesAndValuesFromObject(java.lang.Object object)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> TgetVariableValueFromObject(java.lang.Object object, java.lang.String variable)Deprecated.Convenience method to obtain the value of a variable on a mojo that might not have a getter.<T> Tlookup(java.lang.Class<T> role)Deprecated.<T extends org.apache.maven.plugin.Mojo>
TlookupConfiguredMojo(java.io.File basedir, java.lang.String goal)Deprecated.<T extends org.apache.maven.plugin.Mojo>
TlookupConfiguredMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.plugin.MojoExecution execution)Deprecated.<T extends org.apache.maven.plugin.Mojo>
TlookupConfiguredMojo(org.apache.maven.project.MavenProject project, java.lang.String goal)Deprecated.<T extends org.apache.maven.plugin.Mojo>
TlookupEmptyMojo(java.lang.String goal, java.io.File pom)Deprecated.Lookup the mojo leveraging the actual subprojects pom<T extends org.apache.maven.plugin.Mojo>
TlookupEmptyMojo(java.lang.String goal, java.lang.String pluginPom)Deprecated.Lookup an empty mojo<T extends org.apache.maven.plugin.Mojo>
TlookupMojo(java.lang.String goal, java.io.File pom)Deprecated.Lookup the mojo leveraging the actual subprojects pom<T extends org.apache.maven.plugin.Mojo>
TlookupMojo(java.lang.String goal, java.lang.String pluginPom)Deprecated.Lookup the mojo leveraging the subproject pom<T extends org.apache.maven.plugin.Mojo>
TlookupMojo(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration)Deprecated.org.apache.maven.execution.MavenSessionnewMavenSession(org.apache.maven.project.MavenProject project)Deprecated.org.apache.maven.plugin.MojoExecutionnewMojoExecution(java.lang.String goal)Deprecated.org.apache.maven.project.MavenProjectreadMavenProject(java.io.File basedir)Deprecated.voidsetupContainer()Deprecated.org.codehaus.plexus.ContainerConfigurationsetupContainerConfiguration()Deprecated.<T> voidsetVariableValueToObject(java.lang.Object object, java.lang.String variable, T value)Deprecated.Convenience method to set values to variables in objects that don't have setters
-
-
-
Constructor Detail
-
MojoRule
public MojoRule()
Deprecated.
-
MojoRule
public MojoRule(AbstractMojoTestCase testCase)
Deprecated.
-
-
Method Detail
-
before
protected void before() throws java.lang.ThrowableDeprecated.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:
java.lang.Throwable
-
after
protected void after()
Deprecated.May be overridden in the implementation to do stuff after the current test was run.
-
getPublicDescriptorStream
public java.io.InputStream getPublicDescriptorStream() throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception
-
getPluginDescriptorPath
public java.lang.String getPluginDescriptorPath()
Deprecated.
-
getPluginDescriptorLocation
public java.lang.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(java.lang.String goal, java.lang.String pluginPom) throws java.lang.ExceptionDeprecated.Lookup the mojo leveraging the subproject pom- Parameters:
goal-pluginPom-- Returns:
- a Mojo instance
- Throws:
java.lang.Exception
-
lookupEmptyMojo
public <T extends org.apache.maven.plugin.Mojo> T lookupEmptyMojo(java.lang.String goal, java.lang.String pluginPom) throws java.lang.ExceptionDeprecated.Lookup an empty mojo- Parameters:
goal-pluginPom-- Returns:
- a Mojo instance
- Throws:
java.lang.Exception
-
lookupMojo
public <T extends org.apache.maven.plugin.Mojo> T lookupMojo(java.lang.String goal, java.io.File pom) throws java.lang.ExceptionDeprecated.Lookup the mojo leveraging the actual subprojects pom- Parameters:
goal-pom-- Returns:
- a Mojo instance
- Throws:
java.lang.Exception
-
lookupEmptyMojo
public <T extends org.apache.maven.plugin.Mojo> T lookupEmptyMojo(java.lang.String goal, java.io.File pom) throws java.lang.ExceptionDeprecated.Lookup the mojo leveraging the actual subprojects pom- Parameters:
goal-pom-- Returns:
- a Mojo instance
- Throws:
java.lang.Exception
-
lookupMojo
public <T extends org.apache.maven.plugin.Mojo> T lookupMojo(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception
-
lookupConfiguredMojo
public <T extends org.apache.maven.plugin.Mojo> T lookupConfiguredMojo(org.apache.maven.project.MavenProject project, java.lang.String goal) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.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 java.lang.Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationExceptionDeprecated.- Throws:
java.lang.Exceptionorg.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(java.lang.String goal)
Deprecated.
-
extractPluginConfiguration
public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(java.lang.String artifactId, java.io.File pom) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception
-
extractPluginConfiguration
public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(java.lang.String artifactId, org.codehaus.plexus.util.xml.Xpp3Dom pomDom) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception
-
configureMojo
public <T extends org.apache.maven.plugin.Mojo> T configureMojo(T mojo, java.lang.String artifactId, java.io.File pom) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception
-
configureMojo
public <T extends org.apache.maven.plugin.Mojo> T configureMojo(T mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception
-
getVariableValueFromObject
public <T> T getVariableValueFromObject(java.lang.Object object, java.lang.String variable) throws java.lang.IllegalAccessExceptionDeprecated.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:
java.lang.IllegalArgumentExceptionjava.lang.IllegalAccessException
-
getVariablesAndValuesFromObject
public java.util.Map<java.lang.String,java.lang.Object> getVariablesAndValuesFromObject(java.lang.Object object) throws java.lang.IllegalAccessExceptionDeprecated.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:
java.lang.IllegalAccessException
-
getVariablesAndValuesFromObject
public java.util.Map<java.lang.String,java.lang.Object> getVariablesAndValuesFromObject(java.lang.Class<?> clazz, java.lang.Object object) throws java.lang.IllegalAccessExceptionDeprecated.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:
java.lang.IllegalAccessException
-
setVariableValueToObject
public <T> void setVariableValueToObject(java.lang.Object object, java.lang.String variable, T value) throws java.lang.IllegalAccessExceptionDeprecated.Convenience method to set values to variables in objects that don't have setters- Parameters:
object-variable-value-- Throws:
java.lang.IllegalAccessException
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)Deprecated.- Specified by:
applyin interfaceorg.junit.rules.TestRule
-
readMavenProject
public org.apache.maven.project.MavenProject readMavenProject(java.io.File basedir) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception- Since:
- 3.1.0
-
executeMojo
public void executeMojo(java.io.File basedir, java.lang.String goal) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception- Since:
- 3.1.0
-
lookupConfiguredMojo
public <T extends org.apache.maven.plugin.Mojo> T lookupConfiguredMojo(java.io.File basedir, java.lang.String goal) throws java.lang.Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationExceptionDeprecated.- Throws:
java.lang.Exceptionorg.codehaus.plexus.component.configurator.ComponentConfigurationException- Since:
- 3.1.0
-
lookup
public final <T> T lookup(java.lang.Class<T> role) throws org.codehaus.plexus.component.repository.exception.ComponentLookupExceptionDeprecated.- Throws:
org.codehaus.plexus.component.repository.exception.ComponentLookupException- Since:
- 3.1.0
-
executeMojo
public void executeMojo(org.apache.maven.project.MavenProject project, java.lang.String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception- Since:
- 3.2.0
-
executeMojo
public void executeMojo(org.apache.maven.execution.MavenSession session, org.apache.maven.project.MavenProject project, java.lang.String goal, org.codehaus.plexus.util.xml.Xpp3Dom... parameters) throws java.lang.ExceptionDeprecated.- Throws:
java.lang.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 java.lang.ExceptionDeprecated.- Throws:
java.lang.Exception- Since:
- 3.2.0
-
-