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/05/08 17:50:41 UTC

svn commit: r405076 - /maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java

Author: brett
Date: Mon May  8 08:50:39 2006
New Revision: 405076

URL: http://svn.apache.org/viewcvs?rev=405076&view=rev
Log:
fix line ending test - was testing the wrong thing

Modified:
    maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java

Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java?rev=405076&r1=405075&r2=405076&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/AssemblyMojoTest.java Mon May  8 08:50:39 2006
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub;
 import org.apache.maven.plugin.assembly.stubs.ArchiverStub;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
@@ -61,14 +62,15 @@
 
         assertEquals( "Test number of files in archive", artifactSet.size() + 1, archivedFiles.size() );
 
-        for( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
+        for ( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
         {
             Artifact expected = (Artifact) artifacts.next();
 
             assertTrue( "Test expected dependency artifacts in archive", archivedFiles.contains( expected.getFile() ) );
             assertTrue( "Test expected dependency is not unpacked", expected.getFile().getName().endsWith( ".jar" ) );
 
-            ArchiverStub.ArchiverFile archiveFile = (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
+            ArchiverStub.ArchiverFile archiveFile =
+                (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
             String archivePath = archiveFile.getOutputName();
             assertTrue( "Test includeBaseDirectory", archivePath.startsWith( "assembly/" ) );
         }
@@ -76,7 +78,8 @@
         assertTrue( "Test project is in archive", archivedFiles.contains( project.getArtifact().getFile() ) );
         assertTrue( "Test project is not unpacked", project.getArtifact().getFile().getName().endsWith( ".jar" ) );
 
-        ArchiverStub.ArchiverFile archiveFile = (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
+        ArchiverStub.ArchiverFile archiveFile =
+            (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
         String archivePath = archiveFile.getOutputName();
         assertTrue( "Test includeBaseDirectory", archivePath.startsWith( "assembly/" ) );
     }
@@ -96,7 +99,7 @@
 
         assertEquals( "Test number of files in archive", artifactSet.size() + 1, archivedFiles.size() );
 
-        for( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
+        for ( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
         {
             Artifact expected = (Artifact) artifacts.next();
 
@@ -105,8 +108,8 @@
 
             ArchiverStub.ArchiverFile archiveFile = (ArchiverStub.ArchiverFile) archiveMap.get( expected.getFile() );
             String archivePath = archiveFile.getOutputName();
-            String expectedName = "libs/" + expected.getVersion() + "-" +
-                                  expected.getArtifactId() + "-" + expected.getGroupId();
+            String expectedName =
+                "libs/" + expected.getVersion() + "-" + expected.getArtifactId() + "-" + expected.getGroupId();
             assertTrue( "Test filename mapping was used", archivePath.equals( expectedName ) );
             assertFalse( "Test includeBaseDirectory", archivePath.startsWith( "assembly/" ) );
         }
@@ -114,7 +117,8 @@
         assertTrue( "Test project is in archive", archivedFiles.contains( project.getArtifact().getFile() ) );
         assertTrue( "Test project is not unpacked", project.getArtifact().getFile().getName().endsWith( ".jar" ) );
 
-        ArchiverStub.ArchiverFile archiveFile = (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
+        ArchiverStub.ArchiverFile archiveFile =
+            (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
         String archivePath = archiveFile.getOutputName();
         assertFalse( "Test includeBaseDirectory", archivePath.startsWith( "assembly/" ) );
     }
@@ -132,29 +136,34 @@
         Map archiveMap = ArchiverManagerStub.archiverStub.getFiles();
         Collection archivedFiles = archiveMap.keySet();
 
-        for( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
+        for ( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
         {
             Artifact expected = (Artifact) artifacts.next();
 
             if ( !expected.getScope().equals( Artifact.SCOPE_TEST ) )
             {
-                assertTrue( "Test expected dependency artifacts in archive", archivedFiles.contains( expected.getFile() ) );
-                assertTrue( "Test expected dependency is not unpacked", expected.getFile().getName().endsWith( ".jar" ) );
+                assertTrue( "Test expected dependency artifacts in archive",
+                            archivedFiles.contains( expected.getFile() ) );
+                assertTrue( "Test expected dependency is not unpacked",
+                            expected.getFile().getName().endsWith( ".jar" ) );
 
-                ArchiverStub.ArchiverFile archiveFile = (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
+                ArchiverStub.ArchiverFile archiveFile =
+                    (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
                 String archivePath = archiveFile.getOutputName();
                 assertTrue( "Test includeBaseDirectory", archivePath.startsWith( "assembly/" ) );
             }
             else
             {
-                assertFalse( "Test unexpected dependency artifacts in archive", archivedFiles.contains( expected.getFile() ) );
+                assertFalse( "Test unexpected dependency artifacts in archive",
+                             archivedFiles.contains( expected.getFile() ) );
             }
         }
 
         assertTrue( "Test project is in archive", archivedFiles.contains( project.getArtifact().getFile() ) );
         assertTrue( "Test project is not unpacked", project.getArtifact().getFile().getName().endsWith( ".jar" ) );
 
-        ArchiverStub.ArchiverFile archiveFile = (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
+        ArchiverStub.ArchiverFile archiveFile =
+            (ArchiverStub.ArchiverFile) archiveMap.get( project.getArtifact().getFile() );
         String archivePath = archiveFile.getOutputName();
         assertTrue( "Test includeBaseDirectory", archivePath.startsWith( "assembly/" ) );
     }
@@ -175,7 +184,7 @@
 
         assertEquals( "Test number of files in archive", artifactSet.size() + 1, archivedFileSet.size() );
 
-        for( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
+        for ( Iterator artifacts = artifactSet.iterator(); artifacts.hasNext(); )
         {
             Artifact dependency = (Artifact) artifacts.next();
 
@@ -186,8 +195,8 @@
             assertTrue( "Test if expected dependency is in the archive", archivedFileSet.contains( workPath ) );
         }
 
-        String name = project.getArtifact().getArtifactId() + "-" + project.getArtifact().getVersion() +
-                      "." + project.getArtifact().getType();
+        String name = project.getArtifact().getArtifactId() + "-" + project.getArtifact().getVersion() + "." +
+            project.getArtifact().getType();
         File workPath = new File( workDir, name );
 
         assertTrue( "Test if project is unpacked", workPath.exists() && workPath.isDirectory() );
@@ -210,8 +219,8 @@
 
         assertNotNull( "Test expected FileSet", file );
         assertNull( "Test includes", file.getIncludes() );
-        assertTrue( "Test excludes", assertEquals( FileUtils.getDefaultExcludesAsList().toArray( new String[0] ),
-                                                   file.getExcludes() ) );
+        assertTrue( "Test excludes",
+                    assertEquals( FileUtils.getDefaultExcludesAsList().toArray( new String[0] ), file.getExcludes() ) );
     }
 
     public void testFileSetWithArchiveBaseDir()
@@ -230,8 +239,8 @@
 
         assertNotNull( "Test expected FileSet", file );
         assertNull( "Test includes", file.getIncludes() );
-        assertTrue( "Test excludes", assertEquals( FileUtils.getDefaultExcludesAsList().toArray( new String[0] ),
-                                                   file.getExcludes() ) );
+        assertTrue( "Test excludes",
+                    assertEquals( FileUtils.getDefaultExcludesAsList().toArray( new String[0] ), file.getExcludes() ) );
     }
 
     public void testFileSetIncludesExcludes()
@@ -249,7 +258,7 @@
         ArchiverStub.ArchiverFile file = (ArchiverStub.ArchiverFile) archiverFiles.get( key );
 
         assertNotNull( "Test expected FileSet", file );
-        assertTrue( "Test includes", assertEquals( new String[] { "**/*.txt" }, file.getIncludes() ) );
+        assertTrue( "Test includes", assertEquals( new String[]{"**/*.txt"}, file.getIncludes() ) );
 
         List excludesList = new ArrayList();
         excludesList.add( "**/*.xml" );
@@ -423,21 +432,20 @@
     {
         try
         {
-            executeMojo( "fileSet-crlf-lineEndings-plugin-config.xml" );
+            executeMojo( "fileSet-lineEndings-exception-plugin-config.xml" );
 
             fail( "Expected exception not thrown" );
         }
-        catch( Exception e )
+        catch ( MojoFailureException e )
         {
-            //expected
+            // expected
         }
     }
 
     private AssemblyMojo getMojo( String pluginXml )
         throws Exception
     {
-        return (AssemblyMojo) lookupMojo( "assembly", basedir +
-                                        "/src/test/plugin-configs/assembly/" + pluginXml );
+        return (AssemblyMojo) lookupMojo( "assembly", basedir + "/src/test/plugin-configs/assembly/" + pluginXml );
     }
 
     private AssemblyMojo executeMojo( String pluginXml )
@@ -460,7 +468,7 @@
         {
             for ( int ctr = 0; ctr < obj1.length; ctr++ )
             {
-                if ( !obj1[ ctr ].equals( obj2[ ctr ]) )
+                if ( !obj1[ctr].equals( obj2[ctr] ) )
                 {
                     break;
                 }
@@ -479,23 +487,15 @@
 
         FileUtils.mkdir( fileSetDir + "/configs" );
 
-        String fileContents =
-            "<hibernate>" + lineEnding +
-            "  <hibernate-mapping>" + lineEnding +
-            "    <class/>" + lineEnding +
-            "  </hibernate-mapping>" + lineEnding +
-            "</hibernate>";
+        String fileContents = "<hibernate>" + lineEnding + "  <hibernate-mapping>" + lineEnding + "    <class/>" +
+            lineEnding + "  </hibernate-mapping>" + lineEnding + "</hibernate>";
         FileUtils.fileWrite( fileSetDir + "/hibernate.hbm.xml", fileContents );
 
-        fileContents =
-            "Copyright 2001-2006 The Apache Software Foundation." + lineEnding +
-            lineEnding +
+        fileContents = "Copyright 2001-2006 The Apache Software Foundation." + lineEnding + lineEnding +
             "Licensed under the Apache License, Version 2.0 (the \"License\");" + lineEnding +
             "you may not use this file except in compliance with the License." + lineEnding +
-            "You may obtain a copy of the License at" + lineEnding +
-            lineEnding +
-            "     http://www.apache.org/licenses/LICENSE-2.0" + lineEnding +
-            lineEnding +
+            "You may obtain a copy of the License at" + lineEnding + lineEnding +
+            "     http://www.apache.org/licenses/LICENSE-2.0" + lineEnding + lineEnding +
             "Unless required by applicable law or agreed to in writing, software" + lineEnding +
             "distributed under the License is distributed on an \"AS IS\" BASIS," + lineEnding +
             "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." + lineEnding +
@@ -506,10 +506,8 @@
         fileContents = "Readme file with only one line";
         FileUtils.fileWrite( fileSetDir + "/README.txt", fileContents );
 
-        fileContents = "sample configuration file line 1" + lineEnding +
-                       "sample configuration file line 2" + lineEnding +
-                       "sample configuration file line 3" + lineEnding +
-                       "sample configuration file line 4";
+        fileContents = "sample configuration file line 1" + lineEnding + "sample configuration file line 2" +
+            lineEnding + "sample configuration file line 3" + lineEnding + "sample configuration file line 4";
         FileUtils.fileWrite( fileSetDir + "/configs/config.txt", fileContents );
     }
 }