You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2015/11/29 12:45:03 UTC

svn commit: r1717041 - /maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java

Author: khmarbaise
Date: Sun Nov 29 11:45:02 2015
New Revision: 1717041

URL: http://svn.apache.org/viewvc?rev=1717041&view=rev
Log:
Improved Test code.

Modified:
    maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java

Modified: maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java?rev=1717041&r1=1717040&r2=1717041&view=diff
==============================================================================
--- maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java (original)
+++ maven/plugins/trunk/maven-source-plugin/src/test/java/org/apache/maven/plugins/source/SourceJarMojoTest.java Sun Nov 29 11:45:02 2015
@@ -32,24 +32,40 @@ public class SourceJarMojoTest
         return "jar";
     }
 
+    private String[] addMavenDescriptor( String project, String[] listOfElements )
+    {
+        final String METAINF = "META-INF/";
+        final String MAVENSOURCE = "maven/source/maven-source-plugin-test-";
+        String[] result = new String[listOfElements.length + 5];
+        System.arraycopy( listOfElements, 0, result, 0, listOfElements.length );
+        result[listOfElements.length] = METAINF + "maven/";
+        result[listOfElements.length + 1] = METAINF + "maven/source/";
+        result[listOfElements.length + 2] = METAINF + MAVENSOURCE + project + "/";
+        result[listOfElements.length + 3] = METAINF + MAVENSOURCE + project + "/pom.properties";
+        result[listOfElements.length + 4] = METAINF + MAVENSOURCE + project + "/pom.xml";
+        return result;
+    }
+
     public void testDefaultConfiguration()
         throws Exception
     {
-        doTestProjectWithSourceArchive( "project-001", new String[] { "default-configuration.properties",
-            "foo/project001/App.java", "foo/project001/", "foo/", "META-INF/MANIFEST.MF", "META-INF/",
-            "META-INF/maven/", "META-INF/maven/source/", "META-INF/maven/source/maven-source-plugin-test-project-001/",
-            "META-INF/maven/source/maven-source-plugin-test-project-001/pom.properties",
-            "META-INF/maven/source/maven-source-plugin-test-project-001/pom.xml" }, "sources" );
+        doTestProjectWithSourceArchive( "project-001",
+                                        addMavenDescriptor( "project-001",
+                                                            new String[] { "default-configuration.properties",
+                                                                "foo/project001/App.java", "foo/project001/", "foo/",
+                                                                "META-INF/MANIFEST.MF", "META-INF/" } ),
+                                        "sources" );
     }
 
     public void testExcludes()
         throws Exception
     {
-        doTestProjectWithSourceArchive( "project-003", new String[] { "default-configuration.properties",
-            "foo/project003/App.java", "foo/project003/", "foo/", "META-INF/MANIFEST.MF", "META-INF/",
-            "META-INF/maven/", "META-INF/maven/source/", "META-INF/maven/source/maven-source-plugin-test-project-003/",
-            "META-INF/maven/source/maven-source-plugin-test-project-003/pom.properties",
-            "META-INF/maven/source/maven-source-plugin-test-project-003/pom.xml" }, "sources" );
+        doTestProjectWithSourceArchive( "project-003",
+                                        addMavenDescriptor( "project-003",
+                                                            new String[] { "default-configuration.properties",
+                                                                "foo/project003/App.java", "foo/project003/", "foo/",
+                                                                "META-INF/MANIFEST.MF", "META-INF/" } ),
+                                        "sources" );
     }
 
     public void testNoSources()
@@ -65,32 +81,30 @@ public class SourceJarMojoTest
     public void testIncludes()
         throws Exception
     {
-        doTestProjectWithSourceArchive( "project-007", new String[] { "templates/configuration-template.properties",
-            "foo/project007/App.java", "templates/", "foo/project007/", "foo/", "META-INF/MANIFEST.MF", "META-INF/",
-            "META-INF/maven/", "META-INF/maven/source/", "META-INF/maven/source/maven-source-plugin-test-project-007/",
-            "META-INF/maven/source/maven-source-plugin-test-project-007/pom.properties",
-            "META-INF/maven/source/maven-source-plugin-test-project-007/pom.xml"
-
-        }, "sources" );
+        doTestProjectWithSourceArchive( "project-007", addMavenDescriptor( "project-007", new String[] {
+            "templates/configuration-template.properties", "foo/project007/App.java", "templates/", "foo/project007/",
+            "foo/", "META-INF/MANIFEST.MF", "META-INF/" } ), "sources" );
     }
 
     public void testIncludePom()
         throws Exception
     {
-        doTestProjectWithSourceArchive( "project-009", new String[] { "default-configuration.properties", "pom.xml",
-            "foo/project009/App.java", "foo/project009/", "foo/", "META-INF/MANIFEST.MF", "META-INF/",
-            "META-INF/maven/", "META-INF/maven/source/", "META-INF/maven/source/maven-source-plugin-test-project-009/",
-            "META-INF/maven/source/maven-source-plugin-test-project-009/pom.properties",
-            "META-INF/maven/source/maven-source-plugin-test-project-009/pom.xml" }, "sources" );
+        doTestProjectWithSourceArchive( "project-009",
+                                        addMavenDescriptor( "project-009",
+                                                            new String[] { "default-configuration.properties",
+                                                                "pom.xml", "foo/project009/App.java", "foo/project009/",
+                                                                "foo/", "META-INF/MANIFEST.MF", "META-INF/" } ),
+                                        "sources" );
     }
 
     public void testIncludeMavenDescriptorWhenExplicitlyConfigured()
         throws Exception
     {
-        doTestProjectWithSourceArchive( "project-010", new String[] { "default-configuration.properties",
-            "foo/project010/App.java", "foo/project010/", "foo/", "META-INF/MANIFEST.MF", "META-INF/",
-            "META-INF/maven/", "META-INF/maven/source/", "META-INF/maven/source/maven-source-plugin-test-project-010/",
-            "META-INF/maven/source/maven-source-plugin-test-project-010/pom.xml",
-            "META-INF/maven/source/maven-source-plugin-test-project-010/pom" + ".properties" }, "sources" );
+        doTestProjectWithSourceArchive( "project-010",
+                                        addMavenDescriptor( "project-010",
+                                                            new String[] { "default-configuration.properties",
+                                                                "foo/project010/App.java", "foo/project010/", "foo/",
+                                                                "META-INF/MANIFEST.MF", "META-INF/" } ),
+                                        "sources" );
     }
 }