diff --git a/NOTICE.md b/NOTICE.md
index 3a821056..cc882912 100644
--- a/NOTICE.md
+++ b/NOTICE.md
@@ -33,29 +33,22 @@ The project maintains the following source code repositories:
* https://github.com/eclipse-ee4j/tyrus
## Third-party Content
-The following non-EPL 2.0 code is distributed in Tyrus bundles:
+This project leverages the following third party content:
-jakarta.activation 2.0
-* License: BSD-3-Clause
-* Copyright (c) 2018 Oracle and/or its affiliates
-
-jakarta.enterprise.cdi-api Version 3.0.0
+jakarta.enterprise.cdi-api Version 4.0.1
* License: Apache License, 2.0
* Copyright 2010, Red Hat, Inc., and individual contributors
-jakarta.inject Version: 2.0
+jakarta.inject Version: 2.0.1
* License: Apache License, 2.0
* Copyright (C) 2009 The JSR-330 Expert Group
-jakarta.xml.bind-api Version: 3.0
-* License: BSD-3-Clause
-* Copyright (c) 2017, 2018 Oracle and/or its affiliates
-
-jline (2.14.5)
+jline Version: 2.14.5
* License: BSD-3-Clause
* Project: https://github.com/jline/jline2
* Source: https://github.com/jline/jline2
+
## Cryptography
Content may contain encryption software. The country in which you are currently
diff --git a/archetypes/echo/pom.xml b/archetypes/echo/pom.xml
index 2f0f8e1b..8c70c33d 100644
--- a/archetypes/echo/pom.xml
+++ b/archetypes/echo/pom.xml
@@ -1,7 +1,7 @@
2.1.1
+ 2.1.2
4.0.1
4.0.1
4.0.0
7.0.9
+ 2.0.1
+ 4.0.1
+ 4.0.4
+ 2.14.5
2.1.2
1.1.4
- 4.0.1
- 4.0.3
- 3.3.1
6.0.0
2.6.7
+
+ 3.11.0
+ 3.6.2
3.2.1
+ 3.4.0
jakarta.websocket
org.glassfish
0.0
- 2.0
- 2.0
+ 2.1
+ 2.1
11
- 2.0.0
+ 2.1.0
0.0.0
${api_package}
@@ -133,7 +138,7 @@
org.glassfish.*
- 2.1.0
+ 2.1.1
${spec_version}.99.b${build_number}
${new_impl_version}-b${build_number}
${spec_version}.99.b${build_number}
@@ -290,6 +295,15 @@
{maven-resources},${project.build.directory}/legal
+
+
+ osgi-bundle
+ package
+
+ bundle
+
+
+
org.apache.maven.plugins
@@ -326,7 +340,6 @@
maven-jaxb-plugin
1.1.1
-
@@ -351,7 +364,6 @@
org.apache.maven.plugins
maven-source-plugin
- 3.2.0
attach-sources
@@ -370,7 +382,6 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.10.1
11
@@ -389,7 +400,6 @@
org.apache.maven.plugins
maven-deploy-plugin
- 2.8.1
10
@@ -438,7 +448,7 @@
org.apache.maven.plugins
maven-resources-plugin
- 2.6
+ 3.3.1
true
@@ -519,7 +529,6 @@
org.apache.maven.plugins
maven-release-plugin
- 2.5
forked-path
false
@@ -530,7 +539,6 @@
org.apache.maven.plugins
maven-javadoc-plugin
- ${maven-javadoc-plugin.version}
128m
512m
@@ -556,7 +564,6 @@
org.apache.maven.plugins
maven-javadoc-plugin
- ${maven-javadoc-plugin.version}
*.tests.*,*.sample.*
128m
@@ -598,7 +605,6 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.0.0
etc/config/checkstyle.xml
diff --git a/tests/e2e/standard-config/src/test/java/org/glassfish/tyrus/test/standard_config/HandshakeTest.java b/tests/e2e/standard-config/src/test/java/org/glassfish/tyrus/test/standard_config/HandshakeTest.java
index 42fa16db..fc800e83 100755
--- a/tests/e2e/standard-config/src/test/java/org/glassfish/tyrus/test/standard_config/HandshakeTest.java
+++ b/tests/e2e/standard-config/src/test/java/org/glassfish/tyrus/test/standard_config/HandshakeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -18,20 +18,26 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
import jakarta.websocket.ClientEndpointConfig;
import jakarta.websocket.DeploymentException;
import jakarta.websocket.EndpointConfig;
import jakarta.websocket.HandshakeResponse;
+import jakarta.websocket.OnMessage;
import jakarta.websocket.Session;
import jakarta.websocket.server.HandshakeRequest;
+import jakarta.websocket.server.ServerEndpoint;
+import jakarta.websocket.server.ServerEndpointConfig;
import org.glassfish.tyrus.client.ClientManager;
import org.glassfish.tyrus.server.Server;
+import org.glassfish.tyrus.spi.UpgradeResponse;
import org.glassfish.tyrus.test.standard_config.bean.TestEndpoint;
import org.glassfish.tyrus.test.tools.TestContainer;
@@ -118,4 +124,72 @@ public void onOpen(Session session) {
stopServer(server);
}
}
+
+
+ static final int STATUS = 499;
+ static final String HEADER = "TEST_HEADER";
+
+ public static class StatusSetterConfiguration extends ServerEndpointConfig.Configurator {
+ @Override
+ public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
+ ((UpgradeResponse) response).setStatus(STATUS);
+ response.getHeaders().put(HEADER, Collections.singletonList(HEADER));
+ }
+ }
+
+ @Test
+ public void customResponseTest() throws DeploymentException, IOException {
+ @ServerEndpoint(value = "/status", configurator = StatusSetterConfiguration.class)
+ class StatusSetterEndpoint {
+ @OnMessage
+ public void onMessage(String message) {
+ throw new IllegalStateException("ON MESSAGE");
+ }
+ }
+
+ final AtomicReference status = new AtomicReference<>();
+ final AtomicReference header = new AtomicReference<>();
+
+ Server server = startServer(StatusSetterEndpoint.class);
+
+ ClientEndpointConfig.Configurator cecc = new ClientEndpointConfig.Configurator() {
+ @Override
+ public void afterResponse(HandshakeResponse hr) {
+ status.set(((UpgradeResponse) hr).getStatus());
+ header.set(((UpgradeResponse) hr).getFirstHeaderValue(HEADER));
+ }
+ };
+
+ ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().configurator(cecc).build();
+
+ try {
+ ClientManager client = createClient();
+ Session session = client.connectToServer(new TestEndpointAdapter() {
+ @Override
+ public void onMessage(String message) {
+ }
+
+ @Override
+ public void onOpen(Session session) {
+ try {
+ session.getBasicRemote().sendText("This should never be sent");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public EndpointConfig getEndpointConfig() {
+ return cec;
+ }
+ }, cec, getURI(StatusSetterEndpoint.class));
+
+ throw new IllegalStateException("DeploymentException was not thrown");
+ } catch (DeploymentException de) {
+ Assert.assertEquals(STATUS, status.get().intValue());
+ Assert.assertEquals(HEADER, header.get());
+ } finally {
+ server.stop();
+ }
+ }
}
diff --git a/tests/pom.xml b/tests/pom.xml
index eb8dd7bc..8312fe80 100755
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -33,6 +33,7 @@
containers
e2e
+ release-test
servlet
tools
diff --git a/tests/qa/browser-test/src/test/java/org/glassfish/tyrus/tests/qa/BrowserTest.java b/tests/qa/browser-test/src/test/java/org/glassfish/tyrus/tests/qa/BrowserTest.java
index 09d1f59b..0c567c70 100644
--- a/tests/qa/browser-test/src/test/java/org/glassfish/tyrus/tests/qa/BrowserTest.java
+++ b/tests/qa/browser-test/src/test/java/org/glassfish/tyrus/tests/qa/BrowserTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -68,8 +68,8 @@ private void twoClientsChat(SeleniumToolkit.Browser alice, SeleniumToolkit.Brows
}
private void chatScalabitlity(SeleniumToolkit.Browser browser) throws InterruptedException, Exception {
- logger.log(Level.INFO, "=============testScalabilityWith" + TestScenarios.MAX_CHAT_CLIENTS +
- "Users===============================");
+ logger.log(Level.INFO, "=============testScalabilityWith" + TestScenarios.MAX_CHAT_CLIENTS
+ + "Users===============================");
List toolkits = new ArrayList();
// Launch 100 browsers
for (int idx = 0; idx < TestScenarios.MAX_CHAT_CLIENTS; idx++) {
diff --git a/tests/qa/browser-test/src/test/java/org/glassfish/tyrus/tests/qa/SeleniumToolkit.java b/tests/qa/browser-test/src/test/java/org/glassfish/tyrus/tests/qa/SeleniumToolkit.java
index f79b8ad8..2a2add3c 100644
--- a/tests/qa/browser-test/src/test/java/org/glassfish/tyrus/tests/qa/SeleniumToolkit.java
+++ b/tests/qa/browser-test/src/test/java/org/glassfish/tyrus/tests/qa/SeleniumToolkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -20,14 +20,19 @@
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.io.FileUtils;
-import org.openqa.selenium.*;
+import org.openqa.selenium.By;
+import org.openqa.selenium.ChromeDriverService;
+import org.openqa.selenium.FirefoxProfile;
+import org.openqa.selenium.InternetExplorerDriverService;
+import org.openqa.selenium.Platform;
+import org.openqa.selenium.SafariDriver;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.firefox.FirefoxBinary;
@@ -44,11 +49,9 @@
public class SeleniumToolkit {
enum Browser {
-
FIREFOX, IE, CHROME, SAFARI
}
- ;
private final String WIN_FIREFOX_BIN = "C:/Program Files (x86)/Mozilla Firefox/firefox.exe";
private static final Logger logger = Logger.getLogger(SeleniumToolkit.class.getCanonicalName());
private static List webDriverInstances = new CopyOnWriteArrayList();
@@ -147,8 +150,8 @@ public void setUpChrome() {
public void setUpExplorer() {
try {
System.setProperty(InternetExplorerDriverService.IE_DRIVER_EXE_PROPERTY, getEnv("IE_DRIVER"));
- assert new File(System.getProperty(InternetExplorerDriverService.IE_DRIVER_EXE_PROPERTY)).exists() :
- "IE_DRIVER exists";
+ assert new File(System.getProperty(InternetExplorerDriverService.IE_DRIVER_EXE_PROPERTY)).exists()
+ : "IE_DRIVER exists";
driver = new InternetExplorerDriver();
commonBrowserSetup();
logger.log(Level.INFO, "IE Setup PASSED");
diff --git a/tests/release-test/README.MD b/tests/release-test/README.MD
new file mode 100644
index 00000000..a8e96a58
--- /dev/null
+++ b/tests/release-test/README.MD
@@ -0,0 +1,20 @@
+[//]: # " 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 "
+
+This module is to check the built artifacts before release.
+
+The module can check Tyrus 1.x, 2.0.x, and 2.1.x versions.
+
+Usage:
+ * mvn test -Dtyrus.version= [-Pstaging]
diff --git a/tests/release-test/pom.xml b/tests/release-test/pom.xml
new file mode 100644
index 00000000..1a3d1a82
--- /dev/null
+++ b/tests/release-test/pom.xml
@@ -0,0 +1,180 @@
+
+
+
+
+ 4.0.0
+
+
+ org.glassfish.tyrus
+ tyrus-project
+ 2.1.99-SNAPSHOT
+ ../../pom.xml
+
+
+ org.glassfish.tyrus.tests
+ tyrus-release-test
+ jar
+ Tyrus Release Test
+
+ Tyrus post-release validation tests
+
+
+ 11
+ 11
+ 3.8.6
+ 1.7.3
+ 4.5.14
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ 1
+ false
+ false
+
+ **/ArchetypesTest
+ **/NoticeFilesTest
+
+
+
+
+
+
+
+
+
+ org.glassfish.tyrus
+ tyrus-bom
+ ${project.version}
+ import
+ pom
+
+
+
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+
+
+ org.apache.maven
+ maven-core
+ ${maven.version}
+ provided
+
+
+ org.apache.maven
+ maven-model
+ ${maven.version}
+ provided
+
+
+ org.apache.maven
+ maven-compat
+ ${maven.version}
+ provided
+
+
+ org.apache.httpcomponents
+ httpclient
+ ${httpclient.version}
+ test
+
+
+
+ org.apache.maven.plugin-testing
+ maven-plugin-testing-harness
+ 3.3.0
+ test
+
+
+ org.apache.maven.resolver
+ maven-resolver-connector-basic
+ ${maven.resolver.version}
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-http
+ ${maven.resolver.version}
+
+
+ org.apache.httpcomponents
+ httpcore
+
+
+
+
+
+ org.glassfish.tyrus
+ tyrus-core
+
+
+
+
+
+ ReleaseTests
+
+
+ tyrus.version
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M7
+
+ 1
+ false
+ false
+
+ **/DownloadBomPomDependencies
+ **/*Test
+
+
+
+
+
+
+
+
+ org.glassfish.tyrus
+ tyrus-bom
+ ${tyrus.version}
+ import
+ pom
+
+
+
+
+ ${tyrus.version}
+
+
+
+
diff --git a/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/ClassVersionChecker.java b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/ClassVersionChecker.java
new file mode 100644
index 00000000..f988c01f
--- /dev/null
+++ b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/ClassVersionChecker.java
@@ -0,0 +1,57 @@
+/*
+ * 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.tyrus.test.artifacts;
+
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+class ClassVersionChecker {
+ static TestResult checkClassVersion(JarFile jar, JarEntry entry, Properties properties) throws IOException {
+ final String tyrusVersion = MavenUtil.getTyrusVersion(properties);
+ final int minVersion = tyrusVersion.startsWith("2.1") ? 11 : 8;
+ return checkClassVersion(jar.getInputStream(entry), jar.getName() + File.separator + entry.getName(), minVersion);
+ }
+
+ private static TestResult checkClassVersion(InputStream inputStream, String filename, int version) throws IOException {
+ TestResult result = new TestResult();
+ DataInputStream in = new DataInputStream(inputStream);
+
+ int magic = in.readInt();
+ if (magic != -889275714) {
+ result.exception().append(filename).println(" is not a valid class!");
+ }
+
+ int minor = in.readUnsignedShort();
+ int major = in.readUnsignedShort();
+ int classVersion = convertMajorMinorToSE(major, minor);
+ TestResult.MessageBuilder builder = classVersion <= version ? result.ok() : result.exception();
+ builder.append(filename).append(": ").append(major).append(".").append(minor).append(" = JDK ")
+ .println(String.valueOf(classVersion));
+ in.close();
+ return result;
+ }
+
+ private static int convertMajorMinorToSE(int major, int minor) {
+ int comp = (major - 44 + minor);
+ return comp;
+ }
+}
diff --git a/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/DependencyPair.java b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/DependencyPair.java
new file mode 100644
index 00000000..73514601
--- /dev/null
+++ b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/DependencyPair.java
@@ -0,0 +1,48 @@
+/*
+ * 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.tyrus.test.artifacts;
+
+import java.util.Arrays;
+
+class DependencyPair {
+ private final String groupId;
+ private final String artifactId;
+
+ DependencyPair(String groupId, String artifactId) {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ }
+
+ String artifactId() {
+ return artifactId;
+ }
+
+ String groupId() {
+ return groupId;
+ }
+
+ static DependencyPair[] concat(DependencyPair[] first, DependencyPair[] second) {
+ DependencyPair[] result = Arrays.copyOf(first, first.length + second.length);
+ System.arraycopy(second, 0, result, first.length, second.length);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return groupId + ':' + artifactId;
+ }
+}
diff --git a/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/DependencyResolver.java b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/DependencyResolver.java
new file mode 100644
index 00000000..6227b25b
--- /dev/null
+++ b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/DependencyResolver.java
@@ -0,0 +1,45 @@
+/*
+ * 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.tyrus.test.artifacts;
+
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.ArtifactRequest;
+import org.eclipse.aether.resolution.ArtifactResolutionException;
+
+import java.util.List;
+
+/**
+ *
+ * @author lukas
+ */
+final class DependencyResolver {
+ static Artifact resolveArtifact(org.apache.maven.model.Dependency d, List remoteRepos,
+ RepositorySystem repoSystem, RepositorySystemSession repoSession)
+ throws ArtifactResolutionException {
+ DefaultArtifact artifact = new DefaultArtifact(
+ d.getGroupId(), d.getArtifactId(), d.getClassifier(), d.getType(), d.getVersion()
+ );
+ ArtifactRequest request = new ArtifactRequest();
+ request.setArtifact(artifact);
+ request.setRepositories(remoteRepos);
+ return repoSystem.resolveArtifact(repoSession, request).getArtifact();
+ }
+}
\ No newline at end of file
diff --git a/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/MavenUtil.java b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/MavenUtil.java
new file mode 100644
index 00000000..a3fd4221
--- /dev/null
+++ b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/MavenUtil.java
@@ -0,0 +1,171 @@
+/*
+ * 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.tyrus.test.artifacts;
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Profile;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.file.Files;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.stream.Stream;
+
+public final class MavenUtil {
+
+ static final String TYRUS_VERSION = "tyrus.version";
+ private static final String PROJECT_VERSION = "project.version";
+
+ static File getArtifactJar(File repositoryRoot, Dependency dependency, Properties properties) {
+ return getArtifactFile(repositoryRoot, dependency, properties, "jar");
+ }
+
+ private static File getArtifactFile(File repositoryRoot, Dependency dependency, Properties properties, String extension) {
+ StringBuilder fileSuffix = new StringBuilder();
+ String groupIdParts[] = dependency.getGroupId().split("\\.");
+ for (String groupIdPart : groupIdParts) {
+ fileSuffix.append(groupIdPart).append(File.separator);
+ }
+ String artifactIdParts[] = dependency.getArtifactId().split("\\.");
+ for (String artifactIdPart : artifactIdParts) {
+ fileSuffix.append(artifactIdPart).append(File.separator);
+ }
+ String version = MavenUtil.getDependencyVersion(dependency, properties);
+ fileSuffix.append(version).append(File.separator);
+ fileSuffix.append(dependency.getArtifactId()).append('-').append(version).append(".").append(extension);
+ return new File(repositoryRoot, fileSuffix.toString());
+ }
+
+ static String getDependencyVersion(Dependency dependency, Properties properties) {
+ String version = dependency.getVersion();
+ if (version.startsWith("${") && version.endsWith("}")) {
+ String property = version.substring(2, version.length() - 1);
+ final String value;
+ switch (property) {
+ case TYRUS_VERSION: // in pom.xml
+ case PROJECT_VERSION: // in bom.pom
+ value = getTyrusVersion(properties);
+ break;
+ default:
+ value = properties.getProperty(property);
+ break;
+ }
+ version = value == null ? version : value;
+ }
+ return version;
+ }
+
+ static File getLocalMavenRepository() {
+ String folder = System.getProperty("localRepository");
+ return new File(folder);
+ }
+
+ static Properties getMavenProperties() {
+ try {
+ Model model = getModelFromFile("pom.xml");
+ return model.getProperties();
+ } catch (XmlPullParserException | IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ static Stream keepTyrusJars(Stream stream, DependencyPair... keep) {
+ return stream.filter(dependency -> {
+ for (DependencyPair pair : keep) {
+ if (dependency.getGroupId().equals(pair.groupId()) && dependency.getArtifactId().equals(pair.artifactId())) {
+ return true;
+ }
+ }
+ return false;
+ });
+ }
+
+ static Stream streamTyrusJars() throws IOException, XmlPullParserException {
+ Model model = getModelFromFile("pom.xml");
+ List deps = getBomPomDependencies(model);
+
+ return deps.stream()
+ .filter(dep -> dep.getGroupId().startsWith("org.glassfish.tyrus"))
+ .filter(dep -> dep.getType().equals("jar"));
+ }
+
+ static Model getModelFromFile(String fileName) throws IOException, XmlPullParserException {
+ File pomFile = new File(fileName);
+ return getModelFromFile(pomFile);
+ }
+
+ private static Model getModelFromFile(File file) throws IOException, XmlPullParserException {
+ MavenXpp3Reader mavenReader = new MavenXpp3Reader();
+ try (Reader fileReader = Files.newBufferedReader(file.toPath())) {
+ Model model = mavenReader.read(fileReader);
+ return model;
+ }
+ }
+
+ private static List getBomPomDependencies(Model model) throws IOException, XmlPullParserException {
+ Dependency bomPom = null;
+ List dependencies = model.getDependencyManagement().getDependencies();
+ for (Dependency dependency : dependencies) {
+ if (dependency.getGroupId().equals("org.glassfish.tyrus") && dependency.getArtifactId().equals("tyrus-bom")) {
+ bomPom = dependency;
+ break;
+ }
+ }
+ if (bomPom == null) {
+ throw new IllegalStateException("Bom pom not found");
+ }
+ File pom = getArtifactFile(getLocalMavenRepository(), bomPom, model.getProperties(), "pom");
+ Model bomPomModel = getModelFromFile(pom);
+ return bomPomModel.getDependencyManagement().getDependencies();
+ }
+
+ static String getTyrusVersion(Properties properties) {
+ String property = properties.getProperty(TYRUS_VERSION); // when it is in the pom.file
+ if (property == null || property.startsWith("${")) {
+ property = System.getProperty(TYRUS_VERSION); // not in pom, but -Dtyrus.version
+ }
+ if (property == null || property.startsWith("${")) {
+ throw new IllegalStateException("Property " + TYRUS_VERSION + " not set (-Dtyrus.version=)");
+ }
+ return property;
+ }
+
+ /* Unused at the moment, but could be useful in the future in the case of profiles are needed */
+ private static List getProfileDependency(Model model) {
+ List profileDependencies = Collections.EMPTY_LIST;
+ List profiles = model.getProfiles();
+ String activeProfile = getActiveProfile();
+ for (Profile profile : profiles) {
+ if (activeProfile.equals(profile.getId())) {
+ profileDependencies = profile.getDependencies();
+ break;
+ }
+ }
+ return profileDependencies;
+ }
+
+ private static String getActiveProfile() {
+ String profileId = System.getProperty("profileId"); // set this to the surefire plugin
+ return profileId;
+ }
+}
diff --git a/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/TestResult.java b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/TestResult.java
new file mode 100644
index 00000000..b707f741
--- /dev/null
+++ b/tests/release-test/src/main/java/org/glassfish/tyrus/test/artifacts/TestResult.java
@@ -0,0 +1,89 @@
+/*
+ * 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.tyrus.test.artifacts;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+class TestResult {
+ private List oks = new LinkedList<>();
+ private List exceptions = new LinkedList<>();
+
+ MessageBuilder ok() {
+ return new MessageBuilder(oks);
+ }
+
+ MessageBuilder exception() {
+ return new MessageBuilder(exceptions);
+ }
+ boolean result() {
+ for (String ok : oks) {
+ System.out.append("(pass) ").print(ok);
+ }
+
+ for (String exception : exceptions) {
+ System.out.append("\u001b[31;1m(FAIL) ").append(exception).print("\u001b[0m");
+ }
+
+ return exceptions.isEmpty();
+ }
+
+ public TestResult append(TestResult result) throws IOException {
+ oks.addAll(result.oks);
+ exceptions.addAll(result.exceptions);
+ return this;
+ }
+
+ class MessageBuilder implements Appendable {
+ final List list;
+ final StringBuilder builder = new StringBuilder();
+
+ MessageBuilder(List list) {
+ this.list = list;
+ }
+
+ @Override
+ public MessageBuilder append(CharSequence csq) {
+ builder.append(csq);
+ return this;
+ }
+
+ public MessageBuilder append(int i) {
+ builder.append(i);
+ return this;
+ }
+
+ @Override
+ public MessageBuilder append(CharSequence csq, int start, int end) {
+ builder.append(csq, start, end);
+ return this;
+ }
+
+ @Override
+ public MessageBuilder append(char c) {
+ builder.append(c);
+ return this;
+ }
+
+ public TestResult println(String message) {
+ builder.append(message).append('\n');
+ list.add(builder.toString());
+ return TestResult.this;
+ }
+ }
+}
diff --git a/tests/release-test/src/test/java/org/glassfish/tyrus/test/artifacts/ArchetypesTest.java b/tests/release-test/src/test/java/org/glassfish/tyrus/test/artifacts/ArchetypesTest.java
new file mode 100644
index 00000000..ad785982
--- /dev/null
+++ b/tests/release-test/src/test/java/org/glassfish/tyrus/test/artifacts/ArchetypesTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.tyrus.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/echo/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