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 76219c4246..81eec1824a 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 @@ \${project.build.directory}/\${project.build.finalName}.war + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.mvn.plugin.version} + ${project.version} + 9.4.49.v20220914 UTF-8 - 9.4.28.v20200408 + 3.0.0-M7 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 9dcb68bb61..0519417080 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 @@ \${package}.Main + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.mvn.plugin.version} + @@ -79,5 +85,6 @@ ${project.version} 5.9.1 UTF-8 + 3.0.0-M7 diff --git a/tests/release-test/pom.xml b/tests/release-test/pom.xml index 159c2f76fb..e9d42d2eaa 100644 --- a/tests/release-test/pom.xml +++ b/tests/release-test/pom.xml @@ -59,7 +59,8 @@ false false - **/NoticeFilesTest.class + **/ArchetypesTest + **/NoticeFilesTest @@ -154,8 +155,8 @@ false false - **/DownloadBomPomDependencies.java - **/*Test.class + **/DownloadBomPomDependencies + **/*Test 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 0000000000..b42830ba54 --- /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 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 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 updateEntry(Map.Entry pomEntry) { + if (pomEntry.getKey().equals("junit-jupiter.version")) { + return new Map.Entry() { + @Override + public Object getKey() { + return "junit5.version"; + } + + @Override + public Object getValue() { + return pomEntry.getValue(); + } + + @Override + public Object setValue(Object value) { + return value; + } + }; + } + return pomEntry; + } +}