diff --git a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml
index 9419f9d5..abf0470d 100644
--- a/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/alfresco-allinone-archetype/src/main/resources/archetype-resources/pom.xml
@@ -40,7 +40,7 @@
8888
5555
-
+ @@test.acs.endpoint.path@@
diff --git a/archetypes/archetypes-it/pom.xml b/archetypes/archetypes-it/pom.xml
index 728945d2..e27bd223 100644
--- a/archetypes/archetypes-it/pom.xml
+++ b/archetypes/archetypes-it/pom.xml
@@ -1,19 +1,20 @@
-
- 4.0.0
+
+ 4.0.0
- org.alfresco.maven.archetype
- archetypes-it
- maven-archetype
- Alfresco SDK - All-in-One Archetype
- Sample multi-module project for All-in-One development on the Alfresco platform. Includes modules for Platform/Repository JAR and Share JAR
+ org.alfresco.maven.archetype
+ archetypes-it
+ jar
+ Archetypes IT
+ Archetypes Integration Tests
-
- org.alfresco.maven
- alfresco-sdk-aggregator
- 4.0.0-SNAPSHOT
- ../../pom.xml
-
+
+ org.alfresco.maven
+ alfresco-sdk-aggregator
+ 4.0.0-SNAPSHOT
+ ../../pom.xml
+
@@ -26,9 +27,35 @@
junit
junit
4.8.1
- jar
test
+
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+ 2.19.1
+
+
+ integration-test
+ integration-test
+
+ integration-test
+
+
+
+ verify-test
+ verify
+
+ verify
+
+
+
+
+
+
diff --git a/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/AbstractArchetypeIT.java b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/AbstractArchetypeIT.java
index 2e0c4509..0a1d9bcd 100644
--- a/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/AbstractArchetypeIT.java
+++ b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/AbstractArchetypeIT.java
@@ -1,13 +1,17 @@
-package org.alfresco.maven.archetype.allinone;
+package org.alfresco.maven.archetype;
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.junit.Before;
-import org.junit.Test;
import java.io.File;
import java.io.IOException;
+/**
+ * Exposes the core functionality required to generate a new project from an archetype and execute some of the goals of the runner scripts.
+ *
+ * @author Jose Luis Osorno
+ */
public abstract class AbstractArchetypeIT {
protected static final File ROOT = new File("target/test-classes/");
@@ -26,14 +30,23 @@ public abstract class AbstractArchetypeIT {
Verifier verifier = new Verifier(ROOT.getAbsolutePath());
// Deleting a former created artifact from the archetype to be tested
- verifier.deleteArtifact(archetypeProperties.getProjectGroupId(), archetypeProperties.getProjectArtifactId(), archetypeProperties.getProjectVersion(), null);
+ verifier.deleteArtifact(archetypeProperties.getProjectGroupId(), archetypeProperties.getProjectArtifactId(), archetypeProperties.getProjectVersion(),
+ null);
// Delete the created maven project
verifier.deleteDirectory(archetypeProperties.getProjectArtifactId());
}
+ /**
+ * Create the {@link ArchetypeProperties} object with the details of the archetype to use and the project to generate in the test.
+ *
+ * @return the {@link ArchetypeProperties} object with the details of the archetype to use and the project to generate in the test
+ */
protected abstract ArchetypeProperties createArchetypeProperties();
- protected void generateProject() throws Exception {
+ /**
+ * Generate a new project from an archetype and verify the generation was successful.
+ */
+ protected void generateProjectFromArchetype() throws Exception {
Verifier verifier = new Verifier(ROOT.getAbsolutePath());
verifier.setSystemProperties(archetypeProperties.getSystemProperties());
verifier.setAutoclean(false);
@@ -41,8 +54,14 @@ public abstract class AbstractArchetypeIT {
verifier.verifyErrorFreeLog();
}
- protected ProcessBuilder getProcessBuilder() {
- ProcessBuilder pb = new ProcessBuilder(getCommand(),"build_test");
+ /**
+ * Generate a {@link ProcessBuilder} with the project runner script to execute an specific goal.
+ *
+ * @param goalToExecute the goal to be executed in the {@link ProcessBuilder}
+ * @return the generated {@link ProcessBuilder}
+ */
+ protected ProcessBuilder getProcessBuilder(final String goalToExecute) {
+ ProcessBuilder pb = new ProcessBuilder(getCommand(), goalToExecute);
pb.directory(new File(projectPath));
pb.redirectOutput(new File(projectPath + File.separator + LOG_FILENAME));
pb.redirectError(new File(projectPath + File.separator + ERROR_FILENAME));
@@ -50,6 +69,6 @@ public abstract class AbstractArchetypeIT {
}
private String getCommand() {
- return projectPath + File.separator + (System.getProperty( "os.name" ).startsWith( "Windows" ) ? WINDOWS_EXEC : LINUX_EXEC);
+ return projectPath + File.separator + (System.getProperty("os.name").startsWith("Windows") ? WINDOWS_EXEC : LINUX_EXEC);
}
}
diff --git a/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/AllInOneArchetypeIT.java b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/AllInOneArchetypeIT.java
new file mode 100644
index 00000000..c382dd53
--- /dev/null
+++ b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/AllInOneArchetypeIT.java
@@ -0,0 +1,39 @@
+package org.alfresco.maven.archetype;
+
+import org.apache.maven.it.Verifier;
+import org.junit.Test;
+
+/**
+ * Integration tests for the all-in-one archetype.
+ */
+public class AllInOneArchetypeIT extends AbstractArchetypeIT {
+
+ @Override
+ protected ArchetypeProperties createArchetypeProperties() {
+ return ArchetypeProperties.builder()
+ .withArchetypeGroupId("org.alfresco.maven.archetype")
+ .withArchetypeArtifactId("alfresco-allinone-archetype")
+ .withArchetypeVersion("4.0.0-SNAPSHOT")
+ .withProjectGroupId("archetype.it")
+ .withProjectArtifactId("allinone-test-run")
+ .withProjectVersion("0.1-SNAPSHOT")
+ .build();
+ }
+
+ @Test
+ public void whenGenerateProjectFromArchetypeThenAProperProjectIsCreated() throws Exception {
+
+ generateProjectFromArchetype();
+
+ // Since creating the archetype was successful, we now want to actually build the generated project executing the integration tests
+ ProcessBuilder pb = getProcessBuilder("build_test");
+ pb.start().waitFor();
+
+ // Verify the execution of the integration tests of the project were successful
+ Verifier verifier = new Verifier(projectPath);
+ verifier.setAutoclean(false);
+ verifier.setLogFileName(LOG_FILENAME);
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog("Tests run: 5, Failures: 0, Errors: 0, Skipped: 0");
+ }
+}
diff --git a/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/ArchetypeProperties.java b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/ArchetypeProperties.java
new file mode 100644
index 00000000..d473e837
--- /dev/null
+++ b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/ArchetypeProperties.java
@@ -0,0 +1,115 @@
+package org.alfresco.maven.archetype;
+
+import java.util.Properties;
+
+/**
+ * Represent the properties of a project generation execution from a maven archetype.
+ *
+ * @author Jose Luis Osorno
+ */
+public class ArchetypeProperties {
+
+ private final String archetypeGroupId;
+ private final String archetypeArtifactId;
+ private final String archetypeVersion;
+ private final String projectGroupId;
+ private final String projectArtifactId;
+ private final String projectVersion;
+
+ private ArchetypeProperties(String archetypeGroupId, String archetypeArtifactId, String archetypeVersion, String projectGroupId,
+ String projectArtifactId, String projectVersion) {
+ this.archetypeGroupId = archetypeGroupId;
+ this.archetypeArtifactId = archetypeArtifactId;
+ this.archetypeVersion = archetypeVersion;
+ this.projectGroupId = projectGroupId;
+ this.projectArtifactId = projectArtifactId;
+ this.projectVersion = projectVersion;
+ }
+
+ public static ArchetypePropertiesBuilder builder() {
+ return new ArchetypePropertiesBuilder();
+ }
+
+ public Properties getSystemProperties() {
+ Properties props = new Properties(System.getProperties());
+ props.put("archetypeGroupId", archetypeGroupId);
+ props.put("archetypeArtifactId", archetypeArtifactId);
+ props.put("archetypeVersion", archetypeVersion);
+ props.put("groupId", projectGroupId);
+ props.put("artifactId", projectArtifactId);
+ props.put("version", projectVersion);
+ props.put("interactiveMode", "false");
+ return props;
+ }
+
+ public String getArchetypeGroupId() {
+ return archetypeGroupId;
+ }
+
+ public String getArchetypeArtifactId() {
+ return archetypeArtifactId;
+ }
+
+ public String getArchetypeVersion() {
+ return archetypeVersion;
+ }
+
+ public String getProjectGroupId() {
+ return projectGroupId;
+ }
+
+ public String getProjectArtifactId() {
+ return projectArtifactId;
+ }
+
+ public String getProjectVersion() {
+ return projectVersion;
+ }
+
+ public static class ArchetypePropertiesBuilder {
+ private String archetypeGroupId;
+ private String archetypeArtifactId;
+ private String archetypeVersion;
+ private String projectGroupId;
+ private String projectArtifactId;
+ private String projectVersion;
+
+ private ArchetypePropertiesBuilder() {
+ }
+
+ public ArchetypePropertiesBuilder withArchetypeGroupId(final String archetypeGroupId) {
+ this.archetypeGroupId = archetypeGroupId;
+ return this;
+ }
+
+ public ArchetypePropertiesBuilder withArchetypeArtifactId(final String archetypeArtifactId) {
+ this.archetypeArtifactId = archetypeArtifactId;
+ return this;
+ }
+
+ public ArchetypePropertiesBuilder withArchetypeVersion(final String archetypeVersion) {
+ this.archetypeVersion = archetypeVersion;
+ return this;
+ }
+
+ public ArchetypePropertiesBuilder withProjectGroupId(final String projectGroupId) {
+ this.projectGroupId = projectGroupId;
+ return this;
+ }
+
+ public ArchetypePropertiesBuilder withProjectArtifactId(final String projectArtifactId) {
+ this.projectArtifactId = projectArtifactId;
+ return this;
+ }
+
+ public ArchetypePropertiesBuilder withProjectVersion(final String projectVersion) {
+ this.projectVersion = projectVersion;
+ return this;
+ }
+
+ public ArchetypeProperties build() {
+ return new ArchetypeProperties(archetypeGroupId, archetypeArtifactId, archetypeVersion, projectGroupId,
+ projectArtifactId, projectVersion);
+ }
+ }
+}
diff --git a/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/PlatformJarArchetypeIT.java b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/PlatformJarArchetypeIT.java
new file mode 100644
index 00000000..4f824ef7
--- /dev/null
+++ b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/PlatformJarArchetypeIT.java
@@ -0,0 +1,33 @@
+package org.alfresco.maven.archetype;
+
+import org.apache.maven.it.Verifier;
+import org.junit.Test;
+
+/**
+ * Integration tests for the platform jar archetype.
+ */
+public class PlatformJarArchetypeIT extends AbstractArchetypeIT {
+
+ @Override
+ protected ArchetypeProperties createArchetypeProperties() {
+ return ArchetypeProperties.builder()
+ .withArchetypeGroupId("org.alfresco.maven.archetype")
+ .withArchetypeArtifactId("alfresco-platform-jar-archetype")
+ .withArchetypeVersion("4.0.0-SNAPSHOT")
+ .withProjectGroupId("archetype.it")
+ .withProjectArtifactId("repojar-test-run")
+ .withProjectVersion("0.1-SNAPSHOT")
+ .build();
+ }
+
+ @Test
+ public void whenGenerateProjectFromArchetypeThenAProperProjectIsCreated() throws Exception {
+ generateProjectFromArchetype();
+
+ // Since creating the archetype was successful, we now want to actually build the generated project
+ Verifier verifier = new Verifier(projectPath);
+ verifier.setAutoclean(false);
+ verifier.executeGoal("install");
+ verifier.verifyErrorFreeLog();
+ }
+}
diff --git a/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/ShareJarArchetypeIT.java b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/ShareJarArchetypeIT.java
new file mode 100644
index 00000000..063d39d4
--- /dev/null
+++ b/archetypes/archetypes-it/src/test/java/org/alfresco/maven/archetype/ShareJarArchetypeIT.java
@@ -0,0 +1,33 @@
+package org.alfresco.maven.archetype;
+
+import org.apache.maven.it.Verifier;
+import org.junit.Test;
+
+/**
+ * Integration tests for the share jar archetype.
+ */
+public class ShareJarArchetypeIT extends AbstractArchetypeIT {
+
+ @Override
+ protected ArchetypeProperties createArchetypeProperties() {
+ return ArchetypeProperties.builder()
+ .withArchetypeGroupId("org.alfresco.maven.archetype")
+ .withArchetypeArtifactId("alfresco-share-jar-archetype")
+ .withArchetypeVersion("4.0.0-SNAPSHOT")
+ .withProjectGroupId("archetype.it")
+ .withProjectArtifactId("sharejar-test-run")
+ .withProjectVersion("0.1-SNAPSHOT")
+ .build();
+ }
+
+ @Test
+ public void whenGenerateProjectFromArchetypeThenAProperProjectIsCreated() throws Exception {
+ generateProjectFromArchetype();
+
+ // Since creating the archetype was successful, we now want to actually build the generated project
+ Verifier verifier = new Verifier(projectPath);
+ verifier.setAutoclean(false);
+ verifier.executeGoal("install");
+ verifier.verifyErrorFreeLog();
+ }
+}