You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/03/24 04:16:53 UTC
svn commit: r388344 - in /maven/sandbox/maven-plugin-testing-harness: ./
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/maven/ src/main/java/org/apache/maven/plugins/
src/main/java/org/apache/maven/p...
Author: brett
Date: Thu Mar 23 19:16:49 2006
New Revision: 388344
URL: http://svn.apache.org/viewcvs?rev=388344&view=rev
Log:
[MNG-32] add testing harness
Submitted by: Jesse McConnell
Added:
maven/sandbox/maven-plugin-testing-harness/
maven/sandbox/maven-plugin-testing-harness/pom.xml (with props)
maven/sandbox/maven-plugin-testing-harness/src/
maven/sandbox/maven-plugin-testing-harness/src/main/
maven/sandbox/maven-plugin-testing-harness/src/main/java/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java (with props)
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/ConfigurationException.java (with props)
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/StubResolverExpressionEvaluator.java (with props)
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubArtifact.java (with props)
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubMavenProject.java (with props)
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/codehaus/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/codehaus/plexus/
maven/sandbox/maven-plugin-testing-harness/src/main/java/org/codehaus/plexus/component/
maven/sandbox/maven-plugin-testing-harness/src/main/resources/
maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/
maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/plexus/
maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/plexus/components.xml (with props)
maven/sandbox/maven-plugin-testing-harness/src/test/
maven/sandbox/maven-plugin-testing-harness/src/test/java/
maven/sandbox/maven-plugin-testing-harness/src/test/java/org/
maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/
maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/
maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/
maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/
maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/MojoTestCaseTest.java (with props)
maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/SimpleMojo.java (with props)
Added: maven/sandbox/maven-plugin-testing-harness/pom.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/pom.xml?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/pom.xml (added)
+++ maven/sandbox/maven-plugin-testing-harness/pom.xml Thu Mar 23 19:16:49 2006
@@ -0,0 +1,34 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>maven-parent</artifactId>
+ <groupId>org.apache.maven</groupId>
+ <version>1</version>
+ </parent>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <name>Maven Plugin Testing Mechanism</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.2-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/sandbox/maven-plugin-testing-harness/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java (added)
+++ maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java Thu Mar 23 19:16:49 2006
@@ -0,0 +1,366 @@
+package org.apache.maven.plugins.testing;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.ReflectionUtils;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
+import org.codehaus.plexus.component.configurator.ComponentConfigurator;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+import org.apache.maven.plugin.Mojo;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.monitor.logging.DefaultLog;
+import org.apache.maven.project.MavenProjectBuilder;
+
+import java.io.Reader;
+import java.io.FileReader;
+import java.io.File;
+import java.util.Map;
+
+// 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: standarize 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!
+public abstract class AbstractMojoTestCase
+ extends PlexusTestCase
+{
+ private ComponentConfigurator configurator;
+
+ /*
+ * for the harness I think we have decided against going the route of using the maven project builder.
+ * instead I think we are going to try and make an instance of the localrespository and assign that
+ * to either the project stub or into the mojo directly with injection...not sure yet though.
+ */
+ //private MavenProjectBuilder projectBuilder;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ configurator = (ComponentConfigurator) getContainer().lookup( ComponentConfigurator.ROLE );
+
+ //projectBuilder = (MavenProjectBuilder) getContainer().lookup( MavenProjectBuilder.ROLE );
+ }
+
+ /**
+ * lookup the mojo leveraging the subproject pom
+ *
+ */
+ protected Mojo lookupMojo( String goal, String pluginPom ) throws Exception
+ {
+ return lookupMojo( goal, new File( pluginPom ) );
+ }
+
+ /**
+ * lookup an empty mojo
+ */
+ protected Mojo lookupEmptyMojo( String goal, String pluginPom ) throws Exception
+ {
+ return lookupEmptyMojo( goal, new File( pluginPom ) );
+ }
+
+
+ /**
+ * lookup the mojo leveraging the actual subprojects pom
+ *
+ * @param goal
+ * @param pom
+ * @return
+ * @throws Exception
+ */
+ protected Mojo lookupMojo( String goal, File pom )
+ throws Exception
+ {
+ File pluginPom = new File( getBasedir(), "pom.xml" );
+
+ Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( new FileReader( 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 );
+ }
+
+ /**
+ * lookup the mojo leveraging the actual subprojects pom
+ *
+ * @param goal
+ * @param pom
+ * @return
+ * @throws Exception
+ */
+ protected Mojo lookupEmptyMojo( String goal, File pom )
+ throws Exception
+ {
+ File pluginPom = new File( getBasedir(), "pom.xml" );
+
+ Xpp3Dom pluginPomDom = Xpp3DomBuilder.build( new FileReader( pluginPom ) );
+
+ String artifactId = pluginPomDom.getChild( "artifactId" ).getValue();
+
+ String groupId = resolveFromRootThenParent( pluginPomDom, "groupId" );
+
+ String version = resolveFromRootThenParent( pluginPomDom, "version" );
+
+ return lookupMojo( groupId, artifactId, version, goal, null );
+ }
+
+ /*
+ 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 );
+ }
+ */
+ /**
+ * lookup the mojo while we have all of the relavent information
+ *
+ * @param groupId
+ * @param artifactId
+ * @param version
+ * @param goal
+ * @param pluginConfiguration
+ * @return
+ * @throws Exception
+ */
+ protected Mojo lookupMojo( String groupId, String artifactId, String version, String goal, PlexusConfiguration pluginConfiguration )
+ throws Exception
+ {
+ validateContainerStatus();
+
+ // pluginkey = groupId : artifactId : version : goal
+
+ Mojo mojo = (Mojo) lookup( Mojo.ROLE, groupId + ":" + artifactId + ":" + version + ":" + goal );
+
+ Log mojoLogger = new DefaultLog( container.getLoggerManager().getLoggerForComponent( Mojo.ROLE ) );
+
+ mojo.setLog( mojoLogger );
+
+ if ( pluginConfiguration != null )
+ {
+ /* requires v10 of plexus container for lookup on expression evaluator
+ ExpressionEvaluator evaluator = (ExpressionEvaluator) getContainer().lookup( ExpressionEvaluator.ROLE, "stub-evaluator" );
+ */
+ ExpressionEvaluator evaluator = new StubResolverExpressionEvaluator();
+
+ configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
+ }
+
+ return mojo;
+ }
+
+
+ protected PlexusConfiguration extractPluginConfiguration( String artifactId, File pom )
+ throws Exception
+ {
+ Reader reader = new FileReader( pom );
+
+ Xpp3Dom pomDom = Xpp3DomBuilder.build( reader );
+
+ return extractPluginConfiguration( artifactId, pomDom );
+ }
+
+ protected PlexusConfiguration extractPluginConfiguration( String artifactId, Xpp3Dom pomDom )
+ throws Exception
+ {
+ Xpp3Dom[] pluginElements = pomDom.getChild( "build" ).getChild( "plugins" ).getChildren();
+
+ Xpp3Dom pluginConfigurationElement = null;
+
+ for ( int i = 0; i < pluginElements.length; i++ )
+ {
+ Xpp3Dom pluginElement = pluginElements[i];
+
+ String pluginElementArtifactId = pluginElement.getChild( "artifactId" ).getValue();
+
+ if ( pluginElementArtifactId.equals( artifactId ) )
+ {
+ pluginConfigurationElement = pluginElement.getChild( "configuration" );
+
+ break;
+ }
+ }
+
+ if ( pluginConfigurationElement == null )
+ {
+ throw new ConfigurationException( "Cannot find a configuration element for a plugin with an artifactId of " + artifactId + "." );
+ }
+
+ return new XmlPlexusConfiguration( pluginConfigurationElement );
+ }
+
+ protected Mojo configureMojo( Mojo mojo, String artifactId, File pom )
+ throws Exception
+ {
+ validateContainerStatus();
+
+ PlexusConfiguration pluginConfiguration = extractPluginConfiguration( artifactId, pom );
+
+ ExpressionEvaluator evaluator = new StubResolverExpressionEvaluator();
+
+
+ configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
+
+ return mojo;
+ }
+
+ /**
+ * configure the mojo with the given plexus configuration
+ *
+ * @param mojo
+ * @param pluginConfiguration
+ * @return
+ * @throws Exception
+ */
+ protected Mojo configureMojo( Mojo mojo, PlexusConfiguration pluginConfiguration )
+ throws Exception
+ {
+ validateContainerStatus();
+
+ ExpressionEvaluator evaluator = new StubResolverExpressionEvaluator();
+
+ configurator.configureComponent( mojo, pluginConfiguration, evaluator, getContainer().getContainerRealm() );
+
+ return mojo;
+ }
+
+
+ /**
+ * convience 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.
+ *
+ * @param object
+ * @param variable
+ * @return object value of variable
+ * @throws IllegalArgumentException
+ */
+ protected Object getVariableValueFromObject( Object object, String variable )
+ throws IllegalAccessException
+ {
+ return ReflectionUtils.getValueIncludingSuperclasses( variable, object );
+
+ }
+
+
+ /**
+ * convience 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.
+ *
+ * @param object
+ * @return map of variable names and values
+ */
+ protected Map getVariablesAndValuesFromObject( Object object )
+ throws IllegalAccessException
+ {
+ return ReflectionUtils.getVariablesAndValuesIncludingSuperclasses( object );
+ }
+
+
+ /**
+ * convience method to set values to variables in objects that don't have setters
+ * @param object
+ * @param variable
+ * @param value
+ * @throws IllegalAccessException
+ */
+ protected void setVariableValueToObject( Object object, String variable, Object value )
+ throws IllegalAccessException
+ {
+ ReflectionUtils.setVariableValueInObject( object, variable, value );
+ }
+ /**
+ * sometimes the parent element might contain the correct value so generalize that access
+ *
+ * TODO find out where this is probably done elsewhere
+ *
+ * @param pluginPomDom
+ * @param element
+ * @return
+ * @throws Exception
+ */
+
+ private String resolveFromRootThenParent( Xpp3Dom pluginPomDom, String element ) throws Exception
+ {
+ Xpp3Dom elementDom = pluginPomDom.getChild( element );
+
+ // parent might have the group Id so resolve it
+ if ( elementDom == null )
+ {
+ Xpp3Dom pluginParentDom = pluginPomDom.getChild("parent");
+
+ if (pluginParentDom != null )
+ {
+ elementDom = pluginParentDom.getChild( element );
+
+ if ( elementDom == null )
+ {
+ throw new Exception ( "unable to determine " + element );
+ }
+ else
+ {
+ return elementDom.getValue();
+ }
+ }
+ else
+ {
+ throw new Exception ( "unable to determine " + element );
+ }
+ }
+ else
+ {
+ return elementDom.getValue();
+ }
+ }
+
+
+ /*
+ * We should make sure this is called in each method that makes use of the container,
+ * otherwise we throw ugly NPE's
+ *
+ * crops up when the subclassing code defines the setUp method but doesn't call super.setUp()
+ *
+ * @throws Exception
+ */
+ private void validateContainerStatus() throws Exception {
+ if (container != null)
+ {
+ return;
+ }
+ else
+ {
+ throw new Exception("container is null, make sure super.setUp() is called");
+ }
+ }
+}
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/AbstractMojoTestCase.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/ConfigurationException.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/ConfigurationException.java?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/ConfigurationException.java (added)
+++ maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/ConfigurationException.java Thu Mar 23 19:16:49 2006
@@ -0,0 +1,41 @@
+package org.apache.maven.plugins.testing;
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * ConfigurationException:
+ *
+ * @author: jesse
+ * @date: Mar 20, 2006
+ * @version: $ID:$
+ */
+public class ConfigurationException extends Exception
+{
+ public ConfigurationException( String message )
+ {
+ super(message);
+ }
+
+ public ConfigurationException( Throwable cause )
+ {
+ super(cause);
+ }
+
+ public ConfigurationException( String message, Throwable cause )
+ {
+ super(message, cause);
+ }
+}
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/ConfigurationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/ConfigurationException.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/StubResolverExpressionEvaluator.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/StubResolverExpressionEvaluator.java?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/StubResolverExpressionEvaluator.java (added)
+++ maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/StubResolverExpressionEvaluator.java Thu Mar 23 19:16:49 2006
@@ -0,0 +1,127 @@
+package org.apache.maven.plugins.testing;
+
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
+import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+
+import java.io.File;
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * StubResolverExpressionEvaluator:
+ *
+ * @author: jesse
+ * @date: Feb 24, 2006
+ * @version: $Id:$
+ */
+public class StubResolverExpressionEvaluator
+ implements ExpressionEvaluator
+{
+
+ public Object evaluate( String expr )
+ throws ExpressionEvaluationException
+ {
+
+ Object value = null;
+
+ if ( expr == null )
+ {
+ return null;
+ }
+
+ String expression = stripTokens( expr );
+
+ if ( expression.equals( expr ) )
+ {
+ int index = expr.indexOf( "${" );
+ if ( index >= 0 )
+ {
+ int lastIndex = expr.indexOf( "}", index );
+ if ( lastIndex >= 0 )
+ {
+ String retVal = expr.substring( 0, index );
+
+ if ( index > 0 && expr.charAt( index - 1 ) == '$' )
+ {
+ retVal += expr.substring( index + 1, lastIndex + 1 );
+ }
+ else
+ {
+ retVal += evaluate( expr.substring( index, lastIndex + 1 ) );
+ }
+
+ retVal += evaluate( expr.substring( lastIndex + 1 ) );
+ return retVal;
+ }
+ }
+
+ // Was not an expression
+ if ( expression.indexOf( "$$" ) > -1 )
+ {
+ return expression.replaceAll( "\\$\\$", "\\$" );
+ }
+ }
+
+ if ( "basedir".equals( expression ) )
+ {
+ return PlexusTestCase.getBasedir();
+ }
+ else if ( expression.startsWith( "basedir" ) )
+ {
+ int pathSeparator = expression.indexOf( "/" );
+
+ if ( pathSeparator > 0 )
+ {
+ value = PlexusTestCase.getBasedir() + expression.substring( pathSeparator );
+ }
+ else
+ {
+ System.out.println( "Got expression '" + expression + "' that was not recognised" );
+ }
+ return value;
+ }
+ else
+ {
+ return expr;
+ }
+ }
+
+ private String stripTokens( String expr )
+ {
+ if ( expr.startsWith( "${" ) && expr.indexOf( "}" ) == expr.length() - 1 )
+ {
+ expr = expr.substring( 2, expr.length() - 1 );
+ }
+
+ return expr;
+ }
+
+ public File alignToBaseDirectory( File file )
+ {
+ if ( file.getAbsolutePath().startsWith( PlexusTestCase.getBasedir() ) )
+ {
+ return file;
+ }
+ else
+ {
+ return new File( PlexusTestCase.getBasedir() + File.pathSeparator + file.getPath() );
+ }
+ }
+}
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/StubResolverExpressionEvaluator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/StubResolverExpressionEvaluator.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubArtifact.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubArtifact.java?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubArtifact.java (added)
+++ maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubArtifact.java Thu Mar 23 19:16:49 2006
@@ -0,0 +1,255 @@
+package org.apache.maven.plugins.testing.stubs;
+
+
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
+import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * StubArtifact:
+ *
+ * @author: jesse
+ * @date: Feb 24, 2006
+ * @version: $ID:$
+ */
+public class StubArtifact implements Artifact
+{
+
+ public int compareTo( Object object )
+ {
+ return 0;
+ }
+
+ public String getGroupId()
+ {
+ return null;
+ }
+
+ public String getArtifactId()
+ {
+ return null;
+ }
+
+ public String getVersion()
+ {
+ return null;
+ }
+
+ public void setVersion( String string )
+ {
+ }
+
+ public String getScope()
+ {
+ return null;
+ }
+
+ public String getType()
+ {
+ return null;
+ }
+
+ public String getClassifier()
+ {
+ return null;
+ }
+
+ public boolean hasClassifier()
+ {
+ return false;
+ }
+
+ public File getFile()
+ {
+ return null;
+ }
+
+ public void setFile( File file )
+ {
+
+ }
+
+ public String getBaseVersion()
+ {
+ return null;
+ }
+
+ public void setBaseVersion( String string )
+ {
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public String getDependencyConflictId()
+ {
+ return null;
+ }
+
+ public void addMetadata( ArtifactMetadata artifactMetadata )
+ {
+ }
+
+ public Collection getMetadataList()
+ {
+ return null;
+ }
+
+ public void setRepository( ArtifactRepository artifactRepository )
+ {
+ }
+
+ public ArtifactRepository getRepository()
+ {
+ return null;
+ }
+
+ public void updateVersion( String string, ArtifactRepository artifactRepository )
+ {
+ }
+
+ public String getDownloadUrl()
+ {
+ return null;
+ }
+
+ public void setDownloadUrl( String string )
+ {
+ }
+
+ public ArtifactFilter getDependencyFilter()
+ {
+ return null;
+ }
+
+ public void setDependencyFilter( ArtifactFilter artifactFilter )
+ {
+ }
+
+ public ArtifactHandler getArtifactHandler()
+ {
+ return null;
+ }
+
+ public List getDependencyTrail()
+ {
+ return null;
+ }
+
+ public void setDependencyTrail( List list )
+ {
+ }
+
+ public void setScope( String string )
+ {
+ }
+
+ public VersionRange getVersionRange()
+ {
+ return null;
+ }
+
+ public void setVersionRange( VersionRange versionRange )
+ {
+ }
+
+ public void selectVersion( String string )
+ {
+ }
+
+ public void setGroupId( String string )
+ {
+ }
+
+ public void setArtifactId( String string )
+ {
+ }
+
+ public boolean isSnapshot()
+ {
+ return false;
+ }
+
+ public void setResolved( boolean b )
+ {
+ }
+
+ public boolean isResolved()
+ {
+ return false;
+ }
+
+ public void setResolvedVersion( String string )
+ {
+ }
+
+ public void setArtifactHandler( ArtifactHandler artifactHandler )
+ {
+ }
+
+ public boolean isRelease()
+ {
+ return false;
+ }
+
+ public void setRelease( boolean b )
+ {
+ }
+
+ public List getAvailableVersions()
+ {
+ return null;
+ }
+
+ public void setAvailableVersions( List list )
+ {
+ }
+
+ public boolean isOptional()
+ {
+ return false;
+ }
+
+ public void setOptional( boolean b )
+ {
+ }
+
+ public ArtifactVersion getSelectedVersion()
+ throws OverConstrainedVersionException
+ {
+ return null;
+ }
+
+ public boolean isSelectedVersionKnown()
+ throws OverConstrainedVersionException
+ {
+ return false;
+ }
+}
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubArtifact.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubArtifact.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubMavenProject.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubMavenProject.java?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubMavenProject.java (added)
+++ maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubMavenProject.java Thu Mar 23 19:16:49 2006
@@ -0,0 +1,983 @@
+package org.apache.maven.plugins.testing.stubs;
+
+/*
+ * Copyright 2005 The Codehaus.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.apache.maven.model.DependencyManagement;
+import org.apache.maven.model.Prerequisites;
+import org.apache.maven.model.IssueManagement;
+import org.apache.maven.model.CiManagement;
+import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.Organization;
+import org.apache.maven.model.Scm;
+import org.apache.maven.model.MailingList;
+import org.apache.maven.model.Developer;
+import org.apache.maven.model.Contributor;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Resource;
+import org.apache.maven.model.Reporting;
+import org.apache.maven.model.License;
+import org.apache.maven.model.PluginManagement;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.IOException;
+import java.io.File;
+import java.io.Writer;
+import java.util.List;
+import java.util.Set;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Collections;
+
+/**
+ * very simple stub of maven project, going to take a lot of work to make it useful as a stub though
+ */
+public class StubMavenProject extends MavenProject
+{
+ private String groupId;
+ private String artifactId;
+ private String name;
+
+ private Model model;
+ private MavenProject parent;
+ private File file;
+ private Set artifacts;
+ private Artifact parentArtifact;
+ private Set pluginArtifacts;
+ private List remoteArtifactRepositories;
+ private List collectedProjects;
+ private List attachedArtifacts;
+ private MavenProject executionProject;
+ private List compileSourceRoots;
+ private List testCompileSourceRoots;
+ private List scriptSourceRoots;
+ private List pluginArtifactRepositories;
+ private ArtifactRepository releaseArtifactRepository;
+ private ArtifactRepository snapshotArtifactRepository;
+ private List activeProfiles;
+ private Set dependencyArtifacts;
+ private Artifact artifact;
+ private Map artifactMap;
+ private Model originalModel;
+ private Map pluginArtifactMap;
+ private Set reportArtifacts;
+ private Map reportArtifactMap;
+ private Set extensionArtifacts;
+ private Map extensionArtifactMap;
+ private Map projectReferences;
+ private Build buildOverlay;
+ private boolean executionRoot;
+
+ private List compileArtifacts;
+
+ private List compileDependencies;
+
+ private List systemDependencies;
+
+ private List testClasspathElements;
+ private List testDependencies;
+ private List systemClasspathElements;
+ private List systemArtifacts;
+ private List testArtifacts;
+ private List runtimeArtifacts;
+ private List runtimeDependencies;
+ private List runtimeClasspathElements;
+
+ private String modelVersion;
+ private String packaging;
+ private String inceptionYear;
+ private String url;
+
+ private String description;
+
+ private String version;
+
+ private String defaultGoal;
+
+
+ public StubMavenProject() {}
+
+ // kinda dangerous...
+ public StubMavenProject(Model model)
+ {
+ // super(model);
+ }
+
+ // kinda dangerous...
+ public StubMavenProject(MavenProject project)
+ {
+ //super(project);
+ }
+
+ public String getModulePathAdjustment( MavenProject mavenProject )
+ throws IOException
+ {
+ return "";
+ }
+
+ public Artifact getArtifact()
+ {
+ return artifact;
+ }
+
+ public void setArtifact( Artifact artifact )
+ {
+ this.artifact = artifact;
+ }
+
+ public Model getModel()
+ {
+ return model;
+ }
+
+ public MavenProject getParent()
+ {
+ return parent;
+ }
+
+ public void setParent( MavenProject mavenProject )
+ {
+ this.parent = mavenProject;
+ }
+
+ public void setRemoteArtifactRepositories( List list )
+ {
+
+ }
+
+ public List getRemoteArtifactRepositories()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public boolean hasParent()
+ {
+ if (parent != null)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public void setFile( File file )
+ {
+ this.file = file;
+ }
+
+ public File getBasedir()
+ {
+ return new File(PlexusTestCase.getBasedir());
+ }
+
+ public void setDependencies( List list )
+ {
+
+ }
+
+ public List getDependencies()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public DependencyManagement getDependencyManagement()
+ {
+ return null;
+ }
+
+ public void addCompileSourceRoot( String string )
+ {
+ if ( compileSourceRoots == null )
+ {
+ compileSourceRoots = Collections.singletonList( string );
+ }
+ else
+ {
+ compileSourceRoots.add( string );
+ }
+ }
+
+ public void addScriptSourceRoot( String string )
+ {
+ if ( scriptSourceRoots == null )
+ {
+ scriptSourceRoots = Collections.singletonList( string );
+ }
+ else
+ {
+ scriptSourceRoots.add( string );
+ }
+ }
+
+ public void addTestCompileSourceRoot( String string )
+ {
+ if ( testCompileSourceRoots == null )
+ {
+ testCompileSourceRoots = Collections.singletonList( string );
+ }
+ else
+ {
+ testCompileSourceRoots.add( string );
+ }
+ }
+
+ public List getCompileSourceRoots()
+ {
+ return compileSourceRoots;
+ }
+
+ public List getScriptSourceRoots()
+ {
+ return scriptSourceRoots;
+ }
+
+ public List getTestCompileSourceRoots()
+ {
+ return testCompileSourceRoots;
+ }
+
+ public List getCompileClasspathElements()
+ throws DependencyResolutionRequiredException
+ {
+ return compileSourceRoots;
+ }
+
+ public void setCompileArtifacts( List compileArtifacts )
+ {
+ this.compileArtifacts = compileArtifacts;
+ }
+
+ public List getCompileArtifacts()
+ {
+ return compileArtifacts;
+ }
+
+ public List getCompileDependencies()
+ {
+ return compileDependencies;
+ }
+
+ public List getTestClasspathElements()
+ throws DependencyResolutionRequiredException
+ {
+ return testClasspathElements;
+ }
+
+ public List getTestArtifacts()
+ {
+ return testArtifacts;
+ }
+
+ public List getTestDependencies()
+ {
+ return testDependencies;
+ }
+
+ public List getRuntimeClasspathElements()
+ throws DependencyResolutionRequiredException
+ {
+ return runtimeClasspathElements;
+ }
+
+ public List getRuntimeArtifacts()
+ {
+ return runtimeArtifacts;
+ }
+
+ public List getRuntimeDependencies()
+ {
+ return runtimeDependencies;
+ }
+
+ public List getSystemClasspathElements()
+ throws DependencyResolutionRequiredException
+ {
+ return systemClasspathElements;
+ }
+
+ public List getSystemArtifacts()
+ {
+ return systemArtifacts;
+ }
+
+ public void setRuntimeClasspathElements( List runtimeClasspathElements )
+ {
+ this.runtimeClasspathElements = runtimeClasspathElements;
+ }
+
+ public void setAttachedArtifacts( List attachedArtifacts )
+ {
+ this.attachedArtifacts = attachedArtifacts;
+ }
+
+ public void setCompileSourceRoots( List compileSourceRoots )
+ {
+ this.compileSourceRoots = compileSourceRoots;
+ }
+
+ public void setTestCompileSourceRoots( List testCompileSourceRoots )
+ {
+ this.testCompileSourceRoots = testCompileSourceRoots;
+ }
+
+ public void setScriptSourceRoots( List scriptSourceRoots )
+ {
+ this.scriptSourceRoots = scriptSourceRoots;
+ }
+
+ public void setArtifactMap( Map artifactMap )
+ {
+ this.artifactMap = artifactMap;
+ }
+
+ public void setPluginArtifactMap( Map pluginArtifactMap )
+ {
+ this.pluginArtifactMap = pluginArtifactMap;
+ }
+
+ public void setReportArtifactMap( Map reportArtifactMap )
+ {
+ this.reportArtifactMap = reportArtifactMap;
+ }
+
+ public void setExtensionArtifactMap( Map extensionArtifactMap )
+ {
+ this.extensionArtifactMap = extensionArtifactMap;
+ }
+
+ public void setProjectReferences( Map projectReferences )
+ {
+ this.projectReferences = projectReferences;
+ }
+
+ public void setBuildOverlay( Build buildOverlay )
+ {
+ this.buildOverlay = buildOverlay;
+ }
+
+ public void setCompileDependencies( List compileDependencies )
+ {
+ this.compileDependencies = compileDependencies;
+ }
+
+ public void setSystemDependencies( List systemDependencies )
+ {
+ this.systemDependencies = systemDependencies;
+ }
+
+ public void setTestClasspathElements( List testClasspathElements )
+ {
+ this.testClasspathElements = testClasspathElements;
+ }
+
+ public void setTestDependencies( List testDependencies )
+ {
+ this.testDependencies = testDependencies;
+ }
+
+ public void setSystemClasspathElements( List systemClasspathElements )
+ {
+ this.systemClasspathElements = systemClasspathElements;
+ }
+
+ public void setSystemArtifacts( List systemArtifacts )
+ {
+ this.systemArtifacts = systemArtifacts;
+ }
+
+ public void setTestArtifacts( List testArtifacts )
+ {
+ this.testArtifacts = testArtifacts;
+ }
+
+ public void setRuntimeArtifacts( List runtimeArtifacts )
+ {
+ this.runtimeArtifacts = runtimeArtifacts;
+ }
+
+ public void setRuntimeDependencies( List runtimeDependencies )
+ {
+ this.runtimeDependencies = runtimeDependencies;
+ }
+
+ public void setModel( Model model )
+ {
+ this.model = model;
+ }
+
+ public List getSystemDependencies()
+ {
+ return systemDependencies;
+ }
+
+ public void setModelVersion( String string )
+ {
+ this.modelVersion = string;
+ }
+
+ public String getModelVersion()
+ {
+ return modelVersion;
+ }
+
+ public String getId()
+ {
+ return "";
+ }
+
+ public void setGroupId( String string )
+ {
+ this.groupId = string;
+ }
+
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setArtifactId( String string )
+ {
+ this.artifactId = string;
+ }
+
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ public void setName( String string )
+ {
+ this.name = string;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setVersion( String string )
+ {
+ this.version = string;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public String getPackaging()
+ {
+ return packaging;
+ }
+
+ public void setPackaging( String string )
+ {
+ this.packaging = string;
+ }
+
+ public void setInceptionYear( String string )
+ {
+ this.inceptionYear = string;
+ }
+
+ public String getInceptionYear()
+ {
+ return inceptionYear;
+ }
+
+ public void setUrl( String string )
+ {
+ this.url = string;
+ }
+
+ public String getUrl()
+ {
+ return url;
+ }
+
+ public Prerequisites getPrerequisites()
+ {
+ return null;
+ }
+
+ public void setIssueManagement( IssueManagement issueManagement )
+ {
+
+ }
+
+ public CiManagement getCiManagement()
+ {
+ return null;
+ }
+
+ public void setCiManagement( CiManagement ciManagement )
+ {
+
+ }
+
+ public IssueManagement getIssueManagement()
+ {
+ return null;
+ }
+
+ public void setDistributionManagement( DistributionManagement distributionManagement )
+ {
+
+ }
+
+ public DistributionManagement getDistributionManagement()
+ {
+ return null;
+ }
+
+ public void setDescription( String string )
+ {
+ this.description = string;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setOrganization( Organization organization )
+ {
+
+ }
+
+ public Organization getOrganization()
+ {
+ return null;
+ }
+
+ public void setScm( Scm scm )
+ {
+
+ }
+
+ public Scm getScm()
+ {
+ return null;
+ }
+
+ public void setMailingLists( List list )
+ {
+
+ }
+
+ public List getMailingLists()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public void addMailingList( MailingList mailingList )
+ {
+
+ }
+
+ public void setDevelopers( List list )
+ {
+
+ }
+
+ public List getDevelopers()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public void addDeveloper( Developer developer )
+ {
+
+ }
+
+ public void setContributors( List list )
+ {
+
+ }
+
+ public List getContributors()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public void addContributor( Contributor contributor )
+ {
+
+ }
+
+ public void setBuild( Build build )
+ {
+
+ }
+
+ public Build getBuild()
+ {
+ return null;
+ }
+
+ public List getResources()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public List getTestResources()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public void addResource( Resource resource )
+ {
+
+ }
+
+ public void addTestResource( Resource resource )
+ {
+
+ }
+
+ public void setReporting( Reporting reporting )
+ {
+
+ }
+
+ public Reporting getReporting()
+ {
+ return null;
+ }
+
+ public void setLicenses( List list )
+ {
+
+ }
+
+ public List getLicenses()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public void addLicense( License license )
+ {
+
+ }
+
+ public void setArtifacts( Set set )
+ {
+
+ }
+
+ public Set getArtifacts()
+ {
+ return Collections.singleton( "" );
+ }
+
+ public Map getArtifactMap()
+ {
+ return Collections.singletonMap( "", "" );
+ }
+
+ public void setPluginArtifacts( Set set )
+ {
+
+ }
+
+ public Set getPluginArtifacts()
+ {
+ return Collections.singleton( "" );
+ }
+
+ public Map getPluginArtifactMap()
+ {
+ return Collections.singletonMap( "", "" );
+ }
+
+ public void setReportArtifacts( Set set )
+ {
+
+ }
+
+ public Set getReportArtifacts()
+ {
+ return Collections.singleton( "" );
+ }
+
+ public Map getReportArtifactMap()
+ {
+ return Collections.singletonMap( "", "" );
+ }
+
+ public void setExtensionArtifacts( Set set )
+ {
+
+ }
+
+ public Set getExtensionArtifacts()
+ {
+ return Collections.singleton( "" );
+ }
+
+ public Map getExtensionArtifactMap()
+ {
+ return Collections.singletonMap( "", "" );
+ }
+
+ public void setParentArtifact( Artifact artifact )
+ {
+
+ }
+
+ public Artifact getParentArtifact()
+ {
+ return null;
+ }
+
+ public List getRepositories()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public List getReportPlugins()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public List getBuildPlugins()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public List getModules()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public PluginManagement getPluginManagement()
+ {
+ return null;
+ }
+
+ public void addPlugin( Plugin plugin )
+ {
+
+ }
+
+ public void injectPluginManagementInfo( Plugin plugin )
+ {
+
+ }
+
+ public List getCollectedProjects()
+ {
+ return collectedProjects;
+ }
+
+ public void setCollectedProjects( List list )
+ {
+ this.collectedProjects = list;
+ }
+
+ public void setPluginArtifactRepositories( List list )
+ {
+ this.pluginArtifactRepositories = list;
+ }
+
+ public List getPluginArtifactRepositories()
+ {
+ return pluginArtifactRepositories;
+ }
+
+ public ArtifactRepository getDistributionManagementArtifactRepository()
+ {
+ return null;
+ }
+
+ public List getPluginRepositories()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public void setActiveProfiles( List list )
+ {
+ activeProfiles = list;
+ }
+
+ public List getActiveProfiles()
+ {
+ return activeProfiles;
+ }
+
+ public void addAttachedArtifact( Artifact artifact )
+ {
+ if ( attachedArtifacts == null )
+ {
+ this.attachedArtifacts = Collections.singletonList( artifact );
+ }
+ else
+ {
+ attachedArtifacts.add( artifact );
+ }
+ }
+
+ public List getAttachedArtifacts()
+ {
+ return attachedArtifacts;
+ }
+
+ public Xpp3Dom getGoalConfiguration( String string, String string1, String string2, String string3 )
+ {
+ return null;
+ }
+
+ public Xpp3Dom getReportConfiguration( String string, String string1, String string2 )
+ {
+ return null;
+ }
+
+ public MavenProject getExecutionProject()
+ {
+ return null;
+ }
+
+ public void setExecutionProject( MavenProject mavenProject )
+ {
+
+ }
+
+ public void writeModel( Writer writer )
+ throws IOException
+ {
+
+ }
+
+ public void writeOriginalModel( Writer writer )
+ throws IOException
+ {
+
+ }
+
+ public Set getDependencyArtifacts()
+ {
+ return dependencyArtifacts;
+ }
+
+ public void setDependencyArtifacts( Set set )
+ {
+ this.dependencyArtifacts = set;
+ }
+
+ public void setReleaseArtifactRepository( ArtifactRepository artifactRepository )
+ {
+ this.releaseArtifactRepository = artifactRepository;
+ }
+
+ public void setSnapshotArtifactRepository( ArtifactRepository artifactRepository )
+ {
+ this.snapshotArtifactRepository = artifactRepository;
+ }
+
+ public void setOriginalModel( Model model )
+ {
+ this.originalModel = model;
+ }
+
+ public Model getOriginalModel()
+ {
+ return originalModel;
+ }
+
+ public boolean equals( Object object )
+ {
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return this.hashCode();
+ }
+
+ public List getBuildExtensions()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public Set createArtifacts( ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter )
+ throws InvalidDependencyVersionException
+ {
+ return Collections.singleton( "" );
+ }
+
+ public void addProjectReference( MavenProject mavenProject )
+ {
+
+ }
+
+ public void attachArtifact( String string, String string1, File file )
+ {
+
+ }
+
+ public Properties getProperties()
+ {
+ return null;
+ }
+
+ public List getFilters()
+ {
+ return Collections.singletonList( "" );
+ }
+
+ public Map getProjectReferences()
+ {
+ return Collections.singletonMap( "", "" );
+ }
+
+ public boolean isExecutionRoot()
+ {
+ return executionRoot;
+ }
+
+ public void setExecutionRoot( boolean b )
+ {
+ this.executionRoot = b;
+ }
+
+ public String getDefaultGoal()
+ {
+ return defaultGoal;
+ }
+
+ public Artifact replaceWithActiveArtifact( Artifact artifact )
+ {
+ return null;
+ }
+
+}
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubMavenProject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugins/testing/stubs/StubMavenProject.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/plexus/components.xml?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/plexus/components.xml (added)
+++ maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/plexus/components.xml Thu Mar 23 19:16:49 2006
@@ -0,0 +1,20 @@
+<component-set>
+ <components>
+ <component>
+ <role>org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator</role>
+ <role-hint>stub-evaluator</role-hint>
+ <implementation>org.apache.maven.plugins.testing.StubResolverExpressionEvaluator</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.PlexusContainer</role>
+ <field-name>container</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.apache.maven.artifact.Artifact</role>
+ <role-hint>stub</role-hint>
+ <implementation>org.apache.maven.plugins.testing.stubs.StubArtifact</implementation>
+ </component>
+ </components>
+</component-set>
\ No newline at end of file
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/src/main/resources/META-INF/plexus/components.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/MojoTestCaseTest.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/MojoTestCaseTest.java?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/MojoTestCaseTest.java (added)
+++ maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/MojoTestCaseTest.java Thu Mar 23 19:16:49 2006
@@ -0,0 +1,110 @@
+package org.apache.maven.plugin.testing;
+
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.apache.maven.plugins.testing.AbstractMojoTestCase;
+
+import java.io.StringReader;
+import java.util.Map;
+
+/**
+ * @author Jason van Zyl
+ * @version $Revision:$
+ */
+public class MojoTestCaseTest
+ extends AbstractMojoTestCase
+{
+ private String pom;
+
+ private Xpp3Dom pomDom;
+
+ private PlexusConfiguration pluginConfiguration;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ pom =
+ "<project>" +
+ "<build>" +
+ "<plugins>" +
+ "<plugin>" +
+ "<artifactId>maven-simple-plugin</artifactId>" +
+ "<configuration>" +
+ "<keyOne>valueOne</keyOne>" +
+ "<keyTwo>valueTwo</keyTwo>" +
+ "</configuration>" +
+ "</plugin>" +
+ "</plugins>" +
+ "</build>" +
+ "</project>";
+
+ pomDom = Xpp3DomBuilder.build( new StringReader( pom ) );
+
+ pluginConfiguration = extractPluginConfiguration( "maven-simple-plugin", pomDom );
+ }
+
+ public void testPluginConfigurationExtraction()
+ throws Exception
+ {
+ assertEquals( "valueOne", pluginConfiguration.getChild( "keyOne" ).getValue() );
+
+ assertEquals( "valueTwo", pluginConfiguration.getChild( "keyTwo" ).getValue() );
+ }
+
+ public void testMojoConfiguration()
+ throws Exception
+ {
+ SimpleMojo mojo = new SimpleMojo();
+
+ mojo = (SimpleMojo) configureMojo( mojo, pluginConfiguration );
+
+ assertEquals( "valueOne", mojo.getKeyOne() );
+
+ assertEquals( "valueTwo", mojo.getKeyTwo() );
+ }
+
+ public void testVariableAccessWithoutGetter()
+ throws Exception
+ {
+ SimpleMojo mojo = new SimpleMojo();
+
+ mojo = (SimpleMojo) configureMojo( mojo, pluginConfiguration );
+
+ assertEquals( "valueOne", (String)getVariableValueFromObject( mojo, "keyOne" ) );
+
+ assertEquals( "valueTwo", (String)getVariableValueFromObject( mojo, "keyTwo" ) );
+ }
+
+
+ public void testVariableAccessWithoutGetter2()
+ throws Exception
+ {
+ SimpleMojo mojo = new SimpleMojo();
+
+ mojo = (SimpleMojo) configureMojo( mojo, pluginConfiguration );
+
+ Map map = getVariablesAndValuesFromObject( mojo );
+
+ assertEquals( "valueOne", (String)map.get( "keyOne" ) );
+
+ assertEquals( "valueTwo", (String)map.get( "keyTwo" ) );
+ }
+
+
+ public void testSettingMojoVariables()
+ throws Exception
+ {
+ SimpleMojo mojo = new SimpleMojo();
+
+ mojo = (SimpleMojo) configureMojo( mojo, pluginConfiguration );
+
+ setVariableValueToObject( mojo, "keyOne", "myValueOne" );
+
+ assertEquals( "myValueOne", (String)getVariableValueFromObject( mojo, "keyOne" ) );
+
+ }
+
+}
Propchange: maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/MojoTestCaseTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/MojoTestCaseTest.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/SimpleMojo.java
URL: http://svn.apache.org/viewcvs/maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/SimpleMojo.java?rev=388344&view=auto
==============================================================================
--- maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/SimpleMojo.java (added)
+++ maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/SimpleMojo.java Thu Mar 23 19:16:49 2006
@@ -0,0 +1,31 @@
+package org.apache.maven.plugin.testing;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * @author Jason van Zyl
+ * @version $Revision:$
+ */
+public class SimpleMojo
+ extends AbstractMojo
+{
+ private String keyOne;
+
+ private String keyTwo;
+
+ public String getKeyOne()
+ {
+ return keyOne;
+ }
+
+ public String getKeyTwo()
+ {
+ return keyTwo;
+ }
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ }
+}
Propchange: maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/SimpleMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/maven-plugin-testing-harness/src/test/java/org/apache/maven/plugin/testing/SimpleMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"