Author: andham
Date: Wed Feb  4 21:38:45 2015
New Revision: 1657408

URL: http://svn.apache.org/r1657408
Log:
[ARCHETYPE-431] Only include Apache Maven archetypes in internal archetype 
catalog

Added:
    
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerificationTest.java
      - copied, changed from r1657394, 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java
Removed:
    
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java
    
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogFromWiki.java
Modified:
    maven/archetype/trunk/archetype-common/pom.xml

Modified: maven/archetype/trunk/archetype-common/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/pom.xml?rev=1657408&r1=1657407&r2=1657408&view=diff
==============================================================================
--- maven/archetype/trunk/archetype-common/pom.xml (original)
+++ maven/archetype/trunk/archetype-common/pom.xml Wed Feb  4 21:38:45 2015
@@ -398,24 +398,4 @@
       </plugin>
     </plugins>
   </build>
-
-  <profiles>
-    <profile>
-      <id>internal-catalog</id>
-      <build>
-        <plugins>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <includes>
-                <include>**/InternalCatalogFromWiki.java</include>
-                
<!--include>**/InternalCatalogArchetypesVerification.java</include -->
-              </includes>
-            </configuration>
-          </plugin>
-        </plugins>
-      </build>
-    </profile>
-  </profiles>
 </project>

Copied: 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerificationTest.java
 (from r1657394, 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java)
URL: 
http://svn.apache.org/viewvc/maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerificationTest.java?p2=maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerificationTest.java&p1=maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java&r1=1657394&r2=1657408&rev=1657408&view=diff
==============================================================================
--- 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerification.java
 (original)
+++ 
maven/archetype/trunk/archetype-common/src/test/java/org/apache/maven/archetype/test/InternalCatalogArchetypesVerificationTest.java
 Wed Feb  4 21:38:45 2015
@@ -20,26 +20,25 @@ package org.apache.maven.archetype.test;
  */
 
 import java.io.File;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.maven.archetype.ArchetypeManager;
+
 import org.apache.maven.archetype.ArchetypeGenerationRequest;
 import org.apache.maven.archetype.ArchetypeGenerationResult;
+import org.apache.maven.archetype.ArchetypeManager;
 import org.apache.maven.archetype.catalog.Archetype;
 import org.apache.maven.archetype.catalog.ArchetypeCatalog;
-import org.apache.maven.archetype.catalog.io.xpp3.ArchetypeCatalogXpp3Writer;
 import org.apache.maven.archetype.common.ArchetypeRegistryManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
 
 /**
  *
  * @author rafale
  */
-public class InternalCatalogArchetypesVerification
+public class InternalCatalogArchetypesVerificationTest
     extends PlexusTestCase
 {
+    private static final String CENTRAL = 
"http://repo.maven.apache.org/maven2";;
 
     public void testInternalCatalog()
         throws Exception
@@ -52,74 +51,41 @@ public class InternalCatalogArchetypesVe
 
         File outputDirectory = new File( getBasedir(), 
"target/internal-archetypes-projects" );
         outputDirectory.mkdirs();
+        FileUtils.cleanDirectory( outputDirectory );
 
         ArchetypeManager archetype = (ArchetypeManager) lookup( 
ArchetypeManager.class.getName() );
 
-        ArchetypeCatalog result = archetype.getInternalCatalog();
+        ArchetypeCatalog catalog = archetype.getInternalCatalog();
 
-        List<Archetype> archetypesUsed = new ArrayList<Archetype>();
-        List<Archetype> archetypesRemoved = new ArrayList<Archetype>();
         int count = 1;
-        for ( Archetype a : result.getArchetypes() )
+        for ( Archetype a : catalog.getArchetypes() )
         {
             Archetype ar = new Archetype();
-
             ar.setGroupId( a.getGroupId() );
             ar.setArtifactId( a.getArtifactId() );
-            ar.setVersion( "RELEASE" );
+            ar.setVersion( a.getVersion() );
             ar.setDescription( a.getDescription() );
             ar.setGoals( a.getGoals() );
             ar.setProperties( a.getProperties() );
             ar.setRepository( a.getRepository() );
             if ( ar.getRepository() == null )
             {
-                ar.setRepository( "http://repo.maven.apache.org/maven2"; );
+                ar.setRepository( CENTRAL );
             }
-            System.err.println( "\n\n\n\n\n\nTesting archetype " + ar );
+
             ArchetypeGenerationRequest request =
                 new ArchetypeGenerationRequest( ar )
-                .setGroupId( "groupId" + count )
-                .setArtifactId( "artifactId" + count )
-                .setVersion( "version" + count )
-                .setPackage( "package" + count )
+                .setGroupId( "org.apache.maven.archetype.test" )
+                .setArtifactId( "archetype" + count )
+                .setVersion( "1.0-SNAPSHOT" )
+                .setPackage( "com.acme" )
                 .setOutputDirectory( outputDirectory.getPath() )
                 .setLocalRepository( localRepository );
             ArchetypeGenerationResult generationResult = 
archetype.generateProjectFromArchetype( request );
-            if ( generationResult != null && generationResult.getCause() != 
null )
-            {
-                ar.setVersion( a.getVersion() );
-                request =
-                    new ArchetypeGenerationRequest( ar )
-                    .setGroupId( "groupId" + count )
-                    .setArtifactId( "artifactId" + count )
-                    .setVersion( "version" + count )
-                    .setPackage( "package" + count )
-                    .setOutputDirectory( outputDirectory.getPath() )
-                    .setLocalRepository( localRepository );
-                generationResult = archetype.generateProjectFromArchetype( 
request );
-                if ( generationResult != null && generationResult.getCause() 
!= null )
-                {
-                    archetypesRemoved.add( a );
-                }
-                else
-                {
-                    archetypesUsed.add( a );
-                }
-            }
-            else
-            {
-                archetypesUsed.add( a );
-            }
+            
+            assertTrue ( "Archetype wasn't generated successfully", 
generationResult.getCause() == null );
+            
             count++;
-            System.err.println( "\n\n\n\n\n" );
         }
-        result.setArchetypes( archetypesUsed );
-
-        StringWriter sw = new StringWriter();
-        ArchetypeCatalogXpp3Writer acxw = new ArchetypeCatalogXpp3Writer();
-        acxw.write( sw, result );
-
-        System.err.println( "Resulting catalog is\n" + sw.toString() );
-        System.err.println( "Removed archetypes are \n" + archetypesRemoved );
     }
 }


Reply via email to