You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ra...@apache.org on 2007/09/25 23:34:49 UTC
svn commit: r579392 [1/2] - in /maven/sandbox/trunk/archetypeng:
archetype-common/src/main/java/org/apache/maven/archetype/creator/
archetype-common/src/main/java/org/apache/maven/archetype/generator/
archetype-common/src/test/java/org/apache/maven/arc...
Author: rafale
Date: Tue Sep 25 14:34:46 2007
New Revision: 579392
URL: http://svn.apache.org/viewvc?rev=579392&view=rev
Log:
Move configurators queryers, selector to the plugin module before moving their behaviour in the mojos instead
Added:
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeCreationConfigurator.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreationConfigurator.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeCreationQueryer.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreationQueryer.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeGenerationConfigurator.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerationConfigurator.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeGenerationQueryer.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerationQueryer.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeSelectionQueryer.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeSelectionQueryer.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/ArchetypeSelector.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeSelector.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeCreationConfigurator.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationConfigurator.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeCreationQueryer.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationQueryer.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationConfigurator.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationConfigurator.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeGenerationQueryer.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationQueryer.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelectionQueryer.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeSelectionQueryer.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/ui/DefaultArchetypeSelector.java
- copied, changed from r579346, maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeSelector.java
Removed:
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreationConfigurator.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/creator/ArchetypeCreationQueryer.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationConfigurator.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationQueryer.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerationConfigurator.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeGenerationQueryer.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeSelectionQueryer.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/ArchetypeSelector.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationConfigurator.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationQueryer.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeSelectionQueryer.java
maven/sandbox/trunk/archetypeng/archetype-common/src/main/java/org/apache/maven/archetype/generator/DefaultArchetypeSelector.java
Modified:
maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationConfiguratorTest.java
maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationConfiguratorTest.java
maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeSelectorTest.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateArchetypeFromProjectMojo.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/main/java/org/apache/maven/archetype/mojos/CreateProjectFromArchetypeMojo.java
maven/sandbox/trunk/archetypeng/archetype-plugin/src/test/projects/deep-inheritence/ (props changed)
maven/sandbox/trunk/archetypeng/archetype-plugin/src/test/projects/sibling-dependency/ (props changed)
maven/sandbox/trunk/archetypeng/archetype-plugin/src/test/projects/sibling-dependency/a/ (props changed)
maven/sandbox/trunk/archetypeng/archetype-plugin/src/test/projects/sibling-dependency/b/ (props changed)
Modified: maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationConfiguratorTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationConfiguratorTest.java?rev=579392&r1=579391&r2=579392&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationConfiguratorTest.java (original)
+++ maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/creator/DefaultArchetypeCreationConfiguratorTest.java Tue Sep 25 14:34:46 2007
@@ -19,7 +19,8 @@
package org.apache.maven.archetype.creator;
-import org.apache.maven.archetype.common.Constants;
+//import org.apache.maven.archetype.ui.DefaultArchetypeCreationConfigurator;
+//import org.apache.maven.archetype.ui.ArchetypeCreationConfigurator;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
@@ -30,7 +31,6 @@
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuildingException;
-import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import java.io.File;
@@ -40,7 +40,6 @@
import java.io.FileWriter;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
@@ -52,6 +51,12 @@
private DefaultArtifactRepository localRepository;
private List repositories;
+
+ public void testNothing()
+ {
+ //TODO: All the tests were commented out Because the tested classes are beeing moved for now and will be removed soon
+ }
+
// Commented out since no exception are thrown if using defaults to all values
// public void testBatchModeArchetypeNotConfigured ()
// throws Exception
@@ -152,114 +157,115 @@
// );
// }
// }
-
- public void testBatchModeDefinedAndConfigured()
- throws
- Exception
- {
- System.out.println( "testBatchModePackageDefault" );
-
- String project = "configure-creation-6";
- File projectFile = getProjectFile( project );
- File projectFileSample = getProjectSampleFile( project );
- copy( projectFileSample, projectFile );
- FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
-
- MavenProject mavenProject = loadProject( projectFile );
-
- DefaultArchetypeCreationConfigurator instance =
- (DefaultArchetypeCreationConfigurator) lookup( ArchetypeCreationConfigurator.ROLE );
- instanceDefined( instance );
-
- Properties commandLineProperties = new Properties();
-
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- languages = new ArrayList();
- languages.add( "java" );
- languages.add( "aspectj" );
- languages.add( "csharp" );
- languages.add( "groovy" );
- instance.configureArchetypeCreation(
- mavenProject,
- Boolean.FALSE,
- commandLineProperties,
- propertyFile,
- languages
- );
-
- Properties properties = loadProperties( propertyFile );
-
- assertEquals(
- "org.apache.maven.archetype",
- properties.getProperty( Constants.ARCHETYPE_GROUP_ID )
- );
- assertEquals(
- "maven-archetype-test",
- properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID )
- );
- assertEquals( "1.0", properties.getProperty( Constants.ARCHETYPE_VERSION ) );
- assertEquals( "some.group.id", properties.getProperty( Constants.GROUP_ID ) );
- assertEquals( "some-artifact-id", properties.getProperty( Constants.ARTIFACT_ID ) );
- assertEquals( "1.0", properties.getProperty( Constants.VERSION ) );
- assertEquals( "org.codehaus.mojo", properties.getProperty( Constants.PACKAGE ) );
- }
-
- public void testBatchModePackageDefault()
- throws
- Exception
- {
- System.out.println( "testBatchModePackageDefault" );
-
- String project = "configure-creation-5";
- File projectFile = getProjectFile( project );
- File projectFileSample = getProjectSampleFile( project );
- copy( projectFileSample, projectFile );
- FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
-
- MavenProject mavenProject = loadProject( projectFile );
-
- DefaultArchetypeCreationConfigurator instance =
- (DefaultArchetypeCreationConfigurator) lookup( ArchetypeCreationConfigurator.ROLE );
- instanceDefined( instance );
-
- Properties commandLineProperties = new Properties();
-
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- languages = new ArrayList();
- languages.add( "java" );
- languages.add( "aspectj" );
- languages.add( "csharp" );
- languages.add( "groovy" );
- instance.configureArchetypeCreation(
- mavenProject,
- Boolean.FALSE,
- commandLineProperties,
- propertyFile,
- languages
- );
-
- Properties properties = loadProperties( propertyFile );
-
- assertEquals(
- "org.apache.maven.archetype",
- properties.getProperty( Constants.ARCHETYPE_GROUP_ID )
- );
- assertEquals(
- "maven-archetype-test",
- properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID )
- );
- assertEquals( "1.0", properties.getProperty( Constants.ARCHETYPE_VERSION ) );
- assertEquals( "some.group.id", properties.getProperty( Constants.GROUP_ID ) );
- assertEquals( "some-artifact-id", properties.getProperty( Constants.ARTIFACT_ID ) );
- assertEquals( "1.0", properties.getProperty( Constants.VERSION ) );
- assertEquals( "org.apache.maven.archetype", properties.getProperty( Constants.PACKAGE ) );
- }
+// /*Commented on 2007 09 25
+// public void testBatchModeDefinedAndConfigured()
+// throws
+// Exception
+// {
+// System.out.println( "testBatchModePackageDefault" );
+//
+// String project = "configure-creation-6";
+// File projectFile = getProjectFile( project );
+// File projectFileSample = getProjectSampleFile( project );
+// copy( projectFileSample, projectFile );
+// FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
+//
+// MavenProject mavenProject = loadProject( projectFile );
+//
+// DefaultArchetypeCreationConfigurator instance =
+// (DefaultArchetypeCreationConfigurator) lookup( ArchetypeCreationConfigurator.ROLE );
+// instanceDefined( instance );
+//
+// Properties commandLineProperties = new Properties();
+//
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// languages = new ArrayList();
+// languages.add( "java" );
+// languages.add( "aspectj" );
+// languages.add( "csharp" );
+// languages.add( "groovy" );
+// instance.configureArchetypeCreation(
+// mavenProject,
+// Boolean.FALSE,
+// commandLineProperties,
+// propertyFile,
+// languages
+// );
+//
+// Properties properties = loadProperties( propertyFile );
+//
+// assertEquals(
+// "org.apache.maven.archetype",
+// properties.getProperty( Constants.ARCHETYPE_GROUP_ID )
+// );
+// assertEquals(
+// "maven-archetype-test",
+// properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID )
+// );
+// assertEquals( "1.0", properties.getProperty( Constants.ARCHETYPE_VERSION ) );
+// assertEquals( "some.group.id", properties.getProperty( Constants.GROUP_ID ) );
+// assertEquals( "some-artifact-id", properties.getProperty( Constants.ARTIFACT_ID ) );
+// assertEquals( "1.0", properties.getProperty( Constants.VERSION ) );
+// assertEquals( "org.codehaus.mojo", properties.getProperty( Constants.PACKAGE ) );
+// }
+//
+// public void testBatchModePackageDefault()
+// throws
+// Exception
+// {
+// System.out.println( "testBatchModePackageDefault" );
+//
+// String project = "configure-creation-5";
+// File projectFile = getProjectFile( project );
+// File projectFileSample = getProjectSampleFile( project );
+// copy( projectFileSample, projectFile );
+// FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
+//
+// MavenProject mavenProject = loadProject( projectFile );
+//
+// DefaultArchetypeCreationConfigurator instance =
+// (DefaultArchetypeCreationConfigurator) lookup( ArchetypeCreationConfigurator.ROLE );
+// instanceDefined( instance );
+//
+// Properties commandLineProperties = new Properties();
+//
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// languages = new ArrayList();
+// languages.add( "java" );
+// languages.add( "aspectj" );
+// languages.add( "csharp" );
+// languages.add( "groovy" );
+// instance.configureArchetypeCreation(
+// mavenProject,
+// Boolean.FALSE,
+// commandLineProperties,
+// propertyFile,
+// languages
+// );
+//
+// Properties properties = loadProperties( propertyFile );
+//
+// assertEquals(
+// "org.apache.maven.archetype",
+// properties.getProperty( Constants.ARCHETYPE_GROUP_ID )
+// );
+// assertEquals(
+// "maven-archetype-test",
+// properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID )
+// );
+// assertEquals( "1.0", properties.getProperty( Constants.ARCHETYPE_VERSION ) );
+// assertEquals( "some.group.id", properties.getProperty( Constants.GROUP_ID ) );
+// assertEquals( "some-artifact-id", properties.getProperty( Constants.ARTIFACT_ID ) );
+// assertEquals( "1.0", properties.getProperty( Constants.VERSION ) );
+// assertEquals( "org.apache.maven.archetype", properties.getProperty( Constants.PACKAGE ) );
+// }
+// Commented on 2007 09 25*/
// Commented out since no exception are thrown if using defaults to all values
// public void testBatchModePackageDefaultToEmpty ()
// throws Exception
@@ -359,84 +365,86 @@
// );
// }
// }
-
- public void testInteractiveModeNotConfirm()
- throws
- Exception
- {
- System.out.println( "testInteractiveModeNotConfirm" );
-
- String project = "configure-creation-8";
- File projectFile = getProjectFile( project );
- File projectFileSample = getProjectSampleFile( project );
- copy( projectFileSample, projectFile );
- FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
-
- MavenProject mavenProject = loadProject( projectFile );
-
- DefaultArchetypeCreationConfigurator instance =
- (DefaultArchetypeCreationConfigurator) lookup( ArchetypeCreationConfigurator.ROLE );
- instanceDefined( instance );
-
- Properties commandLineProperties = new Properties();
-
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- MockPrompter prompter = new MockPrompter();
- prompter.addAnswer( "N" );
- prompter.addAnswer( "N" );
- prompter.addAnswer( "org.apache.maven.archetypes2" );
- prompter.addAnswer( "maven-archetype-test2" );
- prompter.addAnswer( "1.0.2" );
- prompter.addAnswer( "some.group.id2" );
- prompter.addAnswer( "some-artifact-id2" );
- prompter.addAnswer( "1.0.2" );
- prompter.addAnswer( "org.codehaus" );
- prompter.addAnswer( "Y" );
- prompter.addAnswer( "aProperty" );
- prompter.addAnswer( "some.value" );
- prompter.addAnswer( "N" );
- prompter.addAnswer( "Y" );
- setVariableValueToObject(
- getVariableValueFromObject( instance, "archetypeCreationQueryer" ),
- "prompter",
- prompter
- );
-
- languages = new ArrayList();
- languages.add( "java" );
- languages.add( "aspectj" );
- languages.add( "csharp" );
- languages.add( "groovy" );
- instance.configureArchetypeCreation(
- mavenProject,
- Boolean.TRUE,
- commandLineProperties,
- propertyFile,
- languages
- );
-
- Properties properties = loadProperties( propertyFile );
-
- assertEquals(
- "org.apache.maven.archetypes2",
- properties.getProperty( Constants.ARCHETYPE_GROUP_ID )
- );
- assertEquals(
- "maven-archetype-test2",
- properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID )
- );
- assertEquals( "1.0.2", properties.getProperty( Constants.ARCHETYPE_VERSION ) );
- assertEquals( "some.group.id2", properties.getProperty( Constants.GROUP_ID ) );
- assertEquals( "some-artifact-id2", properties.getProperty( Constants.ARTIFACT_ID ) );
- assertEquals( "1.0.2", properties.getProperty( Constants.VERSION ) );
- assertEquals( "org.codehaus", properties.getProperty( Constants.PACKAGE ) );
- assertEquals( "some.value", properties.getProperty( "aProperty" ) );
-
- assertEquals( 8, properties.size() );
- }
+//
+// /*Commented on 2007 09 25
+// public void testInteractiveModeNotConfirm()
+// throws
+// Exception
+// {
+// System.out.println( "testInteractiveModeNotConfirm" );
+//
+// String project = "configure-creation-8";
+// File projectFile = getProjectFile( project );
+// File projectFileSample = getProjectSampleFile( project );
+// copy( projectFileSample, projectFile );
+// FileUtils.deleteDirectory( new File( projectFile.getParentFile(), "target" ) );
+//
+// MavenProject mavenProject = loadProject( projectFile );
+//
+// DefaultArchetypeCreationConfigurator instance =
+// (DefaultArchetypeCreationConfigurator) lookup( ArchetypeCreationConfigurator.ROLE );
+// instanceDefined( instance );
+//
+// Properties commandLineProperties = new Properties();
+//
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// MockPrompter prompter = new MockPrompter();
+// prompter.addAnswer( "N" );
+// prompter.addAnswer( "N" );
+// prompter.addAnswer( "org.apache.maven.archetypes2" );
+// prompter.addAnswer( "maven-archetype-test2" );
+// prompter.addAnswer( "1.0.2" );
+// prompter.addAnswer( "some.group.id2" );
+// prompter.addAnswer( "some-artifact-id2" );
+// prompter.addAnswer( "1.0.2" );
+// prompter.addAnswer( "org.codehaus" );
+// prompter.addAnswer( "Y" );
+// prompter.addAnswer( "aProperty" );
+// prompter.addAnswer( "some.value" );
+// prompter.addAnswer( "N" );
+// prompter.addAnswer( "Y" );
+// setVariableValueToObject(
+// getVariableValueFromObject( instance, "archetypeCreationQueryer" ),
+// "prompter",
+// prompter
+// );
+//
+// languages = new ArrayList();
+// languages.add( "java" );
+// languages.add( "aspectj" );
+// languages.add( "csharp" );
+// languages.add( "groovy" );
+// instance.configureArchetypeCreation(
+// mavenProject,
+// Boolean.TRUE,
+// commandLineProperties,
+// propertyFile,
+// languages
+// );
+//
+// Properties properties = loadProperties( propertyFile );
+//
+// assertEquals(
+// "org.apache.maven.archetypes2",
+// properties.getProperty( Constants.ARCHETYPE_GROUP_ID )
+// );
+// assertEquals(
+// "maven-archetype-test2",
+// properties.getProperty( Constants.ARCHETYPE_ARTIFACT_ID )
+// );
+// assertEquals( "1.0.2", properties.getProperty( Constants.ARCHETYPE_VERSION ) );
+// assertEquals( "some.group.id2", properties.getProperty( Constants.GROUP_ID ) );
+// assertEquals( "some-artifact-id2", properties.getProperty( Constants.ARTIFACT_ID ) );
+// assertEquals( "1.0.2", properties.getProperty( Constants.VERSION ) );
+// assertEquals( "org.codehaus", properties.getProperty( Constants.PACKAGE ) );
+// assertEquals( "some.value", properties.getProperty( "aProperty" ) );
+//
+// assertEquals( 8, properties.size() );
+// }
+// Commented on 2007 09 25*/
// Commented out if using defaults to all values => change the prompt question order
// public void testInteractiveModePropertyFileMissing ()
// throws Exception
@@ -557,16 +565,18 @@
assertTrue( in.exists() );
}
- private void instanceDefined( DefaultArchetypeCreationConfigurator instance )
- throws
- IllegalAccessException
- {
- assertNotNull( instance );
- assertNotNull( getVariableValueFromObject( instance, "archetypeCreationQueryer" ) );
- assertNotNull( getVariableValueFromObject( instance, "archetypeFactory" ) );
- assertNotNull( getVariableValueFromObject( instance, "archetypePropertiesManager" ) );
- assertNotNull( getVariableValueFromObject( instance, "archetypeFilesResolver" ) );
- }
+// /*Commented on 2007 09 25
+// private void instanceDefined( DefaultArchetypeCreationConfigurator instance )
+// throws
+// IllegalAccessException
+// {
+// assertNotNull( instance );
+// assertNotNull( getVariableValueFromObject( instance, "archetypeCreationQueryer" ) );
+// assertNotNull( getVariableValueFromObject( instance, "archetypeFactory" ) );
+// assertNotNull( getVariableValueFromObject( instance, "archetypePropertiesManager" ) );
+// assertNotNull( getVariableValueFromObject( instance, "archetypeFilesResolver" ) );
+// }
+// Commented on 2007 09 25*/
private MavenProject loadProject( final File projectFile )
throws
Modified: maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationConfiguratorTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationConfiguratorTest.java?rev=579392&r1=579391&r2=579392&view=diff
==============================================================================
--- maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationConfiguratorTest.java (original)
+++ maven/sandbox/trunk/archetypeng/archetype-common/src/test/java/org/apache/maven/archetype/generator/DefaultArchetypeGenerationConfiguratorTest.java Tue Sep 25 14:34:46 2007
@@ -19,7 +19,8 @@
package org.apache.maven.archetype.generator;
-import org.apache.maven.archetype.exception.ArchetypeNotConfigured;
+//import org.apache.maven.archetype.ui.ArchetypeGenerationConfigurator;
+//import org.apache.maven.archetype.ui.DefaultArchetypeGenerationConfigurator;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
@@ -44,566 +45,573 @@
ArtifactRepository localRepository;
List repositories;
- public void testBatchModeArchetypeNotDefined()
- throws
- Exception
- {
- System.out.println( "testBatchModeArchetypeNotDefined" );
-
- String archetypeGroupId = null;
- String archetypeArtifactId = null;
- String archetypeVersion = null;
-
- Boolean interactiveMode = Boolean.FALSE;
-
- String project = "configure-1";
- File propertyFile = getPropertiesFile( project );
- assertTrue( !propertyFile.exists() || propertyFile.delete() );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- assertFalse( propertyFile.exists() );
-
- try
- {
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- System.getProperties(),
- localRepository,
- repositories
- );
-
- fail( "Exception must be thrown" );
- }
- catch ( FileNotFoundException e )
- {
- assertFalse( propertyFile.exists() );
- }
- }
-
- public void testBatchModeOldArchetype()
- throws
- Exception
+ public void testNothing()
{
- System.out.println( "testBatchModeOldArchetype" );
-
- String archetypeGroupId = null;
- String archetypeArtifactId = null;
- String archetypeVersion = null;
-
- Boolean interactiveMode = Boolean.FALSE;
-
- String project = "configure-7";
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- Properties systemProperties = new Properties();
- systemProperties.setProperty( "groupId", "system-value" );
- systemProperties.setProperty( "artifactId", "system-value" );
- systemProperties.setProperty( "version", "system-value" );
- systemProperties.setProperty( "package", "system-value" );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- assertTrue( propertyFile.exists() );
-
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- systemProperties,
- localRepository,
- repositories
- );
-
- assertTrue( propertyFile.exists() );
-
- Properties properties = loadProperties( propertyFile );
- assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
- assertEquals( "old", properties.getProperty( "archetype.artifactId" ) );
- assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
-
- assertEquals( "system-value", properties.getProperty( "groupId" ) );
- assertEquals( "system-value", properties.getProperty( "artifactId" ) );
- assertEquals( "system-value", properties.getProperty( "version" ) );
- assertEquals( "system-value", properties.getProperty( "package" ) );
- }
-
- public void testBatchModePropertiesDefinedInFile()
- throws
- Exception
- {
- System.out.println( "testBatchModePropertiesDefinedInSytem" );
-
- String archetypeGroupId = null;
- String archetypeArtifactId = null;
- String archetypeVersion = null;
-
- Boolean interactiveMode = Boolean.FALSE;
-
- String project = "configure-4";
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- assertTrue( propertyFile.exists() );
-
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- System.getProperties(),
- localRepository,
- repositories
- );
-
- assertTrue( propertyFile.exists() );
-
- Properties properties = loadProperties( propertyFile );
- assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
- assertEquals( "basic", properties.getProperty( "archetype.artifactId" ) );
- assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
-
- assertEquals( "file-value", properties.getProperty( "groupId" ) );
- assertEquals( "file-value", properties.getProperty( "artifactId" ) );
- assertEquals( "file-value", properties.getProperty( "version" ) );
- assertEquals( "file-value", properties.getProperty( "package" ) );
- assertEquals( "file-value", properties.getProperty( "property-with-default-1" ) );
- assertEquals( "file-value", properties.getProperty( "property-with-default-2" ) );
- assertEquals( "file-value", properties.getProperty( "property-with-default-3" ) );
- assertEquals( "file-value", properties.getProperty( "property-with-default-4" ) );
- assertEquals( "file-value", properties.getProperty( "property-without-default-1" ) );
- assertEquals( "file-value", properties.getProperty( "property-without-default-2" ) );
- assertEquals( "file-value", properties.getProperty( "property-without-default-3" ) );
- assertEquals( "file-value", properties.getProperty( "property-without-default-4" ) );
- }
-
- public void testBatchModePropertiesDefinedInSystem()
- throws
- Exception
- {
- System.out.println( "testBatchModePropertiesDefinedInSystem" );
-
- String archetypeGroupId = null;
- String archetypeArtifactId = null;
- String archetypeVersion = null;
-
- Boolean interactiveMode = Boolean.FALSE;
-
- String project = "configure-3";
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- Properties systemProperties = new Properties();
- systemProperties.setProperty( "groupId", "system-value" );
- systemProperties.setProperty( "artifactId", "system-value" );
- systemProperties.setProperty( "version", "system-value" );
- systemProperties.setProperty( "package", "system-value" );
- systemProperties.setProperty( "property-with-default-1", "system-value" );
- systemProperties.setProperty( "property-with-default-2", "system-value" );
- systemProperties.setProperty( "property-with-default-3", "system-value" );
- systemProperties.setProperty( "property-with-default-4", "system-value" );
- systemProperties.setProperty( "property-without-default-1", "system-value" );
- systemProperties.setProperty( "property-without-default-2", "system-value" );
- systemProperties.setProperty( "property-without-default-3", "system-value" );
- systemProperties.setProperty( "property-without-default-4", "system-value" );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- assertTrue( propertyFile.exists() );
-
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- systemProperties,
- localRepository,
- repositories
- );
-
- assertTrue( propertyFile.exists() );
-
- Properties properties = loadProperties( propertyFile );
- assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
- assertEquals( "basic", properties.getProperty( "archetype.artifactId" ) );
- assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
-
- assertEquals( "system-value", properties.getProperty( "groupId" ) );
- assertEquals( "system-value", properties.getProperty( "artifactId" ) );
- assertEquals( "system-value", properties.getProperty( "version" ) );
- assertEquals( "system-value", properties.getProperty( "package" ) );
- assertEquals( "system-value", properties.getProperty( "property-with-default-1" ) );
- assertEquals( "system-value", properties.getProperty( "property-with-default-2" ) );
- assertEquals( "system-value", properties.getProperty( "property-with-default-3" ) );
- assertEquals( "system-value", properties.getProperty( "property-with-default-4" ) );
- assertEquals( "system-value", properties.getProperty( "property-without-default-1" ) );
- assertEquals( "system-value", properties.getProperty( "property-without-default-2" ) );
- assertEquals( "system-value", properties.getProperty( "property-without-default-3" ) );
- assertEquals( "system-value", properties.getProperty( "property-without-default-4" ) );
- }
-
- public void testBatchModePropertiesNotDefined()
- throws
- Exception
- {
- System.out.println( "testBatchModePropertiesNotDefined" );
-
- String archetypeGroupId = "archetypes";
- String archetypeArtifactId = "basic";
- String archetypeVersion = "1.0";
-
- Boolean interactiveMode = Boolean.FALSE;
-
- String project = "configure-2";
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- assertTrue( propertyFile.exists() );
-
- try
- {
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- System.getProperties(),
- localRepository,
- repositories
- );
-
- fail( "Exception must be thrown" );
- }
- catch ( ArchetypeNotConfigured e )
- {
- assertEquals(
- "Exception not correct",
- "The archetype is not configurated",
- e.getMessage()
- );
- }
- }
-
- public void testInteractiveModeFileSetArchetype()
- throws
- Exception
- {
- System.out.println( "testInteractiveModeFileSetArchetype" );
-
- String archetypeGroupId = "archetypes";
- String archetypeArtifactId = "fileset";
- String archetypeVersion = "1.0";
-
- Boolean interactiveMode = Boolean.TRUE;
-
- String project = "configure-9";
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- MockPrompter prompter = new MockPrompter();
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "N" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "Y" );
- setVariableValueToObject(
- getVariableValueFromObject( instance, "archetypeGenerationQueryer" ),
- "prompter",
- prompter
- );
-
- assertTrue( propertyFile.exists() );
-
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- System.getProperties(),
- localRepository,
- repositories
- );
-
- assertTrue( propertyFile.exists() );
-
- Properties properties = loadProperties( propertyFile );
- assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
- assertEquals( "fileset", properties.getProperty( "archetype.artifactId" ) );
- assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
-
- assertEquals( "user-value2", properties.getProperty( "groupId" ) );
- assertEquals( "user-value2", properties.getProperty( "artifactId" ) );
- assertEquals( "user-value2", properties.getProperty( "version" ) );
- assertEquals( "user-value2", properties.getProperty( "package" ) );
- assertEquals( "user-value2", properties.getProperty( "property-with-default-1" ) );
- assertEquals( "user-value2", properties.getProperty( "property-with-default-2" ) );
- assertEquals( "user-value2", properties.getProperty( "property-with-default-3" ) );
- assertEquals( "user-value2", properties.getProperty( "property-with-default-4" ) );
- assertEquals( "user-value2", properties.getProperty( "property-without-default-1" ) );
- assertEquals( "user-value2", properties.getProperty( "property-without-default-2" ) );
- assertEquals( "user-value2", properties.getProperty( "property-without-default-3" ) );
- assertEquals( "user-value2", properties.getProperty( "property-without-default-4" ) );
- }
-
- public void testInteractiveModeOldArchetype()
- throws
- Exception
- {
- System.out.println( "testInteractiveModePropertiesNotDefined" );
-
- String archetypeGroupId = "archetypes";
- String archetypeArtifactId = "old";
- String archetypeVersion = "1.0";
-
- Boolean interactiveMode = Boolean.TRUE;
-
- String project = "configure-8";
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- MockPrompter prompter = new MockPrompter();
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "Y" );
- setVariableValueToObject(
- getVariableValueFromObject( instance, "archetypeGenerationQueryer" ),
- "prompter",
- prompter
- );
-
- assertTrue( propertyFile.exists() );
-
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- System.getProperties(),
- localRepository,
- repositories
- );
-
- assertTrue( propertyFile.exists() );
-
- Properties properties = loadProperties( propertyFile );
- assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
- assertEquals( "old", properties.getProperty( "archetype.artifactId" ) );
- assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
-
- assertEquals( "user-value", properties.getProperty( "groupId" ) );
- assertEquals( "user-value", properties.getProperty( "artifactId" ) );
- assertEquals( "user-value", properties.getProperty( "version" ) );
- assertEquals( "user-value", properties.getProperty( "package" ) );
- }
-
- public void testInteractiveModePropertiesNotDefined()
- throws
- Exception
- {
- System.out.println( "testInteractiveModePropertiesNotDefined" );
-
- String archetypeGroupId = "archetypes";
- String archetypeArtifactId = "basic";
- String archetypeVersion = "1.0";
-
- Boolean interactiveMode = Boolean.TRUE;
-
- String project = "configure-5";
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- MockPrompter prompter = new MockPrompter();
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "N" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "user-value2" );
- prompter.addAnswer( "Y" );
- setVariableValueToObject(
- getVariableValueFromObject( instance, "archetypeGenerationQueryer" ),
- "prompter",
- prompter
- );
-
- assertTrue( propertyFile.exists() );
-
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- System.getProperties(),
- localRepository,
- repositories
- );
-
- assertTrue( propertyFile.exists() );
-
- Properties properties = loadProperties( propertyFile );
- assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
- assertEquals( "basic", properties.getProperty( "archetype.artifactId" ) );
- assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
-
- assertEquals( "user-value2", properties.getProperty( "groupId" ) );
- assertEquals( "user-value2", properties.getProperty( "artifactId" ) );
- assertEquals( "user-value2", properties.getProperty( "version" ) );
- assertEquals( "user-value2", properties.getProperty( "package" ) );
- assertEquals( "user-value2", properties.getProperty( "property-with-default-1" ) );
- assertEquals( "user-value2", properties.getProperty( "property-with-default-2" ) );
- assertEquals( "user-value2", properties.getProperty( "property-with-default-3" ) );
- assertEquals( "user-value2", properties.getProperty( "property-with-default-4" ) );
- assertEquals( "user-value2", properties.getProperty( "property-without-default-1" ) );
- assertEquals( "user-value2", properties.getProperty( "property-without-default-2" ) );
- assertEquals( "user-value2", properties.getProperty( "property-without-default-3" ) );
- assertEquals( "user-value2", properties.getProperty( "property-without-default-4" ) );
- }
-
- public void testInteractiveModePropertiesOverrided()
- throws
- Exception
- {
- System.out.println( "testInteractiveModePropertiesOverrided" );
-
- String archetypeGroupId = "archetypes";
- String archetypeArtifactId = "basic";
- String archetypeVersion = "1.0";
-
- Boolean interactiveMode = Boolean.TRUE;
-
- String project = "configure-6";
- File propertyFile = getPropertiesFile( project );
- File propertyFileSample = getPropertiesSampleFile( project );
- copy( propertyFileSample, propertyFile );
-
- DefaultArchetypeGenerationConfigurator instance =
- (DefaultArchetypeGenerationConfigurator) lookup(
- ArchetypeGenerationConfigurator.ROLE
- );
- instanceDefined( instance );
-
- MockPrompter prompter = new MockPrompter();
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "user-value" );
- prompter.addAnswer( "Y" );
- setVariableValueToObject(
- getVariableValueFromObject( instance, "archetypeGenerationQueryer" ),
- "prompter",
- prompter
- );
-
- Properties systemProperties = new Properties();
- systemProperties.setProperty( "groupId", "system-value" );
- systemProperties.setProperty( "version", "system-value" );
- systemProperties.setProperty( "property-with-default-1", "system-value" );
- systemProperties.setProperty( "property-with-default-3", "system-value" );
- systemProperties.setProperty( "property-without-default-1", "system-value" );
- systemProperties.setProperty( "property-without-default-3", "system-value" );
-
- assertTrue( propertyFile.exists() );
-
- instance.configureArchetype(
- interactiveMode,
- propertyFile,
- systemProperties,
- localRepository,
- repositories
- );
-
- assertTrue( propertyFile.exists() );
-
- Properties properties = loadProperties( propertyFile );
- assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
- assertEquals( "basic", properties.getProperty( "archetype.artifactId" ) );
- assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
-
- assertEquals( "system-value", properties.getProperty( "groupId" ) );
- assertEquals( "file-value", properties.getProperty( "artifactId" ) );
- assertEquals( "system-value", properties.getProperty( "version" ) );
- assertEquals( "user-value", properties.getProperty( "package" ) );
-
- assertEquals( "system-value", properties.getProperty( "property-with-default-1" ) );
- assertEquals( "file-value", properties.getProperty( "property-with-default-2" ) );
- assertEquals( "system-value", properties.getProperty( "property-with-default-3" ) );
- assertEquals( "default-value", properties.getProperty( "property-with-default-4" ) );
-
- assertEquals( "system-value", properties.getProperty( "property-without-default-1" ) );
- assertEquals( "file-value", properties.getProperty( "property-without-default-2" ) );
- assertEquals( "system-value", properties.getProperty( "property-without-default-3" ) );
- assertEquals( "user-value", properties.getProperty( "property-without-default-4" ) );
+ //TODO: All the tests were commented out Because the tested classes are beeing moved for now and will be removed soon
}
+
+// /*Commented on 2007 09 25
+// public void testBatchModeArchetypeNotDefined()
+// throws
+// Exception
+// {
+// System.out.println( "testBatchModeArchetypeNotDefined" );
+//
+// String archetypeGroupId = null;
+// String archetypeArtifactId = null;
+// String archetypeVersion = null;
+//
+// Boolean interactiveMode = Boolean.FALSE;
+//
+// String project = "configure-1";
+// File propertyFile = getPropertiesFile( project );
+// assertTrue( !propertyFile.exists() || propertyFile.delete() );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// assertFalse( propertyFile.exists() );
+//
+// try
+// {
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// System.getProperties(),
+// localRepository,
+// repositories
+// );
+//
+// fail( "Exception must be thrown" );
+// }
+// catch ( FileNotFoundException e )
+// {
+// assertFalse( propertyFile.exists() );
+// }
+// }
+//
+// public void testBatchModeOldArchetype()
+// throws
+// Exception
+// {
+// System.out.println( "testBatchModeOldArchetype" );
+//
+// String archetypeGroupId = null;
+// String archetypeArtifactId = null;
+// String archetypeVersion = null;
+//
+// Boolean interactiveMode = Boolean.FALSE;
+//
+// String project = "configure-7";
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// Properties systemProperties = new Properties();
+// systemProperties.setProperty( "groupId", "system-value" );
+// systemProperties.setProperty( "artifactId", "system-value" );
+// systemProperties.setProperty( "version", "system-value" );
+// systemProperties.setProperty( "package", "system-value" );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// assertTrue( propertyFile.exists() );
+//
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// systemProperties,
+// localRepository,
+// repositories
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// Properties properties = loadProperties( propertyFile );
+// assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
+// assertEquals( "old", properties.getProperty( "archetype.artifactId" ) );
+// assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
+//
+// assertEquals( "system-value", properties.getProperty( "groupId" ) );
+// assertEquals( "system-value", properties.getProperty( "artifactId" ) );
+// assertEquals( "system-value", properties.getProperty( "version" ) );
+// assertEquals( "system-value", properties.getProperty( "package" ) );
+// }
+//
+// public void testBatchModePropertiesDefinedInFile()
+// throws
+// Exception
+// {
+// System.out.println( "testBatchModePropertiesDefinedInSytem" );
+//
+// String archetypeGroupId = null;
+// String archetypeArtifactId = null;
+// String archetypeVersion = null;
+//
+// Boolean interactiveMode = Boolean.FALSE;
+//
+// String project = "configure-4";
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// assertTrue( propertyFile.exists() );
+//
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// System.getProperties(),
+// localRepository,
+// repositories
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// Properties properties = loadProperties( propertyFile );
+// assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
+// assertEquals( "basic", properties.getProperty( "archetype.artifactId" ) );
+// assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
+//
+// assertEquals( "file-value", properties.getProperty( "groupId" ) );
+// assertEquals( "file-value", properties.getProperty( "artifactId" ) );
+// assertEquals( "file-value", properties.getProperty( "version" ) );
+// assertEquals( "file-value", properties.getProperty( "package" ) );
+// assertEquals( "file-value", properties.getProperty( "property-with-default-1" ) );
+// assertEquals( "file-value", properties.getProperty( "property-with-default-2" ) );
+// assertEquals( "file-value", properties.getProperty( "property-with-default-3" ) );
+// assertEquals( "file-value", properties.getProperty( "property-with-default-4" ) );
+// assertEquals( "file-value", properties.getProperty( "property-without-default-1" ) );
+// assertEquals( "file-value", properties.getProperty( "property-without-default-2" ) );
+// assertEquals( "file-value", properties.getProperty( "property-without-default-3" ) );
+// assertEquals( "file-value", properties.getProperty( "property-without-default-4" ) );
+// }
+//
+// public void testBatchModePropertiesDefinedInSystem()
+// throws
+// Exception
+// {
+// System.out.println( "testBatchModePropertiesDefinedInSystem" );
+//
+// String archetypeGroupId = null;
+// String archetypeArtifactId = null;
+// String archetypeVersion = null;
+//
+// Boolean interactiveMode = Boolean.FALSE;
+//
+// String project = "configure-3";
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// Properties systemProperties = new Properties();
+// systemProperties.setProperty( "groupId", "system-value" );
+// systemProperties.setProperty( "artifactId", "system-value" );
+// systemProperties.setProperty( "version", "system-value" );
+// systemProperties.setProperty( "package", "system-value" );
+// systemProperties.setProperty( "property-with-default-1", "system-value" );
+// systemProperties.setProperty( "property-with-default-2", "system-value" );
+// systemProperties.setProperty( "property-with-default-3", "system-value" );
+// systemProperties.setProperty( "property-with-default-4", "system-value" );
+// systemProperties.setProperty( "property-without-default-1", "system-value" );
+// systemProperties.setProperty( "property-without-default-2", "system-value" );
+// systemProperties.setProperty( "property-without-default-3", "system-value" );
+// systemProperties.setProperty( "property-without-default-4", "system-value" );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// assertTrue( propertyFile.exists() );
+//
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// systemProperties,
+// localRepository,
+// repositories
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// Properties properties = loadProperties( propertyFile );
+// assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
+// assertEquals( "basic", properties.getProperty( "archetype.artifactId" ) );
+// assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
+//
+// assertEquals( "system-value", properties.getProperty( "groupId" ) );
+// assertEquals( "system-value", properties.getProperty( "artifactId" ) );
+// assertEquals( "system-value", properties.getProperty( "version" ) );
+// assertEquals( "system-value", properties.getProperty( "package" ) );
+// assertEquals( "system-value", properties.getProperty( "property-with-default-1" ) );
+// assertEquals( "system-value", properties.getProperty( "property-with-default-2" ) );
+// assertEquals( "system-value", properties.getProperty( "property-with-default-3" ) );
+// assertEquals( "system-value", properties.getProperty( "property-with-default-4" ) );
+// assertEquals( "system-value", properties.getProperty( "property-without-default-1" ) );
+// assertEquals( "system-value", properties.getProperty( "property-without-default-2" ) );
+// assertEquals( "system-value", properties.getProperty( "property-without-default-3" ) );
+// assertEquals( "system-value", properties.getProperty( "property-without-default-4" ) );
+// }
+//
+// public void testBatchModePropertiesNotDefined()
+// throws
+// Exception
+// {
+// System.out.println( "testBatchModePropertiesNotDefined" );
+//
+// String archetypeGroupId = "archetypes";
+// String archetypeArtifactId = "basic";
+// String archetypeVersion = "1.0";
+//
+// Boolean interactiveMode = Boolean.FALSE;
+//
+// String project = "configure-2";
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// assertTrue( propertyFile.exists() );
+//
+// try
+// {
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// System.getProperties(),
+// localRepository,
+// repositories
+// );
+//
+// fail( "Exception must be thrown" );
+// }
+// catch ( ArchetypeNotConfigured e )
+// {
+// assertEquals(
+// "Exception not correct",
+// "The archetype is not configurated",
+// e.getMessage()
+// );
+// }
+// }
+//
+// public void testInteractiveModeFileSetArchetype()
+// throws
+// Exception
+// {
+// System.out.println( "testInteractiveModeFileSetArchetype" );
+//
+// String archetypeGroupId = "archetypes";
+// String archetypeArtifactId = "fileset";
+// String archetypeVersion = "1.0";
+//
+// Boolean interactiveMode = Boolean.TRUE;
+//
+// String project = "configure-9";
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// MockPrompter prompter = new MockPrompter();
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "N" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "Y" );
+// setVariableValueToObject(
+// getVariableValueFromObject( instance, "archetypeGenerationQueryer" ),
+// "prompter",
+// prompter
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// System.getProperties(),
+// localRepository,
+// repositories
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// Properties properties = loadProperties( propertyFile );
+// assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
+// assertEquals( "fileset", properties.getProperty( "archetype.artifactId" ) );
+// assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
+//
+// assertEquals( "user-value2", properties.getProperty( "groupId" ) );
+// assertEquals( "user-value2", properties.getProperty( "artifactId" ) );
+// assertEquals( "user-value2", properties.getProperty( "version" ) );
+// assertEquals( "user-value2", properties.getProperty( "package" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-with-default-1" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-with-default-2" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-with-default-3" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-with-default-4" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-without-default-1" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-without-default-2" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-without-default-3" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-without-default-4" ) );
+// }
+//
+// public void testInteractiveModeOldArchetype()
+// throws
+// Exception
+// {
+// System.out.println( "testInteractiveModePropertiesNotDefined" );
+//
+// String archetypeGroupId = "archetypes";
+// String archetypeArtifactId = "old";
+// String archetypeVersion = "1.0";
+//
+// Boolean interactiveMode = Boolean.TRUE;
+//
+// String project = "configure-8";
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// MockPrompter prompter = new MockPrompter();
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "Y" );
+// setVariableValueToObject(
+// getVariableValueFromObject( instance, "archetypeGenerationQueryer" ),
+// "prompter",
+// prompter
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// System.getProperties(),
+// localRepository,
+// repositories
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// Properties properties = loadProperties( propertyFile );
+// assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
+// assertEquals( "old", properties.getProperty( "archetype.artifactId" ) );
+// assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
+//
+// assertEquals( "user-value", properties.getProperty( "groupId" ) );
+// assertEquals( "user-value", properties.getProperty( "artifactId" ) );
+// assertEquals( "user-value", properties.getProperty( "version" ) );
+// assertEquals( "user-value", properties.getProperty( "package" ) );
+// }
+//
+// public void testInteractiveModePropertiesNotDefined()
+// throws
+// Exception
+// {
+// System.out.println( "testInteractiveModePropertiesNotDefined" );
+//
+// String archetypeGroupId = "archetypes";
+// String archetypeArtifactId = "basic";
+// String archetypeVersion = "1.0";
+//
+// Boolean interactiveMode = Boolean.TRUE;
+//
+// String project = "configure-5";
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// MockPrompter prompter = new MockPrompter();
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "N" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "user-value2" );
+// prompter.addAnswer( "Y" );
+// setVariableValueToObject(
+// getVariableValueFromObject( instance, "archetypeGenerationQueryer" ),
+// "prompter",
+// prompter
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// System.getProperties(),
+// localRepository,
+// repositories
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// Properties properties = loadProperties( propertyFile );
+// assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
+// assertEquals( "basic", properties.getProperty( "archetype.artifactId" ) );
+// assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
+//
+// assertEquals( "user-value2", properties.getProperty( "groupId" ) );
+// assertEquals( "user-value2", properties.getProperty( "artifactId" ) );
+// assertEquals( "user-value2", properties.getProperty( "version" ) );
+// assertEquals( "user-value2", properties.getProperty( "package" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-with-default-1" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-with-default-2" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-with-default-3" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-with-default-4" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-without-default-1" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-without-default-2" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-without-default-3" ) );
+// assertEquals( "user-value2", properties.getProperty( "property-without-default-4" ) );
+// }
+//
+// public void testInteractiveModePropertiesOverrided()
+// throws
+// Exception
+// {
+// System.out.println( "testInteractiveModePropertiesOverrided" );
+//
+// String archetypeGroupId = "archetypes";
+// String archetypeArtifactId = "basic";
+// String archetypeVersion = "1.0";
+//
+// Boolean interactiveMode = Boolean.TRUE;
+//
+// String project = "configure-6";
+// File propertyFile = getPropertiesFile( project );
+// File propertyFileSample = getPropertiesSampleFile( project );
+// copy( propertyFileSample, propertyFile );
+//
+// DefaultArchetypeGenerationConfigurator instance =
+// (DefaultArchetypeGenerationConfigurator) lookup(
+// ArchetypeGenerationConfigurator.ROLE
+// );
+// instanceDefined( instance );
+//
+// MockPrompter prompter = new MockPrompter();
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "user-value" );
+// prompter.addAnswer( "Y" );
+// setVariableValueToObject(
+// getVariableValueFromObject( instance, "archetypeGenerationQueryer" ),
+// "prompter",
+// prompter
+// );
+//
+// Properties systemProperties = new Properties();
+// systemProperties.setProperty( "groupId", "system-value" );
+// systemProperties.setProperty( "version", "system-value" );
+// systemProperties.setProperty( "property-with-default-1", "system-value" );
+// systemProperties.setProperty( "property-with-default-3", "system-value" );
+// systemProperties.setProperty( "property-without-default-1", "system-value" );
+// systemProperties.setProperty( "property-without-default-3", "system-value" );
+//
+// assertTrue( propertyFile.exists() );
+//
+// instance.configureArchetype(
+// interactiveMode,
+// propertyFile,
+// systemProperties,
+// localRepository,
+// repositories
+// );
+//
+// assertTrue( propertyFile.exists() );
+//
+// Properties properties = loadProperties( propertyFile );
+// assertEquals( "archetypes", properties.getProperty( "archetype.groupId" ) );
+// assertEquals( "basic", properties.getProperty( "archetype.artifactId" ) );
+// assertEquals( "1.0", properties.getProperty( "archetype.version" ) );
+//
+// assertEquals( "system-value", properties.getProperty( "groupId" ) );
+// assertEquals( "file-value", properties.getProperty( "artifactId" ) );
+// assertEquals( "system-value", properties.getProperty( "version" ) );
+// assertEquals( "user-value", properties.getProperty( "package" ) );
+//
+// assertEquals( "system-value", properties.getProperty( "property-with-default-1" ) );
+// assertEquals( "file-value", properties.getProperty( "property-with-default-2" ) );
+// assertEquals( "system-value", properties.getProperty( "property-with-default-3" ) );
+// assertEquals( "default-value", properties.getProperty( "property-with-default-4" ) );
+//
+// assertEquals( "system-value", properties.getProperty( "property-without-default-1" ) );
+// assertEquals( "file-value", properties.getProperty( "property-without-default-2" ) );
+// assertEquals( "system-value", properties.getProperty( "property-without-default-3" ) );
+// assertEquals( "user-value", properties.getProperty( "property-without-default-4" ) );
+// }
+// Commented on 2007 09 25*/
protected void tearDown()
throws
@@ -653,16 +661,18 @@
assertTrue( in.exists() );
}
- private void instanceDefined( DefaultArchetypeGenerationConfigurator instance )
- throws
- IllegalAccessException
- {
- assertNotNull( instance );
- assertNotNull( getVariableValueFromObject( instance, "archetypeArtifactManager" ) );
- assertNotNull( getVariableValueFromObject( instance, "archetypeFactory" ) );
- assertNotNull( getVariableValueFromObject( instance, "archetypeGenerationQueryer" ) );
- assertNotNull( getVariableValueFromObject( instance, "archetypePropertiesManager" ) );
- }
+// /*Commented on 2007 09 25
+// private void instanceDefined( DefaultArchetypeGenerationConfigurator instance )
+// throws
+// IllegalAccessException
+// {
+// assertNotNull( instance );
+// assertNotNull( getVariableValueFromObject( instance, "archetypeArtifactManager" ) );
+// assertNotNull( getVariableValueFromObject( instance, "archetypeFactory" ) );
+// assertNotNull( getVariableValueFromObject( instance, "archetypeGenerationQueryer" ) );
+// assertNotNull( getVariableValueFromObject( instance, "archetypePropertiesManager" ) );
+// }
+// Commented on 2007 09 25*/
private Properties loadProperties( File propertyFile )
throws