brett       2004/05/28 09:52:04

  Modified:    maven-plugins/maven-resources-plugin project.xml
  Added:       
maven-plugins/maven-resources-plugin/src/test/java/org/apache/maven/plugin
                        ResourcesPluginTest.java
  Log:
  add failing plugin test for something that should be in the default excludes
  for resources. Test omitted from project.xml at present.
  
  Revision  Changes    Path
  1.7       +7 -0      
maven-components/maven-plugins/maven-resources-plugin/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-plugins/maven-resources-plugin/project.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- project.xml       28 May 2004 12:07:43 -0000      1.6
  +++ project.xml       28 May 2004 16:52:04 -0000      1.7
  @@ -28,4 +28,11 @@
         <version>2.0-SNAPSHOT</version>
       </dependency>
     </dependencies>
  +  <build>
  +    <unitTest>
  +      <excludes>
  +        <exclude>**/ResourcesPluginTest.java</exclude>
  +      </excludes>
  +    </unitTest>
  +  </build>
   </project>
  
  
  
  1.1                  
maven-components/maven-plugins/maven-resources-plugin/src/test/java/org/apache/maven/plugin/ResourcesPluginTest.java
  
  Index: ResourcesPluginTest.java
  ===================================================================
  package org.apache.maven.plugin;
  
  import org.apache.maven.model.Resource;
  import org.apache.maven.plugin.PluginTestCase;
  import org.apache.maven.plugin.ResourcesPlugin;
  import org.apache.maven.project.MavenProjectBuilder;
  import org.apache.maven.project.MavenProject;
  import org.codehaus.plexus.embed.Embedder;
  
  import java.io.File;
  import java.io.FileWriter;
  import java.io.PrintWriter;
  import java.util.Collections;
  import java.util.Map;
  import java.util.HashMap;
  
  /**
   * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a>
   * @version $Id: ResourcesPluginTest.java,v 1.1 2004/05/28 16:52:04 brett Exp $
   */
  public class ResourcesPluginTest
      extends PluginTestCase
  {
      private static final String TEST_DIRECTORY = "target/tests/test-data";
      private static final String OUTPUT_DIRECTORY = "target/tests/output";
  
      public ResourcesPluginTest( String s )
      {
          super( s );
      }
  
      protected void setupPlugin()
          throws Exception
      {
          plugin = new ResourcesPlugin();
  
          // have to mkdir CVS as it can't be in CVS!
          File f = new File( basedir, TEST_DIRECTORY + "/CVS" );
          f.mkdirs();
          f = new File( f, "Root" );
          PrintWriter w = new PrintWriter( new FileWriter( f ) );
          w.println( ":local:/cvs/root" );
          w.close();
  
          w = new PrintWriter( new FileWriter( new File( basedir, TEST_DIRECTORY + 
"/test.txt" ) ) );
          w.println( "test data" );
          w.close();
  
          // make sure the things in the output directory we test aren't there
          f = new File( basedir, OUTPUT_DIRECTORY + "/CVS/Root" );
          f.delete();
          f.getParentFile().delete();
          f = new File( basedir, OUTPUT_DIRECTORY + "/test.txt" );
          f.delete();
          f.getParentFile().delete();
      }
  
      protected Map getTestParameters()
          throws Exception
      {
          Embedder embedder = new Embedder();
  
          embedder.setClassLoader( Thread.currentThread().getContextClassLoader() );
  
          embedder.start();
  
          MavenProjectBuilder builder = (MavenProjectBuilder) embedder.lookup( 
MavenProjectBuilder.ROLE );
  
          // TODO: here it would be much nicer to just use resources from some test 
project.xml file for
          //       testing the standard resources elements
          // MavenProject project = builder.build( new File( basedir, "project.xml" ) 
);
  
          Map parameters = new HashMap();
  
          File directory = new File( basedir, TEST_DIRECTORY );
          assertEquals( "sanity check name of directory " + directory, "test-data", 
directory.getName() );
  
          File f = new File( directory, "CVS/Root" );
          assertTrue( "sanity check creation of CVS file " + f, f.exists() );
          f = new File( directory, "test.txt" );
          assertTrue( "sanity check creation of file " + f, f.exists() );
  
          Resource r = new Resource();
          r.setDirectory( TEST_DIRECTORY );
          parameters.put( "resources", Collections.singletonList( r ) ); 
  
          f = new File( basedir, OUTPUT_DIRECTORY );
          assertFalse( "sanity check no output directory" + f, f.exists() );
  
          parameters.put( "outputDirectory", OUTPUT_DIRECTORY );
  
          return parameters;
      }
  
      protected void validatePluginExecution()
          throws Exception
      {
          File f = new File( basedir + "/" + OUTPUT_DIRECTORY, "CVS/Root" );
          assertFalse( "check no creation of CVS file " + f, f.exists() );
          assertFalse( "check no creation of CVS directory " + f, 
f.getParentFile().exists() );
          f = new File( basedir + "/" + OUTPUT_DIRECTORY, "test.txt" );
          assertTrue( "check creation of resource " + f, f.exists() );
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to