maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject [3/3] maven-archetype git commit: [ARCHETYPE-514] Tests fail with empty repository and 'mvn verify' Switch from surefire to failsafe to ensure jars have been created let maven-invoker-plugin prepare local repo for failsafe ITs
Date Mon, 23 Jan 2017 20:56:19 GMT
[ARCHETYPE-514] Tests fail with empty repository and 'mvn verify'
Switch from surefire to failsafe to ensure jars have been created
let maven-invoker-plugin prepare local repo for failsafe ITs


Project: http://git-wip-us.apache.org/repos/asf/maven-archetype/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-archetype/commit/a02e9922
Tree: http://git-wip-us.apache.org/repos/asf/maven-archetype/tree/a02e9922
Diff: http://git-wip-us.apache.org/repos/asf/maven-archetype/diff/a02e9922

Branch: refs/heads/ARCHETYPE-514
Commit: a02e9922c62313ffa147b4f63d125f4dc41f7280
Parents: afdf0a2
Author: rfscholte <rfscholte@apache.org>
Authored: Mon Jan 23 21:55:42 2017 +0100
Committer: rfscholte <rfscholte@apache.org>
Committed: Mon Jan 23 21:55:42 2017 +0100

----------------------------------------------------------------------
 archetype-testing/archetype-final/pom.xml       |  29 +-
 .../creator/DefaultArchetypeCreatorIT.java      | 511 +++++++++++++++++++
 .../creator/DefaultArchetypeCreatorTest.java    | 510 ------------------
 .../archetype/test/ArchetyperRoundtripIT.java   | 245 +++++++++
 .../archetype/test/ArchetyperRoundtripTest.java | 245 ---------
 .../test/ArchetyperRoundtripWithProxyIT.java    | 246 +++++++++
 .../test/ArchetyperRoundtripWithProxyTest.java  | 246 ---------
 .../archetype/test/RoundtripMultiModuleIT.java  | 317 ++++++++++++
 .../test/RoundtripMultiModuleTest.java          | 317 ------------
 9 files changed, 1345 insertions(+), 1321 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/a02e9922/archetype-testing/archetype-final/pom.xml
----------------------------------------------------------------------
diff --git a/archetype-testing/archetype-final/pom.xml b/archetype-testing/archetype-final/pom.xml
index 632aa2a..5420802 100644
--- a/archetype-testing/archetype-final/pom.xml
+++ b/archetype-testing/archetype-final/pom.xml
@@ -30,7 +30,7 @@
   </parent>
 
   <artifactId>archetype-final</artifactId>
-  <packaging>jar</packaging>
+  <packaging>jar</packaging> <!-- to compile test-classes -->
 
   <name>Maven Archetype Testing Final</name>
 
@@ -38,7 +38,6 @@
     <cargoVersion>1.0-alpha-6</cargoVersion>
   </properties>
 
-
   <dependencies>
     <dependency>
       <groupId>junit</groupId>
