use of org.apache.maven.archetype.ArchetypeGenerationRequest in project maven-archetype by apache.
the class DefaultArchetypeGeneratorTest method testArchetypeNotDefined.
public void testArchetypeNotDefined() throws Exception {
System.out.println("testArchetypeNotDefined");
Archetype archetype = new Archetype("archetypes", null, "1.0");
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-2", archetype);
ArchetypeGenerationResult result = generateProjectFromArchetypeWithFailure(request);
assertEquals("Exception not correct", "The archetype is not defined", result.getCause().getMessage());
}
use of org.apache.maven.archetype.ArchetypeGenerationRequest in project maven-archetype by apache.
the class DefaultArchetypeGeneratorTest method testPropertiesNotDefined.
public void testPropertiesNotDefined() throws Exception {
System.out.println("testPropertiesNotDefined");
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-3", ARCHETYPE_BASIC);
request.setProperties(new Properties());
ArchetypeGenerationResult result = generateProjectFromArchetypeWithFailure(request);
assertTrue("Exception not correct", result.getCause().getMessage().startsWith("Archetype archetypes:basic:1.0 is not configured") && result.getCause().getMessage().endsWith("Property property-without-default-4 is missing."));
}
use of org.apache.maven.archetype.ArchetypeGenerationRequest in project maven-archetype by apache.
the class DefaultArchetypeGeneratorTest method testGenerateArchetypePartialWithoutPoms.
public void testGenerateArchetypePartialWithoutPoms() throws Exception {
System.out.println("testGenerateArchetypePartialWithoutPoms");
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-6", ARCHETYPE_PARTIAL);
File projectFile = new File(projectDirectory, "pom.xml");
FileUtils.forceDelete(projectDirectory);
generateProjectFromArchetype(request);
Model model = readPom(projectFile);
assertNull(model.getParent());
assertEquals("file-value", model.getGroupId());
assertEquals("file-value", model.getArtifactId());
assertEquals("file-value", model.getVersion());
}
use of org.apache.maven.archetype.ArchetypeGenerationRequest in project maven-archetype by apache.
the class DefaultArchetypeGeneratorTest method testGenerateArchetypePartialOnChildDontOverride.
public void testGenerateArchetypePartialOnChildDontOverride() throws Exception {
System.out.println("testGenerateArchetypePartialOnChildDontOverride");
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-9", ARCHETYPE_PARTIAL);
File projectFile = new File(projectDirectory, "pom.xml");
File projectFileSample = new File(projectDirectory, "pom.xml.sample");
copy(projectFileSample, projectFile);
FileUtils.forceDelete(new File(projectDirectory, "src"));
generateProjectFromArchetype(request);
Model model = readPom(projectFile);
assertNotNull(model.getParent());
assertEquals("org.apache.maven.archetype", model.getGroupId());
assertEquals("file-value", model.getArtifactId());
assertEquals("1.0-SNAPSHOT", model.getVersion());
assertTrue(model.getModules().isEmpty());
assertFalse(model.getDependencies().isEmpty());
assertEquals("1.0", ((Dependency) model.getDependencies().get(0)).getVersion());
assertFalse(model.getBuild().getPlugins().isEmpty());
assertEquals("1.0", ((Plugin) model.getBuild().getPlugins().get(0)).getVersion());
assertFalse(model.getReporting().getPlugins().isEmpty());
assertEquals("1.0", ((ReportPlugin) model.getReporting().getPlugins().get(0)).getVersion());
}
use of org.apache.maven.archetype.ArchetypeGenerationRequest in project maven-archetype by apache.
the class DefaultArchetypeGeneratorTest method testGenerateArchetypePartialOnParent.
public void testGenerateArchetypePartialOnParent() throws Exception {
System.out.println("testGenerateArchetypePartialOnParent");
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-7", ARCHETYPE_PARTIAL);
File projectFile = new File(outputDirectory, "pom.xml");
File projectFileSample = new File(outputDirectory, "pom.xml.sample");
copy(projectFileSample, projectFile);
FileUtils.forceDelete(new File(outputDirectory, "src"));
generateProjectFromArchetype(request);
Model model = readPom(getProjectFile());
assertNull(model.getParent());
assertEquals("org.apache.maven.archetype", model.getGroupId());
assertEquals("test-generate-7", model.getArtifactId());
assertEquals("1.0-SNAPSHOT", model.getVersion());
assertTrue(model.getModules().isEmpty());
assertFalse(model.getBuild().getPlugins().isEmpty());
}
Aggregations