public class MojoRule extends Object implements TestRule
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.| Constructor and Description |
|---|
MojoRule() |
MojoRule(AbstractMojoTestCase testCase) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
after()
May be overridden in the implementation to do stuff after the current test was run.
|
Statement |
apply(Statement base,
Description description) |
protected void |
before()
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.
|
Mojo |
configureMojo(Mojo mojo,
org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) |
Mojo |
configureMojo(Mojo mojo,
String artifactId,
File pom) |
void |
executeMojo(File basedir,
String goal) |
void |
executeMojo(MavenProject project,
String goal,
Xpp3Dom... parameters) |
void |
executeMojo(MavenSession session,
MavenProject project,
MojoExecution execution) |
void |
executeMojo(MavenSession session,
MavenProject project,
String goal,
Xpp3Dom... parameters) |
org.codehaus.plexus.configuration.PlexusConfiguration |
extractPluginConfiguration(String artifactId,
File pom) |
org.codehaus.plexus.configuration.PlexusConfiguration |
extractPluginConfiguration(String artifactId,
Xpp3Dom pomDom) |
org.codehaus.plexus.PlexusContainer |
getContainer() |
String |
getPluginDescriptorLocation() |
String |
getPluginDescriptorPath() |
InputStream |
getPublicDescriptorStream() |
Map<String,Object> |
getVariablesAndValuesFromObject(Class<?> clazz,
Object object)
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.
|
Map<String,Object> |
getVariablesAndValuesFromObject(Object object)
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.
|
Object |
getVariableValueFromObject(Object object,
String variable)
Convenience method to obtain the value of a variable on a mojo that might not have a getter.
|
<T> T |
lookup(Class<T> role) |
Mojo |
lookupConfiguredMojo(File basedir,
String goal) |
Mojo |
lookupConfiguredMojo(MavenProject project,
String goal) |
Mojo |
lookupConfiguredMojo(MavenSession session,
MojoExecution execution) |
Mojo |
lookupEmptyMojo(String goal,
File pom)
Lookup the mojo leveraging the actual subprojects pom
|
Mojo |
lookupEmptyMojo(String goal,
String pluginPom)
Lookup an empty mojo
|
Mojo |
lookupMojo(String goal,
File pom)
Lookup the mojo leveraging the actual subprojects pom
|
Mojo |
lookupMojo(String goal,
String pluginPom)
Lookup the mojo leveraging the subproject pom
|
Mojo |
lookupMojo(String groupId,
String artifactId,
String version,
String goal,
org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) |
MavenSession |
newMavenSession(MavenProject project) |
MojoExecution |
newMojoExecution(String goal) |
MavenProject |
readMavenProject(File basedir) |
void |
setupContainer() |
org.codehaus.plexus.ContainerConfiguration |
setupContainerConfiguration() |
void |
setVariableValueToObject(Object object,
String variable,
Object value)
Convenience method to set values to variables in objects that don't have setters
|
public MojoRule()
public MojoRule(AbstractMojoTestCase testCase)
protected void before()
throws Throwable
Throwableprotected void after()
public InputStream getPublicDescriptorStream() throws Exception
Exceptionpublic String getPluginDescriptorPath()
public String getPluginDescriptorLocation()
public void setupContainer()
public org.codehaus.plexus.ContainerConfiguration setupContainerConfiguration()
public org.codehaus.plexus.PlexusContainer getContainer()
public Mojo lookupMojo(String goal, String pluginPom) throws Exception
goal - pluginPom - Exceptionpublic Mojo lookupEmptyMojo(String goal, String pluginPom) throws Exception
goal - pluginPom - Exceptionpublic Mojo lookupMojo(String goal, File pom) throws Exception
goal - pom - Exceptionpublic Mojo lookupEmptyMojo(String goal, File pom) throws Exception
goal - pom - Exceptionpublic Mojo lookupMojo(String groupId, String artifactId, String version, String goal, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws Exception
Exceptionpublic Mojo lookupConfiguredMojo(MavenProject project, String goal) throws Exception
Exceptionpublic Mojo lookupConfiguredMojo(MavenSession session, MojoExecution execution) throws Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException
Exceptionorg.codehaus.plexus.component.configurator.ComponentConfigurationExceptionpublic MavenSession newMavenSession(MavenProject project)
public MojoExecution newMojoExecution(String goal)
public org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId, File pom) throws Exception
Exceptionpublic org.codehaus.plexus.configuration.PlexusConfiguration extractPluginConfiguration(String artifactId, Xpp3Dom pomDom) throws Exception
Exceptionpublic Mojo configureMojo(Mojo mojo, String artifactId, File pom) throws Exception
Exceptionpublic Mojo configureMojo(Mojo mojo, org.codehaus.plexus.configuration.PlexusConfiguration pluginConfiguration) throws Exception
Exceptionpublic Object getVariableValueFromObject(Object object, String variable) throws IllegalAccessException
object - variable - IllegalArgumentExceptionIllegalAccessExceptionpublic Map<String,Object> getVariablesAndValuesFromObject(Object object) throws IllegalAccessException
object - IllegalAccessExceptionpublic Map<String,Object> getVariablesAndValuesFromObject(Class<?> clazz, Object object) throws IllegalAccessException
clazz - object - IllegalAccessExceptionpublic void setVariableValueToObject(Object object, String variable, Object value) throws IllegalAccessException
object - variable - value - IllegalAccessExceptionpublic Statement apply(Statement base, Description description)
public MavenProject readMavenProject(File basedir) throws Exception
Exceptionpublic void executeMojo(File basedir, String goal) throws Exception
Exceptionpublic Mojo lookupConfiguredMojo(File basedir, String goal) throws Exception, org.codehaus.plexus.component.configurator.ComponentConfigurationException
Exceptionorg.codehaus.plexus.component.configurator.ComponentConfigurationExceptionpublic final <T> T lookup(Class<T> role) throws org.codehaus.plexus.component.repository.exception.ComponentLookupException
org.codehaus.plexus.component.repository.exception.ComponentLookupExceptionpublic void executeMojo(MavenProject project, String goal, Xpp3Dom... parameters) throws Exception
Exceptionpublic void executeMojo(MavenSession session, MavenProject project, String goal, Xpp3Dom... parameters) throws Exception
Exceptionpublic void executeMojo(MavenSession session, MavenProject project, MojoExecution execution) throws Exception
ExceptionCopyright © 2008–2014 The Apache Software Foundation. All rights reserved.