You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/08/19 15:04:24 UTC

svn commit: r805786 - /maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java

Author: bentmann
Date: Wed Aug 19 13:04:24 2009
New Revision: 805786

URL: http://svn.apache.org/viewvc?rev=805786&view=rev
Log:
o Decoupled from plugin manager

Modified:
    maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java

Modified: maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java
URL: http://svn.apache.org/viewvc/maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java?rev=805786&r1=805785&r2=805786&view=diff
==============================================================================
--- maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java (original)
+++ maven/plugin-testing/branches/plugin-testing-mvn-3.x/maven-plugin-testing-harness/src/main/java/org/apache/maven/plugin/testing/AbstractMojoTestCase.java Wed Aug 19 13:04:24 2009
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -29,10 +30,9 @@
 import java.util.Map;
 
 import org.apache.maven.monitor.logging.DefaultLog;
-import org.apache.maven.plugin.DefaultPluginManager;
 import org.apache.maven.plugin.Mojo;
-import org.apache.maven.plugin.PluginManager;
 import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
 import org.apache.maven.plugin.logging.Log;
 import org.codehaus.plexus.ContainerConfiguration;
 import org.codehaus.plexus.DefaultContainerConfiguration;
@@ -47,8 +47,10 @@
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
 import org.codehaus.plexus.logging.LoggerManager;
+import org.codehaus.plexus.util.InterpolationFilterReader;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.ReflectionUtils;
+import org.codehaus.plexus.util.xml.XmlStreamReader;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
 
@@ -69,8 +71,6 @@
     extends PlexusTestCase
 {
     private ComponentConfigurator configurator;
-    // this is a little ugly using impl prior the interface 
-    private DefaultPluginManager pluginManager;
 
     private PlexusContainer container;
     
@@ -80,15 +80,20 @@
      * to either the project stub or into the mojo directly with injection...not sure yet though.
      */
     //private MavenProjectBuilder projectBuilder;
+
     protected void setUp()
         throws Exception
     {
-
         configurator = getContainer().lookup( ComponentConfigurator.class, "basic" );
-        pluginManager = (DefaultPluginManager) getContainer().lookup( PluginManager.class );
 
-        InputStream is = getClass().getResourceAsStream( "/" + pluginManager.getComponentDescriptorLocation() );
-        PluginDescriptor pluginDescriptor = pluginManager.parsebuildPluginDescriptor( is ); // closes the stream
+        InputStream is = getClass().getResourceAsStream( "/" + getPluginDescriptorLocation() );
+
+        XmlStreamReader reader = ReaderFactory.newXmlReader( is );
+
+        InterpolationFilterReader interpolationFilterReader =
+            new InterpolationFilterReader( new BufferedReader( reader ), container.getContext().getContextData() );
+
+        PluginDescriptor pluginDescriptor = new PluginDescriptorBuilder().build( interpolationFilterReader );
 
         for ( ComponentDescriptor<?> desc : pluginDescriptor.getComponents() )
         {
@@ -106,8 +111,12 @@
     {
         return getBasedir() + "/target/classes/META-INF/maven/plugin.xml";
     }
-    
-    
+
+    protected String getPluginDescriptorLocation()
+    {
+        return "META-INF/maven/plugin.xml";
+    }
+
     protected void setupContainer()
     {
         ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() );