Tabnine Logo
AbstractMojoTestCase
Code IndexAdd Tabnine to your IDE (free)

How to use
AbstractMojoTestCase
in
org.apache.maven.plugin.testing

Best Java code snippets using org.apache.maven.plugin.testing.AbstractMojoTestCase (Showing top 20 results out of 315)

origin: apache/avro

@Override
protected void setUp() throws Exception {
 super.setUp();
}
origin: apache/avro

@Override
protected void tearDown() throws Exception {
 super.tearDown();
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

public PlexusContainer getContainer()
{
  return testCase.getContainer();
}    

origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Lookup the mojo leveraging the actual subprojects pom
 *
 * @param goal
 * @param pom
 * @return a Mojo instance
 * @throws Exception
 */
protected Mojo lookupMojo( String goal, File pom )
  throws Exception
{
  File pluginPom = new File( getBasedir(), "pom.xml" );
  Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) );
  String artifactId = pluginPomDom.getChild( "artifactId" ).getValue();
  String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" );
  String version = resolveFromRootThenParent( pluginPomDom, "version" );
  PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom );
  return lookupMojo( groupId, artifactId, version, goal, pluginConfiguration );
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

protected void setUp()
  throws Exception
{
  assertTrue( "Maven 3.2.4 or better is required",
        MAVEN_VERSION == null || new DefaultArtifactVersion( "3.2.3" ).compareTo( MAVEN_VERSION ) < 0 );
  configurator = getContainer().lookup( ComponentConfigurator.class, "basic" );
  InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() );
  XmlStreamReader reader = new XmlStreamReader( is );
  InterpolationFilterReader interpolationFilterReader =
    new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() );
  PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader );
  Artifact artifact =
    lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(),
                             pluginDescriptor.getArtifactId(),
                             pluginDescriptor.getVersion(), ".jar" );
  artifact.setFile( getPluginArtifactFile() );
  pluginDescriptor.setPluginArtifact( artifact );
  pluginDescriptor.setArtifacts( Arrays.asList( artifact ) );
  for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() )
  {
    getContainer().addComponentDescriptor( desc );
  }
  mojoDescriptors = new HashMap<String, MojoDescriptor>();
  for ( MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos() )
  {
    mojoDescriptors.put( mojoDescriptor.getGoal(), mojoDescriptor );
  }
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Lookup the mojo leveraging the actual subprojects pom
 *
 * @param goal
 * @param pom
 * @return a Mojo instance
 * @throws Exception
 */
protected Mojo lookupEmptyMojo( String goal, File pom )
  throws Exception
{
  File pluginPom = new File( getBasedir(), "pom.xml" );
  Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) );
  String artifactId = pluginPomDom.getChild( "artifactId" ).getValue();
  String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" );
  String version = resolveFromRootThenParent( pluginPomDom, "version" );
  return lookupMojo( groupId, artifactId, version, goal, null );
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Configure the mojo
 *
 * @param mojo
 * @param artifactId
 * @param pom
 * @return a Mojo instance
 * @throws Exception
 */
protected Mojo configureMojo( Mojo mojo, String artifactId, File pom )
  throws Exception
{
  validateContainerStatus();
  PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom );
  ExpressionEvaluator evaluator = new ResolverExpressionEvaluatorStub();
  configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
  return mojo;
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

throws Exception
validateContainerStatus();
Mojo mojo = (Mojo) lookup( Mojo.ROLE, groupId + ":" + artifactId + ":" + version + ":" + goal );
LoggerManager loggerManager = (LoggerManager) getContainer().lookup( LoggerManager.class );
  configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
origin: com.simpligility.org.apache.maven.plugin-testing/maven-plugin-testing-harness

protected void setUp()
  throws Exception
{
  configurator = getContainer().lookup( ComponentConfigurator.class, "basic" );
  InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() );
  XmlStreamReader reader = new XmlStreamReader( is );
  InterpolationFilterReader interpolationFilterReader =
    new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() );
  PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader );
  Artifact artifact =
    lookup( RepositorySystem.class ).createArtifact( pluginDescriptor.getGroupId(),
                             pluginDescriptor.getArtifactId(),
                             pluginDescriptor.getVersion(), ".jar" );
  artifact.setFile( new File( getBasedir() ).getCanonicalFile() );
  pluginDescriptor.setPluginArtifact( artifact );
  pluginDescriptor.setArtifacts( Arrays.asList( artifact ) );
  for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() )
  {
    getContainer().addComponentDescriptor( desc );
  }
  mojoDescriptors = new HashMap<String, MojoDescriptor>();
  for ( MojoDescriptor mojoDescriptor : pluginDescriptor.getMojos() )
  {
    mojoDescriptors.put( mojoDescriptor.getGoal(), mojoDescriptor );
  }
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

