Skip to content

Commit 957a483

Browse files
committed
Updated archetypes and created a test to keep archetype versions up-to-date
Signed-off-by: jansupol <jan.supol@oracle.com>
1 parent e40b9ac commit 957a483

File tree

4 files changed

+124
-4
lines changed
  • archetypes
    • jersey-heroku-webapp/src/main/resources/archetype-resources
    • jersey-quickstart-grizzly2/src/main/resources/archetype-resources
  • tests/release-test

4 files changed

+124
-4
lines changed

archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,19 @@
100100
<war>\${project.build.directory}/\${project.build.finalName}.war</war>
101101
</configuration>
102102
</plugin>
103+
<plugin>
104+
<!-- Surefire support for JUnit-5 -->
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-surefire-plugin</artifactId>
107+
<version>${surefire.mvn.plugin.version}</version>
108+
</plugin>
103109
</plugins>
104110
</build>
105111

106112
<properties>
107113
<jersey.version>${project.version}</jersey.version>
114+
<jetty.version>9.4.49.v20220914</jetty.version>
108115
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
109-
<jetty.version>9.4.28.v20200408</jetty.version>
116+
<surefire.mvn.plugin.version>3.0.0-M7</surefire.mvn.plugin.version>
110117
</properties>
111118
</project>

archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,19 @@
7272
<mainClass>\${package}.Main</mainClass>
7373
</configuration>
7474
</plugin>
75+
<plugin>
76+
<!-- Surefire support for JUnit-5 -->
77+
<groupId>org.apache.maven.plugins</groupId>
78+
<artifactId>maven-surefire-plugin</artifactId>
79+
<version>${surefire.mvn.plugin.version}</version>
80+
</plugin>
7581
</plugins>
7682
</build>
7783

7884
<properties>
7985
<jersey.version>${project.version}</jersey.version>
8086
<junit-jupiter.version>5.9.1</junit-jupiter.version>
8187
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
88+
<surefire.mvn.plugin.version>3.0.0-M7</surefire.mvn.plugin.version>
8289
</properties>
8390
</project>

tests/release-test/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
<reuseForks>false</reuseForks>
6060
<enableAssertions>false</enableAssertions>
6161
<includes>
62-
<include>**/NoticeFilesTest.class</include>
62+
<include>**/ArchetypesTest</include>
63+
<include>**/NoticeFilesTest</include>
6364
</includes>
6465
</configuration>
6566
</plugin>
@@ -154,8 +155,8 @@
154155
<reuseForks>false</reuseForks>
155156
<enableAssertions>false</enableAssertions>
156157
<includes>
157-
<include>**/DownloadBomPomDependencies.java</include>
158-
<include>**/*Test.class</include>
158+
<include>**/DownloadBomPomDependencies</include>
159+
<include>**/*Test</include>
159160
</includes>
160161
</configuration>
161162
</plugin>
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
package org.glassfish.jersey.test.artifacts;
17+
18+
import org.apache.maven.model.Model;
19+
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
20+
import org.junit.Assert;
21+
import org.junit.Test;
22+
23+
import java.io.File;
24+
import java.io.IOException;
25+
import java.util.Map;
26+
import java.util.Properties;
27+
28+
public class ArchetypesTest {
29+
public static final String[] archetypePoms = {
30+
"../../archetypes/jersey-example-java8-webapp/src/main/resources/archetype-resources/pom.xml",
31+
"../../archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/pom.xml",
32+
"../../archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/pom.xml",
33+
"../../archetypes/jersey-quickstart-webapp/src/main/resources/archetype-resources/pom.xml",
34+
};
35+
36+
@Test
37+
public void testPropertiesVersion() throws XmlPullParserException, IOException {
38+
Properties properties = MavenUtil.getModelFromFile("../../pom.xml").getProperties();
39+
// System.out.println(properties);
40+
TestResult testResult = new TestResult();
41+
for (String pom : archetypePoms) {
42+
File pomFile = new File(pom);
43+
Assert.assertTrue("The pom file " + pom + " does not exist", pomFile.exists());
44+
Assert.assertTrue("The pom file " + pom + " cannot be read", pomFile.canRead());
45+
46+
boolean failed = false;
47+
Model pomModel = MavenUtil.getModelFromFile(pom);
48+
Properties pomProperties = pomModel.getProperties();
49+
for (Map.Entry<Object, Object> pomEntry : pomProperties.entrySet()) {
50+
if (pomEntry.getKey().equals("jersey.config.test.container.port")) {
51+
// Skip the following
52+
continue;
53+
}
54+
// Update the names with the ones in Jersey
55+
Map.Entry<Object, Object> updatedEntry = updateEntry(pomEntry);
56+
// Check the properties are there
57+
if (properties.getProperty(updatedEntry.getKey().toString()) == null) {
58+
testResult.ok().append("Property ")
59+
.append(pomEntry.getKey().toString())
60+
.append(" from ").append(pom).println(" not in Jersey");
61+
failed = true;
62+
}
63+
// check the values
64+
else if (!properties.getProperty(updatedEntry.getKey().toString()).equals(updatedEntry.getValue())) {
65+
testResult.exception().append("The property ")
66+
.append(pomEntry.getKey().toString())
67+
.append(" in archetype pom ")
68+
.append(pom)
69+
.append(" not equals Jersey ")
70+
.println(properties.getProperty(pomEntry.getKey().toString()));
71+
failed = true;
72+
}
73+
}
74+
if (!failed) {
75+
testResult.ok().append("The properties in archetype pom ").append(pom).println(" equals Jersey");
76+
}
77+
}
78+
79+
if (!testResult.result()) {
80+
Assert.fail();
81+
}
82+
}
83+
84+
private Map.Entry<Object, Object> updateEntry(Map.Entry<Object, Object> pomEntry) {
85+
if (pomEntry.getKey().equals("junit-jupiter.version")) {
86+
return new Map.Entry<Object, Object>() {
87+
@Override
88+
public Object getKey() {
89+
return "junit5.version";
90+
}
91+
92+
@Override
93+
public Object getValue() {
94+
return pomEntry.getValue();
95+
}
96+
97+
@Override
98+
public Object setValue(Object value) {
99+
return value;
100+
}
101+
};
102+
}
103+
return pomEntry;
104+
}
105+
}

0 commit comments

Comments
 (0)