Updated archetypes and created a test to keep archetype versions up-to-date

Signed-off-by: jansupol <jan.supol@oracle.com>
diff --git a/archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/pom.xml b/archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/pom.xml
index 76219c4..81eec18 100644
--- a/archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/pom.xml
@@ -100,12 +100,19 @@
                     <war>\${project.build.directory}/\${project.build.finalName}.war</war>
                 </configuration>
             </plugin>
+            <plugin>
+                <!-- Surefire support for JUnit-5 -->
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.mvn.plugin.version}</version>
+            </plugin>
         </plugins>
     </build>
 
     <properties>
         <jersey.version>${project.version}</jersey.version>
+        <jetty.version>9.4.49.v20220914</jetty.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <jetty.version>9.4.28.v20200408</jetty.version>
+        <surefire.mvn.plugin.version>3.0.0-M7</surefire.mvn.plugin.version>
     </properties>
 </project>
diff --git a/archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/pom.xml b/archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/pom.xml
index 9dcb68b..0519417 100644
--- a/archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/pom.xml
@@ -72,6 +72,12 @@
                     <mainClass>\${package}.Main</mainClass>
                 </configuration>
             </plugin>
+            <plugin>
+                <!-- Surefire support for JUnit-5 -->
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.mvn.plugin.version}</version>
+            </plugin>
         </plugins>
     </build>
 
@@ -79,5 +85,6 @@
         <jersey.version>${project.version}</jersey.version>
         <junit-jupiter.version>5.9.1</junit-jupiter.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <surefire.mvn.plugin.version>3.0.0-M7</surefire.mvn.plugin.version>
     </properties>
 </project>
diff --git a/tests/release-test/pom.xml b/tests/release-test/pom.xml
index 159c2f7..e9d42d2 100644
--- a/tests/release-test/pom.xml
+++ b/tests/release-test/pom.xml
@@ -59,7 +59,8 @@
                     <reuseForks>false</reuseForks>
                     <enableAssertions>false</enableAssertions>
                     <includes>
-                        <include>**/NoticeFilesTest.class</include>
+                        <include>**/ArchetypesTest</include>
+                        <include>**/NoticeFilesTest</include>
                     </includes>
                 </configuration>
             </plugin>
@@ -154,8 +155,8 @@
                             <reuseForks>false</reuseForks>
                             <enableAssertions>false</enableAssertions>
                             <includes>
-                                <include>**/DownloadBomPomDependencies.java</include>
-                                <include>**/*Test.class</include>
+                                <include>**/DownloadBomPomDependencies</include>
+                                <include>**/*Test</include>
                             </includes>
                         </configuration>
                     </plugin>
diff --git a/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/ArchetypesTest.java b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/ArchetypesTest.java
new file mode 100644
index 0000000..b42830b
--- /dev/null
+++ b/tests/release-test/src/test/java/org/glassfish/jersey/test/artifacts/ArchetypesTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+package org.glassfish.jersey.test.artifacts;
+
+import org.apache.maven.model.Model;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+public class ArchetypesTest {
+    public static final String[] archetypePoms = {
+            "../../archetypes/jersey-example-java8-webapp/src/main/resources/archetype-resources/pom.xml",
+            "../../archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/pom.xml",
+            "../../archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/pom.xml",
+            "../../archetypes/jersey-quickstart-webapp/src/main/resources/archetype-resources/pom.xml",
+    };
+
+    @Test
+    public void testPropertiesVersion() throws XmlPullParserException, IOException {
+        Properties properties = MavenUtil.getModelFromFile("../../pom.xml").getProperties();
+//        System.out.println(properties);
+        TestResult testResult = new TestResult();
+        for (String pom : archetypePoms) {
+            File pomFile = new File(pom);
+            Assert.assertTrue("The pom file " + pom + " does not exist", pomFile.exists());
+            Assert.assertTrue("The pom file " + pom + " cannot be read", pomFile.canRead());
+
+            boolean failed = false;
+            Model pomModel = MavenUtil.getModelFromFile(pom);
+            Properties pomProperties = pomModel.getProperties();
+            for (Map.Entry<Object, Object> pomEntry : pomProperties.entrySet()) {
+                if (pomEntry.getKey().equals("jersey.config.test.container.port")) {
+                    // Skip the following
+                    continue;
+                }
+                // Update the names with the ones in Jersey
+                Map.Entry<Object, Object> updatedEntry = updateEntry(pomEntry);
+                // Check the properties are there
+                if (properties.getProperty(updatedEntry.getKey().toString()) == null) {
+                    testResult.ok().append("Property ")
+                            .append(pomEntry.getKey().toString())
+                            .append(" from ").append(pom).println(" not in Jersey");
+                    failed = true;
+                }
+                // check the values
+                else if (!properties.getProperty(updatedEntry.getKey().toString()).equals(updatedEntry.getValue())) {
+                    testResult.exception().append("The property ")
+                            .append(pomEntry.getKey().toString())
+                            .append(" in archetype pom ")
+                            .append(pom)
+                            .append(" not equals Jersey ")
+                            .println(properties.getProperty(pomEntry.getKey().toString()));
+                    failed = true;
+                }
+            }
+            if (!failed) {
+                testResult.ok().append("The properties in archetype pom ").append(pom).println(" equals Jersey");
+            }
+        }
+
+        if (!testResult.result()) {
+            Assert.fail();
+        }
+    }
+
+    private Map.Entry<Object, Object> updateEntry(Map.Entry<Object, Object> pomEntry) {
+        if (pomEntry.getKey().equals("junit-jupiter.version")) {
+            return new Map.Entry<Object, Object>() {
+                @Override
+                public Object getKey() {
+                    return "junit5.version";
+                }
+
+                @Override
+                public Object getValue() {
+                    return pomEntry.getValue();
+                }
+
+                @Override
+                public Object setValue(Object value) {
+                    return value;
+                }
+            };
+        }
+        return pomEntry;
+    }
+}