3434import java .util .HashMap ;
3535import java .util .List ;
3636import java .util .Map ;
37+ import java .util .Properties ;
3738
3839import org .apache .commons .io .input .XmlStreamReader ;
3940import org .apache .maven .artifact .Artifact ;
41+ import org .apache .maven .artifact .versioning .DefaultArtifactVersion ;
4042import org .apache .maven .execution .DefaultMavenExecutionRequest ;
4143import org .apache .maven .execution .DefaultMavenExecutionResult ;
4244import org .apache .maven .execution .MavenExecutionRequest ;
7173import org .codehaus .plexus .configuration .PlexusConfiguration ;
7274import org .codehaus .plexus .configuration .xml .XmlPlexusConfiguration ;
7375import org .codehaus .plexus .logging .LoggerManager ;
76+ import org .codehaus .plexus .util .IOUtil ;
7477import org .codehaus .plexus .util .InterpolationFilterReader ;
7578import org .codehaus .plexus .util .ReaderFactory ;
7679import org .codehaus .plexus .util .ReflectionUtils ;
9699public abstract class AbstractMojoTestCase
97100 extends PlexusTestCase
98101{
102+ private static final DefaultArtifactVersion MAVEN_VERSION ;
103+
104+ static
105+ {
106+ DefaultArtifactVersion version = null ;
107+ String path = "/META-INF/maven/org.apache.maven/maven-core/pom.properties" ;
108+ InputStream is = AbstractMojoTestCase .class .getResourceAsStream ( path );
109+ try
110+ {
111+ Properties properties = new Properties ();
112+ if ( is != null )
113+ {
114+ properties .load ( is );
115+ }
116+ String property = properties .getProperty ( "version" );
117+ if ( property != null )
118+ {
119+ version = new DefaultArtifactVersion ( property );
120+ }
121+ }
122+ catch ( IOException e )
123+ {
124+ // odd, where did this come from
125+ }
126+ finally
127+ {
128+ IOUtil .close ( is );
129+ }
130+ MAVEN_VERSION = version ;
131+ }
132+
99133 private ComponentConfigurator configurator ;
100134
101135 private PlexusContainer container ;
@@ -112,6 +146,9 @@ public abstract class AbstractMojoTestCase
112146 protected void setUp ()
113147 throws Exception
114148 {
149+ assertTrue ( "Maven 3.2.4 or better is required" ,
150+ MAVEN_VERSION == null || new DefaultArtifactVersion ( "3.2.3" ).compareTo ( MAVEN_VERSION ) < 0 );
151+
115152 configurator = getContainer ().lookup ( ComponentConfigurator .class , "basic" );
116153
117154 InputStream is = getClass ().getResourceAsStream ( "/" + getPluginDescriptorLocation () );
0 commit comments