@@ -138,7 +137,31 @@
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
+        <artifactId>maven-invoker-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>install</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <localRepositoryPath>target/test-classes/repositories/local</localRepositoryPath>
+        </configuration>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <version>2.19.1</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>integration-test</goal>
+              <goal>verify</goal>
+            </goals>
+          </execution>
+        </executions>
         <configuration>
           <systemPropertyVariables>
             <maven.home>${maven.home}</maven.home>

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/a02e9922/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java
----------------------------------------------------------------------
diff --git a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java
new file mode 100644
index 0000000..bd21568
--- /dev/null
+++ b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorIT.java
@@ -0,0 +1,511 @@
+package org.apache.maven.archetype.creator;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.archetype.ArchetypeCreationRequest;
+import org.apache.maven.archetype.ArchetypeCreationResult;
+import org.apache.maven.archetype.common.Constants;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.MavenProjectBuildingResult;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.PropertyUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class DefaultArchetypeCreatorIT
+    extends AbstractMojoTestCase
+{
+    private List<String> filtereds;
+
+    private List<String> languages;
+
+    private DefaultArtifactRepository localRepository;
+
+    protected void createFilesetArchetype( String project )
+        throws Exception
+    {
+        System.out.println( ">>>>>> testCreateFilesetArchetype( \"" + project + "\" )" );
+        
+        MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
+
+        File projectFile = getProjectFile( project );
+
+        File projectFileSample = getProjectSampleFile( project );
+
+        copy( projectFileSample, projectFile );
+
+        FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
+
+        File propertyFile = getPropertiesFile( project );
+
+        File propertyFileSample = getPropertiesSampleFile( project );
+
+        copy( propertyFileSample, propertyFile );
+
+        Properties p = PropertyUtils.loadProperties( propertyFile );
+
+        MavenProject mavenProject = null;
+
+        {
+            Object result = builder.buildWithDependencies( projectFile, localRepository, null );
+            if ( result instanceof MavenProject )
+            { // Using Maven 2.0.x / x >= 7
+                mavenProject = (MavenProject) result;
+            }
+            else if ( result instanceof MavenProjectBuildingResult )
+            { // Using Maven 3
+                mavenProject = ( (MavenProjectBuildingResult) result ).getProject();
+            }
+            else
+            {
+                fail( "Wrong result class" );
+            }
+        }
+
+        FilesetArchetypeCreator instance =
+            (FilesetArchetypeCreator) lookup( ArchetypeCreator.class.getName(), "fileset" );
+
+        languages = new ArrayList<String>();
+        languages.add( "java" );
+        languages.add( "aspectj" );
+        languages.add( "csharp" );
+        languages.add( "groovy" );
+        languages.add( "resources" );
+
+        filtereds = new ArrayList<String>();
+        filtereds.add( "java" );
+        filtereds.add( "xml" );
+        filtereds.add( "txt" );
+        filtereds.add( "groovy" );
+        filtereds.add( "cs" );
+        filtereds.add( "mdo" );
+        filtereds.add( "aj" );
+        filtereds.add( "jsp" );
+        filtereds.add( "js" );
+        filtereds.add( "gsp" );
+        filtereds.add( "vm" );
+        filtereds.add( "html" );
+        filtereds.add( "xhtml" );
+        filtereds.add( "properties" );
+        filtereds.add( ".classpath" );
+        filtereds.add( ".project" );
+        filtereds.add( "MF" );
+
+        ArchetypeCreationRequest request = new ArchetypeCreationRequest()
+            .setProject( mavenProject )
+            .setPackageName( p.getProperty( Constants.PACKAGE ) )
+            .setProperties( p )
+            .setLanguages( languages )
+            .setFiltereds( filtereds )
+            .setDefaultEncoding( "UTF-8" )
+            .setPartialArchetype( false )
+            .setPreserveCData( false )
+            .setKeepParent( false )
+            .setPostPhase( "verify" )
+            .setLocalRepository( localRepository );
+
+        ArchetypeCreationResult result = new ArchetypeCreationResult();
+
+        instance.createArchetype( request, result );
+
+        if ( result.getCause() != null )
+        {
+            throw result.getCause();
+        }
+
+        System.out.println( "<<<<<< testCreateFilesetArchetype( \"" + project + "\" )" );
+    }
+
+    public void testChangeJavaFilenameWhenCustomPropertyEqualsClassName()
+        throws Exception
+    {
+        String project = "change-file-with-property";
+
+        createFilesetArchetype( project );
+
+        File template = getTemplateFile( project, "src/main/java/__someProperty__.java" );
+        assertExists( template );
+		assertContent( template, "class ${someProperty}" );
+    }
+
+    public void testExcludePatternsMustExcludeDirectory()
+        throws Exception
+    {
+        String project = "exclude-patterns";
+
+        createFilesetArchetype( project );
+
+        File template = getTemplateFile( project, ".toexclude/dummy.file");
+        assertNotExists(template);
+
+        File template1 = getTemplateFile( project, "nottoexclude/dummy.file" );
+        assertExists(template1);
+    }
+
+    public void testExcludePatternsContainingFilesSameExtension()
+        throws Exception
+    {
+        String project = "exclude-patterns-2";
+
+        createFilesetArchetype( project );
+
+        assertNotExists( getTemplateFile( project, ".sonar/file.txt" ) );
+        assertNotExists( getTemplateFile( project, "folder/.sonar/file.txt" ) );
+        assertExists( getTemplateFile( project, "folder/file.txt" ) );
+    }
+
+    public void testIncludeFileWithNoExtension()
+                    throws Exception
+    {
+        String project = "include-file-with-no-extension";
+
+        createFilesetArchetype( project );
+
+        File template1 = getTemplateFile( project, "src/main/csharp/filewithnoextension" );
+        assertExists(template1);
+    }
+
+    public void testCreateFilesetArchetype1()
+        throws Exception
+    {
+        String project = "create-1";
+
+        createFilesetArchetype( project );
+
+        File template = getTemplateFile( project, "src/main/java/subfolder1/App.java" );
+        assertExists( template );
+        assertContent( template, "// ${someProperty}" );
+        assertContent( template, "package ${package}.subfolder1;" );
+        assertNotContent( template, "${packageInPathFormat}" );
+    }
+
+    public void testCreateFilesetArchetype2()
+        throws Exception
+    {
+        String project = "create-2";
+
+        createFilesetArchetype( project );
+    }
+
+    public void testCreateFilesetArchetype3()
+        throws Exception
+    {
+        String project = "create-3";
+
+        createFilesetArchetype( project );
+
+        File template = getTemplateFile( project, "pom.xml" );
+        assertExists( template );
+        assertContent( template, "${groupId}" );
+        assertContent( template, "${artifactId}" );
+        assertContent( template, "${version}" );
+        assertContent( template, "Maven archetype Test create-3" );
+        assertContent( template, "<packaging>pom</packaging>" );
+        assertNotContent( template, "<parent>" );
+
+        template = getTemplateFile( project, "src/site/site.xml" );
+        assertExists( template );
+        assertContent( template, "<!-- ${packageInPathFormat}/test" );
+        assertContent( template, "${someProperty} -->" );
+
+        template = getTemplateFile( project, "src/site/resources/site.png" );
+        assertExists( template );
+        assertNotContent( template, "${someProperty}" );
+
+        template = getTemplateFile( project, ".classpath" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+
+        template = getTemplateFile( project, "profiles.xml" );
+        assertExists( template );
+        assertContent( template, "<!-- ${packageInPathFormat}/test" );
+        assertContent( template, "${someProperty} -->" );
+
+        template = getTemplateFile( project, "libs/pom.xml" );
+        assertExists( template );
+        assertContent( template, "${groupId}" );
+        assertContent( template, "${artifactId}" );
+        assertContent( template, "${version}" );
+        assertContent( template, "Maven archetype Test create-3-libraries" );
+        assertContent( template, "<packaging>pom</packaging>" );
+        assertContent( template, "<parent>" );
+
+        template = getTemplateFile( project, "libs/prj-a/pom.xml" );
+        assertExists( template );
+        assertContent( template, "${groupId}" );
+        assertContent( template, "${artifactId}" );
+        assertContent( template, "${version}" );
+        assertContent( template, "Maven archetype Test create-3-libraries-project-a" );
+        assertNotContent( template, "<packaging>pom</packaging>" );
+        assertContent( template, "<parent>" );
+
+        template = getTemplateFile( project, "libs/prj-a/src/main/mdo/descriptor.xml" );
+        assertExists( template );
+        assertContent( template, "<!-- ${packageInPathFormat}/test" );
+        assertContent( template, "${someProperty} -->" );
+
+        template = getTemplateFile( project, "libs/prj-b/pom.xml" );
+        assertExists( template );
+        assertContent( template, "${groupId}" );
+        assertContent( template, "${artifactId}" );
+        assertContent( template, "${version}" );
+        assertContent( template, "Maven archetype Test create-3-libraries-project-b" );
+        assertNotContent( template, "<packaging>pom</packaging>" );
+        assertContent( template, "<parent>" );
+
+        template = getTemplateFile( project, "libs/prj-b/src/main/java/test/com/Component.java" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}" );
+
+        template = getTemplateFile( project, "libs/prj-b/src/main/java/test/com/package.html" );
+        assertExists( template );
+        assertContent( template, "<!-- ${packageInPathFormat}/test" );
+        assertContent( template, "${someProperty} -->" );
+
+        template = getTemplateFile( project, "libs/prj-b/src/test/java/test/common/ComponentTest.java" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}" );
+
+        template = getTemplateFile( project, "application/pom.xml" );
+        assertExists( template );
+        assertContent( template, "${groupId}" );
+        assertContent( template, "${artifactId}" );
+        assertContent( template, "${version}" );
+        assertContent( template, "Maven archetype Test create-3-application" );
+        assertNotContent( template, "<packaging>pom</packaging>" );
+        assertContent( template, "<parent>" );
+
+        template = getTemplateFile( project, "application/src/main/java/Main.java" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertNotContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}/test" );
+
+        template = getTemplateFile( project, "application/src/main/java/test/application/Application.java" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}" );
+
+        template = getTemplateFile( project, "application/src/main/java/test/application/audios/Application.ogg" );
+        assertExists( template );
+        assertNotContent( template, "${someProperty}" );
+
+        template = getTemplateFile( project, "application/src/main/java/test/application/images/Application.png" );
+        assertExists( template );
+        assertNotContent( template, "${someProperty}" );
+
+        template = getTemplateFile( project, "application/src/main/resources/log4j.properties" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertNotContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}/test" );
+
+        template = getTemplateFile( project, "application/src/main/resources/META-INF/MANIFEST.MF" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertNotContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}/test" );
+
+        template = getTemplateFile( project, "application/src/main/resources/test/application/some/Gro.groovy" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertNotContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}/test" );
+
+        template = getTemplateFile( project, "application/src/main/resources/splash.png" );
+        assertExists( template );
+        assertNotContent( template, "${someProperty}" );
+
+        template = getTemplateFile( project, "application/src/test/java/TestAll.java" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertNotContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}/test" );
+
+        template = getTemplateFile( project, "application/src/test/java/test/application/ApplicationTest.java" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertContent( template, "package ${package}.test.application;" );
+        assertContent( template, "${packageInPathFormat}/test/application" );
+
+        template = getTemplateFile( project, "application/src/it-test/java/test/ItTest1.java" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertContent( template, "package ${package}.test;" );
+        assertContent( template, "${packageInPathFormat}/test" );
+
+        template = getTemplateFile( project, "application/src/it-test/java/ItTestAll.java" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertNotContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}/test" );
+
+        template = getTemplateFile( project, "application/src/it-test/resources/ItTest1Result.txt" );
+        assertExists( template );
+        assertContent( template, "${someProperty}" );
+        assertNotContent( template, "${package}" );
+        assertContent( template, "${packageInPathFormat}/test" );
+    }
+
+    public void testCreateFilesetArchetype4()
+            throws Exception
+    {
+        String project = "create-4";
+
+        createFilesetArchetype( project );
+
+        File template = getTemplateFile( project, "pom.xml" );
+        assertExists( template );
+        assertContent( template, "Maven archetype Test create-4 ${someProperty}" );
+        assertContent( template, "<packaging>pom</packaging>" );
+
+        File earTemplate = getTemplateFile( project, "subModuleEAR/pom.xml" );
+        assertExists( earTemplate );
+        assertContent( earTemplate, "${groupId}" );
+        assertContent( earTemplate, "${artifactId}" );
+        assertContent( earTemplate, "${version}" );
+        assertContent( earTemplate, "Maven archetype Test create-4-subModuleEAR" );
+        assertContent( earTemplate, "<packaging>ear</packaging>" );
+        assertContent( earTemplate, "<parent>" );
+
+        File warTemplate = getTemplateFile( project, "subModuleWar/pom.xml" );
+        assertExists( warTemplate );
+        assertContent( warTemplate, "${groupId}" );
+        assertContent( warTemplate, "${artifactId}" );
+        assertContent( warTemplate, "${version}" );
+        assertContent( warTemplate, "Maven archetype Test create-4-subModuleWar ${someProperty}" );
+        assertContent( warTemplate, "<packaging>war</packaging>" );
+        assertContent( warTemplate, "<parent>" );
+    }
+
+    public void testCreateFilesetArchetype5()
+        throws Exception
+    {
+        String project = "create-5";
+
+        createFilesetArchetype( project );
+
+        File template = getTemplateFile( project, "dummy.file" );
+        assertExists( template );
+    }
+    
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+    }
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        localRepository = new DefaultArtifactRepository( "local",
+           new File( getBasedir(), "target/test-classes/repositories/local" ).toURI().toString(),
+           new DefaultRepositoryLayout() );
+    }
+
+    private void assertContent( File template, String content )
+        throws FileNotFoundException, IOException
+    {
+        String templateContent = FileUtils.fileRead( template, "UTF-8" );
+        assertTrue( "File " + template + " does not contain " + content,
+                    StringUtils.countMatches( templateContent, content ) > 0 );
+    }
+
+    private void assertExists( File file )
+    {
+        assertTrue( "File doesn't exist: " + file.getAbsolutePath(), file.exists() );
+    }
+
+    private void assertNotContent( File template, String content )
+        throws FileNotFoundException, IOException
+    {
+        String templateContent = FileUtils.fileRead( template, "UTF-8" );
+        assertFalse( "File " + template + " contains " + content,
+                     StringUtils.countMatches( templateContent, content ) > 0 );
+    }
+
+    private void copy( File in, File out )
+        throws IOException, FileNotFoundException
+    {
+        assertTrue( !out.exists() || out.delete() );
+        assertFalse( out.exists() );
+        FileUtils.copyFile( in, out );
+        assertTrue( out.exists() );
+        assertTrue( in.exists() );
+    }
+
+    private File getDescriptorFile( String project )
+    {
+        return getFile( project, "target/generated-sources/archetype/src/main/resources/META-INF/maven/archetype.xml" );
+    }
+
+    private void assertNotExists( File file )
+    {
+        assertFalse( "File exists: " + file.getAbsolutePath(), file.exists() );
+    }
+
+    private File getFile( String project, String file )
+    {
+        return new File( getBasedir(), "target/test-classes/projects/" + project + "/" + file );
+    }
+
+    private File getProjectFile( String project )
+    {
+        return getFile( project, "pom.xml" );
+    }
+
+    private File getProjectSampleFile( String project )
+    {
+        return getFile( project, "pom.xml.sample" );
+    }
+
+    private File getPropertiesFile( String project )
+    {
+        return getFile( project, "archetype.properties" );
+    }
+
+    private File getPropertiesSampleFile( final String project )
+    {
+        return getFile( project, "archetype.properties.sample" );
+    }
+
+    private File getTemplateFile( String project, String template )
+    {
+        return getFile( project, "target/generated-sources/archetype/src/main/resources/archetype-resources/"
+            + template );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/a02e9922/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
----------------------------------------------------------------------
diff --git a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
deleted file mode 100644
index c011498..0000000
--- a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreatorTest.java
+++ /dev/null
@@ -1,510 +0,0 @@
-package org.apache.maven.archetype.creator;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.archetype.ArchetypeCreationRequest;
-import org.apache.maven.archetype.ArchetypeCreationResult;
-import org.apache.maven.archetype.common.Constants;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.MavenProjectBuildingResult;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.PropertyUtils;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-public class DefaultArchetypeCreatorTest
-    extends AbstractMojoTestCase
-{
-    private List<String> filtereds;
-
-    private List<String> languages;
-
-    private DefaultArtifactRepository localRepository;
-
-    protected void createFilesetArchetype( String project )
-        throws Exception
-    {
-        System.out.println( ">>>>>> testCreateFilesetArchetype( \"" + project + "\" )" );
-        
-        MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
-
-        File projectFile = getProjectFile( project );
-
-        File projectFileSample = getProjectSampleFile( project );
-
-        copy( projectFileSample, projectFile );
-
-        FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
-
-        File propertyFile = getPropertiesFile( project );
-
-        File propertyFileSample = getPropertiesSampleFile( project );
-
-        copy( propertyFileSample, propertyFile );
-
-        Properties p = PropertyUtils.loadProperties( propertyFile );
-
-        MavenProject mavenProject = null;
-
-        {
-            Object result = builder.buildWithDependencies( projectFile, localRepository, null );
-            if ( result instanceof MavenProject )
-            { // Using Maven 2.0.x / x >= 7
-                mavenProject = (MavenProject) result;
-            }
-            else if ( result instanceof MavenProjectBuildingResult )
-            { // Using Maven 3
-                mavenProject = ( (MavenProjectBuildingResult) result ).getProject();
-            }
-            else
-            {
-                fail( "Wrong result class" );
-            }
-        }
-
-        FilesetArchetypeCreator instance =
-            (FilesetArchetypeCreator) lookup( ArchetypeCreator.class.getName(), "fileset" );
-
-        languages = new ArrayList<String>();
-        languages.add( "java" );
-        languages.add( "aspectj" );
-        languages.add( "csharp" );
-        languages.add( "groovy" );
-        languages.add( "resources" );
-
-        filtereds = new ArrayList<String>();
-        filtereds.add( "java" );
-        filtereds.add( "xml" );
-        filtereds.add( "txt" );
-        filtereds.add( "groovy" );
-        filtereds.add( "cs" );
-        filtereds.add( "mdo" );
-        filtereds.add( "aj" );
-        filtereds.add( "jsp" );
-        filtereds.add( "js" );
-        filtereds.add( "gsp" );
-        filtereds.add( "vm" );
-        filtereds.add( "html" );
-        filtereds.add( "xhtml" );
-        filtereds.add( "properties" );
-        filtereds.add( ".classpath" );
-        filtereds.add( ".project" );
-        filtereds.add( "MF" );
-
-        ArchetypeCreationRequest request = new ArchetypeCreationRequest()
-            .setProject( mavenProject )
-            .setPackageName( p.getProperty( Constants.PACKAGE ) )
-            .setProperties( p )
-            .setLanguages( languages )
-            .setFiltereds( filtereds )
-            .setDefaultEncoding( "UTF-8" )
-            .setPartialArchetype( false )
-            .setPreserveCData( false )
-            .setKeepParent( false )
-            .setPostPhase( "verify" );
-
-        ArchetypeCreationResult result = new ArchetypeCreationResult();
-
-        instance.createArchetype( request, result );
-
-        if ( result.getCause() != null )
-        {
-            throw result.getCause();
-        }
-
-        System.out.println( "<<<<<< testCreateFilesetArchetype( \"" + project + "\" )" );
-    }
-
-    public void testChangeJavaFilenameWhenCustomPropertyEqualsClassName()
-        throws Exception
-    {
-        String project = "change-file-with-property";
-
-        createFilesetArchetype( project );
-
-        File template = getTemplateFile( project, "src/main/java/__someProperty__.java" );
-        assertExists( template );
-		assertContent( template, "class ${someProperty}" );
-    }
-
-    public void testExcludePatternsMustExcludeDirectory()
-        throws Exception
-    {
-        String project = "exclude-patterns";
-
-        createFilesetArchetype( project );
-
-        File template = getTemplateFile( project, ".toexclude/dummy.file");
-        assertNotExists(template);
-
-        File template1 = getTemplateFile( project, "nottoexclude/dummy.file" );
-        assertExists(template1);
-    }
-
-    public void testExcludePatternsContainingFilesSameExtension()
-        throws Exception
-    {
-        String project = "exclude-patterns-2";
-
-        createFilesetArchetype( project );
-
-        assertNotExists( getTemplateFile( project, ".sonar/file.txt" ) );
-        assertNotExists( getTemplateFile( project, "folder/.sonar/file.txt" ) );
-        assertExists( getTemplateFile( project, "folder/file.txt" ) );
-    }
-
-    public void testIncludeFileWithNoExtension()
-                    throws Exception
-    {
-        String project = "include-file-with-no-extension";
-
-        createFilesetArchetype( project );
-
-        File template1 = getTemplateFile( project, "src/main/csharp/filewithnoextension" );
-        assertExists(template1);
-    }
-
-    public void testCreateFilesetArchetype1()
-        throws Exception
-    {
-        String project = "create-1";
-
-        createFilesetArchetype( project );
-
-        File template = getTemplateFile( project, "src/main/java/subfolder1/App.java" );
-        assertExists( template );
-        assertContent( template, "// ${someProperty}" );
-        assertContent( template, "package ${package}.subfolder1;" );
-        assertNotContent( template, "${packageInPathFormat}" );
-    }
-
-    public void testCreateFilesetArchetype2()
-        throws Exception
-    {
-        String project = "create-2";
-
-        createFilesetArchetype( project );
-    }
-
-    public void testCreateFilesetArchetype3()
-        throws Exception
-    {
-        String project = "create-3";
-
-        createFilesetArchetype( project );
-
-        File template = getTemplateFile( project, "pom.xml" );
-        assertExists( template );
-        assertContent( template, "${groupId}" );
-        assertContent( template, "${artifactId}" );
-        assertContent( template, "${version}" );
-        assertContent( template, "Maven archetype Test create-3" );
-        assertContent( template, "<packaging>pom</packaging>" );
-        assertNotContent( template, "<parent>" );
-
-        template = getTemplateFile( project, "src/site/site.xml" );
-        assertExists( template );
-        assertContent( template, "<!-- ${packageInPathFormat}/test" );
-        assertContent( template, "${someProperty} -->" );
-
-        template = getTemplateFile( project, "src/site/resources/site.png" );
-        assertExists( template );
-        assertNotContent( template, "${someProperty}" );
-
-        template = getTemplateFile( project, ".classpath" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-
-        template = getTemplateFile( project, "profiles.xml" );
-        assertExists( template );
-        assertContent( template, "<!-- ${packageInPathFormat}/test" );
-        assertContent( template, "${someProperty} -->" );
-
-        template = getTemplateFile( project, "libs/pom.xml" );
-        assertExists( template );
-        assertContent( template, "${groupId}" );
-        assertContent( template, "${artifactId}" );
-        assertContent( template, "${version}" );
-        assertContent( template, "Maven archetype Test create-3-libraries" );
-        assertContent( template, "<packaging>pom</packaging>" );
-        assertContent( template, "<parent>" );
-
-        template = getTemplateFile( project, "libs/prj-a/pom.xml" );
-        assertExists( template );
-        assertContent( template, "${groupId}" );
-        assertContent( template, "${artifactId}" );
-        assertContent( template, "${version}" );
-        assertContent( template, "Maven archetype Test create-3-libraries-project-a" );
-        assertNotContent( template, "<packaging>pom</packaging>" );
-        assertContent( template, "<parent>" );
-
-        template = getTemplateFile( project, "libs/prj-a/src/main/mdo/descriptor.xml" );
-        assertExists( template );
-        assertContent( template, "<!-- ${packageInPathFormat}/test" );
-        assertContent( template, "${someProperty} -->" );
-
-        template = getTemplateFile( project, "libs/prj-b/pom.xml" );
-        assertExists( template );
-        assertContent( template, "${groupId}" );
-        assertContent( template, "${artifactId}" );
-        assertContent( template, "${version}" );
-        assertContent( template, "Maven archetype Test create-3-libraries-project-b" );
-        assertNotContent( template, "<packaging>pom</packaging>" );
-        assertContent( template, "<parent>" );
-
-        template = getTemplateFile( project, "libs/prj-b/src/main/java/test/com/Component.java" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}" );
-
-        template = getTemplateFile( project, "libs/prj-b/src/main/java/test/com/package.html" );
-        assertExists( template );
-        assertContent( template, "<!-- ${packageInPathFormat}/test" );
-        assertContent( template, "${someProperty} -->" );
-
-        template = getTemplateFile( project, "libs/prj-b/src/test/java/test/common/ComponentTest.java" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}" );
-
-        template = getTemplateFile( project, "application/pom.xml" );
-        assertExists( template );
-        assertContent( template, "${groupId}" );
-        assertContent( template, "${artifactId}" );
-        assertContent( template, "${version}" );
-        assertContent( template, "Maven archetype Test create-3-application" );
-        assertNotContent( template, "<packaging>pom</packaging>" );
-        assertContent( template, "<parent>" );
-
-        template = getTemplateFile( project, "application/src/main/java/Main.java" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertNotContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}/test" );
-
-        template = getTemplateFile( project, "application/src/main/java/test/application/Application.java" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}" );
-
-        template = getTemplateFile( project, "application/src/main/java/test/application/audios/Application.ogg" );
-        assertExists( template );
-        assertNotContent( template, "${someProperty}" );
-
-        template = getTemplateFile( project, "application/src/main/java/test/application/images/Application.png" );
-        assertExists( template );
-        assertNotContent( template, "${someProperty}" );
-
-        template = getTemplateFile( project, "application/src/main/resources/log4j.properties" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertNotContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}/test" );
-
-        template = getTemplateFile( project, "application/src/main/resources/META-INF/MANIFEST.MF" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertNotContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}/test" );
-
-        template = getTemplateFile( project, "application/src/main/resources/test/application/some/Gro.groovy" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertNotContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}/test" );
-
-        template = getTemplateFile( project, "application/src/main/resources/splash.png" );
-        assertExists( template );
-        assertNotContent( template, "${someProperty}" );
-
-        template = getTemplateFile( project, "application/src/test/java/TestAll.java" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertNotContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}/test" );
-
-        template = getTemplateFile( project, "application/src/test/java/test/application/ApplicationTest.java" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertContent( template, "package ${package}.test.application;" );
-        assertContent( template, "${packageInPathFormat}/test/application" );
-
-        template = getTemplateFile( project, "application/src/it-test/java/test/ItTest1.java" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertContent( template, "package ${package}.test;" );
-        assertContent( template, "${packageInPathFormat}/test" );
-
-        template = getTemplateFile( project, "application/src/it-test/java/ItTestAll.java" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertNotContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}/test" );
-
-        template = getTemplateFile( project, "application/src/it-test/resources/ItTest1Result.txt" );
-        assertExists( template );
-        assertContent( template, "${someProperty}" );
-        assertNotContent( template, "${package}" );
-        assertContent( template, "${packageInPathFormat}/test" );
-    }
-
-    public void testCreateFilesetArchetype4()
-            throws Exception
-    {
-        String project = "create-4";
-
-        createFilesetArchetype( project );
-
-        File template = getTemplateFile( project, "pom.xml" );
-        assertExists( template );
-        assertContent( template, "Maven archetype Test create-4 ${someProperty}" );
-        assertContent( template, "<packaging>pom</packaging>" );
-
-        File earTemplate = getTemplateFile( project, "subModuleEAR/pom.xml" );
-        assertExists( earTemplate );
-        assertContent( earTemplate, "${groupId}" );
-        assertContent( earTemplate, "${artifactId}" );
-        assertContent( earTemplate, "${version}" );
-        assertContent( earTemplate, "Maven archetype Test create-4-subModuleEAR" );
-        assertContent( earTemplate, "<packaging>ear</packaging>" );
-        assertContent( earTemplate, "<parent>" );
-
-        File warTemplate = getTemplateFile( project, "subModuleWar/pom.xml" );
-        assertExists( warTemplate );
-        assertContent( warTemplate, "${groupId}" );
-        assertContent( warTemplate, "${artifactId}" );
-        assertContent( warTemplate, "${version}" );
-        assertContent( warTemplate, "Maven archetype Test create-4-subModuleWar ${someProperty}" );
-        assertContent( warTemplate, "<packaging>war</packaging>" );
-        assertContent( warTemplate, "<parent>" );
-    }
-
-    public void testCreateFilesetArchetype5()
-        throws Exception
-    {
-        String project = "create-5";
-
-        createFilesetArchetype( project );
-
-        File template = getTemplateFile( project, "dummy.file" );
-        assertExists( template );
-    }
-    
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-    }
-
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        localRepository = new DefaultArtifactRepository( "local",
-           new File( getBasedir(), "target/test-classes/repositories/local" ).toURI().toString(),
-           new DefaultRepositoryLayout() );
-    }
-
-    private void assertContent( File template, String content )
-        throws FileNotFoundException, IOException
-    {
-        String templateContent = FileUtils.fileRead( template, "UTF-8" );
-        assertTrue( "File " + template + " does not contain " + content,
-                    StringUtils.countMatches( templateContent, content ) > 0 );
-    }
-
-    private void assertExists( File file )
-    {
-        assertTrue( "File doesn't exist: " + file.getAbsolutePath(), file.exists() );
-    }
-
-    private void assertNotContent( File template, String content )
-        throws FileNotFoundException, IOException
-    {
-        String templateContent = FileUtils.fileRead( template, "UTF-8" );
-        assertFalse( "File " + template + " contains " + content,
-                     StringUtils.countMatches( templateContent, content ) > 0 );
-    }
-
-    private void copy( File in, File out )
-        throws IOException, FileNotFoundException
-    {
-        assertTrue( !out.exists() || out.delete() );
-        assertFalse( out.exists() );
-        FileUtils.copyFile( in, out );
-        assertTrue( out.exists() );
-        assertTrue( in.exists() );
-    }
-
-    private File getDescriptorFile( String project )
-    {
-        return getFile( project, "target/generated-sources/archetype/src/main/resources/META-INF/maven/archetype.xml" );
-    }
-
-    private void assertNotExists( File file )
-    {
-        assertFalse( "File exists: " + file.getAbsolutePath(), file.exists() );
-    }
-
-    private File getFile( String project, String file )
-    {
-        return new File( getBasedir(), "target/test-classes/projects/" + project + "/" + file );
-    }
-
-    private File getProjectFile( String project )
-    {
-        return getFile( project, "pom.xml" );
-    }
-
-    private File getProjectSampleFile( String project )
-    {
-        return getFile( project, "pom.xml.sample" );
-    }
-
-    private File getPropertiesFile( String project )
-    {
-        return getFile( project, "archetype.properties" );
-    }
-
-    private File getPropertiesSampleFile( final String project )
-    {
-        return getFile( project, "archetype.properties.sample" );
-    }
-
-    private File getTemplateFile( String project, String template )
-    {
-        return getFile( project, "target/generated-sources/archetype/src/main/resources/archetype-resources/"
-            + template );
-    }
-}

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/a02e9922/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripIT.java
----------------------------------------------------------------------
diff --git a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripIT.java b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripIT.java
new file mode 100644
index 0000000..139d78e
--- /dev/null
+++ b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripIT.java
@@ -0,0 +1,245 @@
+package org.apache.maven.archetype.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.archetype.ArchetypeCreationRequest;
+import org.apache.maven.archetype.ArchetypeCreationResult;
+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.apache.maven.model.Model;
+import org.apache.maven.project.DefaultProjectBuilderConfiguration;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.interpolation.ModelInterpolator;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.Properties;
+
+/**
+ * @author Jason van Zyl
+ */
+public class ArchetyperRoundtripIT
+    extends PlexusTestCase
+{
+
+    public void testArchetyper()
+        throws Exception
+    {
+
+        ArchetypeManager archetype = (ArchetypeManager) lookup( ArchetypeManager.ROLE );
+
+        ArchetypeRegistryManager registryManager = (ArchetypeRegistryManager) lookup( ArchetypeRegistryManager.ROLE );
+
+        MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
+
+        ArtifactRepository localRepository = registryManager.createRepository( new File( getBasedir(),
+                                                                                         "target" + File.separator
+                                                                                             + "test-classes"
+                                                                                             + File.separator
+                                                                                             + "repositories"
+                                                                                             + File.separator
+                                                                                             + "local" ).toURI().toURL().toExternalForm(),
+                                                                               "local-repo" );
+
+        ArtifactRepository centralRepository = registryManager.createRepository( new File( getBasedir(),
+                                                                                           "target" + File.separator
+                                                                                               + "test-classes"
+                                                                                               + File.separator
+                                                                                               + "repositories"
+                                                                                               + File.separator
+                                                                                               + "central" ).toURI().toURL().toExternalForm(),
+                                                                                 "central-repo" );
+
+        // (1) create a project from scratch
+        // (2) create an archetype from the project
+        // (3) create our own archetype catalog properties in memory
+        // (4) create our own archetype catalog describing the archetype we just created
+        // (5) deploy the archetype we just created
+        // (6) create a project form the archetype we just created
+        // ------------------------------------------------------------------------
+        //
+        // ------------------------------------------------------------------------
+        // (1) create a project from scratch
+//        File sourceProject = new File( getBasedir(  ), "target/test-classes/projects/roundtrip-1-project" );
+
+        File workingProject = new File( getBasedir(),
+                                        "target" + File.separator + "test-classes" + File.separator + "projects"
+                                            + File.separator + "roundtrip-1-project" );
+        FileUtils.forceDelete( new File( workingProject, "target" ) );
+
+        // (2) create an archetype from the project
+        File pom = new File( workingProject, "pom.xml" );
+
+        MavenProject project = projectBuilder.build( pom, localRepository, null );
+
+        Properties properties = new Properties();
+        properties.setProperty( "someProperty", "someValue" );
+        ArchetypeCreationRequest acr = new ArchetypeCreationRequest().setProject( project ).
+            setLocalRepository( localRepository ).setProperties( properties ).setPostPhase( "package" );
+
+        ArchetypeCreationResult creationResult = archetype.createArchetypeFromProject( acr );
+
+        if ( creationResult.getCause() != null )
+        {
+            throw creationResult.getCause();
+        }
+
+        // (3) create our own archetype catalog properties in memory
+        File catalogDirectory = new File( getBasedir(), "target" + File.separator + "catalog" );
+        catalogDirectory.mkdirs();
+
+        File catalogFile = new File( catalogDirectory, "archetype-catalog.xml" );
+
+        // (5) install the archetype we just created
+        File generatedArchetypeDirectory = new File( project.getBasedir(),
+                                                     "target" + File.separator + "generated-sources" + File.separator
+                                                         + "archetype" );
+        File generatedArchetypePom = new File( generatedArchetypeDirectory, "pom.xml" );
+        MavenProject generatedArchetypeProject = projectBuilder.build( generatedArchetypePom, localRepository, null );
+        ModelInterpolator modelInterpolator = (ModelInterpolator)lookup( ModelInterpolator.ROLE );
+        Model generatedArchetypeModel = modelInterpolator.interpolate( generatedArchetypeProject.getModel(), generatedArchetypePom.getParentFile(), new DefaultProjectBuilderConfiguration(), true );
+
+        File archetypeDirectory =
+            new File( generatedArchetypeDirectory, "src" + File.separator + "main" + File.separator + "resources" );
+
+        File archetypeArchive = archetype.archiveArchetype( archetypeDirectory, new File(
+            generatedArchetypeModel.getBuild().getDirectory() ),
+                                                            generatedArchetypeModel.getBuild().getFinalName() );
+
+        String baseName =
+            StringUtils.replace( generatedArchetypeProject.getGroupId(), ".", File.separator ) + File.separator
+                + generatedArchetypeProject.getArtifactId() + File.separator + generatedArchetypeProject.getVersion()
+                + File.separator + generatedArchetypeProject.getBuild().getFinalName();
+        File archetypeInRepository = new File( centralRepository.getBasedir(), baseName + ".jar" );
+        File archetypePomInRepository = new File( centralRepository.getBasedir(), baseName + ".pom" );
+        archetypeInRepository.getParentFile().mkdirs();
+        FileUtils.copyFile( archetypeArchive, archetypeInRepository );
+        FileUtils.copyFile( generatedArchetypePom, archetypePomInRepository );
+
+        // (4) create our own archetype catalog describing the archetype we just created
+        ArchetypeCatalog catalog = new ArchetypeCatalog();
+        Archetype generatedArchetype = new Archetype();
+        generatedArchetype.setGroupId( generatedArchetypeProject.getGroupId() );
+        generatedArchetype.setArtifactId( generatedArchetypeProject.getArtifactId() );
+        generatedArchetype.setVersion( generatedArchetypeProject.getVersion() );
+        generatedArchetype.setRepository( "http://localhost:" + port + "/repo" );
+        catalog.addArchetype( generatedArchetype );
+
+        ArchetypeCatalogXpp3Writer catalogWriter = new ArchetypeCatalogXpp3Writer();
+        Writer writer = new FileWriter( catalogFile );
+        catalogWriter.write( writer, catalog );
+        IOUtils.closeQuietly( writer );
+
+        // (6) create a project form the archetype we just created
+        String outputDirectory = new File( getBasedir(),
+                                           "target" + File.separator + "test-classes" + File.separator + "projects"
+                                               + File.separator + "roundtrip-1-recreatedproject" ).getAbsolutePath();
+        FileUtils.forceDelete( outputDirectory );
+
+        ArchetypeGenerationRequest agr =
+            new ArchetypeGenerationRequest().setArchetypeGroupId( generatedArchetypeProject.getGroupId() ).
+                setArchetypeArtifactId( generatedArchetypeProject.getArtifactId() ).
+                setArchetypeVersion( generatedArchetypeProject.getVersion() ).
+                setGroupId( "com.mycompany" ).setArtifactId( "myapp" ).setVersion( "1.0-SNAPSHOT" ).
+                setPackage( "com.mycompany.myapp" ).setProperties( properties ).
+                setOutputDirectory( outputDirectory ).setLocalRepository( localRepository ).
+                setArchetypeRepository( "http://localhost:" + port + "/repo/" );
+        ArchetypeGenerationResult generationResult = archetype.generateProjectFromArchetype( agr );
+
+        if ( generationResult.getCause() != null )
+        {
+            throw generationResult.getCause();
+        }
+
+        //ASSERT symbol_pound replacement (archetype-180 archetype-183)
+        String content = FileUtils.fileRead(
+            outputDirectory + File.separator + "myapp" + File.separator + "src" + File.separator + "main"
+                + File.separator + "java" + File.separator + "com" + File.separator + "mycompany" + File.separator
+                + "myapp" + File.separator + "App.java" );
+        System.err.println( "content=" + content );
+        assertTrue( content.indexOf( "//A   #\\{some}" ) > 0 );
+        assertTrue( content.indexOf( "//B   #{some}" ) > 0 );
+        assertTrue( content.indexOf( "//C   #{some other}" ) > 0 );
+        assertTrue( content.indexOf( "//D   \\#{some other}" ) > 0 );
+        assertTrue( content.indexOf( "//E   #{}" ) > 0 );
+        assertTrue( content.indexOf( "//F   {some}" ) > 0 );
+        assertTrue( content.indexOf( "//G   ${someOtherProperty}" ) > 0 );
+        assertTrue( content.indexOf( "//H   ${someValue}" ) > 0 );
+        assertTrue( content.indexOf( "/*" ) > 0 );
+        assertTrue( content.indexOf( "  A   #\\{some}" ) > 0 );
+        assertTrue( content.indexOf( "  B   #{some}" ) > 0 );
+        assertTrue( content.indexOf( "  C   #{some other}" ) > 0 );
+        assertTrue( content.indexOf( "  D   \\#{some other}" ) > 0 );
+        assertTrue( content.indexOf( "  E   #{}" ) > 0 );
+        assertTrue( content.indexOf( "  F   {some}" ) > 0 );
+        assertTrue( content.indexOf( "  G   ${someOtherProperty}" ) > 0 );
+        assertTrue( content.indexOf( "  H   ${someValue}" ) > 0 );
+        //Assert symbol_dollar archetype-138
+    }
+
+    private Server server;
+
+    int port;
+
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        // Start Jetty
+
+        System.setProperty( "org.apache.maven.archetype.repository.directory",
+                            getTestPath( "target/test-classes/repositories/central" ) );
+
+        server = new Server( 0 );
+
+        WebAppContext webapp = new WebAppContext();
+        webapp.setContextPath( "/repo" );
+        webapp.setWar( "target/wars/archetype-repository.war" );
+        server.setHandler( webapp );
+
+        server.start();
+
+        port = server.getConnectors()[0].getLocalPort();
+
+    }
+
+    public void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        // Stop Jetty
+
+        server.stop();
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/a02e9922/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java
----------------------------------------------------------------------
diff --git a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java
deleted file mode 100644
index f6f9c55..0000000
--- a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripTest.java
+++ /dev/null
@@ -1,245 +0,0 @@
-package org.apache.maven.archetype.test;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.io.IOUtils;
-import org.apache.maven.archetype.ArchetypeCreationRequest;
-import org.apache.maven.archetype.ArchetypeCreationResult;
-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.apache.maven.model.Model;
-import org.apache.maven.project.DefaultProjectBuilderConfiguration;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.interpolation.ModelInterpolator;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.StringUtils;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.webapp.WebAppContext;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.Properties;
-
-/**
- * @author Jason van Zyl
- */
-public class ArchetyperRoundtripTest
-    extends PlexusTestCase
-{
-
-    public void testArchetyper()
-        throws Exception
-    {
-
-        ArchetypeManager archetype = (ArchetypeManager) lookup( ArchetypeManager.ROLE );
-
-        ArchetypeRegistryManager registryManager = (ArchetypeRegistryManager) lookup( ArchetypeRegistryManager.ROLE );
-
-        MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
-
-        ArtifactRepository localRepository = registryManager.createRepository( new File( getBasedir(),
-                                                                                         "target" + File.separator
-                                                                                             + "test-classes"
-                                                                                             + File.separator
-                                                                                             + "repositories"
-                                                                                             + File.separator
-                                                                                             + "local" ).toURI().toURL().toExternalForm(),
-                                                                               "local-repo" );
-
-        ArtifactRepository centralRepository = registryManager.createRepository( new File( getBasedir(),
-                                                                                           "target" + File.separator
-                                                                                               + "test-classes"
-                                                                                               + File.separator
-                                                                                               + "repositories"
-                                                                                               + File.separator
-                                                                                               + "central" ).toURI().toURL().toExternalForm(),
-                                                                                 "central-repo" );
-
-        // (1) create a project from scratch
-        // (2) create an archetype from the project
-        // (3) create our own archetype catalog properties in memory
-        // (4) create our own archetype catalog describing the archetype we just created
-        // (5) deploy the archetype we just created
-        // (6) create a project form the archetype we just created
-        // ------------------------------------------------------------------------
-        //
-        // ------------------------------------------------------------------------
-        // (1) create a project from scratch
-//        File sourceProject = new File( getBasedir(  ), "target/test-classes/projects/roundtrip-1-project" );
-
-        File workingProject = new File( getBasedir(),
-                                        "target" + File.separator + "test-classes" + File.separator + "projects"
-                                            + File.separator + "roundtrip-1-project" );
-        FileUtils.forceDelete( new File( workingProject, "target" ) );
-
-        // (2) create an archetype from the project
-        File pom = new File( workingProject, "pom.xml" );
-
-        MavenProject project = projectBuilder.build( pom, localRepository, null );
-
-        Properties properties = new Properties();
-        properties.setProperty( "someProperty", "someValue" );
-        ArchetypeCreationRequest acr = new ArchetypeCreationRequest().setProject( project ).
-            setLocalRepository( localRepository ).setProperties( properties ).setPostPhase( "package" );
-
-        ArchetypeCreationResult creationResult = archetype.createArchetypeFromProject( acr );
-
-        if ( creationResult.getCause() != null )
-        {
-            throw creationResult.getCause();
-        }
-
-        // (3) create our own archetype catalog properties in memory
-        File catalogDirectory = new File( getBasedir(), "target" + File.separator + "catalog" );
-        catalogDirectory.mkdirs();
-
-        File catalogFile = new File( catalogDirectory, "archetype-catalog.xml" );
-
-        // (5) install the archetype we just created
-        File generatedArchetypeDirectory = new File( project.getBasedir(),
-                                                     "target" + File.separator + "generated-sources" + File.separator
-                                                         + "archetype" );
-        File generatedArchetypePom = new File( generatedArchetypeDirectory, "pom.xml" );
-        MavenProject generatedArchetypeProject = projectBuilder.build( generatedArchetypePom, localRepository, null );
-        ModelInterpolator modelInterpolator = (ModelInterpolator)lookup( ModelInterpolator.ROLE );
-        Model generatedArchetypeModel = modelInterpolator.interpolate( generatedArchetypeProject.getModel(), generatedArchetypePom.getParentFile(), new DefaultProjectBuilderConfiguration(), true );
-
-        File archetypeDirectory =
-            new File( generatedArchetypeDirectory, "src" + File.separator + "main" + File.separator + "resources" );
-
-        File archetypeArchive = archetype.archiveArchetype( archetypeDirectory, new File(
-            generatedArchetypeModel.getBuild().getDirectory() ),
-                                                            generatedArchetypeModel.getBuild().getFinalName() );
-
-        String baseName =
-            StringUtils.replace( generatedArchetypeProject.getGroupId(), ".", File.separator ) + File.separator
-                + generatedArchetypeProject.getArtifactId() + File.separator + generatedArchetypeProject.getVersion()
-                + File.separator + generatedArchetypeProject.getBuild().getFinalName();
-        File archetypeInRepository = new File( centralRepository.getBasedir(), baseName + ".jar" );
-        File archetypePomInRepository = new File( centralRepository.getBasedir(), baseName + ".pom" );
-        archetypeInRepository.getParentFile().mkdirs();
-        FileUtils.copyFile( archetypeArchive, archetypeInRepository );
-        FileUtils.copyFile( generatedArchetypePom, archetypePomInRepository );
-
-        // (4) create our own archetype catalog describing the archetype we just created
-        ArchetypeCatalog catalog = new ArchetypeCatalog();
-        Archetype generatedArchetype = new Archetype();
-        generatedArchetype.setGroupId( generatedArchetypeProject.getGroupId() );
-        generatedArchetype.setArtifactId( generatedArchetypeProject.getArtifactId() );
-        generatedArchetype.setVersion( generatedArchetypeProject.getVersion() );
-        generatedArchetype.setRepository( "http://localhost:" + port + "/repo" );
-        catalog.addArchetype( generatedArchetype );
-
-        ArchetypeCatalogXpp3Writer catalogWriter = new ArchetypeCatalogXpp3Writer();
-        Writer writer = new FileWriter( catalogFile );
-        catalogWriter.write( writer, catalog );
-        IOUtils.closeQuietly( writer );
-
-        // (6) create a project form the archetype we just created
-        String outputDirectory = new File( getBasedir(),
-                                           "target" + File.separator + "test-classes" + File.separator + "projects"
-                                               + File.separator + "roundtrip-1-recreatedproject" ).getAbsolutePath();
-        FileUtils.forceDelete( outputDirectory );
-
-        ArchetypeGenerationRequest agr =
-            new ArchetypeGenerationRequest().setArchetypeGroupId( generatedArchetypeProject.getGroupId() ).
-                setArchetypeArtifactId( generatedArchetypeProject.getArtifactId() ).
-                setArchetypeVersion( generatedArchetypeProject.getVersion() ).
-                setGroupId( "com.mycompany" ).setArtifactId( "myapp" ).setVersion( "1.0-SNAPSHOT" ).
-                setPackage( "com.mycompany.myapp" ).setProperties( properties ).
-                setOutputDirectory( outputDirectory ).setLocalRepository( localRepository ).
-                setArchetypeRepository( "http://localhost:" + port + "/repo/" );
-        ArchetypeGenerationResult generationResult = archetype.generateProjectFromArchetype( agr );
-
-        if ( generationResult.getCause() != null )
-        {
-            throw generationResult.getCause();
-        }
-
-        //ASSERT symbol_pound replacement (archetype-180 archetype-183)
-        String content = FileUtils.fileRead(
-            outputDirectory + File.separator + "myapp" + File.separator + "src" + File.separator + "main"
-                + File.separator + "java" + File.separator + "com" + File.separator + "mycompany" + File.separator
-                + "myapp" + File.separator + "App.java" );
-        System.err.println( "content=" + content );
-        assertTrue( content.indexOf( "//A   #\\{some}" ) > 0 );
-        assertTrue( content.indexOf( "//B   #{some}" ) > 0 );
-        assertTrue( content.indexOf( "//C   #{some other}" ) > 0 );
-        assertTrue( content.indexOf( "//D   \\#{some other}" ) > 0 );
-        assertTrue( content.indexOf( "//E   #{}" ) > 0 );
-        assertTrue( content.indexOf( "//F   {some}" ) > 0 );
-        assertTrue( content.indexOf( "//G   ${someOtherProperty}" ) > 0 );
-        assertTrue( content.indexOf( "//H   ${someValue}" ) > 0 );
-        assertTrue( content.indexOf( "/*" ) > 0 );
-        assertTrue( content.indexOf( "  A   #\\{some}" ) > 0 );
-        assertTrue( content.indexOf( "  B   #{some}" ) > 0 );
-        assertTrue( content.indexOf( "  C   #{some other}" ) > 0 );
-        assertTrue( content.indexOf( "  D   \\#{some other}" ) > 0 );
-        assertTrue( content.indexOf( "  E   #{}" ) > 0 );
-        assertTrue( content.indexOf( "  F   {some}" ) > 0 );
-        assertTrue( content.indexOf( "  G   ${someOtherProperty}" ) > 0 );
-        assertTrue( content.indexOf( "  H   ${someValue}" ) > 0 );
-        //Assert symbol_dollar archetype-138
-    }
-
-    private Server server;
-
-    int port;
-
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-        // Start Jetty
-
-        System.setProperty( "org.apache.maven.archetype.repository.directory",
-                            getTestPath( "target/test-classes/repositories/central" ) );
-
-        server = new Server( 0 );
-
-        WebAppContext webapp = new WebAppContext();
-        webapp.setContextPath( "/repo" );
-        webapp.setWar( "target/wars/archetype-repository.war" );
-        server.setHandler( webapp );
-
-        server.start();
-
-        port = server.getConnectors()[0].getLocalPort();
-
-    }
-
-    public void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-        // Stop Jetty
-
-        server.stop();
-    }
-}

http://git-wip-us.apache.org/repos/asf/maven-archetype/blob/a02e9922/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyIT.java
----------------------------------------------------------------------
diff --git a/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyIT.java b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyIT.java
new file mode 100644
index 0000000..6386214
--- /dev/null
+++ b/archetype-testing/archetype-final/src/test/java/org/apache/maven/archetype/test/ArchetyperRoundtripWithProxyIT.java
@@ -0,0 +1,246 @@
+package org.apache.maven.archetype.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.archetype.ArchetypeCreationRequest;
+import org.apache.maven.archetype.ArchetypeCreationResult;
+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.manager.WagonManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.DefaultProjectBuilderConfiguration;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.interpolation.ModelInterpolator;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.util.Properties;
+
+/**
+ * @author Jason van Zyl
+ */
+public class ArchetyperRoundtripWithProxyIT
+    extends PlexusTestCase
+{
+    Server proxyServer;
+
+    int proxyPort;
+
+    Server server;
+
+    int port;
+
+    public void testArchetyper()
+        throws Exception
+    {
+        ArchetypeManager archetype = (ArchetypeManager) lookup( ArchetypeManager.ROLE );
+
+        ArchetypeRegistryManager registryManager = (ArchetypeRegistryManager) lookup( ArchetypeRegistryManager.ROLE );
+
+        MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
+
+        ArtifactRepository localRepository = registryManager.createRepository( new File( getBasedir(),
+                                                                                         "target" + File.separator
+                                                                                             + "test-classes"
+                                                                                             + File.separator
+                                                                                             + "repositories"
+                                                                                             + File.separator
+                                                                                             + "local" ).toURI().toURL().toExternalForm(),
+                                                                               "local-repo" );
+        ArtifactRepository centralRepository = registryManager.createRepository( new File( getBasedir(),
+                                                                                           "target" + File.separator
+                                                                                               + "test-classes"
+                                                                                               + File.separator
+                                                                                               + "repositories"
+                                                                                               + File.separator
+                                                                                               + "central" ).toURI().toURL().toExternalForm(),
+                                                                                 "central-repo" );
+
+        // (1) create a project from scratch
+        // (2) create an archetype from the project
+        // (3) create our own archetype catalog properties in memory
+        // (4) create our own archetype catalog describing the archetype we just created
+        // (5) deploy the archetype we just created
+        // (6) create a project form the archetype we just created
+        // ------------------------------------------------------------------------
+        //
+        // ------------------------------------------------------------------------
+        // (1) create a project from scratch
+//        File sourceProject = new File( getBasedir(  ), "target/test-classes/projects/roundtrip-1-project" );
+
+        File workingProject = new File( getBasedir(),
+                                        "target" + File.separator + "test-classes" + File.separator + "projects"
+                                            + File.separator + "roundtrip-2-project" );
+        FileUtils.forceDelete( new File( workingProject, "target" ) );
+
+        // (2) create an archetype from the project
+        File pom = new File( workingProject, "pom.xml" );
+
+        MavenProject project = projectBuilder.build( pom, localRepository, null );
+
+        ArchetypeCreationRequest acr = new ArchetypeCreationRequest().setProject( project ).
+            setLocalRepository( localRepository ).setPostPhase( "package" );
+
+        ArchetypeCreationResult creationResult = archetype.createArchetypeFromProject( acr );
+
+        if ( creationResult.getCause() != null )
+        {
+            throw creationResult.getCause();
+        }
+
+        // (3) create our own archetype catalog properties in memory
+        File catalogDirectory = new File( getBasedir(), "target" + File.separator + "catalog" );
+
+        File catalogFile = new File( catalogDirectory, "archetype-catalog.xml" );
+
+        File catalogProperties = new File( catalogDirectory, "archetype-catalog.properties" );
+
+        catalogDirectory.mkdirs();
+
+        Properties p = new Properties();
+        p.setProperty( "sources", "catalog" );
+        p.setProperty( "catalog.file", catalogFile.getAbsolutePath() );
+        OutputStream os = new FileOutputStream( catalogProperties );
+        p.store( os, "Generated catalog properties" );
+
+        // (5) install the archetype we just created
+        File generatedArchetypeDirectory = new File( project.getBasedir(),
+                                                     "target" + File.separator + "generated-sources" + File.separator
+                                                         + "archetype" );
+        File generatedArchetypePom = new File( generatedArchetypeDirectory, "pom.xml" );
+        MavenProject generatedArchetypeProject = projectBuilder.build( generatedArchetypePom, localRepository, null );
+        ModelInterpolator modelInterpolator = (ModelInterpolator)lookup( ModelInterpolator.ROLE );
+        Model generatedArchetypeModel = modelInterpolator.interpolate( generatedArchetypeProject.getModel(), generatedArchetypePom.getParentFile(), new DefaultProjectBuilderConfiguration(), true );
+
+        File archetypeDirectory =
+            new File( generatedArchetypeDirectory, "src" + File.separator + "main" + File.separator + "resources" );
+
+        File archetypeArchive = archetype.archiveArchetype( archetypeDirectory, new File(
+            generatedArchetypeModel.getBuild().getDirectory() ),
+                                                            generatedArchetypeModel.getBuild().getFinalName() );
+
+        String baseName =
+            StringUtils.replace( generatedArchetypeProject.getGroupId(), ".", File.separator ) + File.separator
+                + generatedArchetypeProject.getArtifactId() + File.separator + generatedArchetypeProject.getVersion()
+                + File.separator + generatedArchetypeModel.getBuild().getFinalName();
+        File archetypeInRepository = new File( centralRepository.getBasedir(), baseName + ".jar" );
+        File archetypePomInRepository = new File( centralRepository.getBasedir(), baseName + ".pom" );
+        archetypeInRepository.getParentFile().mkdirs();
+        FileUtils.copyFile( archetypeArchive, archetypeInRepository );
+        FileUtils.copyFile( generatedArchetypePom, archetypePomInRepository );
+
+        // (4) create our own archetype catalog describing the archetype we just created
+        ArchetypeCatalog catalog = new ArchetypeCatalog();
+        Archetype generatedArchetype = new Archetype();
+        generatedArchetype.setGroupId( generatedArchetypeProject.getGroupId() );
+        generatedArchetype.setArtifactId( generatedArchetypeProject.getArtifactId() );
+        generatedArchetype.setVersion( generatedArchetypeProject.getVersion() );
+        generatedArchetype.setRepository( "http://localhost:" + port + "/repo" );
+        catalog.addArchetype( generatedArchetype );
+
+        ArchetypeCatalogXpp3Writer catalogWriter = new ArchetypeCatalogXpp3Writer();
+        Writer writer = new FileWriter( catalogFile );
+        catalogWriter.write( writer, catalog );
+        IOUtils.closeQuietly( writer );
+
+        // (6) create a project form the archetype we just created
+        String outputDirectory = new File( getBasedir(),
+                                           "target" + File.separator + "test-classes" + File.separator + "projects"
+                                               + File.separator + "roundtrip-2-recreatedproject" ).getAbsolutePath();
+        FileUtils.forceDelete( outputDirectory );
+
+        WagonManager manager = (WagonManager) lookup( WagonManager.class.getName() );
+        manager.addProxy( "http", "localhost", proxyPort, null, null, null );
+
+        ArchetypeGenerationRequest agr =
+            new ArchetypeGenerationRequest().setArchetypeGroupId( generatedArchetypeProject.getGroupId() ).
+                setArchetypeArtifactId( generatedArchetypeProject.getArtifactId() ).
+                setArchetypeVersion( generatedArchetypeProject.getVersion() ).
+                setGroupId( "com.mycompany" ).setArtifactId( "myapp" ).setVersion( "1.0-SNAPSHOT" ).
+                setPackage( "com.mycompany.myapp" ).setOutputDirectory( outputDirectory ).
+                setLocalRepository( localRepository ).setArchetypeRepository( "http://localhost:" + port + "/repo" );
+        ArchetypeGenerationResult generationResult = archetype.generateProjectFromArchetype( agr );
+
+        if ( generationResult.getCause() != null )
+        {
+            throw generationResult.getCause();
+        }
+
+    }
+
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        // Start Proxy Jetty
+
+        System.setProperty( "org.apache.maven.archetype.repository.directory",
+                            getTestPath( "target/test-classes/repositories/central" ) );
+
+        proxyServer = new Server( 0 );
+
+        WebAppContext webappProxy = new WebAppContext();
+        webappProxy.setContextPath( "/" );
+        webappProxy.setWar( "target/wars/archetype-proxy.war" );
+        proxyServer.setHandler( webappProxy );
+
+        proxyServer.start();
+
+        proxyPort = proxyServer.getConnectors()[0].getLocalPort();
+
+        server = new Server( 0 );
+
+        WebAppContext webapp = new WebAppContext();
+        webapp.setContextPath( "/repo" );
+        webapp.setWar( "target/wars/archetype-repository.war" );
+        server.setHandler( webapp );
+
+        server.start();
+
+        port = server.getConnectors()[0].getLocalPort();
+
+    }
+
+    public void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        // Stop Jettys
+
+        proxyServer.stop();
+        server.stop();
+    }
+}


Mime
View raw message