All pastes #48990 Raw Edit

Anonymous

public text v1 · immutable
#48990 ·published 2006-04-11 08:13 UTC
rendered paste body
package org.apache.maven.plugin.simple;

import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.Mojo;
import org.codehaus.plexus.configuration.PlexusConfiguration;

import java.io.File;

/**
 * @author Jason van Zyl
 * @version $Revision:$
 */
public class SimpleMojoTestCase
    extends AbstractMojoTestCase
{
    public void testSimpleMojoUsingInstantitaion()
        throws Exception
    {
        File pom = new File( getBasedir(), "src/test/resources/pom.xml" );

        SimpleMojo mojo = new SimpleMojo();

        mojo = (SimpleMojo) configureMojo( mojo, "maven-simple-plugin", pom );

        assertNotNull( mojo );
    }

    public void testSimpleMojoUsingLookupWithExplicitValues()
        throws Exception
    {
        File pom = new File( getBasedir(), "src/test/resources/pom.xml" );

        SimpleMojo mojo = (SimpleMojo) lookupMojo( "org.apache.maven.plugin.simple", "maven-simple-plugin", "1.0-SNAPSHOT", "call", pom );

        assertNotNull( mojo );

        mojo.execute();
    }

    // the following method used to exist in AbstractMojoTestCase but is commented out right now.
    protected Mojo lookupMojo( String groupId, String artifactId, String version, String goal, File pom )
        throws Exception
    {
        PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom );

        return lookupMojo( groupId, artifactId, version, goal, pluginConfiguration );
    }

    public void testSimpleMojoUsingLookupWithGleanedPomValues()
        throws Exception
    {
        File pom = new File( getBasedir(), "src/test/resources/pom.xml" );

        SimpleMojo mojo = (SimpleMojo) lookupMojo( "call", pom );

        assertNotNull( mojo );

        mojo.execute();
    }

}