diff --git a/bundles/client/pom.xml b/bundles/client/pom.xml index d02e0b36..da631057 100644 --- a/bundles/client/pom.xml +++ b/bundles/client/pom.xml @@ -66,7 +66,7 @@ jakarta.websocket;version=${apijar.bundle.version} - org.glassfish.grizzly.*;version="[3.0,5)",* + org.glassfish.grizzly.*;version="3",* true diff --git a/bundles/websocket-ri-bundle/pom.xml b/bundles/websocket-ri-bundle/pom.xml index bc15a905..f938852a 100755 --- a/bundles/websocket-ri-bundle/pom.xml +++ b/bundles/websocket-ri-bundle/pom.xml @@ -246,9 +246,7 @@ jakarta.enterprise.context.spi;version="[3.0,5)", jakarta.enterprise.inject.spi;version="[3.0,5)", jakarta.xml.bind.*;version="[3.0,5)", - org.glassfish.grizzly.*;version="[3.0,5)", - - + org.glassfish.grizzly.*;version="3", * diff --git a/containers/grizzly-client/pom.xml b/containers/grizzly-client/pom.xml index b2ecced6..b2402d8c 100755 --- a/containers/grizzly-client/pom.xml +++ b/containers/grizzly-client/pom.xml @@ -61,7 +61,7 @@ org.glassfish.tyrus.container.grizzly.client.*;version=${project.version} - org.glassfish.grizzly.*;version="[3.0,5)",* + org.glassfish.grizzly.*;version="3",* true diff --git a/containers/grizzly-server/pom.xml b/containers/grizzly-server/pom.xml index a6a27373..51829dba 100755 --- a/containers/grizzly-server/pom.xml +++ b/containers/grizzly-server/pom.xml @@ -62,7 +62,7 @@ jakarta.xml.bind.*;version="[3.0,5)", - org.glassfish.grizzly.*;version="[3.0,5)", + org.glassfish.grizzly.*;version="3", * diff --git a/ext/monitoring-jmx/pom.xml b/ext/monitoring-jmx/pom.xml index 2061afea..56e0f66a 100644 --- a/ext/monitoring-jmx/pom.xml +++ b/ext/monitoring-jmx/pom.xml @@ -70,7 +70,7 @@ org.glassfish.tyrus.ext.monitoring.jmx.*;version=${project.version} - org.glassfish.grizzly.*;version="[3.0,5)",* + org.glassfish.grizzly.*;version="3",* true diff --git a/ext/monitoring-jmx/src/test/java/org/glassfish/tyrus/ext/monitoring/jmx/MessageStatisticsTest.java b/ext/monitoring-jmx/src/test/java/org/glassfish/tyrus/ext/monitoring/jmx/MessageStatisticsTest.java index 30047fa7..278dd8e0 100644 --- a/ext/monitoring-jmx/src/test/java/org/glassfish/tyrus/ext/monitoring/jmx/MessageStatisticsTest.java +++ b/ext/monitoring-jmx/src/test/java/org/glassfish/tyrus/ext/monitoring/jmx/MessageStatisticsTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -52,6 +53,9 @@ */ public class MessageStatisticsTest extends TestContainer { + private final int serverPort1 = getPort(); + private final int serverPort2 = serverPort1 + 1; + @ServerEndpoint("/jmxStatisticsServerEndpoint1") public static class ServerEndpoint1 { @@ -170,7 +174,7 @@ public void test(boolean monitorOnSessionLevel) { new TestApplicationEventListener(applicationMonitor, null, null, messageSentLatch, messageReceivedLatch, null); server1Properties.put(ApplicationEventListener.APPLICATION_EVENT_LISTENER, application1EventListener); - server1 = new Server("localhost", 8025, "/jmxTestApp", server1Properties, ServerEndpoint1.class, + server1 = new Server("localhost", serverPort1, "/jmxTestApp", server1Properties, ServerEndpoint1.class, ServerEndpoint2.class); server1.start(); @@ -179,28 +183,28 @@ public void test(boolean monitorOnSessionLevel) { new TestApplicationEventListener(new ApplicationMonitor(monitorOnSessionLevel), null, null, messageSentLatch, messageReceivedLatch, null); server2Properties.put(ApplicationEventListener.APPLICATION_EVENT_LISTENER, application2EventListener); - server2 = new Server("localhost", 8026, "/jmxTestApp2", server2Properties, ServerEndpoint2.class, + server2 = new Server("localhost", serverPort2, "/jmxTestApp2", server2Properties, ServerEndpoint2.class, ServerEndpoint3.class); server2.start(); ClientManager client = createClient(); Session session1 = client.connectToServer(AnnotatedClientEndpoint.class, - new URI("ws", null, "localhost", 8025, + new URI("ws", null, "localhost", serverPort1, "/jmxTestApp/jmxStatisticsServerEndpoint1", null, null)); Session session2 = client.connectToServer(AnnotatedClientEndpoint.class, - new URI("ws", null, "localhost", 8025, + new URI("ws", null, "localhost", serverPort1, "/jmxTestApp/jmxStatisticsServerEndpoint2", null, null)); Session session3 = client.connectToServer(AnnotatedClientEndpoint.class, - new URI("ws", null, "localhost", 8025, + new URI("ws", null, "localhost", serverPort1, "/jmxTestApp/jmxStatisticsServerEndpoint2", null, null)); Session session4 = client.connectToServer(AnnotatedClientEndpoint.class, - new URI("ws", null, "localhost", 8026, + new URI("ws", null, "localhost", serverPort2, "/jmxTestApp2/jmxStatisticsServerEndpoint2", null, null)); Session session5 = client.connectToServer(AnnotatedClientEndpoint.class, - new URI("ws", null, "localhost", 8026, + new URI("ws", null, "localhost", serverPort2, "/jmxTestApp2/jmxStatisticsServerEndpoint3", null, null)); Session session6 = client.connectToServer(AnnotatedClientEndpoint.class, - new URI("ws", null, "localhost", 8026, + new URI("ws", null, "localhost", serverPort2, "/jmxTestApp2/jmxStatisticsServerEndpoint3", null, null)); session1.getBasicRemote().sendText(getText(1)); diff --git a/ext/monitoring-jmx/src/test/java/org/glassfish/tyrus/ext/monitoring/jmx/RegisteredEndpointsTest.java b/ext/monitoring-jmx/src/test/java/org/glassfish/tyrus/ext/monitoring/jmx/RegisteredEndpointsTest.java index fca382da..223d3abe 100644 --- a/ext/monitoring-jmx/src/test/java/org/glassfish/tyrus/ext/monitoring/jmx/RegisteredEndpointsTest.java +++ b/ext/monitoring-jmx/src/test/java/org/glassfish/tyrus/ext/monitoring/jmx/RegisteredEndpointsTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -46,6 +47,9 @@ */ public class RegisteredEndpointsTest extends TestContainer { + private final int serverPort1 = getPort(); + private final int serverPort2 = serverPort1 + 1; + @ServerEndpoint("/jmxServerEndpoint1") public static class AnnotatedServerEndpoint1 { } @@ -66,14 +70,14 @@ public void testJmx() { Map server1Properties = new HashMap(); ApplicationEventListener application1EventListener = new SessionAwareApplicationMonitor(); server1Properties.put(ApplicationEventListener.APPLICATION_EVENT_LISTENER, application1EventListener); - server1 = new Server("localhost", 8025, "/jmxTestApp", server1Properties, AnnotatedServerEndpoint1.class, + server1 = new Server("localhost", serverPort1, "/jmxTestApp", server1Properties, AnnotatedServerEndpoint1.class, AnnotatedServerEndpoint2.class); server1.start(); Map server2Properties = new HashMap(); server2Properties .put(ApplicationEventListener.APPLICATION_EVENT_LISTENER, new SessionAwareApplicationMonitor()); - server2 = new Server("localhost", 8026, "/jmxTestApp2", server2Properties, AnnotatedServerEndpoint2.class, + server2 = new Server("localhost", serverPort2, "/jmxTestApp2", server2Properties, AnnotatedServerEndpoint2.class, AnnotatedServerEndpoint3.class); server2.start(); diff --git a/pom.xml b/pom.xml index c1129a04..db46f8fb 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ 4.0.2 4.0.5 @@ -127,7 +127,7 @@ 3.11.2 3.5.3 3.4.0 - 5.1.9 + 6.0.0 2.8.0 jakarta.websocket @@ -154,6 +154,8 @@ gf-cddl-gpl org.glassfish.tyrus.samples:*,*:*-project,*:tyrus-archetype*,*:*-documentation,org.glassfish.tyrus.tests:*e2e*,org.glassfish.tyrus.tests.servlet*:*,org.glassfish.tyrus.bundles:*,org.glassfish.tyrus.tests:*containers* + + 8025 @@ -299,7 +301,7 @@ org.apache.felix maven-bundle-plugin - ${maven.bundle.plugin.version} + ${maven.bundle.plugin.version} true diff --git a/tests/e2e/jetty/auth-basic/pom.xml b/tests/e2e/jetty/auth-basic/pom.xml index 68b79d4a..3f44086c 100644 --- a/tests/e2e/jetty/auth-basic/pom.xml +++ b/tests/e2e/jetty/auth-basic/pom.xml @@ -25,7 +25,7 @@ 2.2.99-SNAPSHOT - jar + war tyrus-tests-e2e-auth-basic Tyrus End-to-End Basic Auth Tests @@ -70,16 +70,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - org/glassfish/tyrus/tests/e2e/auth/basic/BasicAuthTest.java - - - diff --git a/tests/e2e/jetty/auth-digest/pom.xml b/tests/e2e/jetty/auth-digest/pom.xml index 6b398829..6d542cb1 100644 --- a/tests/e2e/jetty/auth-digest/pom.xml +++ b/tests/e2e/jetty/auth-digest/pom.xml @@ -25,7 +25,7 @@ 2.2.99-SNAPSHOT - jar + war tyrus-tests-e2e-auth-digest Tyrus End-to-End Digest Auth Tests @@ -70,16 +70,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - - - org/glassfish/tyrus/tests/e2e/auth/basic/DigestAuthTest.java - - - diff --git a/tests/e2e/jetty/pom.xml b/tests/e2e/jetty/pom.xml index f1132200..f70d21a3 100755 --- a/tests/e2e/jetty/pom.xml +++ b/tests/e2e/jetty/pom.xml @@ -64,23 +64,25 @@ true + + 8026 + org.eclipse.jetty jetty-maven-plugin - 9.2.1.v20140609 + 11.0.26 - 10 - 8026 + ${tyrus.test.port2} STOP 5 / - 8025 + ${tyrus.test.port} 10000 @@ -91,10 +93,6 @@ start - - 0 - true - stop-jetty diff --git a/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/RedirectTest.java b/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/RedirectTest.java index cccc6305..276714e5 100644 --- a/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/RedirectTest.java +++ b/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/RedirectTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -61,10 +62,10 @@ */ public class RedirectTest extends TestContainer { - private static final int REDIRECTION_PORT = 8026; - private static final String REDIRECTION_URI = "ws://localhost:" + REDIRECTION_PORT; + private final int redirectionPort = getPort() + 1; + private final String redirectionUri = "ws://localhost:" + redirectionPort; private static final String REDIRECTION_PATH = "/redirect"; - private static final List statuses = + private static final List STATUSES = Arrays.asList(HttpStatus.MULTIPLE_CHOICES_300, HttpStatus.MOVED_PERMANENTLY_301, HttpStatus.FOUND_302, HttpStatus.SEE_OTHER_303, HttpStatus.TEMPORARY_REDIRECT_307, HttpStatus.PERMANENT_REDIRECT_308); @@ -81,7 +82,7 @@ public void testRedirect() throws InterruptedException, DeploymentException, Aut try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testRedirect(httpstatus); } } finally { @@ -96,8 +97,8 @@ private void testRedirect(HttpStatus httpStatus) throws DeploymentException, Int HttpServer httpServer = null; try { - httpServer = startHttpRedirectionServer(REDIRECTION_PORT, httpStatus, - "ws://localhost:8025/redirect-echo/echo"); + httpServer = startHttpRedirectionServer(redirectionPort, httpStatus, + "ws://localhost:" + getPort() + "/redirect-echo/echo"); final ClientManager client = ClientManager.createClient(); final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); @@ -124,7 +125,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH)); messageLatch.await(1, TimeUnit.SECONDS); assertEquals(0, messageLatch.getCount()); @@ -142,7 +143,7 @@ public void testRelativePath() throws InterruptedException, DeploymentException, try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testRelativePath(httpstatus); } } finally { @@ -156,18 +157,19 @@ private void testRelativePath(HttpStatus httpStatus) throws InterruptedException AuthenticationException, DeploymentException { HttpServer httpServer = null; try { - httpServer = createHttpServer(REDIRECTION_PORT); + httpServer = createHttpServer(redirectionPort); httpServer.getServerConfiguration().addHttpHandler( new RedirectHandler(httpStatus, REDIRECTION_PATH + 1), REDIRECTION_PATH + 0); httpServer.getServerConfiguration().addHttpHandler( - new RedirectHandler(httpStatus, REDIRECTION_URI + REDIRECTION_PATH + 2), REDIRECTION_PATH + 1); + new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 2), REDIRECTION_PATH + 1); httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, "/la/la/la/.././../.." + REDIRECTION_PATH + 3), REDIRECTION_PATH + 2); httpServer.getServerConfiguration().addHttpHandler( - new RedirectHandler(httpStatus, "http://127.0.0.1:8026" + REDIRECTION_PATH + 4), - REDIRECTION_PATH + 3); + new RedirectHandler(httpStatus, "http://127.0.0.1:" + redirectionPort + REDIRECTION_PATH + 4), + REDIRECTION_PATH + 3); httpServer.getServerConfiguration().addHttpHandler( - new RedirectHandler(httpStatus, "ws://localhost:8025/redirect-echo/echo"), REDIRECTION_PATH + 4); + new RedirectHandler(httpStatus, "ws://localhost:" + getPort() + "/redirect-echo/echo"), + REDIRECTION_PATH + 4); httpServer.start(); final ClientManager client = createClient(); @@ -194,7 +196,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH + 0)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH + 0)); messageLatch.await(1, TimeUnit.SECONDS); assertEquals(0, messageLatch.getCount()); @@ -224,8 +226,8 @@ private void testRedirectUnsupported3xx(HttpStatus httpStatus) throws Interrupte AuthenticationException { HttpServer httpServer = null; try { - httpServer = startHttpRedirectionServer(REDIRECTION_PORT, httpStatus, - "ws://localhost:8025/redirect-echo/echo"); + httpServer = startHttpRedirectionServer(redirectionPort, httpStatus, + "ws://localhost:" + getPort() + "/redirect-echo/echo"); final CountDownLatch messageLatch = new CountDownLatch(1); @@ -252,7 +254,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH)); messageLatch.await(1, TimeUnit.SECONDS); assertTrue("Redirect for this 3xx code is not supported. HandshakeException must be thrown.", false); @@ -273,7 +275,7 @@ public void testRedirectNotAllowed() throws InterruptedException, DeploymentExce try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testRedirectNotAllowed(httpstatus); } } finally { @@ -287,8 +289,8 @@ private void testRedirectNotAllowed(HttpStatus httpStatus) throws InterruptedExc AuthenticationException { HttpServer httpServer = null; try { - httpServer = startHttpRedirectionServer(REDIRECTION_PORT, httpStatus, - "ws://localhost:8025/redirect-echo/echo"); + httpServer = startHttpRedirectionServer(redirectionPort, httpStatus, + "ws://localhost:" + getPort() + "/redirect-echo/echo"); final CountDownLatch messageLatch = new CountDownLatch(1); @@ -315,7 +317,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH)); messageLatch.await(1, TimeUnit.SECONDS); assertTrue("Redirect is not allowed. RedirectException must be thrown.", false); @@ -336,7 +338,7 @@ public void testRedirectNotAllowedByDefault() throws InterruptedException, Deplo try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testRedirectNotAllowedByDefault(httpstatus); } } finally { @@ -351,8 +353,8 @@ private void testRedirectNotAllowedByDefault(HttpStatus httpStatus) throws Inter HttpServer httpServer = null; try { - httpServer = startHttpRedirectionServer(REDIRECTION_PORT, httpStatus, - "ws://localhost:8025/redirect-echo/echo"); + httpServer = startHttpRedirectionServer(redirectionPort, httpStatus, + "ws://localhost:" + getPort() + "/redirect-echo/echo"); final CountDownLatch messageLatch = new CountDownLatch(1); @@ -377,7 +379,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH)); messageLatch.await(1, TimeUnit.SECONDS); assertTrue("Redirect is not allowed. RedirectException must be thrown.", false); @@ -398,7 +400,7 @@ public void testRedirectLoop() throws InterruptedException, DeploymentException, try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testRedirectLoop(httpstatus); } } finally { @@ -412,7 +414,7 @@ private void testRedirectLoop(HttpStatus httpStatus) throws InterruptedException AuthenticationException { HttpServer httpServer = null; try { - httpServer = startHttpRedirectionServer(REDIRECTION_PORT, httpStatus, REDIRECTION_URI + REDIRECTION_PATH); + httpServer = startHttpRedirectionServer(redirectionPort, httpStatus, redirectionUri + REDIRECTION_PATH); final CountDownLatch messageLatch = new CountDownLatch(1); @@ -438,7 +440,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH)); assertTrue("Redirect loop must cause RedirectException", false); } catch (DeploymentException e) { @@ -458,7 +460,7 @@ public void testMaxRedirectionExceed() throws InterruptedException, DeploymentEx try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testMaxRedirectionExceed(httpstatus); } } finally { @@ -472,18 +474,18 @@ private void testMaxRedirectionExceed(HttpStatus httpStatus) throws InterruptedE AuthenticationException { HttpServer httpServer = null; try { - httpServer = createHttpServer(REDIRECTION_PORT); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer = createHttpServer(redirectionPort); + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 1), REDIRECTION_PATH + 0); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 2), REDIRECTION_PATH + 1); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 3), REDIRECTION_PATH + 2); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 4), REDIRECTION_PATH + 3); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 5), REDIRECTION_PATH + 4); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 6), REDIRECTION_PATH + 5); httpServer.start(); @@ -508,7 +510,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH + 0)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH + 0)); assertTrue("Too much redirection must cause RedirectException", false); } catch (DeploymentException e) { @@ -527,7 +529,7 @@ public void testMaxRedirectionConfig() throws InterruptedException, DeploymentEx try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testMaxRedirectionConfig(httpstatus); } } finally { @@ -541,12 +543,12 @@ private void testMaxRedirectionConfig(HttpStatus httpStatus) throws InterruptedE AuthenticationException { HttpServer httpServer = null; try { - httpServer = createHttpServer(REDIRECTION_PORT); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer = createHttpServer(redirectionPort); + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 1), REDIRECTION_PATH + 0); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 2), REDIRECTION_PATH + 1); - httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, REDIRECTION_URI + httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 3), REDIRECTION_PATH + 2); httpServer.start(); @@ -573,7 +575,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH + 0)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH + 0)); assertTrue("Too much redirection must cause RedirectException", false); } catch (DeploymentException e) { @@ -592,7 +594,7 @@ public void testMaxRedirectionConfigNeg() throws InterruptedException, Deploymen try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testMaxRedirectionConfigNeg(httpstatus); } } finally { @@ -600,7 +602,7 @@ public void testMaxRedirectionConfigNeg() throws InterruptedException, Deploymen server.stop(); } } - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testMaxRedirectionConfigNeg(httpstatus); } } @@ -611,9 +613,9 @@ private void testMaxRedirectionConfigNeg(HttpStatus httpStatus) throws Interrupt HttpServer httpServer = null; try { - httpServer = createHttpServer(REDIRECTION_PORT); + httpServer = createHttpServer(redirectionPort); httpServer.getServerConfiguration().addHttpHandler( - new RedirectHandler(httpStatus, REDIRECTION_URI + REDIRECTION_PATH + 1), REDIRECTION_PATH + 0); + new RedirectHandler(httpStatus, redirectionUri + REDIRECTION_PATH + 1), REDIRECTION_PATH + 0); httpServer.start(); final ClientManager client = createClient(); @@ -639,7 +641,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH + 0)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH + 0)); assertTrue("Too much redirection must cause RedirectException", false); } catch (DeploymentException e) { @@ -658,7 +660,7 @@ public void testRedirectMissingLocation() throws InterruptedException, Deploymen try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testRedirectMissingLocation(httpstatus); } } finally { @@ -674,7 +676,7 @@ private void testRedirectMissingLocation(HttpStatus httpStatus) throws Interrupt HttpServer httpServer = null; try { - httpServer = createHttpServer(REDIRECTION_PORT); + httpServer = createHttpServer(redirectionPort); httpServer.getServerConfiguration().addHttpHandler(new BadRedirectHandler(httpStatus), REDIRECTION_PATH); httpServer.start(); @@ -700,7 +702,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH)); assertTrue("Missing location must cause RedirectException", false); } catch (DeploymentException e) { @@ -719,7 +721,7 @@ public void testRedirectEmptyLocation() throws InterruptedException, DeploymentE try { server = startServer(RedirectedEchoEndpoint.class); - for (HttpStatus httpstatus : statuses) { + for (HttpStatus httpstatus : STATUSES) { testRedirectEmptyLocation(httpstatus); } } finally { @@ -735,7 +737,7 @@ private void testRedirectEmptyLocation(HttpStatus httpStatus) throws Interrupted HttpServer httpServer = null; try { - httpServer = createHttpServer(REDIRECTION_PORT); + httpServer = createHttpServer(redirectionPort); httpServer.getServerConfiguration().addHttpHandler(new RedirectHandler(httpStatus, ""), REDIRECTION_PATH); httpServer.start(); @@ -761,7 +763,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create(REDIRECTION_URI + REDIRECTION_PATH)); + }, cec, URI.create(redirectionUri + REDIRECTION_PATH)); assertTrue("Missing location must cause RedirectException", false); } catch (DeploymentException e) { diff --git a/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/RetryAfterTest.java b/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/RetryAfterTest.java index 6d63eb0f..3738f20f 100644 --- a/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/RetryAfterTest.java +++ b/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/RetryAfterTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -57,9 +58,9 @@ */ public class RetryAfterTest extends TestContainer { - private static final int REDIRECTION_PORT = 8026; private static final HttpStatus SERVICE_UNAVAILABLE = HttpStatus.SERVICE_UNAVAILABLE_503; private static final String CONTEXT_ROOT = "/retry-after-echo"; + private final int redirectionPort = getPort() + 1; public RetryAfterTest() { setContextPath(CONTEXT_ROOT); @@ -104,9 +105,8 @@ private void testRetryAfter(String retryAfter) throws DeploymentException, Inter HttpServer httpServer = null; try { - httpServer = startHttpServer( - REDIRECTION_PORT, - new MultipleRetryAfterHandler(1, retryAfter, "ws://localhost:8025/retry-after-echo/echo")); + httpServer = startHttpServer(redirectionPort, + new MultipleRetryAfterHandler(1, retryAfter, "ws://localhost:" + getPort() + "/retry-after-echo/echo")); final ClientManager client = ClientManager.createClient(); final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); @@ -134,7 +134,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create("ws://localhost:8026/retry-after-echo/echo")); + }, cec, URI.create("ws://localhost:" + redirectionPort + "/retry-after-echo/echo")); assertTrue("Message has not been received", messageLatch.await(1, TimeUnit.SECONDS)); } finally { @@ -263,10 +263,8 @@ private void testRetryAfterWrongHeader(String retryAfter, Boolean retryAfterEnab HttpServer httpServer = null; try { - httpServer = startHttpServer( - REDIRECTION_PORT, - new MultipleRetryAfterHandler(numberOfRetries, retryAfter, - "ws://localhost:8025/retry-after-echo/echo")); + httpServer = startHttpServer(redirectionPort, new MultipleRetryAfterHandler(numberOfRetries, retryAfter, + "ws://localhost:" + getPort() + "/retry-after-echo/echo")); final ClientManager client = ClientManager.createClient(); final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); @@ -293,7 +291,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create("ws://localhost:8026/retry-after-echo/echo")); + }, cec, URI.create("ws://localhost:" + redirectionPort + "/retry-after-echo/echo")); fail("Connection to the endpoint should fail"); } catch (Exception e) { @@ -319,9 +317,8 @@ private void testRetryAfterConnectFail(String retryAfter, Boolean retryAfterEnab HttpServer httpServer = null; try { - httpServer = startHttpServer( - REDIRECTION_PORT, new MultipleRetryAfterHandler(numberOfRetries, retryAfter, - "ws://localhost:8025/retry-after-echo/echo")); + httpServer = startHttpServer(redirectionPort, new MultipleRetryAfterHandler(numberOfRetries, retryAfter, + "ws://localhost:" + getPort() + "/retry-after-echo/echo")); final ClientManager client = ClientManager.createClient(); final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); @@ -348,7 +345,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create("ws://localhost:8026/retry-after-echo/echo")); + }, cec, URI.create("ws://localhost:" + redirectionPort + "/retry-after-echo/echo")); fail("Connection to the endpoint should fail"); } catch (Exception e) { @@ -387,9 +384,8 @@ private void testRetryAfterTwice(String retryAfter) throws DeploymentException, HttpServer httpServer = null; try { - httpServer = startHttpServer( - REDIRECTION_PORT, - new MultipleRetryAfterHandler(2, retryAfter, "ws://localhost:8025/retry-after-echo/echo")); + httpServer = startHttpServer(redirectionPort, + new MultipleRetryAfterHandler(2, retryAfter, "ws://localhost:" + getPort() + "/retry-after-echo/echo")); final ClientManager client = ClientManager.createClient(); final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); @@ -417,7 +413,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create("ws://localhost:8026/retry-after-echo/echo")); + }, cec, URI.create("ws://localhost:" + redirectionPort + "/retry-after-echo/echo")); assertTrue("Message has not been received", messageLatch.await(1, TimeUnit.SECONDS)); } finally { @@ -448,9 +444,8 @@ private void testRetryAfterUserDefinedHandler(String retryAfter) throws Deployme HttpServer httpServer = null; try { - httpServer = startHttpServer( - REDIRECTION_PORT, new MultipleRetryAfterHandler(6, retryAfter, - "ws://localhost:8025/retry-after-echo/echo")); + httpServer = startHttpServer(redirectionPort, + new MultipleRetryAfterHandler(6, retryAfter, "ws://localhost:" + getPort() + "/retry-after-echo/echo")); final ClientManager client = ClientManager.createClient(); final ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build(); @@ -492,7 +487,7 @@ public void onMessage(String message) { // do nothing } } - }, cec, URI.create("ws://localhost:8026/retry-after-echo/echo")); + }, cec, URI.create("ws://localhost:" + redirectionPort + "/retry-after-echo/echo")); assertTrue("Message has not been received", messageLatch.await(1, TimeUnit.SECONDS)); assertTrue("User-defined ReconnectHandler was not called", reconnectHandlerLatch.await(1, TimeUnit diff --git a/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/SameHeadersOnClientTest.java b/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/SameHeadersOnClientTest.java index 2c7dea36..4e7b1add 100644 --- a/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/SameHeadersOnClientTest.java +++ b/tests/e2e/non-deployable/src/test/java/org/glassfish/tyrus/test/e2e/non_deployable/SameHeadersOnClientTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -81,7 +82,7 @@ public void afterResponse(HandshakeResponse hr) { responseLatch.countDown(); } } - }).build(), URI.create("ws://localhost:8025/testSameHeader")); + }).build(), URI.create("ws://localhost:" + getPort() + "/testSameHeader")); assertTrue(responseLatch.await(5, TimeUnit.SECONDS)); } catch (Exception e) { @@ -97,6 +98,7 @@ public void afterResponse(HandshakeResponse hr) { private HttpServer getHandshakeServer() throws IOException { HttpServer server = HttpServer.createSimpleServer("/testSameHeader", getHost(), getPort()); server.getServerConfiguration().addHttpHandler(new HttpHandler() { + @Override public void service(Request request, Response response) throws Exception { response.setStatus(101); diff --git a/tests/e2e/standard-config/src/test/java/org/glassfish/tyrus/test/standard_config/ClientExecutorsManagementTest.java b/tests/e2e/standard-config/src/test/java/org/glassfish/tyrus/test/standard_config/ClientExecutorsManagementTest.java index 65b273d6..671239bd 100644 --- a/tests/e2e/standard-config/src/test/java/org/glassfish/tyrus/test/standard_config/ClientExecutorsManagementTest.java +++ b/tests/e2e/standard-config/src/test/java/org/glassfish/tyrus/test/standard_config/ClientExecutorsManagementTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -57,6 +58,8 @@ */ public class ClientExecutorsManagementTest extends TestContainer { + private final int port = getPort() + 1; + /** * Test basic executor services life cycle. */ @@ -159,8 +162,8 @@ public void testConnectionFail() { HttpServer lazyServer = getLazyServer(blockResponseLatch); clientManager.getProperties().put(ClientProperties.HANDSHAKE_TIMEOUT, 2000); try { - clientManager.connectToServer( - AnnotatedClientEndpoint.class, URI.create("ws://localhost:8026/lazyServer")); + clientManager.connectToServer(AnnotatedClientEndpoint.class, + URI.create("ws://localhost:" + port + "/lazyServer")); fail(); } catch (Exception e) { // exception is expected @@ -342,9 +345,10 @@ public void managedExecutorsTest() { } private HttpServer getLazyServer(final CountDownLatch blockResponseLatch) throws IOException { - HttpServer server = HttpServer.createSimpleServer("/lazyServer", "localhost", 8026); + HttpServer server = HttpServer.createSimpleServer("/lazyServer", "localhost", port); server.getServerConfiguration().addHttpHandler( new HttpHandler() { + @Override public void service(Request request, Response response) throws Exception { blockResponseLatch.await(1, TimeUnit.MINUTES); } diff --git a/tests/servlet/debug/src/test/java/org/glassfish/tyrus/tests/servlet/debug/DebugSampleTest.java b/tests/servlet/debug/src/test/java/org/glassfish/tyrus/tests/servlet/debug/DebugSampleTest.java index 35c63df1..756e0624 100644 --- a/tests/servlet/debug/src/test/java/org/glassfish/tyrus/tests/servlet/debug/DebugSampleTest.java +++ b/tests/servlet/debug/src/test/java/org/glassfish/tyrus/tests/servlet/debug/DebugSampleTest.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -219,7 +220,8 @@ public void onOpen(Session session, EndpointConfig EndpointConfig) { onOpenLatch.countDown(); } - }, ClientEndpointConfig.Builder.create().build(), URI.create("ws://localhost:8025/testAuthentication")); + }, ClientEndpointConfig.Builder.create().build(), + URI.create("ws://localhost:" + getPort() + "/testAuthentication")); assertTrue(onOpenLatch.await(3, TimeUnit.SECONDS)); } catch (Exception e) { diff --git a/tests/servlet/embedded-glassfish-test/pom.xml b/tests/servlet/embedded-glassfish-test/pom.xml index ab727c06..fbc8be87 100644 --- a/tests/servlet/embedded-glassfish-test/pom.xml +++ b/tests/servlet/embedded-glassfish-test/pom.xml @@ -31,9 +31,9 @@ Tyrus Servlet Tests on Glassfish - ${project.build.directory}/glassfish8 + glassfish7 + ${project.build.directory}/${glassfish.directoryName} ${glassfish.home}/glassfish/modules - ${glassfish.version} 5.7.2 @@ -96,20 +96,14 @@ org.jboss.arquillian.junit5 arquillian-junit5-container - 1.7.0.Alpha10 + 1.10.0.Final test - org.jboss.arquillian.container - arquillian-glassfish-managed-6 - 1.0.0.Alpha1 + ee.omnifish.arquillian + arquillian-glassfish-server-managed + 2.1.2 test - - - org.glassfish.hk2 - hk2-locator - - org.glassfish.hk2 @@ -152,12 +146,11 @@ org.glassfish.tyrus.tests.servlet:tyrus-tests-servlet-embedded-gf - 8080 + ${glassfish.home} + ${tyrus.test.port} + ${glassfish.container.version} true - - ${glassfish.home} - diff --git a/tests/servlet/embedded-glassfish-test/src/test/java/org/glassfish/tyrus/tests/servlet/embedded/SSLTestIT.java b/tests/servlet/embedded-glassfish-test/src/test/java/org/glassfish/tyrus/tests/servlet/embedded/SSLTestIT.java index a67a4a36..ba1aa8a6 100644 --- a/tests/servlet/embedded-glassfish-test/src/test/java/org/glassfish/tyrus/tests/servlet/embedded/SSLTestIT.java +++ b/tests/servlet/embedded-glassfish-test/src/test/java/org/glassfish/tyrus/tests/servlet/embedded/SSLTestIT.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -18,15 +19,8 @@ import jakarta.websocket.ClientEndpointConfig; import jakarta.websocket.DeploymentException; -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.junit5.ArquillianExtension; -import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -38,6 +32,16 @@ import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManagerFactory; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + @ExtendWith(ArquillianExtension.class) public class SSLTestIT extends ServletTestBase { @@ -74,7 +78,7 @@ public void plainEchoTest() throws DeploymentException, IOException, Interrupted @Override protected ClientEndpointConfig createClientEndpointConfig() throws DeploymentException { final String password = "changeit"; - final String keyStore = System.getenv("GLASSFISH_HOME") + "/glassfish/domains/domain1/config/keystore.jks"; + final File keyStore = getKeyStoreFile(); try { KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); @@ -102,4 +106,17 @@ protected ClientEndpointConfig createClientEndpointConfig() throws DeploymentExc throw new DeploymentException(e.getMessage(), e); } } + + private File getKeyStoreFile() throws DeploymentException { + final File cfgDir = new File(System.getProperty("glassfish.home") + "/glassfish/domains/domain1/config"); + final File pkcsFile = new File(cfgDir, "keystore.p12"); + if (pkcsFile.exists()) { + return pkcsFile; + } + final File jksFile = new File(cfgDir, "keystore.jks"); + if (jksFile.exists()) { + return jksFile; + } + throw new DeploymentException("Could not find supported keystore file in directory " + cfgDir); + } } diff --git a/tests/servlet/embedded-glassfish-test/src/test/java/org/glassfish/tyrus/tests/servlet/embedded/ServletTestBase.java b/tests/servlet/embedded-glassfish-test/src/test/java/org/glassfish/tyrus/tests/servlet/embedded/ServletTestBase.java index 1bd746a7..ebf1158d 100644 --- a/tests/servlet/embedded-glassfish-test/src/test/java/org/glassfish/tyrus/tests/servlet/embedded/ServletTestBase.java +++ b/tests/servlet/embedded-glassfish-test/src/test/java/org/glassfish/tyrus/tests/servlet/embedded/ServletTestBase.java @@ -1,4 +1,5 @@ /* + * Copyright (c) 2026 Contributors to the Eclipse Foundation. * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -49,7 +50,7 @@ public abstract class ServletTestBase { private static final String defaultHost = "localhost"; - private static final int defaultPort = 8025; + private static final int defaultPort = Integer.getInteger("glassfish.httpPort", 8025); private String contextPath; protected abstract String getScheme(); @@ -226,7 +227,7 @@ protected URI getURI(String endpointPath, String scheme) { * @return port used for creating remote endpoint {@link URI}. */ protected int getPort() { - final String port = System.getProperty("tyrus.test.port"); + final String port = System.getProperty("glassfish.httpPort"); if (port != null) { try { return Integer.parseInt(port);