public Mojo lookupMojo( String groupId, String artifactId, String version, String goal,
              PlexusConfiguration pluginConfiguration )
  throws Exception
{
  return testCase.lookupMojo( groupId, artifactId, version, goal, pluginConfiguration );
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Configure the mojo with the given plexus configuration
 *
 * @param mojo
 * @param pluginConfiguration
 * @return a Mojo instance
 * @throws Exception
 */
protected Mojo configureMojo( Mojo mojo, PlexusConfiguration pluginConfiguration )
  throws Exception
{
  validateContainerStatus();
  ExpressionEvaluator evaluator = new ResolverExpressionEvaluatorStub();
  configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
  return mojo;
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

MojoDescriptor mojoDescriptor = execution.getMojoDescriptor();
Mojo mojo = (Mojo) lookup( mojoDescriptor.getRole(), mojoDescriptor.getRoleHint() );
  configurator = getContainer().lookup( ComponentConfigurator.class, mojoDescriptor.getComponentConfigurator() );
configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

protected void setupContainer()
{
  ContainerConfiguration cc = setupContainerConfiguration();
  try
  {
    List<Module> modules = new ArrayList<Module>();
    addGuiceModules( modules );
    container = new DefaultPlexusContainer( cc, modules.toArray( new Module[modules.size()] ) );
  }
  catch ( PlexusContainerException e )
  {
    e.printStackTrace();
    fail( "Failed to create plexus container." );
  }   
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * 
 * @param goal
 * @return
 * @since 2.0
 */
protected MojoExecution newMojoExecution( String goal )
{
  MojoDescriptor mojoDescriptor = mojoDescriptors.get( goal );
  assertNotNull(String.format("The MojoDescriptor for the goal %s cannot be null.", goal),  mojoDescriptor );
  MojoExecution execution = new MojoExecution( mojoDescriptor );
  finalizeMojoConfiguration( execution );
  return execution;
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

public PlexusConfiguration extractPluginConfiguration( String artifactId, File pom )
  throws Exception
{
  return testCase.extractPluginConfiguration( artifactId, pom );
}
origin: com.simpligility.org.apache.maven.plugin-testing/maven-plugin-testing-harness

protected void setupContainer()
{
  ContainerConfiguration cc = setupContainerConfiguration();
  try
  {
    container = new DefaultPlexusContainer( cc );
  }
  catch ( PlexusContainerException e )
  {
    e.printStackTrace();
    fail( "Failed to create plexus container." );
  }   
}
origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

public Mojo configureMojo( Mojo mojo, PlexusConfiguration pluginConfiguration )
  throws Exception
{
  return testCase.configureMojo( mojo, pluginConfiguration );
}
origin: com.simpligility.org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Lookup the mojo leveraging the actual subprojects pom
 *
 * @param goal
 * @param pom
 * @return a Mojo instance
 * @throws Exception
 */
protected Mojo lookupMojo( String goal, File pom )
  throws Exception
{
  File pluginPom = new File( getBasedir(), "pom.xml" );
  Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) );
  String artifactId = pluginPomDom.getChild( "artifactId" ).getValue();
  String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" );
  String version = resolveFromRootThenParent( pluginPomDom, "version" );
  PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom );
  return lookupMojo( groupId, artifactId, version, goal, pluginConfiguration );
}
origin: com.simpligility.org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Lookup the mojo leveraging the actual subprojects pom
 *
 * @param goal
 * @param pom
 * @return a Mojo instance
 * @throws Exception
 */
protected Mojo lookupEmptyMojo( String goal, File pom )
  throws Exception
{
  File pluginPom = new File( getBasedir(), "pom.xml" );
  Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( ReaderFactory.newXmlReader( pluginPom ) );
  String artifactId = pluginPomDom.getChild( "artifactId" ).getValue();
  String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" );
  String version = resolveFromRootThenParent( pluginPomDom, "version" );
  return lookupMojo( groupId, artifactId, version, goal, null );
}
origin: com.simpligility.org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Configure the mojo
 *
 * @param mojo
 * @param artifactId
 * @param pom
 * @return a Mojo instance
 * @throws Exception
 */
protected Mojo configureMojo( Mojo mojo, String artifactId, File pom )
  throws Exception
{
  validateContainerStatus();
  PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom );
  ExpressionEvaluator evaluator = new ResolverExpressionEvaluatorStub();
  configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
  return mojo;
}
org.apache.maven.plugin.testingAbstractMojoTestCase

Javadoc

TODO: add a way to use the plugin POM for the lookup so that the user doesn't have to provide the a:g:v:goal as the role hint for the mojo lookup. TODO: standardize the execution of the mojo and looking at the results, but could simply have a template method for verifying the state of the mojo post execution TODO: need a way to look at the state of the mojo without adding getters, this could be where we finally specify the expressions which extract values from the mojo. TODO: create a standard directory structure for picking up POMs to make this even easier, we really just need a testing descriptor and make this entirely declarative!

Most used methods

  • setUp
  • tearDown
  • getContainer
  • lookupMojo
    lookup the mojo while we have all of the relavent information
  • assertNotNull
  • configureMojo
    Configure the mojo with the given plexus configuration
  • extractPluginConfiguration
  • fail
  • finalizeMojoConfiguration
  • getBasedir
  • getPluginDescriptorLocation
  • getPluginDescriptorPath
  • getPluginDescriptorLocation,
  • getPluginDescriptorPath,
  • getPublicDescriptorStream,
  • getVariableValueFromObject,
  • getVariablesAndValuesFromObject,
  • lookup,
  • lookupConfiguredMojo,
  • lookupEmptyMojo,
  • newMavenSession,
  • newMojoExecution

Popular in Java

  • Making http post requests using okhttp
  • setScale (BigDecimal)
  • setContentView (Activity)
  • startActivity (Activity)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now