Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions archetype-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,17 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;
import org.apache.maven.archetype.metadata.FileSet;
import org.junit.jupiter.api.Test;

public class TestDefaultArchetypeFilesResolver extends TestCase {
import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestDefaultArchetypeFilesResolver {
@Test
public void testResourceFiltering() throws Exception {
FileSet fileSet = new FileSet();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import java.util.regex.Pattern;

import org.apache.maven.archetype.exception.InvalidPackaging;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class TestPomManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
import java.util.ArrayList;
import java.util.List;

import junit.framework.TestCase;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/** @author <a href="mailto:brianf@apache.org">Brian Fox</a> */
public class TestListScanner extends TestCase {
public class TestListScanner {
@Test
public void testUnixPaths() {
List<String> archetypeResources = new ArrayList<>();

Expand Down Expand Up @@ -53,6 +57,7 @@ public void testUnixPaths() {
assertTrue(result.contains("src/main/java/inner/package/App2.java"));
}

@Test
public void testWindowsPaths() {
List<String> archetypeResources = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
import java.io.StringReader;
import java.io.StringWriter;

import junit.framework.TestCase;
import org.jdom2.Document;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertTrue;

/** @author <a href="mailto:jdcasey@apache.org">John Casey</a> */
public class TestXMLOutputter extends TestCase {
public class TestXMLOutputter {
@Test
public void testOutputDocumentShouldParseAndOutputCDATASectionNoMods() throws JDOMException, IOException {
String content = "<document>" + "<element1>This is some text</element1>"
+ "<description>And then,"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

public class DefaultArchetypeGeneratorTest extends PlexusTestCase {
// archetypes prepared by antrun execution (see pom.xml) from src/test/archetypes
Expand Down Expand Up @@ -102,6 +112,7 @@ private ArchetypeGenerationResult generateProjectFromArchetypeWithFailure(Archet
return result;
}

@Test
public void testArchetypeNotDefined() throws Exception {
Archetype archetype = new Archetype("archetypes", null, "1.0");

Expand All @@ -110,11 +121,12 @@ public void testArchetypeNotDefined() throws Exception {
ArchetypeGenerationResult result = generateProjectFromArchetypeWithFailure(request);

assertEquals(
"Exception not correct",
"The archetype is not defined",
result.getCause().getMessage());
result.getCause().getMessage(),
"Exception not correct");
}

@Test
public void testGenerateArchetypeCompleteWithoutParent() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-4", ARCHETYPE_BASIC);

Expand All @@ -140,6 +152,7 @@ public void testGenerateArchetypeCompleteWithoutParent() throws Exception {
assertEquals("file-value", model.getVersion());
}

@Test
public void testGenerateArchetypeCompleteWithParent() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-5", ARCHETYPE_BASIC);

Expand All @@ -163,6 +176,7 @@ public void testGenerateArchetypeCompleteWithParent() throws Exception {
assertTrue(parentModel.getModules().contains("file-value"));
}

@Test
public void testGenerateArchetypePartialOnChild() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-8", ARCHETYPE_PARTIAL);

Expand All @@ -189,6 +203,7 @@ public void testGenerateArchetypePartialOnChild() throws Exception {
assertFalse(model.getReporting().getPlugins().isEmpty());
}

@Test
public void testGenerateArchetypePartialOnChildDontOverride() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-9", ARCHETYPE_PARTIAL);

Expand All @@ -214,6 +229,7 @@ public void testGenerateArchetypePartialOnChildDontOverride() throws Exception {
assertEquals("1.0", model.getReporting().getPlugins().get(0).getVersion());
}

@Test
public void testGenerateArchetypePartialOnParent() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-7", ARCHETYPE_PARTIAL);

Expand All @@ -234,6 +250,7 @@ public void testGenerateArchetypePartialOnParent() throws Exception {
assertFalse(model.getBuild().getPlugins().isEmpty());
}

@Test
public void testGenerateArchetypePartialWithoutPoms() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-6", ARCHETYPE_PARTIAL);

Expand All @@ -250,6 +267,7 @@ public void testGenerateArchetypePartialWithoutPoms() throws Exception {
assertEquals("file-value", model.getVersion());
}

@Test
public void testGenerateArchetypeSite() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-10", ARCHETYPE_SITE);

Expand All @@ -269,6 +287,7 @@ public void testGenerateArchetypeSite() throws Exception {
assertEquals("file-value", model.getVersion());
}

@Test
public void testGenerateFileSetArchetype() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-12", ARCHETYPE_FILESET);

Expand Down Expand Up @@ -351,6 +370,7 @@ public void testGenerateFileSetArchetype() throws Exception {
assertEquals("file-value", model.getVersion());
}

@Test
public void testGenerateOldArchetype() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-11", ARCHETYPE_OLD);

Expand All @@ -371,6 +391,7 @@ public void testGenerateOldArchetype() throws Exception {
assertEquals("file-value", model.getVersion());
}

@Test
public void testPropertiesNotDefined() throws Exception {
ArchetypeGenerationRequest request = createArchetypeGenerationRequest("generate-3", ARCHETYPE_BASIC);

Expand All @@ -379,11 +400,12 @@ public void testPropertiesNotDefined() throws Exception {
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."));
&& result.getCause().getMessage().endsWith("Property property-without-default-4 is missing."),
"Exception not correct");
}

@Test
public void testGenerateArchetypeWithPostScriptIncluded() throws Exception {
ArchetypeGenerationRequest request =
createArchetypeGenerationRequest("generate-13", ARCHETYPE_FILESET_WITH_POSTCREATE_SCRIPT);
Expand All @@ -401,7 +423,7 @@ public void testGenerateArchetypeWithPostScriptIncluded() throws Exception {
assertTemplateCopiedWithFileSetArchetype("src/main/java/file/value/package/App.ogg");

File templateFile = new File(projectDirectory, "src/main/java/file/value/package/ToDelete.java");
assertFalse(templateFile + " should have been removed (by post-generate.groovy script", templateFile.exists());
assertFalse(templateFile.exists(), templateFile + " should have been removed (by post-generate.groovy script");

assertTemplateContentGeneratedWithFileSetArchetype("src/main/resources/App.properties", "file-value");
assertTemplateContentGeneratedWithFileSetArchetype("src/main/resources/file-value/touch.txt", "file-value");
Expand Down Expand Up @@ -464,8 +486,8 @@ public void testGenerateArchetypeWithPostScriptIncluded() throws Exception {
assertEquals("file-value", model.getVersion());
}

@Override
protected void tearDown() throws Exception {
@AfterEach
public void tearDown() throws Exception {
super.tearDown();

outputDirectory = null;
Expand All @@ -476,8 +498,8 @@ protected void customizeContainerConfiguration(ContainerConfiguration configurat
configuration.setClassPathScanning("index");
}

@Override
protected void setUp() throws Exception {
@BeforeEach
public void setUp() throws Exception {
super.setUp();

File repositories = new File(getBasedir(), "target/test-classes/repositories");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@
import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResult;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.xmlunit.matchers.CompareMatcher.isIdenticalTo;

/**
Expand All @@ -68,6 +74,7 @@ protected void customizeContainerConfiguration(ContainerConfiguration configurat
configuration.setClassPathScanning("index");
}

@Test
public void testArchetype() throws Exception {
FileUtils.deleteDirectory(getTestFile("target/quickstart"));

Expand Down Expand Up @@ -176,33 +183,33 @@ public void testArchetype() throws Exception {
throw new ArchetypeTemplateProcessingException("Error reading generated POM", e);
}
assertEquals(
"Generated POM ArtifactId is not equivalent to expected result.",
generatedModel.getArtifactId(),
templateModel.getArtifactId());
templateModel.getArtifactId(),
"Generated POM ArtifactId is not equivalent to expected result.");
assertEquals(
"Generated POM GroupId is not equivalent to expected result.",
generatedModel.getGroupId(),
templateModel.getGroupId());
templateModel.getGroupId(),
"Generated POM GroupId is not equivalent to expected result.");
assertEquals(
"Generated POM Id is not equivalent to expected result.",
generatedModel.getId(),
templateModel.getId());
templateModel.getId(),
"Generated POM Id is not equivalent to expected result.");
assertEquals(
"Generated POM Version is not equivalent to expected result.",
generatedModel.getVersion(),
templateModel.getVersion());
templateModel.getVersion(),
"Generated POM Version is not equivalent to expected result.");
assertEquals(
"Generated POM Packaging is not equivalent to expected result.",
generatedModel.getPackaging(),
templateModel.getPackaging());
templateModel.getPackaging(),
"Generated POM Packaging is not equivalent to expected result.");
assertEquals(
"Generated POM Developers is not equivalent to expected result.",
generatedModel.getDevelopers(),
templateModel.getDevelopers());
templateModel.getDevelopers(),
"Generated POM Developers is not equivalent to expected result.");
assertEquals(
"Generated POM Scm is not equivalent to expected result.",
generatedModel.getScm(),
templateModel.getScm());
templateModel.getScm(),
"Generated POM Scm is not equivalent to expected result.");
}

// Gets the classloader for this artifact's file.
Expand All @@ -218,6 +225,7 @@ private ClassLoader getContextClassloader(
return new URLClassLoader(urls);
}

@Test
public void testAddModuleToParentPOM() throws Exception {
String pom = "<project>\n" + " <packaging>pom</packaging>\n" + "</project>";

Expand Down Expand Up @@ -365,6 +373,7 @@ public void testAddModuleToParentPOM() throws Exception {
.normalizeWhitespace());
}

@Test
public void testAddModuleToParentPOMNoPackaging() throws Exception {
try {
String pom = "<project>\n</project>";
Expand All @@ -378,6 +387,7 @@ public void testAddModuleToParentPOMNoPackaging() throws Exception {
}
}

@Test
public void testAddModuleToParentPOMJarPackaging() throws Exception {
try {
String pom = "<project>\n <packaging>jar</packaging>\n</project>";
Expand All @@ -391,8 +401,8 @@ public void testAddModuleToParentPOMJarPackaging() throws Exception {
}
}

@Override
protected void setUp() throws Exception {
@BeforeEach
public void setUp() throws Exception {
super.setUp();
archetype = (OldArchetype) lookup(OldArchetype.ROLE);
}
Expand Down
Loading
Loading