diff --git a/archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/src/test/java/MyResourceTest.java b/archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/src/test/java/MyResourceTest.java index f0c141c0cb..1212f6f9fa 100644 --- a/archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/src/test/java/MyResourceTest.java +++ b/archetypes/jersey-heroku-webapp/src/main/resources/archetype-resources/src/test/java/MyResourceTest.java @@ -5,8 +5,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import ${package}.MyResource; 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 42416bbd12..9dcb68bb61 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 @@ -38,9 +38,9 @@ --> - junit - junit - 4.12 + org.junit.jupiter + junit-jupiter + \${junit-jupiter.version} test @@ -77,6 +77,7 @@ ${project.version} + 5.9.1 UTF-8 diff --git a/archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/src/test/java/MyResourceTest.java b/archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/src/test/java/MyResourceTest.java index 6986107bcb..901bc19283 100644 --- a/archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/src/test/java/MyResourceTest.java +++ b/archetypes/jersey-quickstart-grizzly2/src/main/resources/archetype-resources/src/test/java/MyResourceTest.java @@ -6,17 +6,17 @@ import org.glassfish.grizzly.http.server.HttpServer; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MyResourceTest { private HttpServer server; private WebTarget target; - @Before + @BeforeEach public void setUp() throws Exception { // start the server server = Main.startServer(); @@ -32,7 +32,7 @@ public void setUp() throws Exception { target = c.target(Main.BASE_URI); } - @After + @AfterEach public void tearDown() throws Exception { server.stop(); } diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/AsyncTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/AsyncTest.java index 82e2d5d49d..4c6702b04a 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/AsyncTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/AsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -40,10 +40,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.hamcrest.Matchers; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Asynchronous connector test. @@ -210,7 +210,7 @@ public String call() throws Exception { } }); - assertTrue("Waiting for results has timed out.", latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS)); + assertTrue(latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), "Waiting for results has timed out."); final long toc = System.currentTimeMillis(); assertEquals("DONE-1", r1.get()); diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/AuthTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/AuthTest.java index dceb272c62..9bced7a7f4 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/AuthTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/AuthTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -44,12 +44,12 @@ import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Paul Sandoz @@ -398,7 +398,7 @@ public void testAuthGetWithDigestFilter() { } @Test - @Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + @Disabled("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + " Allow repeatable write in jersey?") public void testAuthPost() { CredentialsProvider credentialsProvider = new org.apache.http.impl.client.BasicCredentialsProvider(); @@ -474,7 +474,7 @@ public void testAuthInteractiveGet() { } @Test - @Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + @Disabled("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + " Allow repeatable write in jersey?") public void testAuthInteractivePost() { CredentialsProvider credentialsProvider = new org.apache.http.impl.client.BasicCredentialsProvider(); diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CookieTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CookieTest.java index c387fcecf3..5e2c66bb6a 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CookieTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CookieTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -34,11 +34,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CustomLoggingFilter.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CustomLoggingFilter.java index d6c4259576..a26aea8f54 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CustomLoggingFilter.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/CustomLoggingFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,7 +27,7 @@ import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Custom logging filter. @@ -43,28 +43,28 @@ public class CustomLoggingFilter implements ContainerRequestFilter, ContainerRes @Override public void filter(ClientRequestContext context) throws IOException { System.out.println("CustomLoggingFilter.preFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); preFilterCalled++; } @Override public void filter(ClientRequestContext context, ClientResponseContext clientResponseContext) throws IOException { System.out.println("CustomLoggingFilter.postFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); postFilterCalled++; } @Override public void filter(ContainerRequestContext context) throws IOException { System.out.println("CustomLoggingFilter.preFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); preFilterCalled++; } @Override public void filter(ContainerRequestContext context, ContainerResponseContext containerResponseContext) throws IOException { System.out.println("CustomLoggingFilter.postFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); postFilterCalled++; } } diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/DisableContentEncodingTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/DisableContentEncodingTest.java index 4e2681feb5..dfd5b17cd9 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/DisableContentEncodingTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/DisableContentEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.apache.http.client.config.RequestConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Ondrej Kosatka diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/FollowRedirectsTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/FollowRedirectsTest.java index f55bf78f66..c789a1a905 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/FollowRedirectsTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/FollowRedirectsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -36,8 +36,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Apache connector follow redirect tests. diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/GZIPContentEncodingTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/GZIPContentEncodingTest.java index fb2503e78f..bfa86988d5 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/GZIPContentEncodingTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/GZIPContentEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HelloWorldTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HelloWorldTest.java index e6a29e5be9..dab72b3232 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HelloWorldTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -63,11 +63,11 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.params.HttpParams; import org.apache.http.protocol.HttpContext; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Jakub Podlesak @@ -160,11 +160,11 @@ public void _testConnectionPoolSharing(final boolean sharingEnabled) throws Exce try { target.request().get(); if (exceptionExpected) { - Assert.fail("Exception expected"); + Assertions.fail("Exception expected"); } } catch (Exception e) { if (!exceptionExpected) { - Assert.fail("Exception not expected"); + Assertions.fail("Exception not expected"); } } finally { clientTwo.close(); @@ -603,10 +603,10 @@ public void shutdown() { final String response = rootTarget.path("error2").request().get(String.class); fail("Exception expected. Received: " + response); } catch (InternalServerErrorException isee) { - assertEquals("Received unexpected data.", "Error2.", isee.getResponse().readEntity(String.class)); + assertEquals("Error2.", isee.getResponse().readEntity(String.class), "Received unexpected data."); // Test buffering: // second read would fail if entity was not buffered - assertEquals("Unexpected data in the entity buffer.", "Error2.", isee.getResponse().readEntity(String.class)); + assertEquals("Error2.", isee.getResponse().readEntity(String.class), "Unexpected data in the entity buffer."); } assertEquals(0, connectionCounter.get()); diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpEntityTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpEntityTest.java index f7d2b161c3..19d9784279 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpEntityTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -65,8 +65,8 @@ public void testInputStreamEntity() { InputStreamEntity entity = new InputStreamEntity(bais); try (Response response = target().request().post(Entity.entity(entity, MediaType.APPLICATION_OCTET_STREAM))) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(ECHO_MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(ECHO_MESSAGE, response.readEntity(String.class)); } } @@ -75,8 +75,8 @@ public void testByteArrayEntity() { ByteArrayEntity entity = new ByteArrayEntity(ECHO_MESSAGE.getBytes()); try (Response response = target().request().post(Entity.entity(entity, MediaType.APPLICATION_OCTET_STREAM))) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(ECHO_MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(ECHO_MESSAGE, response.readEntity(String.class)); } } } diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpHeadersTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpHeadersTest.java index 5302beff77..c4d5ed7177 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpHeadersTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -43,9 +43,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpMethodTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpMethodTest.java index f507504348..b21940d658 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpMethodTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/HttpMethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -39,13 +39,12 @@ import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; - import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/LargeDataTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/LargeDataTest.java index 938096c7df..059a3c0597 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/LargeDataTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/LargeDataTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -37,8 +37,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * The LargeDataTest reproduces a problem when bytes of large data sent are incorrectly sent. @@ -107,9 +107,8 @@ public void postWithLargeData() throws Throwable { throw exception; } - Assert.assertEquals("Unexpected error: " + response.getStatus(), - Status.Family.SUCCESSFUL, - response.getStatusInfo().getFamily()); + Assertions.assertEquals(Status.Family.SUCCESSFUL, response.getStatusInfo().getFamily(), + "Unexpected error: " + response.getStatus()); } finally { response.close(); } diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/ManagedClientTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/ManagedClientTest.java index a263177d22..d3c5644156 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/ManagedClientTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/ManagedClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -46,8 +46,8 @@ import org.glassfish.jersey.server.Uri; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Jersey programmatic managed client test diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/NoEntityTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/NoEntityTest.java index a162e14648..27ba0ca5f3 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/NoEntityTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/NoEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -31,7 +31,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Paul Sandoz diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/RetryHandlerTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/RetryHandlerTest.java index f779d12698..7a135af18c 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/RetryHandlerTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/RetryHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -36,8 +36,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.apache.http.client.HttpRequestRetryHandler; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RetryHandlerTest extends JerseyTest { private static final int READ_TIMEOUT_MS = 100; diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/SpecialHeaderTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/SpecialHeaderTest.java index 25bfadb4e2..0d17af5f06 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/SpecialHeaderTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/SpecialHeaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * @@ -67,23 +67,23 @@ protected void configureClient(ClientConfig config) { @Test - @Ignore("Apache connector does not provide information about encoding for gzip and deflate encoding") + @Disabled("Apache connector does not provide information about encoding for gzip and deflate encoding") public void testEncoded() { final Response response = target().path("resource/encoded").request("text/plain").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); - Assert.assertEquals("gzip", response.getHeaderString(HttpHeaders.CONTENT_ENCODING)); - Assert.assertEquals("text/plain", response.getHeaderString(HttpHeaders.CONTENT_TYPE)); - Assert.assertEquals(3, response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); + Assertions.assertEquals("gzip", response.getHeaderString(HttpHeaders.CONTENT_ENCODING)); + Assertions.assertEquals("text/plain", response.getHeaderString(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(3, response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); } @Test public void testNonEncoded() { final Response response = target().path("resource/non-encoded").request("text/plain").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); - Assert.assertNull(response.getHeaderString(HttpHeaders.CONTENT_ENCODING)); - Assert.assertEquals("text/plain", response.getHeaderString(HttpHeaders.CONTENT_TYPE)); - Assert.assertEquals("3", response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); + Assertions.assertNull(response.getHeaderString(HttpHeaders.CONTENT_ENCODING)); + Assertions.assertEquals("text/plain", response.getHeaderString(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals("3", response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); } } diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/StreamingTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/StreamingTest.java index c5ef31e4b0..10dcbcf0b9 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/StreamingTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/StreamingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -38,8 +38,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Petr Janouch diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/TimeoutTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/TimeoutTest.java index 66860cf517..6947b6666e 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/TimeoutTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/TimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,11 +31,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/TraceSupportTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/TraceSupportTest.java index c0442f2d44..e6c593bafb 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/TraceSupportTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/TraceSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -45,10 +45,10 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * This very basic resource showcases support of a HTTP TRACE method, @@ -129,9 +129,9 @@ public void testProgrammaticApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsProgrammatic) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } @@ -143,9 +143,9 @@ public void testAnnotatedApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsAnnotated) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/UnderlyingCookieStoreAccessTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/UnderlyingCookieStoreAccessTest.java index 3238c8162f..808fef960b 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/UnderlyingCookieStoreAccessTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/UnderlyingCookieStoreAccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.client.ClientConfig; import org.apache.http.client.CookieStore; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Test of access to the underlying CookieStore instance used by the connector. @@ -44,9 +44,9 @@ public void testCookieStoreInstanceAccess() { final WebTarget target = client.target("http://localhost/"); final CookieStore csOnTarget = ApacheConnectorProvider.getCookieStore(target); - assertNotNull("CookieStore instance set on JerseyClient should not be null.", csOnClient); - assertNotNull("CookieStore instance set on JerseyWebTarget should not be null.", csOnTarget); - assertSame("CookieStore instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget" - + "(provided the target instance has not been further configured).", csOnClient, csOnTarget); + assertNotNull(csOnClient, "CookieStore instance set on JerseyClient should not be null."); + assertNotNull(csOnTarget, "CookieStore instance set on JerseyWebTarget should not be null."); + assertSame(csOnClient, csOnTarget, "CookieStore instance set on JerseyClient should be the same instance as the one " + + "set on JerseyWebTarget (provided the target instance has not been further configured)."); } } diff --git a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/UnderlyingHttpClientAccessTest.java b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/UnderlyingHttpClientAccessTest.java index 61b9bd0225..18b3eee118 100644 --- a/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/UnderlyingHttpClientAccessTest.java +++ b/connectors/apache-connector/src/test/java/org/glassfish/jersey/apache/connector/UnderlyingHttpClientAccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.client.ClientConfig; import org.apache.http.client.HttpClient; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Test of access to the underlying HTTP client instance used by the connector. @@ -47,11 +47,9 @@ public void testHttpClientInstanceAccess() { final WebTarget target = client.target("http://localhost/"); final HttpClient hcOnTarget = ApacheConnectorProvider.getHttpClient(target); - assertNotNull("HTTP client instance set on JerseyClient should not be null.", hcOnClient); - assertNotNull("HTTP client instance set on JerseyWebTarget should not be null.", hcOnTarget); - assertSame("HTTP client instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget" - + "(provided the target instance has not been further configured).", - hcOnClient, hcOnTarget - ); + assertNotNull(hcOnClient, "HTTP client instance set on JerseyClient should not be null."); + assertNotNull(hcOnTarget, "HTTP client instance set on JerseyWebTarget should not be null."); + assertSame(hcOnClient, hcOnTarget, "HTTP client instance set on JerseyClient should be the same instance as the one " + + "set on JerseyWebTarget (provided the target instance has not been further configured)."); } } diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/AsyncTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/AsyncTest.java index 50e8f6571f..6ac74e5049 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/AsyncTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/AsyncTest.java @@ -40,10 +40,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.hamcrest.Matchers; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Asynchronous connector test. @@ -210,7 +210,7 @@ public String call() throws Exception { } }); - assertTrue("Waiting for results has timed out.", latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS)); + assertTrue(latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), "Waiting for results has timed out."); final long toc = System.currentTimeMillis(); assertEquals("DONE-1", r1.get()); diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/AuthTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/AuthTest.java index f59c0cf9bf..c16e4855d8 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/AuthTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/AuthTest.java @@ -44,12 +44,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Paul Sandoz @@ -398,7 +398,7 @@ public void testAuthGetWithDigestFilter() { } @Test - @Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + @Disabled("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + " Allow repeatable write in jersey?") public void testAuthPost() { CredentialsStore credentialsProvider = new BasicCredentialsProvider(); @@ -474,7 +474,7 @@ public void testAuthInteractiveGet() { } @Test - @Ignore("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + @Disabled("JERSEY-1750: Cannot retry request with a non-repeatable request entity. How to buffer the entity?" + " Allow repeatable write in jersey?") public void testAuthInteractivePost() { CredentialsStore credentialsProvider = new BasicCredentialsProvider(); diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/CookieTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/CookieTest.java index 0e619a661a..1ff230006f 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/CookieTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/CookieTest.java @@ -34,11 +34,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/CustomLoggingFilter.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/CustomLoggingFilter.java index 27caedad53..60e4cc8d34 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/CustomLoggingFilter.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/CustomLoggingFilter.java @@ -27,7 +27,7 @@ import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Custom logging filter. @@ -43,28 +43,28 @@ public class CustomLoggingFilter implements ContainerRequestFilter, ContainerRes @Override public void filter(ClientRequestContext context) throws IOException { System.out.println("CustomLoggingFilter.preFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); preFilterCalled++; } @Override public void filter(ClientRequestContext context, ClientResponseContext clientResponseContext) throws IOException { System.out.println("CustomLoggingFilter.postFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); postFilterCalled++; } @Override public void filter(ContainerRequestContext context) throws IOException { System.out.println("CustomLoggingFilter.preFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); preFilterCalled++; } @Override public void filter(ContainerRequestContext context, ContainerResponseContext containerResponseContext) throws IOException { System.out.println("CustomLoggingFilter.postFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); postFilterCalled++; } } diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/DisableContentEncodingTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/DisableContentEncodingTest.java index 51bc6a007c..9bd1572c31 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/DisableContentEncodingTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/DisableContentEncodingTest.java @@ -30,8 +30,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Ondrej Kosatka diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/FollowRedirectsTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/FollowRedirectsTest.java index 9377a0a741..27a54c94e9 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/FollowRedirectsTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/FollowRedirectsTest.java @@ -36,8 +36,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Apache connector follow redirect tests. diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/GZIPContentEncodingTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/GZIPContentEncodingTest.java index 0230ba14e0..298ca42dbf 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/GZIPContentEncodingTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/GZIPContentEncodingTest.java @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HelloWorldTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HelloWorldTest.java index e0f6612177..2dc697c23b 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HelloWorldTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HelloWorldTest.java @@ -52,11 +52,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Jakub Podlesak @@ -149,11 +149,11 @@ public void _testConnectionPoolSharing(final boolean sharingEnabled) throws Exce try { target.request().get(); if (exceptionExpected) { - Assert.fail("Exception expected"); + Assertions.fail("Exception expected"); } } catch (Exception e) { if (!exceptionExpected) { - Assert.fail("Exception not expected"); + Assertions.fail("Exception not expected"); } } finally { clientTwo.close(); @@ -389,10 +389,10 @@ public void close() throws IOException { final String response = rootTarget.path("error2").request().get(String.class); fail("Exception expected. Received: " + response); } catch (InternalServerErrorException isee) { - assertEquals("Received unexpected data.", "Error2.", isee.getResponse().readEntity(String.class)); + assertEquals("Error2.", isee.getResponse().readEntity(String.class), "Received unexpected data."); // Test buffering: // second read would fail if entity was not buffered - assertEquals("Unexpected data in the entity buffer.", "Error2.", isee.getResponse().readEntity(String.class)); + assertEquals("Error2.", isee.getResponse().readEntity(String.class), "Unexpected data in the entity buffer."); } assertEquals(0, connectionCounter.get()); diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpEntityTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpEntityTest.java index cad5ea8494..5581fc92a6 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpEntityTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpEntityTest.java @@ -23,8 +23,8 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -66,8 +66,8 @@ public void testInputStreamEntity() { InputStreamEntity entity = new InputStreamEntity(bais, ContentType.TEXT_PLAIN); try (Response response = target().request().post(Entity.entity(entity, MediaType.APPLICATION_OCTET_STREAM))) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(ECHO_MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(ECHO_MESSAGE, response.readEntity(String.class)); } } @@ -76,8 +76,8 @@ public void testByteArrayEntity() { ByteArrayEntity entity = new ByteArrayEntity(ECHO_MESSAGE.getBytes(), ContentType.TEXT_PLAIN); try (Response response = target().request().post(Entity.entity(entity, MediaType.APPLICATION_OCTET_STREAM))) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(ECHO_MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(ECHO_MESSAGE, response.readEntity(String.class)); } } } diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpHeadersTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpHeadersTest.java index c63b7a87ee..cea6db2a09 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpHeadersTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpHeadersTest.java @@ -43,9 +43,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpMethodTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpMethodTest.java index 00a45a15b6..1f4830378c 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpMethodTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/HttpMethodTest.java @@ -41,11 +41,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/LargeDataTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/LargeDataTest.java index 40f1b4136d..fc67712c3f 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/LargeDataTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/LargeDataTest.java @@ -37,8 +37,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * The LargeDataTest reproduces a problem when bytes of large data sent are incorrectly sent. @@ -107,9 +107,8 @@ public void postWithLargeData() throws Throwable { throw exception; } - Assert.assertEquals("Unexpected error: " + response.getStatus(), - Status.Family.SUCCESSFUL, - response.getStatusInfo().getFamily()); + Assertions.assertEquals(Status.Family.SUCCESSFUL, response.getStatusInfo().getFamily(), + "Unexpected error: " + response.getStatus()); } finally { response.close(); } diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/ManagedClientTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/ManagedClientTest.java index 46ba4ee018..cd3468252f 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/ManagedClientTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/ManagedClientTest.java @@ -46,8 +46,8 @@ import org.glassfish.jersey.server.Uri; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Jersey programmatic managed client test diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/NoEntityTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/NoEntityTest.java index cdea49be4c..e00ded91e0 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/NoEntityTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/NoEntityTest.java @@ -31,7 +31,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Paul Sandoz diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/RetryStrategyTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/RetryStrategyTest.java index 6254c430fc..cdfc30fbd2 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/RetryStrategyTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/RetryStrategyTest.java @@ -40,8 +40,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RetryStrategyTest extends JerseyTest { private static final int READ_TIMEOUT_MS = 100; diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/SpecialHeaderTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/SpecialHeaderTest.java index ce6a377883..8803ac43d8 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/SpecialHeaderTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/SpecialHeaderTest.java @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * @@ -67,23 +67,23 @@ protected void configureClient(ClientConfig config) { @Test - @Ignore("Apache connector does not provide information about encoding for gzip and deflate encoding") + @Disabled("Apache connector does not provide information about encoding for gzip and deflate encoding") public void testEncoded() { final Response response = target().path("resource/encoded").request("text/plain").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); - Assert.assertEquals("gzip", response.getHeaderString(HttpHeaders.CONTENT_ENCODING)); - Assert.assertEquals("text/plain", response.getHeaderString(HttpHeaders.CONTENT_TYPE)); - Assert.assertEquals(3, response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); + Assertions.assertEquals("gzip", response.getHeaderString(HttpHeaders.CONTENT_ENCODING)); + Assertions.assertEquals("text/plain", response.getHeaderString(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals(3, response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); } @Test public void testNonEncoded() { final Response response = target().path("resource/non-encoded").request("text/plain").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); - Assert.assertNull(response.getHeaderString(HttpHeaders.CONTENT_ENCODING)); - Assert.assertEquals("text/plain", response.getHeaderString(HttpHeaders.CONTENT_TYPE)); - Assert.assertEquals("3", response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); + Assertions.assertNull(response.getHeaderString(HttpHeaders.CONTENT_ENCODING)); + Assertions.assertEquals("text/plain", response.getHeaderString(HttpHeaders.CONTENT_TYPE)); + Assertions.assertEquals("3", response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); } } diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/StreamingTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/StreamingTest.java index ea90e79879..7a05f61c53 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/StreamingTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/StreamingTest.java @@ -37,8 +37,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Petr Janouch diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/TimeoutTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/TimeoutTest.java index 7eab1b30b6..0d69457105 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/TimeoutTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/TimeoutTest.java @@ -31,11 +31,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/TraceSupportTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/TraceSupportTest.java index d95c2f21c8..c4c2d3a037 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/TraceSupportTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/TraceSupportTest.java @@ -45,10 +45,10 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * This very basic resource showcases support of a HTTP TRACE method, @@ -129,9 +129,9 @@ public void testProgrammaticApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsProgrammatic) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } @@ -143,9 +143,9 @@ public void testAnnotatedApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsAnnotated) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/UnderlyingCookieStoreAccessTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/UnderlyingCookieStoreAccessTest.java index 8248fdd7d8..1250637ac7 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/UnderlyingCookieStoreAccessTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/UnderlyingCookieStoreAccessTest.java @@ -23,9 +23,9 @@ import org.apache.hc.client5.http.cookie.CookieStore; import org.glassfish.jersey.client.ClientConfig; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Test of access to the underlying CookieStore instance used by the connector. @@ -44,9 +44,9 @@ public void testCookieStoreInstanceAccess() { final WebTarget target = client.target("http://localhost/"); final CookieStore csOnTarget = Apache5ConnectorProvider.getCookieStore(target); - assertNotNull("CookieStore instance set on JerseyClient should not be null.", csOnClient); - assertNotNull("CookieStore instance set on JerseyWebTarget should not be null.", csOnTarget); - assertSame("CookieStore instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget" - + "(provided the target instance has not been further configured).", csOnClient, csOnTarget); + assertNotNull(csOnClient, "CookieStore instance set on JerseyClient should not be null."); + assertNotNull(csOnTarget, "CookieStore instance set on JerseyWebTarget should not be null."); + assertSame(csOnClient, csOnTarget, "CookieStore instance set on JerseyClient should be the same instance as the one " + + "set on JerseyWebTarget (provided the target instance has not been further configured)."); } } diff --git a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/UnderlyingHttpClientAccessTest.java b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/UnderlyingHttpClientAccessTest.java index 0c2e320b62..d8aec2ca3b 100644 --- a/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/UnderlyingHttpClientAccessTest.java +++ b/connectors/apache5-connector/src/test/java/org/glassfish/jersey/apache5/connector/UnderlyingHttpClientAccessTest.java @@ -23,9 +23,9 @@ import org.apache.hc.client5.http.classic.HttpClient; import org.glassfish.jersey.client.ClientConfig; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Test of access to the underlying HTTP client instance used by the connector. @@ -47,11 +47,9 @@ public void testHttpClientInstanceAccess() { final WebTarget target = client.target("http://localhost/"); final HttpClient hcOnTarget = Apache5ConnectorProvider.getHttpClient(target); - assertNotNull("HTTP client instance set on JerseyClient should not be null.", hcOnClient); - assertNotNull("HTTP client instance set on JerseyWebTarget should not be null.", hcOnTarget); - assertSame("HTTP client instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget" - + "(provided the target instance has not been further configured).", - hcOnClient, hcOnTarget - ); + assertNotNull(hcOnClient, "HTTP client instance set on JerseyClient should not be null."); + assertNotNull(hcOnTarget, "HTTP client instance set on JerseyWebTarget should not be null."); + assertSame(hcOnClient, hcOnTarget, "HTTP client instance set on JerseyClient should be the same instance as the one" + + " set on JerseyWebTarget (provided the target instance has not been further configured)."); } } diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/AsyncTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/AsyncTest.java index 754c371a44..bc970c7329 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/AsyncTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/AsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,9 +36,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.hamcrest.Matchers; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Asynchronous connector test. diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/CustomizersTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/CustomizersTest.java index 75e0ca0f9f..23a82880c9 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/CustomizersTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/CustomizersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -32,9 +32,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.ning.http.client.AsyncHttpClientConfig; import com.ning.http.client.RequestBuilder; diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/FollowRedirectsTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/FollowRedirectsTest.java index 21f8879f3d..2d86199ea0 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/FollowRedirectsTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/FollowRedirectsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Grizzly connector follow redirect tests. diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/HttpHeadersTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/HttpHeadersTest.java index 2772864450..81576091da 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/HttpHeadersTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/HttpHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -26,9 +26,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the headers. diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/HttpMethodTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/HttpMethodTest.java index 3f905042e2..6752870471 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/HttpMethodTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/HttpMethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -19,7 +19,7 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -30,8 +30,8 @@ import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the Http methods. diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/NoEntityTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/NoEntityTest.java index a6db9eef1d..8e7cfe5b7f 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/NoEntityTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/NoEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,7 +31,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Paul Sandoz diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/ParallelTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/ParallelTest.java index 8cd48ba650..2016b583e2 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/ParallelTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/ParallelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -37,10 +37,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the parallel execution of multiple requests. @@ -120,15 +120,15 @@ public void run() { startBarrier.await(1, TimeUnit.SECONDS); - assertTrue("Waiting for clients to finish has timed out.", doneLatch.await(5 * getAsyncTimeoutMultiplier(), - TimeUnit.SECONDS)); + assertTrue(doneLatch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), + "Waiting for clients to finish has timed out."); - assertEquals("Resource counter", PARALLEL_CLIENTS, resourceCounter.get()); + assertEquals(PARALLEL_CLIENTS, resourceCounter.get(), "Resource counter"); - assertEquals("Received counter", PARALLEL_CLIENTS, receivedCounter.get()); + assertEquals(PARALLEL_CLIENTS, receivedCounter.get(), "Received counter"); } finally { executor.shutdownNow(); - Assert.assertTrue("Executor termination", executor.awaitTermination(5, TimeUnit.SECONDS)); + Assertions.assertTrue(executor.awaitTermination(5, TimeUnit.SECONDS), "Executor termination"); } } } diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/TimeoutTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/TimeoutTest.java index f920bd7802..0d771af14e 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/TimeoutTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/TimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,11 +29,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/TraceSupportTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/TraceSupportTest.java index d5b2cf5c46..d11646bd23 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/TraceSupportTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/TraceSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -45,10 +45,10 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * This very basic resource showcases support of a HTTP TRACE method, @@ -129,9 +129,9 @@ public void testProgrammaticApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsProgrammatic) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } @@ -143,9 +143,9 @@ public void testAnnotatedApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsAnnotated) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } diff --git a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/UnderlyingHttpClientAccessTest.java b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/UnderlyingHttpClientAccessTest.java index eee7992a49..2edae61143 100644 --- a/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/UnderlyingHttpClientAccessTest.java +++ b/connectors/grizzly-connector/src/test/java/org/glassfish/jersey/grizzly/connector/UnderlyingHttpClientAccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -22,9 +22,9 @@ import org.glassfish.jersey.client.ClientConfig; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; import com.ning.http.client.AsyncHttpClient; @@ -48,11 +48,9 @@ public void testHttpClientInstanceAccess() { final WebTarget target = client.target("http://localhost/"); final AsyncHttpClient hcOnTarget = GrizzlyConnectorProvider.getHttpClient(target); - assertNotNull("HTTP client instance set on JerseyClient should not be null.", hcOnClient); - assertNotNull("HTTP client instance set on JerseyWebTarget should not be null.", hcOnTarget); - assertSame("HTTP client instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget" - + "(provided the target instance has not been further configured).", - hcOnClient, hcOnTarget - ); + assertNotNull(hcOnClient, "HTTP client instance set on JerseyClient should not be null."); + assertNotNull(hcOnTarget, "HTTP client instance set on JerseyWebTarget should not be null."); + assertSame(hcOnClient, hcOnTarget, "HTTP client instance set on JerseyClient should be the same instance as the one " + + "set on JerseyWebTarget (provided the target instance has not been further configured)."); } } diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/AsyncTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/AsyncTest.java index b6189db57a..4d6c9b3b30 100644 --- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/AsyncTest.java +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/AsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -21,7 +21,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.hamcrest.Matchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -36,8 +36,8 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Logger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Asynchronous connector test. diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/BasicHelidonConnectorTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/BasicHelidonConnectorTest.java index 4af0ebec99..48d7db5506 100644 --- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/BasicHelidonConnectorTest.java +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/BasicHelidonConnectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -21,10 +21,11 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -45,7 +46,9 @@ import javax.ws.rs.core.Response; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Locale; import java.util.Map; @@ -55,21 +58,9 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(Parameterized.class) -public class BasicHelidonConnectorTest extends JerseyTest { - - private final String entityType; - - public BasicHelidonConnectorTest(String entityType) { - this.entityType = entityType; - } - - @Parameterized.Parameters - public static Object[] data() { - return new Object[]{"BYTE_ARRAY_OUTPUT_STREAM", "READABLE_BYTE_CHANNEL", "OUTPUT_STREAM_PUBLISHER"}; - } +public class BasicHelidonConnectorTest { @Path("basic") public static class BasicResource { @@ -112,6 +103,10 @@ public String putConsumesProduces(String content) { } } + public static List data() { + return Arrays.asList("BYTE_ARRAY_OUTPUT_STREAM", "READABLE_BYTE_CHANNEL", "OUTPUT_STREAM_PUBLISHER"); + } + @Path("async") public static class AsyncResource { private static CountDownLatch shortLong = null; @@ -137,181 +132,200 @@ public String shortGet() { } } - @Override - protected Application configure() { - return new ResourceConfig(BasicResource.class, AsyncResource.class) - .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING"); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + data().forEach(entityType -> { + BasicHelidonConnectorTemplateTest test = new BasicHelidonConnectorTemplateTest(entityType) {}; + tests.add(TestHelper.toTestContainer(test, entityType)); + }); + return tests; } - @Override - protected void configureClient(ClientConfig config) { - super.configureClient(config); - config.connectorProvider(new HelidonConnectorProvider()); - config.property("jersey.config.helidon.client.entity.type", entityType); - } + public abstract static class BasicHelidonConnectorTemplateTest extends JerseyTest { + + private final String entityType; - @Test - public void testBasicGet() { - try (Response response = target("basic").path("get").request().get()) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("ok", response.readEntity(String.class)); + public BasicHelidonConnectorTemplateTest(String entityType) { + this.entityType = entityType; } - } - @Test - public void testBasicPost() { - try (Response response = target("basic").path("post").request() - .buildPost(Entity.entity("ok", MediaType.TEXT_PLAIN_TYPE)).invoke()) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("okok", response.readEntity(String.class)); + @Override + protected Application configure() { + return new ResourceConfig(BasicResource.class, AsyncResource.class) + .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING"); } - } - @Test - public void queryGetTest() { - try (Response response = target("basic").path("getquery") - .queryParam("first", "hello") - .queryParam("second", "world") - .request().get()) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("helloworld", response.readEntity(String.class)); + @Override + protected void configureClient(ClientConfig config) { + super.configureClient(config); + config.connectorProvider(new HelidonConnectorProvider()); + config.property("jersey.config.helidon.client.entity.type", entityType); } - } - @Test - public void testHeaders() { - String[][] headers = new String[][]{{"X-TEST-ONE", "ONE"}, {"X-TEST-TWO", "TWO"}, {"X-TEST-THREE", "THREE"}}; - MultivaluedHashMap map = new MultivaluedHashMap<>(); - Arrays.stream(headers).forEach(a -> map.add(a[0], a[1])); - try (Response response = target("basic").path("headers").request().headers(map).get()) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("ok", response.readEntity(String.class)); - for (int i = 0; i != headers.length; i++) { - Assert.assertTrue(response.getHeaders().containsKey(headers[i][0])); - Assert.assertEquals(headers[i][1], response.getStringHeaders().getFirst(headers[i][0])); + @Test + public void testBasicGet() { + try (Response response = target("basic").path("get").request().get()) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("ok", response.readEntity(String.class)); } } - } - @Test - public void testProduces() { - try (Response response = target("basic").path("produces/consumes").request("test/z-test") - .put(Entity.entity("ok", new MediaType("test", "x-test")))) { - Assert.assertEquals(406, response.getStatus()); + @Test + public void testBasicPost() { + try (Response response = target("basic").path("post").request() + .buildPost(Entity.entity("ok", MediaType.TEXT_PLAIN_TYPE)).invoke()) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("okok", response.readEntity(String.class)); + } } - try (Response response = target("basic").path("produces/consumes").request() - .put(Entity.entity("ok", new MediaType("test", "x-test")))) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("okok", response.readEntity(String.class)); - Assert.assertEquals("test/y-test", response.getStringHeaders().getFirst(HttpHeaders.CONTENT_TYPE)); + @Test + public void queryGetTest() { + try (Response response = target("basic").path("getquery") + .queryParam("first", "hello") + .queryParam("second", "world") + .request().get()) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("helloworld", response.readEntity(String.class)); + } } - } - @Test - public void testAsyncGet() throws ExecutionException, InterruptedException { - Future futureResponse = target("basic").path("get").request().async().get(); - try (Response response = futureResponse.get()) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("ok", response.readEntity(String.class)); + @Test + public void testHeaders() { + String[][] headers = new String[][]{{"X-TEST-ONE", "ONE"}, {"X-TEST-TWO", "TWO"}, {"X-TEST-THREE", "THREE"}}; + MultivaluedHashMap map = new MultivaluedHashMap<>(); + Arrays.stream(headers).forEach(a -> map.add(a[0], a[1])); + try (Response response = target("basic").path("headers").request().headers(map).get()) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("ok", response.readEntity(String.class)); + for (int i = 0; i != headers.length; i++) { + Assertions.assertTrue(response.getHeaders().containsKey(headers[i][0])); + Assertions.assertEquals(headers[i][1], response.getStringHeaders().getFirst(headers[i][0])); + } + } + } + + @Test + public void testProduces() { + try (Response response = target("basic").path("produces/consumes").request("test/z-test") + .put(Entity.entity("ok", new MediaType("test", "x-test")))) { + Assertions.assertEquals(406, response.getStatus()); + } + + try (Response response = target("basic").path("produces/consumes").request() + .put(Entity.entity("ok", new MediaType("test", "x-test")))) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("okok", response.readEntity(String.class)); + Assertions.assertEquals("test/y-test", response.getStringHeaders().getFirst(HttpHeaders.CONTENT_TYPE)); + } } - } - @Test - public void testConsumes() { - try (Response response = target("basic").path("produces/consumes").request("test/y-test") - .put(Entity.entity("ok", new MediaType("test", "z-test")))) { - Assert.assertEquals(415, response.getStatus()); + @Test + public void testAsyncGet() throws ExecutionException, InterruptedException { + Future futureResponse = target("basic").path("get").request().async().get(); + try (Response response = futureResponse.get()) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("ok", response.readEntity(String.class)); + } } - try (Response response = target("basic").path("produces/consumes").request("test/y-test") - .put(Entity.entity("ok", MediaType.WILDCARD_TYPE))) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("okok", response.readEntity(String.class)); - Assert.assertEquals("test/y-test", response.getStringHeaders().getFirst(HttpHeaders.CONTENT_TYPE)); + @Test + public void testConsumes() { + try (Response response = target("basic").path("produces/consumes").request("test/y-test") + .put(Entity.entity("ok", new MediaType("test", "z-test")))) { + Assertions.assertEquals(415, response.getStatus()); + } + + try (Response response = target("basic").path("produces/consumes").request("test/y-test") + .put(Entity.entity("ok", MediaType.WILDCARD_TYPE))) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("okok", response.readEntity(String.class)); + Assertions.assertEquals("test/y-test", response.getStringHeaders().getFirst(HttpHeaders.CONTENT_TYPE)); + } } - } - @Test - public void testRxGet() throws ExecutionException, InterruptedException { - CompletableFuture futureResponse = - target("basic").path("get").request().rx(JerseyCompletionStageRxInvoker.class).get(); + @Test + public void testRxGet() throws ExecutionException, InterruptedException { + CompletableFuture futureResponse = + target("basic").path("get").request().rx(JerseyCompletionStageRxInvoker.class).get(); - try (Response response = futureResponse.get()) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("ok", response.readEntity(String.class)); + try (Response response = futureResponse.get()) { + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("ok", response.readEntity(String.class)); + } } - } - @Test - public void testInputStreamEntity() throws IOException { - try (Response response = target("basic").path("get").request().get()) { - Assert.assertEquals(200, response.getStatus()); - InputStream is = response.readEntity(InputStream.class); - Assert.assertEquals('o', is.read()); - Assert.assertEquals('k', is.read()); - is.close(); + @Test + public void testInputStreamEntity() throws IOException { + try (Response response = target("basic").path("get").request().get()) { + Assertions.assertEquals(200, response.getStatus()); + InputStream is = response.readEntity(InputStream.class); + Assertions.assertEquals('o', is.read()); + Assertions.assertEquals('k', is.read()); + is.close(); + } } - } - // -----------Async + // -----------Async - @Test - public void testTwoClientsAsync() throws ExecutionException, InterruptedException { - try (Response resetResponse = target("async").path("reset").request().get()) { - Assert.assertEquals(204, resetResponse.getStatus()); - } + @Test + public void testTwoClientsAsync() throws ExecutionException, InterruptedException { + try (Response resetResponse = target("async").path("reset").request().get()) { + Assertions.assertEquals(204, resetResponse.getStatus()); + } - ClientConfig config = new ClientConfig(); - config.connectorProvider(new HelidonConnectorProvider()); + ClientConfig config = new ClientConfig(); + config.connectorProvider(new HelidonConnectorProvider()); - Client longClient = ClientBuilder.newClient(config); - Invocation.Builder longRequest = longClient.target(getBaseUri()).path("async/long").request(); + Client longClient = ClientBuilder.newClient(config); + Invocation.Builder longRequest = longClient.target(getBaseUri()).path("async/long").request(); - Client shortClient = ClientBuilder.newClient(config); - Invocation.Builder shortRequest = shortClient.target(getBaseUri()).path("async/short").request(); + Client shortClient = ClientBuilder.newClient(config); + Invocation.Builder shortRequest = shortClient.target(getBaseUri()).path("async/short").request(); - Future futureLongResponse = longRequest.async().get(); - Future futureShortResponse = shortRequest.async().get(); + Future futureLongResponse = longRequest.async().get(); + Future futureShortResponse = shortRequest.async().get(); - try (Response shortResponse = futureShortResponse.get()) { - Assert.assertEquals(200, shortResponse.getStatus()); - Assert.assertEquals("short", shortResponse.readEntity(String.class)); - } + try (Response shortResponse = futureShortResponse.get()) { + Assertions.assertEquals(200, shortResponse.getStatus()); + Assertions.assertEquals("short", shortResponse.readEntity(String.class)); + } - try (Response longResponse = futureLongResponse.get()) { - Assert.assertEquals(200, longResponse.getStatus()); - Assert.assertEquals("long", longResponse.readEntity(String.class)); + try (Response longResponse = futureLongResponse.get()) { + Assertions.assertEquals(200, longResponse.getStatus()); + Assertions.assertEquals("long", longResponse.readEntity(String.class)); + } } - } - @Test - public void testOneClientsTwoReqestsAsync() throws ExecutionException, InterruptedException { - try (Response resetResponse = target("async").path("reset").request().get()) { - Assert.assertEquals(204, resetResponse.getStatus()); - } + @Test + public void testOneClientsTwoReqestsAsync() throws ExecutionException, InterruptedException { + try (Response resetResponse = target("async").path("reset").request().get()) { + Assertions.assertEquals(204, resetResponse.getStatus()); + } - Invocation.Builder longRequest = target().path("async/long").request(); - Invocation.Builder shortRequest = target().path("async/short").request(); + Invocation.Builder longRequest = target().path("async/long").request(); + Invocation.Builder shortRequest = target().path("async/short").request(); - Future futureLongResponse = longRequest.async().get(); - Future futureShortResponse = shortRequest.async().get(); + Future futureLongResponse = longRequest.async().get(); + Future futureShortResponse = shortRequest.async().get(); - try (Response shortResponse = futureShortResponse.get()) { - Assert.assertEquals(200, shortResponse.getStatus()); - Assert.assertEquals("short", shortResponse.readEntity(String.class)); - } + try (Response shortResponse = futureShortResponse.get()) { + Assertions.assertEquals(200, shortResponse.getStatus()); + Assertions.assertEquals("short", shortResponse.readEntity(String.class)); + } - try (Response longResponse = futureLongResponse.get()) { - Assert.assertEquals(200, longResponse.getStatus()); - Assert.assertEquals("long", longResponse.readEntity(String.class)); + try (Response longResponse = futureLongResponse.get()) { + Assertions.assertEquals(200, longResponse.getStatus()); + Assertions.assertEquals("long", longResponse.readEntity(String.class)); + } } - } - @Test - public void testOptionsWithEntity() { - Response response = target("basic").path("get").request().build("OPTIONS", Entity.text("OPTIONS")).invoke(); - assertEquals(200, response.getStatus()); - response.close(); + @Test + public void testOptionsWithEntity() { + Response response = target("basic").path("get").request().build("OPTIONS", Entity.text("OPTIONS")).invoke(); + assertEquals(200, response.getStatus()); + response.close(); + } } } diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/FollowRedirectsTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/FollowRedirectsTest.java index 87105d666a..60a2826bae 100644 --- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/FollowRedirectsTest.java +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/FollowRedirectsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -22,7 +22,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -36,7 +36,7 @@ import java.io.IOException; import java.util.logging.Logger; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Helidon connector follow redirect tests. diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/LargeDataTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/LargeDataTest.java index 8a7a6907df..8b6792eadb 100644 --- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/LargeDataTest.java +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/LargeDataTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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,8 +20,8 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.POST; import javax.ws.rs.Path; @@ -106,9 +106,8 @@ public void postWithLargeData() throws Throwable { throw exception; } - Assert.assertEquals("Unexpected error: " + response.getStatus(), - Status.Family.SUCCESSFUL, - response.getStatusInfo().getFamily()); + Assertions.assertEquals(Status.Family.SUCCESSFUL, response.getStatusInfo().getFamily(), + "Unexpected error: " + response.getStatus()); } finally { response.close(); } diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/ParallelTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/ParallelTest.java index 94a1d26a41..6ef37cd3b6 100644 --- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/ParallelTest.java +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/ParallelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -19,8 +19,8 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -38,8 +38,8 @@ import java.util.logging.Level; import java.util.logging.Logger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the parallel execution of multiple requests. @@ -119,15 +119,15 @@ public void run() { startBarrier.await(1, TimeUnit.SECONDS); - assertTrue("Waiting for clients to finish has timed out.", doneLatch.await(5 * getAsyncTimeoutMultiplier(), - TimeUnit.SECONDS)); + assertTrue(doneLatch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), + "Waiting for clients to finish has timed out."); - assertEquals("Resource counter", PARALLEL_CLIENTS, resourceCounter.get()); + assertEquals(PARALLEL_CLIENTS, resourceCounter.get(), "Resource counter"); - assertEquals("Received counter", PARALLEL_CLIENTS, receivedCounter.get()); + assertEquals(PARALLEL_CLIENTS, receivedCounter.get(), "Received counter"); } finally { executor.shutdownNow(); - Assert.assertTrue("Executor termination", executor.awaitTermination(5, TimeUnit.SECONDS)); + Assertions.assertTrue(executor.awaitTermination(5, TimeUnit.SECONDS), "Executor termination"); } } } diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/TimeoutTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/TimeoutTest.java index 1fe6374177..3ae1470e41 100644 --- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/TimeoutTest.java +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/TimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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,8 +20,8 @@ import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -29,8 +29,8 @@ import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula @@ -82,7 +82,7 @@ public void testSlow() { } } - @Ignore + @Disabled // TODO - WebClient change request public void testTimeoutInRequest() { try { diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/sse/EventOutputTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/sse/EventOutputTest.java index 5eb76e8e50..cd98a6d430 100644 --- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/sse/EventOutputTest.java +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/sse/EventOutputTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.media.sse.SseFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -48,10 +48,10 @@ import java.util.concurrent.atomic.AtomicReference; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Event output tests. @@ -179,12 +179,12 @@ public void onEvent(InboundEvent inboundEvent) { closeTimedOut = es.close(5, TimeUnit.SECONDS); } - assertEquals("Unexpected event count", 2, eventComments.size()); + assertEquals(2, eventComments.size(), "Unexpected event count"); for (int i = 1; i <= 2; i++) { - assertEquals("Unexpected comment data on event #" + i, "No comment #" + i, eventComments.poll()); + assertEquals("No comment #" + i, eventComments.poll(), "Unexpected comment data on event #" + i); } - assertTrue("Event latch has timed out", latchTimedOut); - assertTrue("EventSource.close() has timed out", closeTimedOut); + assertTrue(latchTimedOut, "Event latch has timed out"); + assertTrue(closeTimedOut, "EventSource.close() has timed out"); } @Test @@ -265,8 +265,8 @@ public void onEvent(InboundEvent inboundEvent) { } // 2.0.0.-M3 assertEquals("Unexpected event count", 1, counter.get()); - assertEquals("Unexpected event data", "single", eventData.get()); - assertTrue("Event latch has timed out", latchTimedOut); - assertTrue("EventSource.close() has timed out", closeTimedOut); + assertEquals("single", eventData.get(), "Unexpected event data"); + assertTrue(latchTimedOut, "Event latch has timed out"); + assertTrue(closeTimedOut, "EventSource.close() has timed out"); } } diff --git a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/sse/SseTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/sse/SseTest.java index cba0763f2d..a102d9bc2b 100644 --- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/sse/SseTest.java +++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/sse/SseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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,8 +20,8 @@ import org.glassfish.jersey.helidon.connector.HelidonConnectorProvider; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.annotation.PostConstruct; import javax.inject.Singleton; @@ -119,8 +119,8 @@ public void testSend() throws InterruptedException { latch.await(WAIT_TIME, TimeUnit.MILLISECONDS); } - Assert.assertEquals("AAAAAAAAAA", sb.toString()); - Assert.assertEquals(0, latch.getCount()); + Assertions.assertEquals("AAAAAAAAAA", sb.toString()); + Assertions.assertEquals(0, latch.getCount()); } @Test @@ -137,11 +137,11 @@ public void testBroadcast() throws InterruptedException { clientOne.messageLatch.await(WAIT_TIME, TimeUnit.MILLISECONDS); clientTwo.messageLatch.await(WAIT_TIME, TimeUnit.MILLISECONDS); - Assert.assertEquals(0, clientOne.messageLatch.getCount()); - Assert.assertEquals(0, clientTwo.messageLatch.getCount()); + Assertions.assertEquals(0, clientOne.messageLatch.getCount()); + Assertions.assertEquals(0, clientTwo.messageLatch.getCount()); - Assert.assertEquals(BroadcasterResource.WELCOME + PALINDROME + PALINDROME, clientOne.message.toString()); - Assert.assertEquals(BroadcasterResource.WELCOME + PALINDROME + PALINDROME, clientTwo.message.toString()); + Assertions.assertEquals(BroadcasterResource.WELCOME + PALINDROME + PALINDROME, clientOne.message.toString()); + Assertions.assertEquals(BroadcasterResource.WELCOME + PALINDROME + PALINDROME, clientTwo.message.toString()); clientOne.close(); clientTwo.close(); @@ -168,13 +168,13 @@ private void register() throws InterruptedException { source.open(); latch.await(WAIT_TIME, TimeUnit.MILLISECONDS); - Assert.assertEquals(0, latch.getCount()); + Assertions.assertEquals(0, latch.getCount()); } private void broadcast() { try (Response r = target.path("broadcast/broadcast") .request().buildPost(Entity.entity(PALINDROME, MediaType.TEXT_PLAIN)).invoke()) { - Assert.assertEquals(204, r.getStatus()); + Assertions.assertEquals(204, r.getStatus()); } } diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/HttpMethodTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/HttpMethodTest.java index 60f5f1bc6d..0f68e2050c 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/HttpMethodTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/HttpMethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -19,7 +19,7 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -30,8 +30,8 @@ import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the Http methods. diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/AsynchronousBodyInputStreamTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/AsynchronousBodyInputStreamTest.java index 3d64abeeb9..f67aa01b6c 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/AsynchronousBodyInputStreamTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/AsynchronousBodyInputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -26,14 +26,13 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import static junit.framework.TestCase.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/AsynchronousBodyOutputStreamTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/AsynchronousBodyOutputStreamTest.java index 2feea43ecc..e936df75c4 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/AsynchronousBodyOutputStreamTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/AsynchronousBodyOutputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -31,13 +31,12 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import static junit.framework.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ChunkedBodyOutputStreamTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ChunkedBodyOutputStreamTest.java index 474e9e9c85..a54345b33e 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ChunkedBodyOutputStreamTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ChunkedBodyOutputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -19,11 +19,11 @@ import java.io.IOException; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertFalse; -import static junit.framework.TestCase.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ConnectionPoolTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ConnectionPoolTest.java index 9585c54af1..2c5be92a6b 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ConnectionPoolTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ConnectionPoolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -44,9 +44,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/CookieTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/CookieTest.java index 82fee74e79..33ccc8534a 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/CookieTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/CookieTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -34,9 +34,9 @@ import org.glassfish.jersey.jdk.connector.JdkConnectorProvider; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz @@ -102,7 +102,7 @@ public void testIssue4678() { .get(); // Issue 4678 happens here. HttpParser splits the headers value by comma. List setCookies = response.getHeaders().get(HttpHeaders.SET_COOKIE); - assertEquals("Expected 1 cookie, but it received: " + setCookies, 1, setCookies.size()); + assertEquals(1, setCookies.size(), "Expected 1 cookie, but it received: " + setCookies); NewCookie newCookie = response.getCookies().get("foo2"); assertEquals("bar", newCookie.getValue()); } diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/EntityWriteTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/EntityWriteTest.java index 65ce246b32..0024fb852d 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/EntityWriteTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/EntityWriteTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/HttpConnectionTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/HttpConnectionTest.java index d2af874457..44b5dcf765 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/HttpConnectionTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/HttpConnectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -40,8 +40,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.AfterClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; import static org.glassfish.jersey.jdk.connector.internal.HttpConnection.State.CLOSED; import static org.glassfish.jersey.jdk.connector.internal.HttpConnection.State.CONNECTING; import static org.glassfish.jersey.jdk.connector.internal.HttpConnection.State.CONNECT_TIMEOUT; @@ -53,8 +53,8 @@ import static org.glassfish.jersey.jdk.connector.internal.HttpConnection.State.RECEIVING_HEADER; import static org.glassfish.jersey.jdk.connector.internal.HttpConnection.State.RESPONSE_TIMEOUT; import static org.glassfish.jersey.jdk.connector.internal.HttpConnection.State.SENDING_REQUEST; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Petr Janouch @@ -64,7 +64,7 @@ public class HttpConnectionTest extends JerseyTest { private static final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); private static final Throwable testError = new Throwable(); - @AfterClass + @AfterAll public static void cleanUp() { scheduler.shutdownNow(); } diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/HttpParserTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/HttpParserTest.java index 3dccc763c0..f3ed35adcc 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/HttpParserTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/HttpParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,13 +25,13 @@ import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Petr Janouch @@ -42,7 +42,7 @@ public class HttpParserTest { private HttpParser httpParser; - @Before + @BeforeEach public void prepare() { httpParser = new HttpParser(1000, 1000); } @@ -350,7 +350,7 @@ public void testSpacesInChunkSizeHeader() throws Exception { /** * This seems to be broken in Grizzly parser */ - @Ignore + @Disabled @Test public void testChunkExtension() throws ParseException, IOException { httpParser.reset(true); diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ModifyHeaderInBodyWriterTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ModifyHeaderInBodyWriterTest.java index f35cba79f4..6032eef4fc 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ModifyHeaderInBodyWriterTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ModifyHeaderInBodyWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -41,8 +41,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/MultiValueHeaderTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/MultiValueHeaderTest.java index 89348300be..b606a909e2 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/MultiValueHeaderTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/MultiValueHeaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Adam Lindenthal @@ -74,10 +74,10 @@ public void testCookieResource() { .header("tools", "drill") .get(); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final String values = response.getHeaderString("animals"); - Assert.assertEquals("mole,hedgehog,bat,rabbit", values); + Assertions.assertEquals("mole,hedgehog,bat,rabbit", values); } } diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ProxyTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ProxyTest.java index 266646cf0a..73d0f33beb 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ProxyTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ProxyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -42,10 +42,10 @@ import org.glassfish.grizzly.http.server.Request; import org.glassfish.grizzly.http.server.Response; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/PublicSitesTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/PublicSitesTest.java index 40f0181371..03cb5dcc2e 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/PublicSitesTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/PublicSitesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,16 +24,16 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Petr Janouch */ -@Ignore +@Disabled public class PublicSitesTest extends JerseyTest { @Test diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ReadChunkedEntity.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ReadChunkedEntity.java index 49dc28df93..6853c06762 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ReadChunkedEntity.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/ReadChunkedEntity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/RedirectTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/RedirectTest.java index 52722ec25b..966e1fcd0a 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/RedirectTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/RedirectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -33,11 +33,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Petr Janouch diff --git a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTest.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTest.java index 0a9dc13098..7cef70b14c 100644 --- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTest.java +++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -39,11 +39,11 @@ import javax.net.ssl.SSLSocket; import org.glassfish.jersey.SslConfigurator; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Petr Janouch diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AsyncTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AsyncTest.java index 53f98f39f2..6934a6007e 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AsyncTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,9 +36,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.hamcrest.Matchers; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Asynchronous connector test. diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AuthFilterTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AuthFilterTest.java index a3c90f75b9..e6b8636b5e 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AuthFilterTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AuthFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AuthTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AuthTest.java index 9008d9b025..f74656b142 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AuthTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/AuthTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -39,9 +39,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.eclipse.jetty.client.util.BasicAuthentication; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/CookieTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/CookieTest.java index d6cb6f1d27..31b9898bb7 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/CookieTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/CookieTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -37,11 +37,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/CustomLoggingFilter.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/CustomLoggingFilter.java index 8ab646bf8c..c2ffba7e3d 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/CustomLoggingFilter.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/CustomLoggingFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,7 +27,7 @@ import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Custom logging filter. @@ -43,28 +43,28 @@ public class CustomLoggingFilter implements ContainerRequestFilter, ContainerRes @Override public void filter(ClientRequestContext context) throws IOException { System.out.println("CustomLoggingFilter.preFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); preFilterCalled++; } @Override public void filter(ClientRequestContext context, ClientResponseContext clientResponseContext) throws IOException { System.out.println("CustomLoggingFilter.postFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); postFilterCalled++; } @Override public void filter(ContainerRequestContext context) throws IOException { System.out.println("CustomLoggingFilter.preFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); preFilterCalled++; } @Override public void filter(ContainerRequestContext context, ContainerResponseContext containerResponseContext) throws IOException { System.out.println("CustomLoggingFilter.postFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); postFilterCalled++; } } diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/EntityTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/EntityTest.java index eaaa126f18..7a8b3d2a74 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/EntityTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/EntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,8 +36,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests the Http content negotiation. diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/ErrorTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/ErrorTest.java index 3425f63b02..128807aa7c 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/ErrorTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/ErrorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/FollowRedirectsTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/FollowRedirectsTest.java index b618241679..448494c8b2 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/FollowRedirectsTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/FollowRedirectsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -39,8 +39,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Jetty connector follow redirect tests. diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/GZIPContentEncodingTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/GZIPContentEncodingTest.java index 9ecb0aaa5c..5769766317 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/GZIPContentEncodingTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/GZIPContentEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,8 +36,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/HelloWorldTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/HelloWorldTest.java index 73743ebe67..e2e36ac0a8 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/HelloWorldTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -37,9 +37,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/HttpHeadersTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/HttpHeadersTest.java index b6e3ec8142..73a327ff95 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/HttpHeadersTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/HttpHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -33,10 +33,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -96,6 +96,6 @@ public void testPost() { @Test public void testUserAgent() { String response = target().path("test").request().get(String.class); - assertTrue("User-agent header should start with 'Jersey', but was " + response, response.startsWith("Jersey")); + assertTrue(response.startsWith("Jersey"), "User-agent header should start with 'Jersey', but was " + response); } } diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/ManagedClientTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/ManagedClientTest.java index 4c2606760b..9cb39841c6 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/ManagedClientTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/ManagedClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -46,8 +46,8 @@ import org.glassfish.jersey.server.Uri; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Jersey programmatic managed client test diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/MethodTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/MethodTest.java index 6ce7a9198f..2e25101e3a 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/MethodTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/MethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -35,8 +35,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests the Http methods. diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/NoEntityTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/NoEntityTest.java index 35ca43645d..8b64d10b50 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/NoEntityTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/NoEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,7 +31,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Paul Sandoz diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/SyncResponseSizeTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/SyncResponseSizeTest.java index 423cc7e1cb..21816cf276 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/SyncResponseSizeTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/SyncResponseSizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,7 +21,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -37,10 +37,10 @@ import java.util.logging.Logger; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Default synchronous jetty client implementation has a hard response size limit of 2MiB. diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/TimeoutTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/TimeoutTest.java index 48c5bed5c1..ec7944294c 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/TimeoutTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/TimeoutTest.java @@ -16,12 +16,6 @@ package org.glassfish.jersey.jetty.connector; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; @@ -46,7 +40,13 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; + +import org.junit.jupiter.api.Test; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula @@ -200,7 +200,7 @@ public void testSlowlyStreamedContentDoesTotalTimeout() throws Exception { int pauseMillis = 50; try { - target("test") + target("test") .property(JettyClientProperties.TOTAL_TIMEOUT, 100L) .property(CommonProperties.OUTBOUND_CONTENT_LENGTH_BUFFER_SERVER, "-1") .path("stream") diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/TraceSupportTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/TraceSupportTest.java index f2642eb27b..022667a262 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/TraceSupportTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/TraceSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -45,10 +45,10 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * This very basic resource showcases support of a HTTP TRACE method, @@ -129,9 +129,9 @@ public void testProgrammaticApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsProgrammatic) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } @@ -143,9 +143,9 @@ public void testAnnotatedApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsAnnotated) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } diff --git a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/UnderlyingHttpClientAccessTest.java b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/UnderlyingHttpClientAccessTest.java index ff64489f97..e5d9ec6691 100644 --- a/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/UnderlyingHttpClientAccessTest.java +++ b/connectors/jetty-connector/src/test/java/org/glassfish/jersey/jetty/connector/UnderlyingHttpClientAccessTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,12 +23,12 @@ import org.glassfish.jersey.client.ClientConfig; import org.eclipse.jetty.client.HttpClient; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test of access to the underlying HTTP client instance used by the connector. @@ -50,12 +50,10 @@ public void testHttpClientInstanceAccess() { final WebTarget target = client.target("http://localhost/"); final HttpClient hcOnTarget = JettyConnectorProvider.getHttpClient(target); - assertNotNull("HTTP client instance set on JerseyClient should not be null.", hcOnClient); - assertNotNull("HTTP client instance set on JerseyWebTarget should not be null.", hcOnTarget); - assertSame("HTTP client instance set on JerseyClient should be the same instance as the one set on JerseyWebTarget" - + "(provided the target instance has not been further configured).", - hcOnClient, hcOnTarget - ); + assertNotNull(hcOnClient, "HTTP client instance set on JerseyClient should not be null."); + assertNotNull(hcOnTarget, "HTTP client instance set on JerseyWebTarget should not be null."); + assertSame(hcOnClient, hcOnTarget, "HTTP client instance set on JerseyClient should be the same instance as the one " + + "set on JerseyWebTarget (provided the target instance has not been further configured)."); } @Test diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/AsyncTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/AsyncTest.java index 6a9637bade..6217b52758 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/AsyncTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/AsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -35,9 +35,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.hamcrest.Matchers; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Asynchronous connector test. diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/CustomLoggingFilter.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/CustomLoggingFilter.java index 44dbc2a82a..e83ca382ae 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/CustomLoggingFilter.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/CustomLoggingFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -28,7 +28,7 @@ import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Custom logging filter. @@ -46,28 +46,28 @@ public class CustomLoggingFilter implements ContainerRequestFilter, ContainerRes @Override public void filter(ClientRequestContext context) throws IOException { LOGGER.info("CustomLoggingFilter.preFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); preFilterCalled++; } @Override public void filter(ClientRequestContext context, ClientResponseContext clientResponseContext) throws IOException { LOGGER.info("CustomLoggingFilter.postFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); postFilterCalled++; } @Override public void filter(ContainerRequestContext context) throws IOException { LOGGER.info("CustomLoggingFilter.preFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); preFilterCalled++; } @Override public void filter(ContainerRequestContext context, ContainerResponseContext containerResponseContext) throws IOException { LOGGER.info("CustomLoggingFilter.postFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); postFilterCalled++; } } diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/FollowRedirectsTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/FollowRedirectsTest.java index 269562297d..3a52c65be1 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/FollowRedirectsTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/FollowRedirectsTest.java @@ -16,8 +16,8 @@ package org.glassfish.jersey.netty.connector; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.net.URI; import java.util.logging.Logger; @@ -37,7 +37,7 @@ import org.glassfish.jersey.netty.connector.internal.RedirectException; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class FollowRedirectsTest extends JerseyTest { diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HelloWorldTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HelloWorldTest.java index 20caa533d3..d30c9b9e8f 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HelloWorldTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -36,9 +36,9 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HttpHeadersTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HttpHeadersTest.java index f5438e5ac6..905e155973 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HttpHeadersTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HttpHeadersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the headers. diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HugeEntityTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HugeEntityTest.java index 44d7f38eec..f3cfd7ef01 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HugeEntityTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/HugeEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -38,7 +38,7 @@ import org.glassfish.jersey.client.RequestEntityProcessing; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/MethodTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/MethodTest.java index f0c639b283..d4ec71810a 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/MethodTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/MethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests the Http methods. diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/NoEntityTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/NoEntityTest.java index 2677c3ed11..f9670ce84b 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/NoEntityTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/NoEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -29,7 +29,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Paul Sandoz diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/ParallelTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/ParallelTest.java index e457b31330..43ce709292 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/ParallelTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/ParallelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -36,10 +36,10 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the parallel execution of multiple requests. @@ -119,15 +119,15 @@ public void run() { startBarrier.await(1, TimeUnit.SECONDS); - assertTrue("Waiting for clients to finish has timed out.", doneLatch.await(5 * getAsyncTimeoutMultiplier(), - TimeUnit.SECONDS)); + assertTrue(doneLatch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), + "Waiting for clients to finish has timed out."); - assertEquals("Resource counter", PARALLEL_CLIENTS, resourceCounter.get()); + assertEquals(PARALLEL_CLIENTS, resourceCounter.get(), "Resource counter"); - assertEquals("Received counter", PARALLEL_CLIENTS, receivedCounter.get()); + assertEquals(PARALLEL_CLIENTS, receivedCounter.get(), "Received counter"); } finally { executor.shutdownNow(); - Assert.assertTrue("Executor termination", executor.awaitTermination(5, TimeUnit.SECONDS)); + Assertions.assertTrue(executor.awaitTermination(5, TimeUnit.SECONDS), "Executor termination"); } } } diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/TimeoutTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/TimeoutTest.java index f88e132622..26c2884535 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/TimeoutTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/TimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -29,11 +29,11 @@ import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula diff --git a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/TraceSupportTest.java b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/TraceSupportTest.java index 4ce24f54b7..102307f848 100644 --- a/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/TraceSupportTest.java +++ b/connectors/netty-connector/src/test/java/org/glassfish/jersey/netty/connector/TraceSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -44,10 +44,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * This very basic resource showcases support of a HTTP TRACE method, @@ -128,9 +128,9 @@ public void testProgrammaticApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsProgrammatic) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } @@ -142,9 +142,9 @@ public void testAnnotatedApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsAnnotated) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } diff --git a/connectors/pom.xml b/connectors/pom.xml index d3a0f47f9b..9e60cb3df8 100644 --- a/connectors/pom.xml +++ b/connectors/pom.xml @@ -60,8 +60,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/containers/jdk-http/pom.xml b/containers/jdk-http/pom.xml index a2d341d7d0..fc8d7359ac 100644 --- a/containers/jdk-http/pom.xml +++ b/containers/jdk-http/pom.xml @@ -39,6 +39,11 @@ test ${commons.io.version} + + org.hamcrest + hamcrest + test + diff --git a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/AbstractJdkHttpServerTester.java b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/AbstractJdkHttpServerTester.java index 9e1660a559..02b47735b4 100644 --- a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/AbstractJdkHttpServerTester.java +++ b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/AbstractJdkHttpServerTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.internal.util.PropertiesHelper; import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; /** * Abstract JDK HTTP Server unit tester. @@ -103,7 +103,7 @@ public void stopServer() { } } - @After + @AfterEach public void tearDown() { if (server != null) { stopServer(); diff --git a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/BasicJdkHttpServerTest.java b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/BasicJdkHttpServerTest.java index 67eaab80ae..32a98e1c74 100644 --- a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/BasicJdkHttpServerTest.java +++ b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/BasicJdkHttpServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.internal.util.JdkVersion; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; @@ -72,7 +72,7 @@ public void testCreateHttpsServer() throws Exception { } } - @After + @AfterEach public void tearDown() { if (server != null) { server.stop(3); diff --git a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpPackageTest.java b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpPackageTest.java index ea327c0ec2..6b5100d0e1 100644 --- a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpPackageTest.java +++ b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpPackageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Jdk Http Container package scanning test. diff --git a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpsServerTest.java b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpsServerTest.java index e814720ff8..02a0dda0b2 100644 --- a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpsServerTest.java +++ b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/JdkHttpsServerTest.java @@ -35,8 +35,8 @@ import org.glassfish.jersey.internal.util.JdkVersion; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpsConfigurator; @@ -45,7 +45,8 @@ import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Jdk Https Server tests. @@ -95,9 +96,10 @@ public void testCreateHttpsServerNoSslContext() throws Exception { * Test, that exception is thrown when attempting to start a {@link HttpsServer} with empty SSLContext. * @throws Exception */ - @Test(expected = IllegalArgumentException.class) + @Test public void testStartHttpServerNoSslContext() throws Exception { - server = JdkHttpServerFactory.createHttpServer(httpsUri, rc, null, true); + assertThrows(IllegalArgumentException.class, + () -> JdkHttpServerFactory.createHttpServer(httpsUri, rc, null, true)); } /** @@ -105,18 +107,20 @@ public void testStartHttpServerNoSslContext() throws Exception { * not configured correctly. * @throws Exception */ - @Test(expected = SSLHandshakeException.class) + @Test public void testCreateHttpsServerDefaultSslContext() throws Throwable { - server = JdkHttpServerFactory.createHttpServer(httpsUri, rc, SSLContext.getDefault(), true); - assertThat(server, instanceOf(HttpsServer.class)); - - // access the https server with not configured client - final Client client = ClientBuilder.newBuilder().newClient(); - try { - client.target(httpsUri).path("testHttps").request().get(String.class); - } catch (final ProcessingException e) { - throw e.getCause(); - } + assertThrows(SSLHandshakeException.class, () -> { + server = JdkHttpServerFactory.createHttpServer(httpsUri, rc, SSLContext.getDefault(), true); + assertThat(server, instanceOf(HttpsServer.class)); + + // access the https server with not configured client + final Client client = ClientBuilder.newBuilder().newClient(); + try { + client.target(httpsUri).path("testHttps").request().get(String.class); + } catch (final ProcessingException e) { + throw e.getCause(); + } + }); } /** @@ -124,30 +128,34 @@ public void testCreateHttpsServerDefaultSslContext() throws Throwable { * on request. * @throws Exception */ - @Test(expected = IOException.class) + @Test public void testHttpsServerNoSslContextDelayedStart() throws Throwable { - server = JdkHttpServerFactory.createHttpServer(httpsUri, rc, null, false); - assertThat(server, instanceOf(HttpsServer.class)); - server.start(); - - final Client client = ClientBuilder.newBuilder().newClient(); - try { - client.target(httpsUri).path("testHttps").request().get(String.class); - } catch (final ProcessingException e) { - throw e.getCause(); - } + assertThrows(IOException.class, () -> { + server = JdkHttpServerFactory.createHttpServer(httpsUri, rc, null, false); + assertThat(server, instanceOf(HttpsServer.class)); + server.start(); + + final Client client = ClientBuilder.newBuilder().newClient(); + try { + client.target(httpsUri).path("testHttps").request().get(String.class); + } catch (final ProcessingException e) { + throw e.getCause(); + } + }); } /** * Test, that {@link HttpsServer} cannot be configured with {@link HttpsConfigurator} after it has started. * @throws Exception */ - @Test(expected = IllegalStateException.class) + @Test public void testConfigureSslContextAfterStart() throws Throwable { - server = JdkHttpServerFactory.createHttpServer(httpsUri, rc, null, false); - assertThat(server, instanceOf(HttpsServer.class)); - server.start(); - ((HttpsServer) server).setHttpsConfigurator(new HttpsConfigurator(getServerSslContext())); + assertThrows(IllegalStateException.class, () -> { + server = JdkHttpServerFactory.createHttpServer(httpsUri, rc, null, false); + assertThat(server, instanceOf(HttpsServer.class)); + server.start(); + ((HttpsServer) server).setHttpsConfigurator(new HttpsConfigurator(getServerSslContext())); + }); } /** @@ -208,7 +216,7 @@ private SSLContext getServerSslContext() throws IOException { return sslConfigServer.createSSLContext(); } - @After + @AfterEach public void tearDown() { if (server != null) { server.stop(0); diff --git a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/LifecycleListenerTest.java b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/LifecycleListenerTest.java index c2acf8daf6..61670a3b9d 100644 --- a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/LifecycleListenerTest.java +++ b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/LifecycleListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,11 +26,11 @@ import org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener; import org.glassfish.jersey.server.spi.Container; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Reload and ContainerLifecycleListener support test. @@ -129,7 +129,7 @@ public void testStartupShutdownHooks() { stopServer(); - assertTrue("ContainerLifecycleListener.onStartup has not been called.", listener.started); - assertTrue("ContainerLifecycleListener.onShutdown has not been called.", listener.stopped); + assertTrue(listener.started, "ContainerLifecycleListener.onStartup has not been called."); + assertTrue(listener.stopped, "ContainerLifecycleListener.onShutdown has not been called."); } } diff --git a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/RuntimeDelegateTest.java b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/RuntimeDelegateTest.java index 26abd46b7f..9b37c35eee 100644 --- a/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/RuntimeDelegateTest.java +++ b/containers/jdk-http/src/test/java/org/glassfish/jersey/jdkhttp/RuntimeDelegateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -28,9 +28,9 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.ext.RuntimeDelegate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; diff --git a/containers/jersey-servlet-core/src/test/java/org/glassfish/jersey/servlet/internal/ContextPathEncodingTest.java b/containers/jersey-servlet-core/src/test/java/org/glassfish/jersey/servlet/internal/ContextPathEncodingTest.java index 9ab2e92de2..c23e4d1d6f 100644 --- a/containers/jersey-servlet-core/src/test/java/org/glassfish/jersey/servlet/internal/ContextPathEncodingTest.java +++ b/containers/jersey-servlet-core/src/test/java/org/glassfish/jersey/servlet/internal/ContextPathEncodingTest.java @@ -22,8 +22,8 @@ import org.glassfish.jersey.internal.util.collection.Value; import org.glassfish.jersey.internal.util.collection.Values; import org.glassfish.jersey.servlet.ServletContainer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.lang.reflect.InvocationHandler; @@ -141,8 +141,8 @@ static class EncodingTestServletContainer extends ServletContainer { @Override public Value service(URI baseUri, URI requestUri, HttpServletRequest request, HttpServletResponse response) { - Assert.assertEquals(this.baseUri, baseUri.toASCIIString()); - Assert.assertEquals(this.requestUri, requestUri.toASCIIString()); + Assertions.assertEquals(this.baseUri, baseUri.toASCIIString()); + Assertions.assertEquals(this.requestUri, requestUri.toASCIIString()); return Values.of(0); } diff --git a/containers/jersey-servlet-core/src/test/java/org/glassfish/jersey/servlet/internal/ThreadLocalInvokerTest.java b/containers/jersey-servlet-core/src/test/java/org/glassfish/jersey/servlet/internal/ThreadLocalInvokerTest.java index b4476fcb6a..b69603d526 100644 --- a/containers/jersey-servlet-core/src/test/java/org/glassfish/jersey/servlet/internal/ThreadLocalInvokerTest.java +++ b/containers/jersey-servlet-core/src/test/java/org/glassfish/jersey/servlet/internal/ThreadLocalInvokerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,9 +18,9 @@ import java.lang.reflect.Proxy; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos diff --git a/containers/jetty-http/pom.xml b/containers/jetty-http/pom.xml index 86ea4683b1..47593ecbfc 100644 --- a/containers/jetty-http/pom.xml +++ b/containers/jetty-http/pom.xml @@ -54,6 +54,11 @@ httpclient test + + org.hamcrest + hamcrest + test + diff --git a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/AbstractJettyServerTester.java b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/AbstractJettyServerTester.java index dcfe4b7848..13bfe6ad4b 100644 --- a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/AbstractJettyServerTester.java +++ b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/AbstractJettyServerTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,7 +28,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.eclipse.jetty.server.Server; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; /** * Abstract Jetty Server unit tester. @@ -105,7 +105,7 @@ public void stopServer() { } } - @After + @AfterEach public void tearDown() { if (server != null) { stopServer(); diff --git a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/AsyncTest.java b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/AsyncTest.java index b4d6b811e1..da156be06b 100644 --- a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/AsyncTest.java +++ b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/AsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,12 +31,12 @@ import javax.ws.rs.container.TimeoutHandler; import javax.ws.rs.core.Response; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Arul Dhesiaseelan (aruld at acm.org) @@ -121,14 +121,14 @@ public void run() { private Client client; - @Before + @BeforeEach public void setUp() throws Exception { startServer(AsyncResource.class); client = ClientBuilder.newClient(); } @Override - @After + @AfterEach public void tearDown() { super.tearDown(); client = null; diff --git a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/ExceptionTest.java b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/ExceptionTest.java index ce299cdf81..039a7a8e13 100644 --- a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/ExceptionTest.java +++ b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/ExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -21,7 +21,7 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.message.BasicHttpRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -35,7 +35,7 @@ import java.io.IOException; import java.net.URI; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/LifecycleListenerTest.java b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/LifecycleListenerTest.java index 15b299a186..12ee763380 100644 --- a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/LifecycleListenerTest.java +++ b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/LifecycleListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -19,7 +19,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener; import org.glassfish.jersey.server.spi.Container; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -29,9 +29,9 @@ import javax.ws.rs.core.Response; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -127,7 +127,7 @@ public void testStartupShutdownHooks() { stopServer(); - assertTrue("ContainerLifecycleListener.onStartup has not been called.", listener.started); - assertTrue("ContainerLifecycleListener.onShutdown has not been called.", listener.stopped); + assertTrue(listener.started, "ContainerLifecycleListener.onStartup has not been called."); + assertTrue(listener.stopped, "ContainerLifecycleListener.onShutdown has not been called."); } } diff --git a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/OptionsTest.java b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/OptionsTest.java index 8866c336d1..94d0c33599 100644 --- a/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/OptionsTest.java +++ b/containers/jetty-http/src/test/java/org/glassfish/jersey/jetty/OptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -16,7 +16,7 @@ package org.glassfish.jersey.jetty; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -25,8 +25,8 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class OptionsTest extends AbstractJettyServerTester { diff --git a/containers/pom.xml b/containers/pom.xml index 00ee924f3e..44386266f3 100644 --- a/containers/pom.xml +++ b/containers/pom.xml @@ -70,8 +70,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/containers/simple-http/pom.xml b/containers/simple-http/pom.xml index d75aa7a8e4..76c62903da 100644 --- a/containers/simple-http/pom.xml +++ b/containers/simple-http/pom.xml @@ -49,6 +49,11 @@ org.simpleframework simple-common + + org.hamcrest + hamcrest + test + diff --git a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/AbstractSimpleServerTester.java b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/AbstractSimpleServerTester.java index eb653ca4d8..290de5242a 100644 --- a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/AbstractSimpleServerTester.java +++ b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/AbstractSimpleServerTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; /** * Abstract Simple HTTP Server unit tester. @@ -127,7 +127,7 @@ public void stopServer() { } } - @After + @AfterEach public void tearDown() { if (server != null) { stopServer(); diff --git a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/AsyncTest.java b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/AsyncTest.java index 9587b04f3c..5ef98f81af 100644 --- a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/AsyncTest.java +++ b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/AsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,12 +31,12 @@ import javax.ws.rs.container.TimeoutHandler; import javax.ws.rs.core.Response; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Arul Dhesiaseelan (aruld at acm.org) @@ -123,14 +123,14 @@ public void run() { private Client client; - @Before + @BeforeEach public void setUp() throws Exception { startServer(AsyncResource.class); client = ClientBuilder.newClient(); } @Override - @After + @AfterEach public void tearDown() { super.tearDown(); client = null; diff --git a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/ExceptionTest.java b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/ExceptionTest.java index 15e7b28925..8c36c1d9ca 100644 --- a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/ExceptionTest.java +++ b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/ExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,8 +25,8 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/LifecycleListenerTest.java b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/LifecycleListenerTest.java index 4c163292ee..bbab64068f 100644 --- a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/LifecycleListenerTest.java +++ b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/LifecycleListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -26,11 +26,11 @@ import org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener; import org.glassfish.jersey.server.spi.Container; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** @@ -124,7 +124,7 @@ public void testStartupShutdownHooks() { stopServer(); - assertTrue("ContainerLifecycleListener.onStartup has not been called.", listener.started); - assertTrue("ContainerLifecycleListener.onShutdown has not been called.", listener.stopped); + assertTrue(listener.started, "ContainerLifecycleListener.onStartup has not been called."); + assertTrue(listener.stopped, "ContainerLifecycleListener.onShutdown has not been called."); } } diff --git a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/OptionsTest.java b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/OptionsTest.java index 3b12b1a34f..b0d2f876f5 100644 --- a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/OptionsTest.java +++ b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/OptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -23,13 +23,13 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class OptionsTest extends AbstractSimpleServerTester { @@ -57,14 +57,14 @@ public String getCurrentUser() { private Client client; - @Before + @BeforeEach public void setUp() throws Exception { startServer(HelloWorldResource.class, UserResource.class); client = ClientBuilder.newClient(); } @Override - @After + @AfterEach public void tearDown() { super.tearDown(); client = null; diff --git a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/ParallelTest.java b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/ParallelTest.java index e0b6611065..1386bc592f 100644 --- a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/ParallelTest.java +++ b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/ParallelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests the parallel execution of multiple requests. diff --git a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/TraceTest.java b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/TraceTest.java index 1e2d7378ef..00e980f5ec 100644 --- a/containers/simple-http/src/test/java/org/glassfish/jersey/simple/TraceTest.java +++ b/containers/simple-http/src/test/java/org/glassfish/jersey/simple/TraceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -23,13 +23,13 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.Response; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TraceTest extends AbstractSimpleServerTester { @@ -57,7 +57,7 @@ public String getCurrentUser() { private Client client; - @Before + @BeforeEach public void setUp() throws Exception { startServerNoLoggingFilter(HelloWorldResource.class, UserResource.class); // disable crude // LoggingFilter @@ -66,7 +66,7 @@ public void setUp() throws Exception { } @Override - @After + @AfterEach public void tearDown() { super.tearDown(); client = null; diff --git a/core-client/pom.xml b/core-client/pom.xml index 196cca9684..9769e7e50d 100644 --- a/core-client/pom.xml +++ b/core-client/pom.xml @@ -127,8 +127,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/core-client/src/test/java/org/glassfish/jersey/client/AutoDiscoverableClientTest.java b/core-client/src/test/java/org/glassfish/jersey/client/AutoDiscoverableClientTest.java index d81380ad8f..f0eba7b405 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/AutoDiscoverableClientTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/AutoDiscoverableClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,12 +35,11 @@ import org.glassfish.jersey.CommonProperties; import org.glassfish.jersey.internal.spi.AutoDiscoverable; import org.glassfish.jersey.internal.util.PropertiesHelper; - -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Note: Auto-discoverables from this test "affects" all other tests in suit. @@ -171,7 +170,7 @@ public void testAutoDiscoverableGlobalEnabledServerDisabled() throws Exception { * {@link javax.ws.rs.core.Feature} will be notified when {@link javax.ws.rs.client.Client#close()} is invoked. */ @Test - @Ignore("intermittent failures.") + @Disabled("intermittent failures.") public void testAutoDiscoverableClosing() { final ClientConfig config = new ClientConfig(); config.property(PROPERTY, true); @@ -180,12 +179,12 @@ public void testAutoDiscoverableClosing() { assertFalse(FooLifecycleListener.isClosed()); client.getConfiguration().getRuntime(); // force runtime init - assertTrue("FooLifecycleListener was expected to be already initialized.", FooLifecycleListener.isInitialized()); - assertFalse("FooLifecycleListener was not expected to be closed yet.", FooLifecycleListener.isClosed()); + assertTrue(FooLifecycleListener.isInitialized(), "FooLifecycleListener was expected to be already initialized."); + assertFalse(FooLifecycleListener.isClosed(), "FooLifecycleListener was not expected to be closed yet."); client.close(); - assertTrue("FooLifecycleListener should have been closed.", FooLifecycleListener.isClosed()); + assertTrue(FooLifecycleListener.isClosed(), "FooLifecycleListener should have been closed."); } private void _test(final String response, final Boolean globalDisable, final Boolean clientDisable) throws Exception { diff --git a/core-client/src/test/java/org/glassfish/jersey/client/ClientConfigTest.java b/core-client/src/test/java/org/glassfish/jersey/client/ClientConfigTest.java index f813eae8ed..eff6b19246 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/ClientConfigTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/ClientConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,18 +29,19 @@ import org.glassfish.jersey.internal.util.collection.UnsafeValue; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * {@link ClientConfig} unit test. @@ -52,19 +53,19 @@ public class ClientConfigTest { public ClientConfigTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { } - @AfterClass + @AfterAll public static void tearDownClass() throws Exception { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } @@ -180,16 +181,20 @@ public void testGetFeatures() { assertTrue(runtimeConfig.isEnabled(emptyFeature)); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testGetProviderClasses() { - ClientConfig instance = new ClientConfig(); - instance.getClasses().add(ClientConfigTest.class); + assertThrows(UnsupportedOperationException.class, () -> { + ClientConfig instance = new ClientConfig(); + instance.getClasses().add(ClientConfigTest.class); + }); } - @Test(expected = UnsupportedOperationException.class) + @Test public void testGetProviderInstances() { - ClientConfig instance = new ClientConfig(); - instance.getInstances().add(this); + assertThrows(UnsupportedOperationException.class, () -> { + ClientConfig instance = new ClientConfig(); + instance.getInstances().add(this); + }); } @Test diff --git a/core-client/src/test/java/org/glassfish/jersey/client/ClientRequestTest.java b/core-client/src/test/java/org/glassfish/jersey/client/ClientRequestTest.java index 965241138a..58f689c72a 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/ClientRequestTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/ClientRequestTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,19 +32,20 @@ import org.glassfish.jersey.message.MessageBodyWorkers; import org.hamcrest.core.Is; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.same; @@ -63,12 +64,12 @@ public class ClientRequestTest { private AutoCloseable mockito; - @Before + @BeforeEach public void initMocks() { mockito = MockitoAnnotations.openMocks(this); } - @After + @AfterEach public void closeMocks() throws Exception { mockito.close(); } @@ -178,7 +179,7 @@ public void testSSLExceptionHandling() request.doWriteEntity(workers, entityType); fail("An IOException exception should be thrown."); } catch (IOException e) { - Assert.assertThat("Detected a un-expected exception! \n" + ExceptionUtils.exceptionStackTraceAsString(e), + MatcherAssert.assertThat("Detected a un-expected exception! \n" + ExceptionUtils.exceptionStackTraceAsString(e), e, Is.is(ioException)); } } @@ -193,9 +194,9 @@ public void testRuntimeExceptionBeingReThrown() try { request.doWriteEntity(workers, entityType); - Assert.fail("A RuntimeException exception should be thrown."); + Assertions.fail("A RuntimeException exception should be thrown."); } catch (RuntimeException e) { - Assert.assertThat("Detected a un-expected exception! \n" + ExceptionUtils.exceptionStackTraceAsString(e), + MatcherAssert.assertThat("Detected a un-expected exception! \n" + ExceptionUtils.exceptionStackTraceAsString(e), e, Is.is(runtimeException)); } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/ClientResponseTest.java b/core-client/src/test/java/org/glassfish/jersey/client/ClientResponseTest.java index 7456edb6db..41601afeb5 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/ClientResponseTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/ClientResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -17,8 +17,8 @@ package org.glassfish.jersey.client; import org.glassfish.jersey.message.internal.InboundMessageContext; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.ClientRequestFilter; @@ -37,27 +37,27 @@ protected Iterable getReaderInterceptors() { } }; - Assert.assertFalse(inboundMessageContext.hasEntity()); + Assertions.assertFalse(inboundMessageContext.hasEntity()); inboundMessageContext.bufferEntity(); - Assert.assertFalse(inboundMessageContext.hasEntity()); + Assertions.assertFalse(inboundMessageContext.hasEntity()); } @Test public void testHasEntity() { final ClientRequestFilter abortFilter = requestContext -> requestContext.abortWith(Response.ok("hello").build()); try (Response r = ClientBuilder.newClient().register(abortFilter).target("http://localhost:8080").request().get()) { - Assert.assertTrue(r.hasEntity()); + Assertions.assertTrue(r.hasEntity()); r.bufferEntity(); - Assert.assertTrue(r.hasEntity()); + Assertions.assertTrue(r.hasEntity()); final String s = r.readEntity(String.class); - Assert.assertTrue(r.hasEntity()); + Assertions.assertTrue(r.hasEntity()); final InputStream bufferedEntityStream = r.readEntity(InputStream.class); - Assert.assertNotNull(bufferedEntityStream); - Assert.assertTrue(r.hasEntity()); + Assertions.assertNotNull(bufferedEntityStream); + Assertions.assertTrue(r.hasEntity()); } } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/ClientRxTest.java b/core-client/src/test/java/org/glassfish/jersey/client/ClientRxTest.java index f7792f1971..a2ecf082c9 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/ClientRxTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/ClientRxTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -47,14 +47,13 @@ import org.glassfish.jersey.spi.ExecutorServiceProvider; import org.hamcrest.core.AllOf; import org.hamcrest.core.StringContains; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Sanity test for {@link Invocation.Builder#rx()} methods. @@ -75,16 +74,13 @@ public ClientRxTest() { CLIENT_WITH_EXECUTOR = ClientBuilder.newBuilder().executorService(EXECUTOR_SERVICE).build(); } - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @After + @AfterEach public void afterTest() { CLIENT.close(); CLIENT_WITH_EXECUTOR.close(); } - @AfterClass + @AfterAll public static void afterClass() { EXECUTOR_SERVICE.shutdownNow(); } @@ -96,7 +92,7 @@ public void testRxInvoker() { String s = target(CLIENT).request().rx(TestRxInvoker.class).get(); - assertTrue("Provided RxInvoker was not used.", s.startsWith("rxTestInvoker")); + assertTrue(s.startsWith("rxTestInvoker"), "Provided RxInvoker was not used."); } @Test @@ -104,8 +100,8 @@ public void testRxInvokerWithExecutor() { // implicit register (not saying that the contract is RxInvokerProvider). String s = target(CLIENT_WITH_EXECUTOR).register(TestRxInvokerProvider.class).request().rx(TestRxInvoker.class).get(); - assertTrue("Provided RxInvoker was not used.", s.startsWith("rxTestInvoker")); - assertTrue("Executor Service was not passed to RxInvoker", s.contains("rxTest-")); + assertTrue(s.startsWith("rxTestInvoker"), "Provided RxInvoker was not used."); + assertTrue(s.contains("rxTest-"), "Executor Service was not passed to RxInvoker"); } @Test @@ -119,7 +115,7 @@ public void testDefaultRxInvokerWithExecutor() throws ExecutionException, Interr .request().rx().get().toCompletableFuture().get()) { assertEquals(200, r.getStatus()); - assertTrue("Executor Service was not passed to RxInvoker", threadName.get().contains("rxTest-")); + assertTrue(threadName.get().contains("rxTest-"), "Executor Service was not passed to RxInvoker"); } } @@ -131,8 +127,8 @@ public void testRxInvokerWithExecutorServiceProvider() { .register(TestExecutorServiceProvider.class) .request().rx(TestRxInvoker.class).get(); - assertTrue("Provided RxInvoker was not used.", s.startsWith("rxTestInvoker")); - assertTrue("Executor Service was not passed to RxInvoker", s.contains("rxTest-")); + assertTrue(s.startsWith("rxTestInvoker"), "Provided RxInvoker was not used."); + assertTrue(s.contains("rxTest-"), "Executor Service was not passed to RxInvoker"); } @Test @@ -147,27 +143,33 @@ public void testDefaultRxInvokerWithExecutorServiceProvider() throws ExecutionEx .request().rx().get().toCompletableFuture().get()) { assertEquals(200, r.getStatus()); - assertTrue("Executor Service was not passed to RxInvoker", threadName.get().contains("rxTest-")); + assertTrue(threadName.get().contains("rxTest-"), "Executor Service was not passed to RxInvoker"); } } @Test public void testRxInvokerInvalid() { - Invocation.Builder request = target(CLIENT).request(); - thrown.expect(IllegalArgumentException.class); - thrown.expectMessage(AllOf.allOf(new StringContains("null"), new StringContains("clazz"))); - request.rx(null).get(); + IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> { + Invocation.Builder request = target(CLIENT).request(); + request.rx(null).get(); + }); + String message = exception.getMessage(); + Assertions.assertTrue(AllOf.allOf(new StringContains("null"), new StringContains("clazz")).matches(message)); } @Test public void testRxInvokerNotRegistered() { - Invocation.Builder request = target(CLIENT).request(); - thrown.expect(IllegalStateException.class); - thrown.expectMessage(AllOf.allOf( - new StringContains("TestRxInvoker"), - new StringContains("not registered"), - new StringContains("RxInvokerProvider"))); - request.rx(TestRxInvoker.class).get(); + IllegalStateException exception = Assertions.assertThrows(IllegalStateException.class, () -> { + Invocation.Builder request = target(CLIENT).request(); + request.rx(TestRxInvoker.class).get(); + }); + String message = exception.getMessage(); + Assertions.assertTrue(AllOf.allOf( + new StringContains("TestRxInvoker"), + new StringContains("not registered"), + new StringContains("RxInvokerProvider")) + .matches(message)); + } @Test @@ -258,8 +260,8 @@ public void testRxInvokerWithPriorityExecutorServiceProvider() { .register(PriorityTestExecutorServiceProvider.class) .request().rx(PriorityTestRxInvoker.class).get(); - assertTrue("Provided RxInvoker was not used.", s.startsWith("PriorityTestRxInvoker")); - assertTrue("@ClientAsyncExecutor Executor Service was not passed to RxInvoker", s.contains("TRUE")); + assertTrue(s.startsWith("PriorityTestRxInvoker"), "Provided RxInvoker was not used."); + assertTrue(s.contains("TRUE"), "@ClientAsyncExecutor Executor Service was not passed to RxInvoker"); } @ClientAsyncExecutor diff --git a/core-client/src/test/java/org/glassfish/jersey/client/CustomConnectorTest.java b/core-client/src/test/java/org/glassfish/jersey/client/CustomConnectorTest.java index 17b83e7e33..d02e80a9cd 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/CustomConnectorTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/CustomConnectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -34,10 +34,10 @@ import org.glassfish.jersey.client.spi.Connector; import org.glassfish.jersey.client.spi.ConnectorProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/core-client/src/test/java/org/glassfish/jersey/client/DefaultSslContextProviderTest.java b/core-client/src/test/java/org/glassfish/jersey/client/DefaultSslContextProviderTest.java index d0ef2bdf2a..973637b78a 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/DefaultSslContextProviderTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/DefaultSslContextProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -26,10 +26,10 @@ import org.glassfish.jersey.internal.util.collection.UnsafeValue; import org.glassfish.jersey.internal.util.collection.Values; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/core-client/src/test/java/org/glassfish/jersey/client/FixedBoundaryParserTest.java b/core-client/src/test/java/org/glassfish/jersey/client/FixedBoundaryParserTest.java index 16b956f150..326a3f4c63 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/FixedBoundaryParserTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/FixedBoundaryParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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,9 +20,9 @@ import java.io.IOException; import java.io.InputStream; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests several parsing use-cases of ChunkedInput diff --git a/core-client/src/test/java/org/glassfish/jersey/client/FixedMultiBoundaryParserTest.java b/core-client/src/test/java/org/glassfish/jersey/client/FixedMultiBoundaryParserTest.java index 936d6a46d0..1c8f0b4065 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/FixedMultiBoundaryParserTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/FixedMultiBoundaryParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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,9 +20,9 @@ import java.io.IOException; import java.io.InputStream; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests several parsing use-cases of ChunkedInput diff --git a/core-client/src/test/java/org/glassfish/jersey/client/HttpUrlConnectorTest.java b/core-client/src/test/java/org/glassfish/jersey/client/HttpUrlConnectorTest.java index 5bb7a78780..394b08787a 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/HttpUrlConnectorTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/HttpUrlConnectorTest.java @@ -46,10 +46,10 @@ import org.glassfish.jersey.client.internal.HttpUrlConnector; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Various tests for the default client connector. @@ -69,7 +69,7 @@ public class HttpUrlConnectorTest { * TODO: fix and re-enable the test, it could give java.net.NoRouteToHostException in certain environments instead of timeout exception */ @Test - @Ignore + @Disabled public void testConnectionTimeoutWithEntity() { _testInvocationTimeout(createNonRoutableTarget().request().buildPost(Entity.text("does not matter"))); } @@ -79,7 +79,7 @@ public void testConnectionTimeoutWithEntity() { * TODO: see above, rewrite server part, the "non-routable" target solution is fragile */ @Test - @Ignore + @Disabled public void testConnectionTimeoutNoEntity() { _testInvocationTimeout(createNonRoutableTarget().request().buildGet()); } @@ -408,21 +408,19 @@ private void _testInvocationTimeout(Invocation invocation) { try { invocation.invoke(); - Assert.fail("Timeout expected!"); + Assertions.fail("Timeout expected!"); } catch (Exception ex) { - Assert.assertTrue(String.format("Bad exception, %s, caught! Timeout expected.", ex.getCause()), - ex.getCause() instanceof SocketTimeoutException); + Assertions.assertTrue(ex.getCause() instanceof SocketTimeoutException, + String.format("Bad exception, %s, caught! Timeout expected.", ex.getCause())); final long stop = System.currentTimeMillis(); long time = stop - start; - Assert.assertTrue( - String.format( - "Actual time, %d ms, should not be more than twice as longer as the original timeout, %d ms", - time, TimeoutBASE), - time < 2 * TimeoutBASE); + Assertions.assertTrue(time < 2 * TimeoutBASE, + String.format("Actual time, %d ms, should not be more than twice as longer as the original timeout, %d ms", + time, TimeoutBASE)); } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/JaxRsFeatureRegistrationClientTest.java b/core-client/src/test/java/org/glassfish/jersey/client/JaxRsFeatureRegistrationClientTest.java index 8bfb921e7d..740e6c54a5 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/JaxRsFeatureRegistrationClientTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/JaxRsFeatureRegistrationClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -17,7 +17,7 @@ package org.glassfish.jersey.client; import org.glassfish.jersey.CommonProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; @@ -27,8 +27,8 @@ import javax.ws.rs.core.FeatureContext; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; public class JaxRsFeatureRegistrationClientTest { diff --git a/core-client/src/test/java/org/glassfish/jersey/client/JerseyClientBuilderTest.java b/core-client/src/test/java/org/glassfish/jersey/client/JerseyClientBuilderTest.java index bb4a680098..ff6fee951e 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/JerseyClientBuilderTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/JerseyClientBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,10 +16,9 @@ package org.glassfish.jersey.client; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.annotation.Priority; import javax.net.ssl.SSLContext; @@ -40,11 +39,12 @@ import java.util.concurrent.TimeUnit; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; /** * {@link JerseyClient} unit test. @@ -54,12 +54,9 @@ */ public class JerseyClientBuilderTest { - @Rule - public final ExpectedException exception = ExpectedException.none(); - private JerseyClientBuilder builder; - @Before + @BeforeEach public void setUp() { builder = new JerseyClientBuilder(); } @@ -128,10 +125,10 @@ public void testOverridingSslConfig() throws KeyStoreException, NoSuchAlgorithmE Client client; client = new JerseyClientBuilder().keyStore(ks, "qwerty").sslContext(ctx).build(); - assertSame("SSL context not the same as set in the client builder.", ctx, client.getSslContext()); + assertSame(ctx, client.getSslContext(), "SSL context not the same as set in the client builder."); client = new JerseyClientBuilder().sslContext(ctx).trustStore(ks).build(); - assertNotSame("SSL context not overridden in the client builder.", ctx, client.getSslContext()); + assertNotSame(ctx, client.getSslContext(), "SSL context not overridden in the client builder."); } @Priority(2) @@ -234,7 +231,7 @@ public void testRegisterNullMap() { assertNull(contracts); } - @Test(expected = Test.None.class) //no exception shall be thrown + @Test public void testRegisterIrrelevantImmutableContractsMap() { final ClientBuilder clientBuilder = ClientBuilder.newBuilder(); final Map, Integer> contracts = new HashMap<>(); @@ -251,17 +248,19 @@ public void testRegisterIrrelevantImmutableContractsMap() { @Test public void testNegativeConnectTimeout() { - ClientBuilder clientBuilder = ClientBuilder.newBuilder(); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + ClientBuilder clientBuilder = ClientBuilder.newBuilder(); - exception.expect(IllegalArgumentException.class); - clientBuilder.connectTimeout(-1, TimeUnit.SECONDS); + clientBuilder.connectTimeout(-1, TimeUnit.SECONDS); + }); } @Test public void testNegativeReadTimeout() { - ClientBuilder clientBuilder = ClientBuilder.newBuilder(); + Assertions.assertThrows(IllegalArgumentException.class, () -> { + ClientBuilder clientBuilder = ClientBuilder.newBuilder(); - exception.expect(IllegalArgumentException.class); - clientBuilder.readTimeout(-1, TimeUnit.SECONDS); + clientBuilder.readTimeout(-1, TimeUnit.SECONDS); + }); } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/JerseyClientTest.java b/core-client/src/test/java/org/glassfish/jersey/client/JerseyClientTest.java index 8a851f63d2..41d9efb501 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/JerseyClientTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/JerseyClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -42,14 +42,15 @@ import org.glassfish.jersey.internal.Version; import org.glassfish.jersey.internal.inject.AbstractBinder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * {@link JerseyClient} unit test. @@ -63,12 +64,12 @@ public class JerseyClientTest { public JerseyClientTest() { } - @Before + @BeforeEach public void setUp() { this.client = (JerseyClient) ClientBuilder.newClient(); } - @After + @AfterEach public void tearDown() { } @@ -114,9 +115,9 @@ public void testTarget() { assertEquals(client.getConfiguration(), target.getConfiguration()); } - @Test(expected = IllegalArgumentException.class) + @Test public void testTargetIAE() { - final UriBuilder uriBuilder = UriBuilder.fromUri(":xxx:8080//yyy:90090//jaxrs "); + assertThrows(IllegalArgumentException.class, () -> UriBuilder.fromUri(":xxx:8080//yyy:90090//jaxrs ")); } public static class TestProvider implements ReaderInterceptor { diff --git a/core-client/src/test/java/org/glassfish/jersey/client/JerseyCompletionStageRxInvokerTest.java b/core-client/src/test/java/org/glassfish/jersey/client/JerseyCompletionStageRxInvokerTest.java index cf3ba575de..50879fceb8 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/JerseyCompletionStageRxInvokerTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/JerseyCompletionStageRxInvokerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -31,10 +31,11 @@ import org.glassfish.jersey.process.JerseyProcessingUncaughtExceptionHandler; import org.hamcrest.Matcher; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; @@ -48,7 +49,7 @@ public class JerseyCompletionStageRxInvokerTest { private Client client; private ExecutorService executor; - @Before + @BeforeEach public void setUp() throws Exception { client = ClientBuilder.newClient().register(TerminalClientRequestFilter.class); executor = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder() @@ -57,7 +58,7 @@ public void setUp() throws Exception { .build()); } - @After + @AfterEach public void tearDown() throws Exception { executor.shutdown(); client.close(); @@ -70,7 +71,7 @@ public void testNewClient() throws Exception { } @Test - @Ignore("TODO JAX-RS 2.1") + @Disabled("TODO JAX-RS 2.1") public void testNewClientExecutor() throws Exception { testClient(ClientBuilder.newBuilder() .executorService(executor) @@ -88,41 +89,45 @@ public void testNotFoundResponse() throws Exception { testInvoker(invoker, 404, false); } - @Test(expected = NotFoundException.class) + @Test public void testNotFoundReadEntityViaClass() throws Throwable { - try { - client.target("http://jersey.java.net") - .request() - .header("Response-Status", 404) - .rx() - .get(String.class) - .toCompletableFuture() - .get(); - } catch (final Exception expected) { - // java.util.concurrent.ExecutionException - throw expected - // javax.ws.rs.NotFoundException - .getCause(); - } + Assertions.assertThrows(NotFoundException.class, () -> { + try { + client.target("http://jersey.java.net") + .request() + .header("Response-Status", 404) + .rx() + .get(String.class) + .toCompletableFuture() + .get(); + } catch (final Exception expected) { + // java.util.concurrent.ExecutionException + throw expected + // javax.ws.rs.NotFoundException + .getCause(); + } + }); } - @Test(expected = NotFoundException.class) + @Test public void testNotFoundReadEntityViaGenericType() throws Throwable { - try { - client.target("http://jersey.java.net") - .request() - .header("Response-Status", 404) - .rx() - .get(new GenericType() { - }) - .toCompletableFuture() - .get(); - } catch (final Exception expected) { - // java.util.concurrent.ExecutionException - throw expected - // javax.ws.rs.NotFoundException - .getCause(); - } + Assertions.assertThrows(NotFoundException.class, () ->{ + try { + client.target("http://jersey.java.net") + .request() + .header("Response-Status", 404) + .rx() + .get(new GenericType() { + }) + .toCompletableFuture() + .get(); + } catch (final Exception expected) { + // java.util.concurrent.ExecutionException + throw expected + // javax.ws.rs.NotFoundException + .getCause(); + } + }); } @Test diff --git a/core-client/src/test/java/org/glassfish/jersey/client/JerseyInvocationTest.java b/core-client/src/test/java/org/glassfish/jersey/client/JerseyInvocationTest.java index dc021a399f..99e5a2a544 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/JerseyInvocationTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/JerseyInvocationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -43,14 +43,14 @@ import javax.ws.rs.core.Response; import org.hamcrest.CoreMatchers; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula @@ -271,10 +271,10 @@ public void failed(final Throwable throwable) { fail("future.get() should have failed."); } catch (final ExecutionException e) { final Throwable pe = e.getCause(); - assertTrue("Execution exception cause is not a ProcessingException: " + pe.toString(), - pe instanceof ProcessingException); + assertTrue(pe instanceof ProcessingException, + "Execution exception cause is not a ProcessingException: " + pe.toString()); final Throwable ioe = pe.getCause(); - assertTrue("Execution exception cause is not an IOException: " + ioe.toString(), ioe instanceof IOException); + assertTrue(ioe instanceof IOException, "Execution exception cause is not an IOException: " + ioe.toString()); } catch (final InterruptedException e) { throw new RuntimeException(e); } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/JerseyWebTargetTest.java b/core-client/src/test/java/org/glassfish/jersey/client/JerseyWebTargetTest.java index e3be2f91c2..072e70e499 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/JerseyWebTargetTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/JerseyWebTargetTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -33,11 +33,12 @@ import org.glassfish.jersey.uri.internal.JerseyUriBuilder; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; /** * {@code JerseyWebTarget} implementation unit tests. @@ -48,7 +49,7 @@ public class JerseyWebTargetTest { private JerseyClient client; private JerseyWebTarget target; - @Before + @BeforeEach public void setUp() { this.client = (JerseyClient) ClientBuilder.newClient(); this.target = client.target("/"); @@ -377,46 +378,58 @@ public void testReplaceMatrixParam() { assertEquals("/path1;matrix11=segment11/path2/path3;matrix30=segment30/path4", uri.toString()); } - @Test(expected = NullPointerException.class) + @Test public void testQueryParamNull() { - WebTarget wt = target; + assertThrows(NullPointerException.class, () -> { + WebTarget wt = target; - wt.queryParam(null); + wt.queryParam(null); + }); } - @Test(expected = NullPointerException.class) + @Test public void testPathNull() { - WebTarget wt = target; + assertThrows(NullPointerException.class, () -> { + WebTarget wt = target; - wt.path(null); + wt.path(null); + }); } - @Test(expected = NullPointerException.class) + @Test public void testResolveTemplateNull1() { - WebTarget wt = target; + assertThrows(NullPointerException.class, () -> { + WebTarget wt = target; - wt.resolveTemplate(null, "", true); + wt.resolveTemplate(null, "", true); + }); } - @Test(expected = NullPointerException.class) + @Test public void testResolveTemplateNull2() { - WebTarget wt = target; + assertThrows(NullPointerException.class, () -> { + WebTarget wt = target; - wt.resolveTemplate("name", null, true); + wt.resolveTemplate("name", null, true); + }); } - @Test(expected = NullPointerException.class) + @Test public void testResolveTemplateFromEncodedNull1() { - WebTarget wt = target; + assertThrows(NullPointerException.class, () -> { + WebTarget wt = target; - wt.resolveTemplateFromEncoded(null, ""); + wt.resolveTemplateFromEncoded(null, ""); + }); } - @Test(expected = NullPointerException.class) + @Test public void testResolveTemplateFromEncodedNull2() { - WebTarget wt = target; + assertThrows(NullPointerException.class, () -> { + WebTarget wt = target; - wt.resolveTemplateFromEncoded("name", null); + wt.resolveTemplateFromEncoded("name", null); + }); } @Test diff --git a/core-client/src/test/java/org/glassfish/jersey/client/LinkTest.java b/core-client/src/test/java/org/glassfish/jersey/client/LinkTest.java index f7b6027ba1..278abfe548 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/LinkTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/LinkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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,10 +20,10 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.core.Link; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * LinkTest class. @@ -37,7 +37,7 @@ public class LinkTest { public LinkTest() { } - @Before + @BeforeEach public void setUp() { this.client = (JerseyClient) ClientBuilder.newClient(); } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/ShutdownHookLeakTest.java b/core-client/src/test/java/org/glassfish/jersey/client/ShutdownHookLeakTest.java index ff88ab8007..7ddd82c351 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/ShutdownHookLeakTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/ShutdownHookLeakTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,10 +24,10 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.number.OrderingComparison.lessThan; -import static org.junit.Assert.assertThat; /** * Reproducer for JERSEY-2786. diff --git a/core-client/src/test/java/org/glassfish/jersey/client/WebTargetPropertiesTest.java b/core-client/src/test/java/org/glassfish/jersey/client/WebTargetPropertiesTest.java index 2fb4850306..0776f93afc 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/WebTargetPropertiesTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/WebTargetPropertiesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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,9 +20,9 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author pavel.bucek@oracle.com diff --git a/core-client/src/test/java/org/glassfish/jersey/client/authentication/HttpDigestAuthFilterTest.java b/core-client/src/test/java/org/glassfish/jersey/client/authentication/HttpDigestAuthFilterTest.java index 284e87cf68..b7a80b649b 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/authentication/HttpDigestAuthFilterTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/authentication/HttpDigestAuthFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.client.authentication.DigestAuthenticator.DigestScheme; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Raphael Jolivet (raphael.jolivet at gmail.com) @@ -42,7 +42,7 @@ public void testParseHeaders1() throws Exception { // no digest scheme "basic toto=\"tutu\"" })); - Assert.assertNull(ds); + Assertions.assertNull(ds); } @Test @@ -55,9 +55,9 @@ public void testParseHeaders2() throws Exception { // Two concurrent schemes "Digest realm=\"tata\"", "basic toto=\"tutu\"" })); - Assert.assertNotNull(ds); + Assertions.assertNotNull(ds); - Assert.assertEquals("tata", ds.getRealm()); + Assertions.assertEquals("tata", ds.getRealm()); } @Test @@ -70,9 +70,9 @@ public void testParseHeaders3() throws Exception { // Complex case, with comma i "digest realm=\"tata\",nonce=\"foo, bar\"" })); - Assert.assertNotNull(ds); - Assert.assertEquals("tata", ds.getRealm()); - Assert.assertEquals("foo, bar", ds.getNonce()); + Assertions.assertNotNull(ds); + Assertions.assertEquals("tata", ds.getRealm()); + Assertions.assertEquals("foo, bar", ds.getNonce()); } @Test @@ -85,10 +85,10 @@ public void testParseHeaders4() throws Exception { // Spaces " digest realm = \"tata\" , opaque=\"bar\" ,nonce=\"foo, bar\"" })); - Assert.assertNotNull(ds); - Assert.assertEquals("tata", ds.getRealm()); - Assert.assertEquals("foo, bar", ds.getNonce()); - Assert.assertEquals("bar", ds.getOpaque()); + Assertions.assertNotNull(ds); + Assertions.assertEquals("tata", ds.getRealm()); + Assertions.assertEquals("foo, bar", ds.getNonce()); + Assertions.assertEquals("bar", ds.getOpaque()); } @Test @@ -101,10 +101,10 @@ public void testParseHeaders5() throws Exception { // Mix of quotes and non-quo " digest realm = \"tata\" , opaque =bar ,nonce=\"foo, bar\", algorithm=md5" })); - Assert.assertNotNull(ds); - Assert.assertEquals("tata", ds.getRealm()); - Assert.assertEquals("foo, bar", ds.getNonce()); - Assert.assertEquals("bar", ds.getOpaque()); - Assert.assertEquals("MD5", ds.getAlgorithm().name()); + Assertions.assertNotNull(ds); + Assertions.assertEquals("tata", ds.getRealm()); + Assertions.assertEquals("foo, bar", ds.getNonce()); + Assertions.assertEquals("bar", ds.getOpaque()); + Assertions.assertEquals("MD5", ds.getAlgorithm().name()); } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/filter/ClientProviderInstanceInjectionTest.java b/core-client/src/test/java/org/glassfish/jersey/client/filter/ClientProviderInstanceInjectionTest.java index 8ec83fae9e..6cb65a72d5 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/filter/ClientProviderInstanceInjectionTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/filter/ClientProviderInstanceInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.internal.inject.AbstractBinder; import org.glassfish.jersey.internal.inject.InjectionManager; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests injections into provider instances. diff --git a/core-client/src/test/java/org/glassfish/jersey/client/filter/CsrfProtectionFilterTest.java b/core-client/src/test/java/org/glassfish/jersey/client/filter/CsrfProtectionFilterTest.java index a69df0331f..702c971795 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/filter/CsrfProtectionFilterTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/filter/CsrfProtectionFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,10 +34,10 @@ import org.glassfish.jersey.client.spi.Connector; import org.glassfish.jersey.client.spi.ConnectorProvider; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Cross-site request forgery client filter test. @@ -47,7 +47,7 @@ public class CsrfProtectionFilterTest { private Invocation.Builder invBuilder; - @Before + @BeforeEach public void setUp() { Client client = ClientBuilder.newClient(new ClientConfig(CsrfProtectionFilter.class) .connectorProvider(new TestConnector())); diff --git a/core-client/src/test/java/org/glassfish/jersey/client/filter/EncodingFilterTest.java b/core-client/src/test/java/org/glassfish/jersey/client/filter/EncodingFilterTest.java index 4d1fe390a5..a48671fc27 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/filter/EncodingFilterTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/filter/EncodingFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -42,12 +42,11 @@ import org.glassfish.jersey.message.DeflateEncoder; import org.glassfish.jersey.message.GZipEncoder; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Client-side content encoding filter unit tests. @@ -148,7 +147,7 @@ public ClientResponse apply(ClientRequest requestContext) throws ProcessingExcep response.readEntity(String.class); fail("Exception caused by invalid gzip stream expected."); } catch (ProcessingException ex) { - assertTrue("Response input stream not closed when exception is thrown.", responseStream.isClosed); + assertTrue(responseStream.isClosed, "Response input stream not closed when exception is thrown."); } } @@ -177,7 +176,7 @@ public ClientResponse apply(ClientRequest requestContext) throws ProcessingExcep client.target(UriBuilder.fromUri("/").build()).request().get(String.class); fail("Exception caused by invalid gzip stream expected."); } catch (ProcessingException ex) { - assertTrue("Response input stream not closed when exception is thrown.", responseStream.isClosed); + assertTrue(responseStream.isClosed, "Response input stream not closed when exception is thrown."); } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/filter/HttpBasicAuthFilterTest.java b/core-client/src/test/java/org/glassfish/jersey/client/filter/HttpBasicAuthFilterTest.java index e967db0e26..72f73ae52e 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/filter/HttpBasicAuthFilterTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/filter/HttpBasicAuthFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -37,8 +37,8 @@ import org.glassfish.jersey.client.spi.ConnectorProvider; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * HTTP Basic authentication filter test. diff --git a/core-client/src/test/java/org/glassfish/jersey/client/spi/CachingConnectorProviderTest.java b/core-client/src/test/java/org/glassfish/jersey/client/spi/CachingConnectorProviderTest.java index d4f9363972..4eec0cdbcb 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/spi/CachingConnectorProviderTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/spi/CachingConnectorProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.client.ClientRequest; import org.glassfish.jersey.client.ClientResponse; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Caching connector provider unit tests. diff --git a/core-client/src/test/java/org/glassfish/jersey/client/spi/ClientBuilderListenerTest.java b/core-client/src/test/java/org/glassfish/jersey/client/spi/ClientBuilderListenerTest.java index e2776fc79c..38811762ca 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/spi/ClientBuilderListenerTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/spi/ClientBuilderListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -17,8 +17,8 @@ package org.glassfish.jersey.client.spi; import org.glassfish.jersey.client.ClientConfig; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.annotation.Priority; import javax.ws.rs.Priorities; @@ -55,7 +55,7 @@ public void onNewBuilder(ClientBuilder builder) { @Test public void testClientBuilderListener() { Client client = ClientBuilder.newClient(); - Assert.assertEquals(70, client.getConfiguration().getProperty(PROPERTY_NAME)); + Assertions.assertEquals(70, client.getConfiguration().getProperty(PROPERTY_NAME)); } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/spi/InvocationBuilderListenerTest.java b/core-client/src/test/java/org/glassfish/jersey/client/spi/InvocationBuilderListenerTest.java index ddb6e76fae..0e5fe4404b 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/spi/InvocationBuilderListenerTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/spi/InvocationBuilderListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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,9 +18,10 @@ import org.glassfish.jersey.internal.PropertiesDelegate; import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.annotation.Priority; import javax.ws.rs.client.ClientBuilder; @@ -48,7 +49,7 @@ public class InvocationBuilderListenerTest { private WebTarget target; - @Before + @BeforeEach public void setUp() { target = ClientBuilder.newClient().target("http://localhost:8080").register(AbortRequestFilter.class) .register(new PropertySetterInvocationBuilderListener(a -> a.property(key(ONE), ONE))); @@ -80,7 +81,7 @@ public void testConfigurationProperties() { String value = "OTHER_VALUE"; try (Response r = target.property(key(ConfigurationInvocationBuilderListener.OTHER_PROPERTY), value) .register(ConfigurationInvocationBuilderListener.class).request().get()) { - Assert.assertTrue( + Assertions.assertTrue( r.readEntity(String.class).contains(key(ConfigurationInvocationBuilderListener.OTHER_PROPERTY) + "=" + value) ); } @@ -95,7 +96,7 @@ public void testGetters() { } private void assertDefault(Response response) { - Assert.assertEquals(key(ONE) + "=" + ONE, response.readEntity(String.class)); + Assertions.assertEquals(key(ONE) + "=" + ONE, response.readEntity(String.class)); } private static String key(String keySuffix) { @@ -161,10 +162,10 @@ public static class GetterInvocationBuilderListener implements InvocationBuilder public void onNewBuilder(InvocationBuilderContext context) { Date date = new Date(); RuntimeDelegate.HeaderDelegate localeDelegate = RuntimeDelegate.getInstance().createHeaderDelegate(Locale.class); - Assert.assertThat(context.getAccepted(), + MatcherAssert.assertThat(context.getAccepted(), Matchers.containsInAnyOrder(MediaType.APPLICATION_JSON, MediaType.APPLICATION_JSON_PATCH_JSON)); - Assert.assertThat(context.getEncodings(), Matchers.contains("GZIP")); - Assert.assertThat(context.getAcceptedLanguages(), + MatcherAssert.assertThat(context.getEncodings(), Matchers.contains("GZIP")); + MatcherAssert.assertThat(context.getAcceptedLanguages(), Matchers.containsInAnyOrder(localeDelegate.toString(Locale.GERMAN), localeDelegate.toString( new Locale.Builder().setLanguage("sr").setScript("Latn").setRegion("RS").build() @@ -172,24 +173,24 @@ public void onNewBuilder(InvocationBuilderContext context) { ) ); - Assert.assertThat(context.getHeader(HttpHeaders.CONTENT_ID), Matchers.contains(PROPERTY_NAME)); + MatcherAssert.assertThat(context.getHeader(HttpHeaders.CONTENT_ID), Matchers.contains(PROPERTY_NAME)); context.getHeaders().add(HttpHeaders.DATE, date); - Assert.assertThat(context.getHeader(HttpHeaders.DATE), Matchers.notNullValue()); - Assert.assertThat(context.getHeaders().getFirst(HttpHeaders.DATE), Matchers.is(date)); + MatcherAssert.assertThat(context.getHeader(HttpHeaders.DATE), Matchers.notNullValue()); + MatcherAssert.assertThat(context.getHeaders().getFirst(HttpHeaders.DATE), Matchers.is(date)); - Assert.assertNotNull(context.getUri()); - Assert.assertTrue(context.getUri().toASCIIString().startsWith("http://")); + Assertions.assertNotNull(context.getUri()); + Assertions.assertTrue(context.getUri().toASCIIString().startsWith("http://")); - Assert.assertThat(context.getPropertyNames(), Matchers.contains(PROPERTY_NAME)); - Assert.assertThat(context.getProperty(PROPERTY_NAME), Matchers.is(PROPERTY_NAME)); + MatcherAssert.assertThat(context.getPropertyNames(), Matchers.contains(PROPERTY_NAME)); + MatcherAssert.assertThat(context.getProperty(PROPERTY_NAME), Matchers.is(PROPERTY_NAME)); context.removeProperty(PROPERTY_NAME); - Assert.assertTrue(context.getPropertyNames().isEmpty()); + Assertions.assertTrue(context.getPropertyNames().isEmpty()); - Assert.assertThat(context.getCacheControls().get(0).toString(), + MatcherAssert.assertThat(context.getCacheControls().get(0).toString(), Matchers.is(CacheControl.valueOf(PROPERTY_NAME).toString()) ); - Assert.assertThat(context.getCookies().size(), Matchers.is(1)); - Assert.assertThat(context.getCookies().get("Cookie"), Matchers.notNullValue()); + MatcherAssert.assertThat(context.getCookies().size(), Matchers.is(1)); + MatcherAssert.assertThat(context.getCookies().get("Cookie"), Matchers.notNullValue()); } } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/spi/PostInvocationInterceptorTest.java b/core-client/src/test/java/org/glassfish/jersey/client/spi/PostInvocationInterceptorTest.java index b5f362402e..f454ce96c6 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/spi/PostInvocationInterceptorTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/spi/PostInvocationInterceptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -16,9 +16,9 @@ package org.glassfish.jersey.client.spi; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.ProcessingException; import javax.ws.rs.client.ClientBuilder; @@ -44,7 +44,7 @@ public class PostInvocationInterceptorTest { private AtomicInteger counter; - @Before + @BeforeEach public void setup() { counter = new AtomicInteger(); } @@ -55,10 +55,10 @@ public void testSyncNoConnectionPostInvocationInterceptor() { .register(new CounterPostInvocationInterceptor((a, b) -> false, (a, b) -> true)) .build().target(URL).request(); try (Response r = builder.get()) { - Assert.fail(); + Assertions.fail(); } catch (ProcessingException pe) { - Assert.assertEquals(1000, counter.get()); - Assert.assertEquals(ConnectException.class, pe.getCause().getClass()); + Assertions.assertEquals(1000, counter.get()); + Assertions.assertEquals(ConnectException.class, pe.getCause().getClass()); } } @@ -74,8 +74,8 @@ public void testPreThrowsPostFixes() { })) .build().target(URL).request(); try (Response response = builder.get()) { - Assert.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); - Assert.assertEquals(1000, counter.get()); // counter.increment would be after ISE + Assertions.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); + Assertions.assertEquals(1000, counter.get()); // counter.increment would be after ISE } } @@ -91,8 +91,8 @@ public void testPreThrowsPostFixesAsync() throws ExecutionException, Interrupted })) .build().target(URL).request(); try (Response response = builder.async().get().get()) { - Assert.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); - Assert.assertEquals(1000, counter.get()); // counter.increment would be after ISE + Assertions.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); + Assertions.assertEquals(1000, counter.get()); // counter.increment would be after ISE } } @@ -111,8 +111,8 @@ public void testFilterThrowsPostFixesAsync() throws ExecutionException, Interrup try (Response response = builder.async() .get(new TestInvocationCallback(a -> a.getStatus() == Response.Status.ACCEPTED.getStatusCode(), a -> false)) .get()) { - Assert.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); - Assert.assertEquals(1000, counter.get()); // counter.increment would be after ISE + Assertions.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); + Assertions.assertEquals(1000, counter.get()); // counter.increment would be after ISE } } @@ -147,8 +147,8 @@ public void testPostThrowsFixesThrowsFixes() { 400) .build().target(URL).request(); try (Response response = builder.get()) { - Assert.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); - Assert.assertEquals(2000, counter.get()); + Assertions.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); + Assertions.assertEquals(2000, counter.get()); } } @@ -170,7 +170,7 @@ public void testMultipleResolvesThrows() { 200) .build().target(URL).request(); try (Response response = builder.get()) { - Assert.fail(); + Assertions.fail(); } catch (IllegalStateException pe) { // expected } @@ -189,9 +189,9 @@ public void testPostChangesStatusAndEntity() { (a, b) -> false)) .build().target(URL).request(); try (Response response = builder.get()) { - Assert.assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatus()); - Assert.assertEquals(1, counter.get()); - Assert.assertEquals("HELLO", response.readEntity(String.class)); + Assertions.assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatus()); + Assertions.assertEquals(1, counter.get()); + Assertions.assertEquals("HELLO", response.readEntity(String.class)); } } @@ -216,8 +216,8 @@ public void testPostOnExceptionWhenNoThrowableAndNoResponseContext() { 300) .build().target(URL).request(); try (Response response = builder.get()) { - Assert.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); - Assert.assertEquals(2000, counter.get()); + Assertions.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); + Assertions.assertEquals(2000, counter.get()); } } @@ -227,11 +227,11 @@ public void testAsyncNoConnectionPostInvocationInterceptor() throws InterruptedE .register(new CounterPostInvocationInterceptor((a, b) -> false, (a, b) -> true)) .build().target(URL).request(); try (Response r = builder.async().get(new TestInvocationCallback(a -> false, a -> true)).get()) { - Assert.fail(); + Assertions.fail(); } catch (ExecutionException ee) { - Assert.assertEquals(1000, counter.get()); - Assert.assertEquals(ProcessingException.class, ee.getCause().getClass()); - Assert.assertEquals(ConnectException.class, ee.getCause().getCause().getClass()); + Assertions.assertEquals(1000, counter.get()); + Assertions.assertEquals(ProcessingException.class, ee.getCause().getClass()); + Assertions.assertEquals(ConnectException.class, ee.getCause().getCause().getClass()); } } @@ -248,7 +248,7 @@ public void testPreThrowsPostResolves() { })) .build().target(URL).request(); try (Response response = builder.get()) { - Assert.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatus()); } } @@ -259,8 +259,8 @@ public void testPostInvocationInterceptorIsHitforEachRequest() { .register(new AbortRequestFilter()).build().target(URL).request(); for (int i = 1; i != 10; i++) { try (Response response = builder.get()) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(i, counter.get()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(i, counter.get()); } } } @@ -276,12 +276,12 @@ private TestInvocationCallback(Predicate responsePredicate, Predicate< @Override public void completed(Response response) { - Assert.assertTrue(responsePredicate.test(response)); + Assertions.assertTrue(responsePredicate.test(response)); } @Override public void failed(Throwable throwable) { - Assert.assertTrue(throwablePredicate.test(throwable)); + Assertions.assertTrue(throwablePredicate.test(throwable)); } } @@ -297,13 +297,13 @@ private CounterPostInvocationInterceptor(BiPredicate predicat @Override public void beforeRequest(ClientRequestContext requestContext) { - Assert.assertTrue(predicate.test(requestContext)); + Assertions.assertTrue(predicate.test(requestContext)); counter.incrementAndGet(); } } diff --git a/core-client/src/test/java/org/glassfish/jersey/client/spi/PreInvocationInterceptorTest.java b/core-client/src/test/java/org/glassfish/jersey/client/spi/PreInvocationInterceptorTest.java index 905cb57ddf..a438a58954 100644 --- a/core-client/src/test/java/org/glassfish/jersey/client/spi/PreInvocationInterceptorTest.java +++ b/core-client/src/test/java/org/glassfish/jersey/client/spi/PreInvocationInterceptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -17,9 +17,9 @@ package org.glassfish.jersey.client.spi; import org.glassfish.jersey.spi.ThreadPoolExecutorProvider; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.annotation.Priority; import javax.ws.rs.ProcessingException; @@ -43,7 +43,7 @@ public class PreInvocationInterceptorTest { private AtomicInteger counter; - @Before + @BeforeEach public void setup() { counter = new AtomicInteger(); } @@ -55,7 +55,7 @@ public void testPreInvocationInterceptorExecutedWhenBuilderBuild() { .register(new CounterRequestFilter(a -> a.get() == 1)) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.build("GET").invoke()) { - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } } @@ -66,7 +66,7 @@ public void testPreInvocationInterceptorExecutedWhenMethodGET() { .register(new CounterRequestFilter(a -> a.get() == 1)) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.method("GET")) { - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } } @@ -77,7 +77,7 @@ public void testPreInvocationInterceptorPropertySet() { .register(new PropertyRequestFilter(a -> PROPERTY_VALUE.equals(a.getProperty(PROPERTY_NAME)))) .register(AbortRequestFilter.class).build().target(URL).request().property(PROPERTY_NAME, PROPERTY_VALUE); try (Response response = builder.method("GET")) { - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } } @@ -88,7 +88,7 @@ public void testPreInvocationInterceptorHasInjection() { .register(InjectedPreInvocationInterceptor.class) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.method("GET")) { - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } } @@ -101,7 +101,7 @@ public void testPreInvocationInterceptorInTheSameThreadInAsync() throws Executio .register(new PropertyRequestFilter(a -> Thread.currentThread().getName().startsWith(EXECUTOR_THREAD_NAME))) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.async().method("GET").get()) { - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } } @@ -114,7 +114,7 @@ public void testPreInvocationInterceptorInTheSameThreadInJerseyRx() throws Execu .register(new PropertyRequestFilter(a -> Thread.currentThread().getName().startsWith(EXECUTOR_THREAD_NAME))) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.rx().method("GET").toCompletableFuture().get()) { - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } } @@ -129,7 +129,7 @@ public void testPreInvocationInterceptorAbortWith() { .register(new PropertyRequestFilter(a -> {throw new IllegalStateException(); })) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.get()) { - Assert.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); } } @@ -154,9 +154,9 @@ public void testPreInvocationInterceptorAbortWithThrowsInMultiple() { .register(new PropertyRequestFilter(a -> {throw new IllegalStateException(); })) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.get()) { - Assert.fail(); + Assertions.fail(); } catch (ProcessingException exception) { - Assert.assertEquals(IllegalStateException.class, exception.getCause().getClass()); + Assertions.assertEquals(IllegalStateException.class, exception.getCause().getClass()); } } @@ -169,7 +169,7 @@ public void testPrioritiesOnPreInvocationInterceptor() { .register(new Priority200PreInvocationInterceptor(a -> a.get() < 2){}) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.get()) { - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } } @@ -181,10 +181,10 @@ public void testMultiExceptionInPreInvocationInterceptor() { .register(new Priority100PreInvocationInterceptor(a -> {throw new RuntimeException("TWO"); })) .register(AbortRequestFilter.class).build().target(URL).request(); try (Response response = builder.get()) { - Assert.fail(); + Assertions.fail(); } catch (RuntimeException e) { - Assert.assertEquals("ONE", e.getSuppressed()[0].getMessage()); - Assert.assertEquals("TWO", e.getSuppressed()[1].getMessage()); + Assertions.assertEquals("ONE", e.getSuppressed()[0].getMessage()); + Assertions.assertEquals("TWO", e.getSuppressed()[1].getMessage()); } } @@ -195,8 +195,8 @@ public void testPreInvocationInterceptorIsHitforEachRequest() { .register(new AbortRequestFilter()).build().target(URL).request(); for (int i = 1; i != 10; i++) { try (Response response = builder.get()) { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(i, counter.get()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(i, counter.get()); } } } @@ -217,7 +217,7 @@ private CounterRequestFilter(Predicate consumer) { @Override public void filter(ClientRequestContext requestContext) throws IOException { - Assert.assertTrue(consumer.test(counter)); + Assertions.assertTrue(consumer.test(counter)); counter.getAndIncrement(); } } @@ -231,7 +231,7 @@ private CounterPreInvocationInterceptor(Predicate predicate) { @Override public void beforeRequest(ClientRequestContext requestContext) { - Assert.assertTrue(predicate.test(counter)); + Assertions.assertTrue(predicate.test(counter)); counter.getAndIncrement(); } } @@ -245,7 +245,7 @@ private PropertyRequestFilter(Predicate predicate) { @Override public void filter(ClientRequestContext requestContext) throws IOException { - Assert.assertTrue(predicate.test(requestContext)); + Assertions.assertTrue(predicate.test(requestContext)); } } @@ -258,7 +258,7 @@ private PropertyPreInvocationInterceptor(Predicate predica @Override public void beforeRequest(ClientRequestContext requestContext) { - Assert.assertTrue(predicate.test(requestContext)); + Assertions.assertTrue(predicate.test(requestContext)); } } @@ -268,8 +268,8 @@ private static class InjectedPreInvocationInterceptor implements PreInvocationIn @Override public void beforeRequest(ClientRequestContext requestContext) { - Assert.assertNotNull(configuration); - Assert.assertEquals(PROPERTY_VALUE, configuration.getProperty(PROPERTY_NAME)); + Assertions.assertNotNull(configuration); + Assertions.assertEquals(PROPERTY_VALUE, configuration.getProperty(PROPERTY_NAME)); } } diff --git a/core-common/pom.xml b/core-common/pom.xml index 223109f556..2f61b3bfc1 100644 --- a/core-common/pom.xml +++ b/core-common/pom.xml @@ -172,6 +172,29 @@ org.apache.maven.plugins maven-surefire-plugin + + + default-test + + + **/ByteBufferInputStreamTest.java + + + + + tests-with-additional-permissions + test + + test + + + -Djava.security.policy=${project.build.directory}/test-classes/surefire-jdk17.policy + + **/ByteBufferInputStreamTest.java + + + + classesAndMethods @@ -206,8 +229,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/core-common/src/test/java/org/glassfish/jersey/SecurityManagerConfiguredTest.java b/core-common/src/test/java/org/glassfish/jersey/SecurityManagerConfiguredTest.java index cfae326453..4c90296f1e 100644 --- a/core-common/src/test/java/org/glassfish/jersey/SecurityManagerConfiguredTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/SecurityManagerConfiguredTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test that verifies that security manager is setup to run the Jersey core server unit tests. @@ -30,7 +30,6 @@ public class SecurityManagerConfiguredTest { */ @Test public void testSecurityManagerIsConfigured() { - assertNotNull("Jersey core server unit tests should run with active security manager", - System.getSecurityManager()); + assertNotNull(System.getSecurityManager(), "Jersey core server unit tests should run with active security manager"); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/TestRuntimeDelegate.java b/core-common/src/test/java/org/glassfish/jersey/internal/TestRuntimeDelegate.java index 0f025f199c..33b9fb307a 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/TestRuntimeDelegate.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/TestRuntimeDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.message.internal.MessagingBinders; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** * Test runtime delegate. @@ -48,31 +48,31 @@ public T createEndpoint(Application application, Class endpointType) public void testMediaType() { MediaType m = new MediaType("text", "plain"); - Assert.assertNotNull(m); + Assertions.assertNotNull(m); } public void testUriBuilder() { UriBuilder ub = RuntimeDelegate.getInstance().createUriBuilder(); - Assert.assertNotNull(ub); + Assertions.assertNotNull(ub); } public void testResponseBuilder() { Response.ResponseBuilder rb = RuntimeDelegate.getInstance().createResponseBuilder(); - Assert.assertNotNull(rb); + Assertions.assertNotNull(rb); } public void testVariantListBuilder() { Variant.VariantListBuilder vlb = RuntimeDelegate.getInstance().createVariantListBuilder(); - Assert.assertNotNull(vlb); + Assertions.assertNotNull(vlb); } public void testLinkBuilder() { final Link.Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder(); - Assert.assertNotNull(linkBuilder); + Assertions.assertNotNull(linkBuilder); } public void testWebApplicationException() { WebApplicationException wae = new WebApplicationException(); - Assert.assertNotNull(wae); + Assertions.assertNotNull(wae); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/config/AdditionalSystemPropertiesTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/config/AdditionalSystemPropertiesTest.java index 1cc853e236..09a85812c2 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/config/AdditionalSystemPropertiesTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/config/AdditionalSystemPropertiesTest.java @@ -17,10 +17,10 @@ package org.glassfish.jersey.internal.config; import org.glassfish.jersey.CommonProperties; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.Collections; import java.util.Properties; @@ -32,14 +32,14 @@ private static class AdditionalSystemProperties { public static final String SECOND_PROPERTY = "second.property"; } - @BeforeClass + @BeforeAll public static void setUp() { System.setProperty(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER, Boolean.TRUE.toString()); System.getProperties().put(AdditionalSystemProperties.FIRST_PROPERTY, "first value"); System.getProperties().put(AdditionalSystemProperties.SECOND_PROPERTY, "second value"); } - @AfterClass + @AfterAll public static void tearDown() { System.clearProperty(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER); System.clearProperty(AdditionalSystemProperties.FIRST_PROPERTY); @@ -57,10 +57,10 @@ public void readAdditionalSystemPropertiesTest() { Collections.singletonList(new ExternalConfigurationProviderImpl(testModel)) ); - Assert.assertFalse(properties.isEmpty()); - Assert.assertTrue(properties.containsKey(AdditionalSystemProperties.FIRST_PROPERTY)); - Assert.assertTrue(properties.containsKey(AdditionalSystemProperties.SECOND_PROPERTY)); - Assert.assertEquals("first value", properties.get(AdditionalSystemProperties.FIRST_PROPERTY)); - Assert.assertEquals("second value", properties.get(AdditionalSystemProperties.SECOND_PROPERTY)); + Assertions.assertFalse(properties.isEmpty()); + Assertions.assertTrue(properties.containsKey(AdditionalSystemProperties.FIRST_PROPERTY)); + Assertions.assertTrue(properties.containsKey(AdditionalSystemProperties.SECOND_PROPERTY)); + Assertions.assertEquals("first value", properties.get(AdditionalSystemProperties.FIRST_PROPERTY)); + Assertions.assertEquals("second value", properties.get(AdditionalSystemProperties.SECOND_PROPERTY)); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/config/DisabledProvidersTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/config/DisabledProvidersTest.java index cccd36c564..57b95d0b19 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/config/DisabledProvidersTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/config/DisabledProvidersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.message.internal.MessagingBinders; import org.glassfish.jersey.message.internal.RenderedImageProvider; import org.glassfish.jersey.message.internal.SourceProvider; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.RuntimeType; import java.util.HashMap; @@ -55,11 +55,11 @@ public void testNoRenderedImageProviderNoSourceProvider() { DisabledProvidersChecker checker = new DisabledProvidersChecker(properties, RuntimeType.CLIENT); checker.configure(); - Assert.assertFalse(checker.bindSet.contains(RenderedImageProvider.class)); - Assert.assertFalse(checker.bindSet.contains(SourceProvider.SourceWriter.class)); - Assert.assertTrue(checker.bindSet.contains(SourceProvider.StreamSourceReader.class)); - Assert.assertTrue(checker.bindSet.contains(SourceProvider.SaxSourceReader.class)); - Assert.assertTrue(checker.bindSet.contains(SourceProvider.DomSourceReader.class)); + Assertions.assertFalse(checker.bindSet.contains(RenderedImageProvider.class)); + Assertions.assertFalse(checker.bindSet.contains(SourceProvider.SourceWriter.class)); + Assertions.assertTrue(checker.bindSet.contains(SourceProvider.StreamSourceReader.class)); + Assertions.assertTrue(checker.bindSet.contains(SourceProvider.SaxSourceReader.class)); + Assertions.assertTrue(checker.bindSet.contains(SourceProvider.DomSourceReader.class)); } @Test @@ -69,11 +69,11 @@ public void testNoDisabledProvider() { DisabledProvidersChecker checker = new DisabledProvidersChecker(properties, RuntimeType.CLIENT); checker.configure(); - Assert.assertFalse(checker.bindSet.contains(RenderedImageProvider.class)); - Assert.assertFalse(checker.bindSet.contains(SourceProvider.StreamSourceReader.class)); - Assert.assertFalse(checker.bindSet.contains(SourceProvider.SourceWriter.class)); - Assert.assertFalse(checker.bindSet.contains(SourceProvider.SaxSourceReader.class)); - Assert.assertFalse(checker.bindSet.contains(SourceProvider.DomSourceReader.class)); + Assertions.assertFalse(checker.bindSet.contains(RenderedImageProvider.class)); + Assertions.assertFalse(checker.bindSet.contains(SourceProvider.StreamSourceReader.class)); + Assertions.assertFalse(checker.bindSet.contains(SourceProvider.SourceWriter.class)); + Assertions.assertFalse(checker.bindSet.contains(SourceProvider.SaxSourceReader.class)); + Assertions.assertFalse(checker.bindSet.contains(SourceProvider.DomSourceReader.class)); } diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/config/ExternalPropertiesConfigurationFactoryTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/config/ExternalPropertiesConfigurationFactoryTest.java index f6e6758af6..6f1f7b163e 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/config/ExternalPropertiesConfigurationFactoryTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/config/ExternalPropertiesConfigurationFactoryTest.java @@ -17,10 +17,10 @@ package org.glassfish.jersey.internal.config; import org.glassfish.jersey.CommonProperties; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.HashMap; import java.util.Map; @@ -33,7 +33,7 @@ public class ExternalPropertiesConfigurationFactoryTest { /** * Predefine some properties to be read from config */ - @BeforeClass + @BeforeAll public static void setUp() { System.setProperty(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER, Boolean.TRUE.toString()); @@ -42,7 +42,7 @@ public static void setUp() { System.setProperty("jersey.config.client.readTimeout", "10"); } - @AfterClass + @AfterAll public static void tearDown() { System.clearProperty("jersey.config.server.provider.scanning.recursive"); System.clearProperty(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE); @@ -53,24 +53,25 @@ public static void tearDown() { public void readSystemPropertiesTest() { final Object result = readExternalPropertiesMap().get("jersey.config.server.provider.scanning.recursive"); - Assert.assertNull(result); - Assert.assertEquals(Boolean.TRUE, + Assertions.assertNull(result); + Assertions.assertEquals(Boolean.TRUE, getConfig().isProperty(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE)); - Assert.assertEquals(Boolean.TRUE, + Assertions.assertEquals(Boolean.TRUE, getConfig().as(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE, Boolean.class)); - Assert.assertEquals(Boolean.FALSE, + Assertions.assertEquals(Boolean.FALSE, getConfig().as("jersey.config.client.readTimeout", Boolean.class)); - Assert.assertEquals(Boolean.FALSE, + Assertions.assertEquals(Boolean.FALSE, getConfig().isProperty("jersey.config.client.readTimeout")); - Assert.assertEquals(1, + Assertions.assertEquals(1, getConfig().as(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE, Integer.class)); - Assert.assertEquals(10, + Assertions.assertEquals(10, getConfig().as("jersey.config.client.readTimeout", Integer.class)); } - @Test(expected = IllegalArgumentException.class) + @Test public void unsupportedMapperTest() { - getConfig().as(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE, Double.class); + Assertions.assertThrows(IllegalArgumentException.class, + () -> getConfig().as(CommonProperties.JSON_PROCESSING_FEATURE_DISABLE, Double.class)); } @Test @@ -80,8 +81,8 @@ public void mergePropertiesTest() { inputProperties.put("org.jersey.microprofile.config.added", "ADDED"); getConfig().mergeProperties(inputProperties); final Object result = readExternalPropertiesMap().get("jersey.config.server.provider.scanning.recursive"); - Assert.assertNull(result); - Assert.assertNull(readExternalPropertiesMap().get("org.jersey.microprofile.config.added")); + Assertions.assertNull(result); + Assertions.assertNull(readExternalPropertiesMap().get("org.jersey.microprofile.config.added")); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/inject/ProvidersTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/inject/ProvidersTest.java index dc15766709..2c80b350d2 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/inject/ProvidersTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/inject/ProvidersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.spi.Contract; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests {@link Providers}. diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/routing/CombinedMediaTypeTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/routing/CombinedMediaTypeTest.java index f4414f5b42..c0c3112617 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/routing/CombinedMediaTypeTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/routing/CombinedMediaTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,10 +24,10 @@ import javax.ws.rs.core.MediaType; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Combined media type tests. diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/sonar/SonarJerseyCommonTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/sonar/SonarJerseyCommonTest.java index 06a97ad8d7..3a0557c19e 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/sonar/SonarJerseyCommonTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/sonar/SonarJerseyCommonTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.internal.sonar; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Stepan Vavra @@ -26,6 +26,6 @@ public class SonarJerseyCommonTest { @Test public void testUnitTest() { - Assert.assertEquals("common unit test", new SonarJerseyCommon().unitTest()); + Assertions.assertEquals("common unit test", new SonarJerseyCommon().unitTest()); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/Base64Test.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/Base64Test.java index b083ad94aa..2878f795ca 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/Base64Test.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/Base64Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -19,10 +19,10 @@ import java.util.Arrays; import java.util.Base64; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @@ -64,21 +64,21 @@ public void testDecodeString() throws Exception { public void testRoundtripLengthMod3Equals0() { byte[] data = {0, 1, 2, 3, 4, 5, 6, 7, 8}; byte[] result = Base64.getDecoder().decode(Base64.getEncoder().encode(data)); - assertTrue("failed to roundtrip value to base64", Arrays.equals(data, result)); + assertTrue(Arrays.equals(data, result), "failed to roundtrip value to base64"); } @Test public void testRoundtripLengthMod3Equals1() { byte[] data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; byte[] result = Base64.getDecoder().decode(Base64.getEncoder().encode(data)); - assertTrue("failed to roundtrip value to base64", Arrays.equals(data, result)); + assertTrue(Arrays.equals(data, result), "failed to roundtrip value to base64"); } @Test public void testRoundtripLengthMod3Equals2() { byte[] data = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; byte[] result = Base64.getDecoder().decode(Base64.getEncoder().encode(data)); - assertTrue("failed to roundtrip value to base64", Arrays.equals(data, result)); + assertTrue(Arrays.equals(data, result), "failed to roundtrip value to base64"); } @Test @@ -125,9 +125,9 @@ public void testDecodeString2() { + "/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w=="; byte[] result = Base64.getDecoder().decode(data.getBytes()); - assertEquals("incorrect length", result.length, 256); + assertEquals(256, result.length, "incorrect length"); for (int i = 0; i < 256; ++i) { - assertEquals("incorrect value", result[i], (byte) i); + assertEquals((byte) i, result[i], "incorrect value"); } } } diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/JdkVersionCompareTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/JdkVersionCompareTest.java index 423ab0a19b..47781d5e7f 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/JdkVersionCompareTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/JdkVersionCompareTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -16,9 +16,9 @@ package org.glassfish.jersey.internal.util; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JdkVersionCompareTest { diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/JdkVersionParseTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/JdkVersionParseTest.java index b0e8c4d0c6..306a760d60 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/JdkVersionParseTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/JdkVersionParseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -16,48 +16,36 @@ package org.glassfish.jersey.internal.util; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; -@RunWith(Parameterized.class) public class JdkVersionParseTest { - @Parameterized.Parameter - public String rawVersionString; - @Parameterized.Parameter(1) - public int expectedMajorVersion; - @Parameterized.Parameter(2) - public int expectedMinorVersion; - @Parameterized.Parameter(3) - public int expectedMaintenanceVersion; - @Parameterized.Parameter(4) - public int expectedUpdateVersion; - - @Parameterized.Parameters - public static Collection provideVersions() { - return Arrays.asList(new Object[][]{ + public static Stream provideVersions() { + return Stream.of( // Java 8 - {"1.8.0_141-b15", 1, 8, 0, 141}, - {"1.8.0_141", 1, 8, 0, 141}, + Arguments.of("1.8.0_141-b15", 1, 8, 0, 141), + Arguments.of("1.8.0_141", 1, 8, 0, 141), // Java 9 and above - {"9", 9, 0, 0, 0}, - {"9.0.3", 9, 0, 3, 0}, - {"11", 11, 0, 0, 0}, + Arguments.of("9", 9, 0, 0, 0), + Arguments.of("9.0.3", 9, 0, 3, 0), + Arguments.of("11", 11, 0, 0, 0), // malformed version - {"invalid version", -1, -1, -1, -1} - }); + Arguments.of("invalid version", -1, -1, -1, -1) + ); } - @Test - public void testParseVersion() { + @ParameterizedTest + @MethodSource("provideVersions") + public void testParseVersion(String rawVersionString, int expectedMajorVersion, int expectedMinorVersion, + int expectedMaintenanceVersion, int expectedUpdateVersion) { JdkVersion version = JdkVersion.parseVersion(rawVersionString); assertEquals(expectedMajorVersion, version.getMajor()); diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/JerseyPublisherTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/JerseyPublisherTest.java index 659f9041f4..e9516922be 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/JerseyPublisherTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/JerseyPublisherTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -27,11 +27,11 @@ import org.glassfish.jersey.internal.jsr166.Flow; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test Jersey {@link Flow.Publisher} implementation, {@link JerseyPublisher}. diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/OsgiRegistryTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/OsgiRegistryTest.java index fe3de0c1b9..f71f9b4f64 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/OsgiRegistryTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/OsgiRegistryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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,8 +18,8 @@ import org.glassfish.jersey.internal.OsgiRegistry; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Utility class {@ling OsgiRegistry} tests. @@ -32,136 +32,136 @@ public class OsgiRegistryTest { public void testWebInfClassesBundleEntryPathTranslation() { String className = OsgiRegistry .bundleEntryPathToClassName("org/glassfish/jersey", "/WEB-INF/classes/org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testWebInfClassesBundleEntryPathTranslationPackageTrailingSlash() { String className = OsgiRegistry .bundleEntryPathToClassName("org/glassfish/jersey/", "/WEB-INF/classes/org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testWebInfClassesBundleEntryPathTranslationPackageLeadingSlash() { String className = OsgiRegistry .bundleEntryPathToClassName("/org/glassfish/jersey", "/WEB-INF/classes/org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testWebInfClassesBundleEntryPathTranslationBundleNoLeadingSlash() { String className = OsgiRegistry .bundleEntryPathToClassName("/org/glassfish/jersey", "WEB-INF/classes/org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testOsgiInfClassesBundleEntryPathTranslation() { String className = OsgiRegistry .bundleEntryPathToClassName("/org/glassfish/jersey", "OSGI-INF/directory/org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testBundleEntryPathTranslation() { String className = OsgiRegistry.bundleEntryPathToClassName("/org/glassfish/jersey", "/org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testBundleEntryPathTranslationBundleNoLeadingSlash() { String className = OsgiRegistry.bundleEntryPathToClassName("/org/glassfish/jersey", "org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testBundleEntryPathTranslationNotMatching() { String className = OsgiRegistry.bundleEntryPathToClassName("/com/oracle", "org/glassfish/jersey/Test.class"); - Assert.assertEquals("com.oracle.Test", className); + Assertions.assertEquals("com.oracle.Test", className); } @Test public void testWebInfClassesBundleEntryPathTranslationNotMatching() { String className = OsgiRegistry .bundleEntryPathToClassName("/com/oracle/", "/WEB-INF/classes/org/glassfish/jersey/Test.class"); - Assert.assertEquals("com.oracle.Test", className); + Assertions.assertEquals("com.oracle.Test", className); } @Test public void testWebInfClassesBundleEntryPathTranslationNotMatching2() { String className = OsgiRegistry.bundleEntryPathToClassName("com/oracle", "/org/glassfish/jersey/Test.class"); - Assert.assertEquals("com.oracle.Test", className); + Assertions.assertEquals("com.oracle.Test", className); } @Test public void testRootBundleEntryPathTranslation() { String className = OsgiRegistry.bundleEntryPathToClassName("/", "/org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testRootBundleEntryPathTranslationNoLeadingSlash() { String className = OsgiRegistry.bundleEntryPathToClassName("/", "org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testRootWebInfClassesBundleEntryPathTranslationNoLeadingSlash() { String className = OsgiRegistry.bundleEntryPathToClassName("/", "/WEB-INF/classes/org/glassfish/jersey/Test.class"); - Assert.assertEquals("org.glassfish.jersey.Test", className); + Assertions.assertEquals("org.glassfish.jersey.Test", className); } @Test public void testDotClassInPackageName() { String className = OsgiRegistry.bundleEntryPathToClassName("/", "com/classification/Test"); - Assert.assertEquals("com.classification.Test", className); + Assertions.assertEquals("com.classification.Test", className); } @Test public void testRootWebInfClassesBundleEntryPathEsTranslation() { String className = OsgiRegistry.bundleEntryPathToClassName("es", "/WEB-INF/classes/es/a/Test.class"); - Assert.assertEquals("es.a.Test", className); + Assertions.assertEquals("es.a.Test", className); } @Test public void testIsTopLevelEntry() { - Assert.assertTrue(OsgiRegistry.isPackageLevelEntry("a", "/a/Foo.class")); + Assertions.assertTrue(OsgiRegistry.isPackageLevelEntry("a", "/a/Foo.class")); } @Test public void testIsTopLevelEntrySequenceRepeats() { - Assert.assertFalse(OsgiRegistry.isPackageLevelEntry("o", "/a/Foo.class")); + Assertions.assertFalse(OsgiRegistry.isPackageLevelEntry("o", "/a/Foo.class")); } @Test public void testIsTopLevelEntryNoSlash() { - Assert.assertTrue(OsgiRegistry.isPackageLevelEntry("a", "a/Foo.class")); + Assertions.assertTrue(OsgiRegistry.isPackageLevelEntry("a", "a/Foo.class")); } @Test public void testIsTopLevelEntrySequenceRepeatsNoSlash() { - Assert.assertFalse(OsgiRegistry.isPackageLevelEntry("o", "a/Foo.class")); + Assertions.assertFalse(OsgiRegistry.isPackageLevelEntry("o", "a/Foo.class")); } @Test public void testIsTopLevelEntrySlash() { - Assert.assertTrue(OsgiRegistry.isPackageLevelEntry("a/", "/a/Foo.class")); + Assertions.assertTrue(OsgiRegistry.isPackageLevelEntry("a/", "/a/Foo.class")); } @Test public void testIsTopLevelEntrySequenceRepeatsSlash() { - Assert.assertFalse(OsgiRegistry.isPackageLevelEntry("o/", "/a/Foo.class")); + Assertions.assertFalse(OsgiRegistry.isPackageLevelEntry("o/", "/a/Foo.class")); } @Test public void testIsTopLevelEntryRoot() { - Assert.assertTrue(OsgiRegistry.isPackageLevelEntry("/", "/Foo.class")); + Assertions.assertTrue(OsgiRegistry.isPackageLevelEntry("/", "/Foo.class")); } @Test public void testIsTopLevelEntryRootFalse() { - Assert.assertFalse(OsgiRegistry.isPackageLevelEntry("/", "/a/Foo.class")); + Assertions.assertFalse(OsgiRegistry.isPackageLevelEntry("/", "/a/Foo.class")); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/PropertiesHelperTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/PropertiesHelperTest.java index 1b319a8afb..68f6aac7d4 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/PropertiesHelperTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/PropertiesHelperTest.java @@ -21,9 +21,9 @@ import javax.ws.rs.RuntimeType; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * @author Miroslav Fuksa diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/ReflectionHelperTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/ReflectionHelperTest.java index edeef20c6d..8074527e14 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/ReflectionHelperTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/ReflectionHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -21,13 +21,14 @@ import java.security.AccessController; import java.security.PrivilegedAction; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; /** * {@code ReflectionHelper} unit tests. @@ -64,29 +65,36 @@ public void getParameterizedClassArgumentsTest() { assertEquals(aClass, arguments[0]); } - @Test(expected = AccessControlException.class) + @Test public void securityManagerSetContextClassLoader() throws Exception { - final ClassLoader loader = ReflectionHelper.class.getClassLoader(); + assertThrows(AccessControlException.class, () -> { + final ClassLoader loader = ReflectionHelper.class.getClassLoader(); - Thread.currentThread().setContextClassLoader(loader); - fail("It should not be possible to set context class loader from unprivileged block"); + Thread.currentThread().setContextClassLoader(loader); + fail("It should not be possible to set context class loader from unprivileged block"); + }); } - @Test(expected = AccessControlException.class) + @Test public void securityManagerSetContextClassLoaderPA() throws Exception { - final ClassLoader loader = ReflectionHelper.class.getClassLoader(); + assertThrows(AccessControlException.class, () -> { + final ClassLoader loader = ReflectionHelper.class.getClassLoader(); - ReflectionHelper.setContextClassLoaderPA(loader).run(); - fail("It should not be possible to set context class loader from unprivileged block even via Jersey ReflectionHelper"); + ReflectionHelper.setContextClassLoaderPA(loader).run(); + fail("It should not be possible to set context class loader " + + "from unprivileged block even via Jersey ReflectionHelper"); + }); } - @Test(expected = AccessControlException.class) + @Test public void securityManagerSetContextClassLoaderInDoPrivileged() throws Exception { - final ClassLoader loader = ReflectionHelper.class.getClassLoader(); + assertThrows(AccessControlException.class, () -> { + final ClassLoader loader = ReflectionHelper.class.getClassLoader(); - AccessController.doPrivileged(ReflectionHelper.setContextClassLoaderPA(loader)); - fail("It should not be possible to set context class loader even from privileged block via Jersey ReflectionHelper " + AccessController.doPrivileged(ReflectionHelper.setContextClassLoaderPA(loader)); + fail("It should not be possible to set context class loader even from privileged block via Jersey ReflectionHelper " + "utility"); + }); } public static class FromStringClass { diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/TokenizerTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/TokenizerTest.java index 02ba36a7b7..d0f51fd573 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/TokenizerTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/TokenizerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.internal.util; -import org.junit.Test; -import static org.junit.Assert.assertArrayEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** * Tokenizer utility unit test. diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/AbstractKeyComparatorHashMapTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/AbstractKeyComparatorHashMapTest.java index fa008dd6cd..6faf736e4b 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/AbstractKeyComparatorHashMapTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/AbstractKeyComparatorHashMapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -16,9 +16,9 @@ package org.glassfish.jersey.internal.util.collection; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; /** * diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/ByteBufferInputStreamTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/ByteBufferInputStreamTest.java index b5fbeba35d..6890b02246 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/ByteBufferInputStreamTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/ByteBufferInputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,13 +27,13 @@ import org.glassfish.jersey.internal.LocalizationMessages; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * {@link ByteBufferInputStream} unit tests. @@ -200,14 +200,14 @@ public void run() { Thread.yield(); // Give the other thread a chance to run. continue; } - assertEquals("At position: " + j, (byte) (i & 0xFF), (byte) (c & 0xFF)); + assertEquals((byte) (i & 0xFF), (byte) (c & 0xFF), "At position: " + j); if (++j % BUFFER_SIZE == 0) { i++; Thread.yield(); // Give the other thread a chance to run. } } - assertEquals("Number of bytes produced and bytes read does not match.", ROUNDS * BUFFER_SIZE, j); + assertEquals(ROUNDS * BUFFER_SIZE, j, "Number of bytes produced and bytes read does not match."); } finally { executor.shutdownNow(); bbis.close(); @@ -272,7 +272,7 @@ public void run() { continue; } for (int p = 0; p < c; p++) { - assertEquals("At position: " + j, (byte) (i & 0xFF), (byte) buffer[p]); + assertEquals((byte) (i & 0xFF), (byte) buffer[p], "At position: " + j); if (++j % BUFFER_SIZE == 0) { i++; Thread.yield(); // Give the other thread a chance to run. @@ -280,7 +280,7 @@ public void run() { } } - assertEquals("Number of bytes produced and bytes read does not match.", ROUNDS * BUFFER_SIZE, j); + assertEquals(ROUNDS * BUFFER_SIZE, j, "Number of bytes produced and bytes read does not match."); } finally { executor.shutdownNow(); bbis.close(); @@ -338,16 +338,16 @@ public void run() { int j = 0; int c; while ((c = bbis.read()) != -1) { - assertNotEquals("Should not read 'nothing' in blocking mode.", Integer.MIN_VALUE, c); + assertNotEquals(Integer.MIN_VALUE, c, "Should not read 'nothing' in blocking mode."); - assertEquals("At position: " + j, (byte) (i & 0xFF), (byte) c); + assertEquals((byte) (i & 0xFF), (byte) c, "At position: " + j); if (++j % BUFFER_SIZE == 0) { i++; Thread.yield(); // Give the other thread a chance to run. } } - assertEquals("Number of bytes produced and bytes read does not match.", ROUNDS * BUFFER_SIZE, j); + assertEquals(ROUNDS * BUFFER_SIZE, j, "Number of bytes produced and bytes read does not match."); } finally { executor.shutdownNow(); bbis.close(); @@ -406,10 +406,10 @@ public void run() { int c; byte[] buffer = new byte[443]; while ((c = bbis.read(buffer)) != -1) { - assertNotEquals("Should not read 0 bytes in blocking mode.", 0, c); + assertNotEquals(0, c, "Should not read 0 bytes in blocking mode."); for (int p = 0; p < c; p++) { - assertEquals("At position: " + j, (byte) (i & 0xFF), buffer[p]); + assertEquals((byte) (i & 0xFF), buffer[p], "At position: " + j); if (++j % BUFFER_SIZE == 0) { i++; Thread.yield(); // Give the other thread a chance to run. @@ -417,7 +417,7 @@ public void run() { } } - assertEquals("Number of bytes produced and bytes read does not match.", ROUNDS * BUFFER_SIZE, j); + assertEquals(ROUNDS * BUFFER_SIZE, j, "Number of bytes produced and bytes read does not match."); } finally { executor.shutdownNow(); bbis.close(); @@ -446,7 +446,7 @@ public void testAvailable() throws Exception { data.flip(); bbis.put(data); - assertEquals("Available bytes", BUFFER_SIZE, bbis.available()); + assertEquals(BUFFER_SIZE, bbis.available(), "Available bytes"); data = ByteBuffer.allocate(BUFFER_SIZE); data.clear(); @@ -456,27 +456,27 @@ public void testAvailable() throws Exception { data.flip(); bbis.put(data); - assertEquals("Available bytes", 2 * BUFFER_SIZE, bbis.available()); + assertEquals(2 * BUFFER_SIZE, bbis.available(), "Available bytes"); int c = bbis.read(); - assertEquals("Byte read", 'A', c); - assertEquals("Available bytes", 2 * BUFFER_SIZE - 1, bbis.available()); + assertEquals('A', c, "Byte read"); + assertEquals(2 * BUFFER_SIZE - 1, bbis.available(), "Available bytes"); byte[] buff = new byte[199]; int l = bbis.read(buff); - assertEquals("Number of bytes read", buff.length, l); - assertEquals("Available bytes", 2 * BUFFER_SIZE - 200, bbis.available()); + assertEquals(buff.length, l, "Number of bytes read"); + assertEquals(2 * BUFFER_SIZE - 200, bbis.available(), "Available bytes"); buff = new byte[1000]; l = bbis.read(buff); - assertEquals("Number of bytes read", buff.length, l); - assertEquals("Available bytes", 2 * BUFFER_SIZE - 1200, bbis.available()); + assertEquals(buff.length, l, "Number of bytes read"); + assertEquals(2 * BUFFER_SIZE - 1200, bbis.available(), "Available bytes"); bbis.closeQueue(); l = bbis.read(buff); - assertEquals("Number of bytes read", 2 * BUFFER_SIZE - 1200, l); - assertEquals("Available bytes", 0, bbis.available()); + assertEquals(2 * BUFFER_SIZE - 1200, l, "Number of bytes read"); + assertEquals(0, bbis.available(), "Available bytes"); bbis.close(); } @@ -557,8 +557,8 @@ private void testAction(Task task, String exMsg, boolean retryFailOnClosed) thro task.run(); fail("IOException expected."); } catch (IOException ex) { - assertNotNull("Custom exception cause", ex.getCause()); - assertEquals("Custom exception cause message", exMsg, ex.getCause().getMessage()); + assertNotNull(ex.getCause(), "Custom exception cause"); + assertEquals(exMsg, ex.getCause().getMessage(), "Custom exception cause message"); } if (retryFailOnClosed) { @@ -566,8 +566,8 @@ private void testAction(Task task, String exMsg, boolean retryFailOnClosed) thro task.run(); fail("IOException expected."); } catch (IOException ex) { - assertEquals("Closed IOException message", LocalizationMessages.INPUT_STREAM_CLOSED(), ex.getMessage()); - assertNull("Closed IOException cause", ex.getCause()); + assertEquals(LocalizationMessages.INPUT_STREAM_CLOSED(), ex.getMessage(), "Closed IOException message"); + assertNull(ex.getCause(), "Closed IOException cause"); } } else { task.run(); diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/KeyComparatorHashMapTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/KeyComparatorHashMapTest.java index 9d71c1dc9c..fcafac578a 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/KeyComparatorHashMapTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/KeyComparatorHashMapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -16,7 +16,7 @@ package org.glassfish.jersey.internal.util.collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/KeyComparatorLinkedHashMapTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/KeyComparatorLinkedHashMapTest.java index 48000b0edd..9e8ec188e9 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/KeyComparatorLinkedHashMapTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/KeyComparatorLinkedHashMapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -16,7 +16,7 @@ package org.glassfish.jersey.internal.util.collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Paul Sandoz diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/ViewsTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/ViewsTest.java index 11bb457c29..c7be09dfdd 100644 --- a/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/ViewsTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/collection/ViewsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -24,10 +24,10 @@ import java.util.Map; import java.util.Set; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Pavel Bucek diff --git a/core-common/src/test/java/org/glassfish/jersey/logging/HasEntityTimeoutTest.java b/core-common/src/test/java/org/glassfish/jersey/logging/HasEntityTimeoutTest.java index 35459f9422..e1886d46ac 100644 --- a/core-common/src/test/java/org/glassfish/jersey/logging/HasEntityTimeoutTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/logging/HasEntityTimeoutTest.java @@ -24,7 +24,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.UriInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java b/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java index 9034406c14..abd4d54877 100644 --- a/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -25,13 +25,13 @@ import java.util.Arrays; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.glassfish.jersey.logging.LoggingFeature.Verbosity.HEADERS_ONLY; import static org.glassfish.jersey.logging.LoggingFeature.Verbosity.PAYLOAD_ANY; import static org.glassfish.jersey.logging.LoggingFeature.Verbosity.PAYLOAD_TEXT; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; diff --git a/core-common/src/test/java/org/glassfish/jersey/message/AbstractEncodingTest.java b/core-common/src/test/java/org/glassfish/jersey/message/AbstractEncodingTest.java index 11a3a977ab..161b9b192f 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/AbstractEncodingTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/AbstractEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,8 +22,8 @@ import java.io.InputStream; import java.io.OutputStream; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Super class for encoding tests - contains convenient way of defining the test by simply providing the encoding and diff --git a/core-common/src/test/java/org/glassfish/jersey/message/DeflateEncodingTest.java b/core-common/src/test/java/org/glassfish/jersey/message/DeflateEncodingTest.java index 3d14861c22..dfeabe606d 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/DeflateEncodingTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/DeflateEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,7 +35,7 @@ import javax.inject.Provider; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Martin Matula diff --git a/core-common/src/test/java/org/glassfish/jersey/message/GZipEncodingTest.java b/core-common/src/test/java/org/glassfish/jersey/message/GZipEncodingTest.java index 43d81bc643..d453668a54 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/GZipEncodingTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/GZipEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,7 +22,7 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Martin Matula diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/DateProviderTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/DateProviderTest.java index 9c5a132c6c..052ab284b0 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/DateProviderTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/DateProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,11 +16,11 @@ package org.glassfish.jersey.message.internal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Date; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Libor Kramolis diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/FormMultivaluedMapProviderTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/FormMultivaluedMapProviderTest.java index efbfa84ff7..695fd4ffe2 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/FormMultivaluedMapProviderTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/FormMultivaluedMapProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -27,10 +27,10 @@ import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * {@link FormProvider} unit tests diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/FormProviderTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/FormProviderTest.java index 79c5675671..5dcc075d38 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/FormProviderTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/FormProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -27,10 +27,10 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * {@link FormProvider} unit tests diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/LanguageTagTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/LanguageTagTest.java index f8be76924b..bb82964d7d 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/LanguageTagTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/LanguageTagTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,11 +18,12 @@ import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalToIgnoringCase; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests for {@link LanguageTag} class. @@ -38,9 +39,9 @@ public void testLanguageCountry() throws Exception { _test("CZ", "cs"); } - @Test(expected = IllegalArgumentException.class) + @Test public void testLanguageCountryInvalid() throws Exception { - _test("en", "gbgbgbgbgb"); + assertThrows(IllegalArgumentException.class, () -> _test("en", "gbgbgbgbgb")); } @Test diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/MessageBodyFactoryTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/MessageBodyFactoryTest.java index c6ff32ce1f..5cc89dde98 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/MessageBodyFactoryTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/MessageBodyFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,10 +27,10 @@ import org.glassfish.jersey.message.WriterModel; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import static org.glassfish.jersey.message.internal.MessageBodyFactory.WORKER_BY_TYPE_COMPARATOR; @@ -46,9 +46,9 @@ public void testWorkerByTypeComparatorContract() { for (WriterModel a : list) { for (WriterModel b : list) { assertEquals( - "Comparator breaks contract: compare(a, b) != -compare(b, a)", -Integer.signum(WORKER_BY_TYPE_COMPARATOR.compare(a, b)), - Integer.signum(WORKER_BY_TYPE_COMPARATOR.compare(b, a))); + Integer.signum(WORKER_BY_TYPE_COMPARATOR.compare(b, a)), + "Comparator breaks contract: compare(a, b) != -compare(b, a)"); for (WriterModel c : list) { if (WORKER_BY_TYPE_COMPARATOR.compare(a, b) > 0 @@ -59,9 +59,9 @@ public void testWorkerByTypeComparatorContract() { if (WORKER_BY_TYPE_COMPARATOR.compare(a, b) == 0) { assertEquals( - "Comparator breaks contract: a == b but a < c and b > c or vice versa", Integer.signum(WORKER_BY_TYPE_COMPARATOR.compare(a, c)), - Integer.signum(WORKER_BY_TYPE_COMPARATOR.compare(b, c))); + Integer.signum(WORKER_BY_TYPE_COMPARATOR.compare(b, c)), + "Comparator breaks contract: a == b but a < c and b > c or vice versa"); } } } diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/QualityTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/QualityTest.java index 1856c92f1b..3cf9bac3de 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/QualityTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/QualityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,95 +16,85 @@ package org.glassfish.jersey.message.internal; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + import java.text.ParseException; -import java.util.Arrays; import java.util.Collections; import java.util.Locale; import java.util.Map; +import java.util.stream.Stream; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Quality unit tests. * * @author Marek Potociar */ -@RunWith(Parameterized.class) public class QualityTest { private static final Locale ORIGINAL_LOCALE = Locale.getDefault(); - @Parameterized.Parameters(name = "{0}") - public static Iterable data() { - return Arrays.asList(new Object[][]{{Locale.US}, {Locale.GERMANY}}); - } - - @Parameterized.Parameter(0) - public Locale locale; - - @Before - public void setUp() throws Exception { - Locale.setDefault(locale); - } - - @After - public void tearDown() throws Exception { - Locale.setDefault(ORIGINAL_LOCALE); + public static Stream data() { + return Stream.of(Arguments.of(Locale.US), Arguments.of(Locale.GERMANY)); } /** * Test enhancing HTT header parameter map with a quality parameter. */ - @Test - public void testEnhanceWithQualityParameter() { - Map result; + @ParameterizedTest + @MethodSource("data") + public void testEnhanceWithQualityParameter(Locale locale) { + try { + Locale.setDefault(locale); + Map result; - result = Quality.enhanceWithQualityParameter(null, "q", 1000); - assertThat(result, equalTo(null)); + result = Quality.enhanceWithQualityParameter(null, "q", 1000); + assertThat(result, equalTo(null)); - result = Quality.enhanceWithQualityParameter(null, "q", 200); - assertThat(result, equalTo(asMap("q=0.2"))); + result = Quality.enhanceWithQualityParameter(null, "q", 200); + assertThat(result, equalTo(asMap("q=0.2"))); - result = Quality.enhanceWithQualityParameter(null, "q", 220); - assertThat(result, equalTo(asMap("q=0.22"))); + result = Quality.enhanceWithQualityParameter(null, "q", 220); + assertThat(result, equalTo(asMap("q=0.22"))); - result = Quality.enhanceWithQualityParameter(null, "q", 222); - assertThat(result, equalTo(asMap("q=0.222"))); + result = Quality.enhanceWithQualityParameter(null, "q", 222); + assertThat(result, equalTo(asMap("q=0.222"))); - Map parameters; + Map parameters; - parameters = asMap("a=b"); - result = Quality.enhanceWithQualityParameter(parameters, "q", 1000); - assertThat(result, equalTo(parameters)); + parameters = asMap("a=b"); + result = Quality.enhanceWithQualityParameter(parameters, "q", 1000); + assertThat(result, equalTo(parameters)); - result = Quality.enhanceWithQualityParameter(parameters, "q", 200); - assertThat(result, equalTo(asMap("a=b;q=0.2"))); + result = Quality.enhanceWithQualityParameter(parameters, "q", 200); + assertThat(result, equalTo(asMap("a=b;q=0.2"))); - result = Quality.enhanceWithQualityParameter(parameters, "q", 220); - assertThat(result, equalTo(asMap("a=b;q=0.22"))); + result = Quality.enhanceWithQualityParameter(parameters, "q", 220); + assertThat(result, equalTo(asMap("a=b;q=0.22"))); - result = Quality.enhanceWithQualityParameter(parameters, "q", 222); - assertThat(result, equalTo(asMap("a=b;q=0.222"))); + result = Quality.enhanceWithQualityParameter(parameters, "q", 222); + assertThat(result, equalTo(asMap("a=b;q=0.222"))); - // test quality parameter override - parameters = asMap("a=b;q=0.3"); - result = Quality.enhanceWithQualityParameter(parameters, "q", 1000); - assertThat(result, equalTo(asMap("a=b;q=1.0"))); + // test quality parameter override + parameters = asMap("a=b;q=0.3"); + result = Quality.enhanceWithQualityParameter(parameters, "q", 1000); + assertThat(result, equalTo(asMap("a=b;q=1.0"))); - result = Quality.enhanceWithQualityParameter(parameters, "q", 200); - assertThat(result, equalTo(asMap("a=b;q=0.2"))); + result = Quality.enhanceWithQualityParameter(parameters, "q", 200); + assertThat(result, equalTo(asMap("a=b;q=0.2"))); - result = Quality.enhanceWithQualityParameter(parameters, "q", 220); - assertThat(result, equalTo(asMap("a=b;q=0.22"))); + result = Quality.enhanceWithQualityParameter(parameters, "q", 220); + assertThat(result, equalTo(asMap("a=b;q=0.22"))); - result = Quality.enhanceWithQualityParameter(parameters, "q", 222); - assertThat(result, equalTo(asMap("a=b;q=0.222"))); + result = Quality.enhanceWithQualityParameter(parameters, "q", 222); + assertThat(result, equalTo(asMap("a=b;q=0.222"))); + } finally { + Locale.setDefault(ORIGINAL_LOCALE); + } } /** diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/ResponseTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/ResponseTest.java index ba7e6bd7db..d43c4f663b 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/ResponseTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/ResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -21,10 +21,10 @@ import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.Response.StatusType; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/StringBuilderUtilsTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/StringBuilderUtilsTest.java index 0b1627d408..dc9fc0290a 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/StringBuilderUtilsTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/StringBuilderUtilsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,10 +16,10 @@ package org.glassfish.jersey.message.internal; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @@ -30,11 +30,11 @@ public class StringBuilderUtilsTest { public StringBuilderUtilsTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { } - @AfterClass + @AfterAll public static void tearDownClass() throws Exception { } diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/UtilsTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/UtilsTest.java index e6baf4c404..55976fe629 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/UtilsTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/UtilsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.message.internal; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; @@ -39,7 +39,7 @@ public void createTempFile() throws IOException { } finally { stream.close(); } - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/VariantListBuilderTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/VariantListBuilderTest.java index 06032e91ec..7fb708c7dd 100644 --- a/core-common/src/test/java/org/glassfish/jersey/message/internal/VariantListBuilderTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/VariantListBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,9 +22,9 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Variant; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * TODO: javadoc. diff --git a/core-common/src/test/java/org/glassfish/jersey/process/internal/RankedComparatorTest.java b/core-common/src/test/java/org/glassfish/jersey/process/internal/RankedComparatorTest.java index 53cf7b6150..78df231d30 100644 --- a/core-common/src/test/java/org/glassfish/jersey/process/internal/RankedComparatorTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/process/internal/RankedComparatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.model.internal.RankedComparator; import org.glassfish.jersey.model.internal.RankedProvider; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests {@link org.glassfish.jersey.model.internal.RankedComparator}. diff --git a/core-common/src/test/java/org/glassfish/jersey/uri/PathPatternTest.java b/core-common/src/test/java/org/glassfish/jersey/uri/PathPatternTest.java index e876ae2c02..460db0e989 100644 --- a/core-common/src/test/java/org/glassfish/jersey/uri/PathPatternTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/uri/PathPatternTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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,11 +18,10 @@ import java.util.regex.MatchResult; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests {@link PathTemplate}. @@ -61,12 +60,12 @@ public void testTerminalPathPatterMatching() { for (PathPattern pattern : patterns) { matchResult = pattern.match(rhp); - assertNotNull("No match of " + rhp + " for pattern " + pattern, matchResult); + assertNotNull(matchResult, "No match of " + rhp + " for pattern " + pattern); rhp = matchResult.group(matchResult.groupCount()); rhp = (rhp == null) ? "" : rhp; } - Assert.assertEquals("", rhp); + assertEquals("", rhp); rhp = path2; @@ -89,8 +88,8 @@ public void testSimplePattern() throws Exception { public void testSimplePatternWithRightHandSide() throws Exception { PathPattern pattern = new PathPattern(new PathTemplate("/test/{template: abc.*}")); - assertNull("Why matched?", pattern.match("/test/me")); - assertNotNull("Why not matched?", pattern.match("/test/abc-should_work")); + assertNull(pattern.match("/test/me"), "Why matched?"); + assertNotNull(pattern.match("/test/abc-should_work"), "Why not matched?"); } @Test @@ -98,9 +97,9 @@ public void testSetsAndGetsUriTemplate() throws Exception { PathTemplate tmpl = new PathTemplate("/test"); PathPattern pattern = new PathPattern(tmpl); assertEquals( - "We just injected the value, why it is different?", tmpl, - pattern.getTemplate() + pattern.getTemplate(), + "We just injected the value, why it is different?" ); } @@ -113,9 +112,9 @@ public void testLastElementOfMatchIsRestOfPath() throws Exception { String value = m.group(m.groupCount()); assertEquals( - "Last value should match all of the trailing part", "/d", - value + value, + "Last value should match all of the trailing part" ); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/uri/UriComponentTest.java b/core-common/src/test/java/org/glassfish/jersey/uri/UriComponentTest.java index 8e26e491e6..a98f8ae723 100644 --- a/core-common/src/test/java/org/glassfish/jersey/uri/UriComponentTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/uri/UriComponentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,9 +21,9 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.PathSegment; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Unit test for {@link UriComponent} class. diff --git a/core-common/src/test/java/org/glassfish/jersey/uri/UriTemplateTest.java b/core-common/src/test/java/org/glassfish/jersey/uri/UriTemplateTest.java index e696602ff6..7826506379 100644 --- a/core-common/src/test/java/org/glassfish/jersey/uri/UriTemplateTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/uri/UriTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,12 +28,12 @@ import org.glassfish.jersey.uri.internal.UriTemplateParser; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Taken from Jersey 1: jersey-tests: com.sun.jersey.impl.uri.UriTemplateTest @@ -475,15 +475,15 @@ public void testSingleQueryParameter() throws Exception { tmpl.match("/test?query=x", result); assertEquals( - "incorrect size for match string", 1, - result.size() + result.size(), + "incorrect size for match string" ); assertEquals( - "query parameter is not matched", "x", - result.get("query") + result.get("query"), + "query parameter is not matched" ); } @@ -498,20 +498,20 @@ public void testDoubleQueryParameter() throws Exception { tmpl.match("/test?query=x&secondQuery=y", result); assertEquals( - "incorrect size for match string", 2, - result.size() + result.size(), + "incorrect size for match string" ); assertEquals( - "query parameter is not matched", "x", - result.get("query") + result.get("query"), + "query parameter is not matched" ); assertEquals( - "query parameter is not matched", "y", - result.get("secondQuery") + result.get("secondQuery"), + "query parameter is not matched" ); } @@ -524,9 +524,9 @@ public void testSettingQueryParameter() throws Exception { final String uri = tmpl.createURI(values); assertEquals( - "query string is not set", "/test?query=example", - uri + uri, + "query string is not set" ); } @@ -540,9 +540,9 @@ public void testSettingTwoQueryParameter() throws Exception { final String uri = tmpl.createURI(values); assertEquals( - "query string is not set", "/test?query=example&other=otherExample", - uri + uri, + "query string is not set" ); } @@ -555,9 +555,9 @@ public void testNotSettingQueryParameter() throws Exception { final String uri = tmpl.createURI(values); assertEquals( - "query string is set", "/test", - uri + uri, + "query string is set" ); } @@ -571,9 +571,9 @@ public void testSettingMatrixParameter() throws Exception { final String uri = tmpl.createURI(values); assertEquals( - "query string is not set", "/test;matrix=example/other", - uri + uri, + "query string is not set" ); } @@ -588,9 +588,9 @@ public void testSettingTwoMatrixParameter() throws Exception { final String uri = tmpl.createURI(values); assertEquals( - "query string is not set", "/test;matrix=example;other=otherExample/other", - uri + uri, + "query string is not set" ); } @@ -605,9 +605,9 @@ public void testSettingTwoSeperatedMatrixParameter() throws Exception { final String uri = tmpl.createURI(values); assertEquals( - "query string is not set", "/test;matrix=example/other;other=otherExample", - uri + uri, + "query string is not set" ); } @@ -619,9 +619,9 @@ public void testNotSettingMatrixParameter() throws Exception { final String uri = tmpl.createURI(values); assertEquals( - "query string is set", "/test/other", - uri + uri, + "query string is set" ); } @@ -700,17 +700,17 @@ public void testRfc6570QueryTemplateExamples() { private void assertEncodedQueryTemplateExpansion(final String expectedExpansion, final String queryTemplate, final Object... values) { - assertEquals("Unexpected encoded query template expansion result.", - expectedExpansion, - UriTemplate.createURI(null, null, null, null, null, null, queryTemplate, null, values, true, false)); + assertEquals(expectedExpansion, + UriTemplate.createURI(null, null, null, null, null, null, queryTemplate, null, values, true, false), + "Unexpected encoded query template expansion result."); } private void assertEncodedQueryTemplateExpansion(final String expectedExpansion, final String queryTemplate, final Map values) { - assertEquals("Unexpected encoded query template expansion result.", - expectedExpansion, - UriTemplate.createURI(null, null, null, null, null, null, queryTemplate, null, values, true, false)); + assertEquals(expectedExpansion, + UriTemplate.createURI(null, null, null, null, null, null, queryTemplate, null, values, true, false), + "Unexpected encoded query template expansion result."); } @Test @@ -753,16 +753,16 @@ public void testRfc6570MatrixTemplateExamples() { private void assertEncodedPathTemplateExpansion(final String expectedExpansion, final String pathTemplate, final Object... values) { - assertEquals("Unexpected encoded matrix parameter template expansion result.", - expectedExpansion, - UriTemplate.createURI(null, null, null, null, null, pathTemplate, null, null, values, true, false)); + assertEquals(expectedExpansion, + UriTemplate.createURI(null, null, null, null, null, pathTemplate, null, null, values, true, false), + "Unexpected encoded matrix parameter template expansion result."); } private void assertEncodedPathTemplateExpansion(final String expectedExpansion, final String pathTemplate, final Map values) { - assertEquals("Unexpected encoded matrix parameter template expansion result.", - expectedExpansion, - UriTemplate.createURI(null, null, null, null, null, pathTemplate, null, null, values, true, false)); + assertEquals(expectedExpansion, + UriTemplate.createURI(null, null, null, null, null, pathTemplate, null, null, values, true, false), + "Unexpected encoded matrix parameter template expansion result."); } } diff --git a/core-common/src/test/java/org/glassfish/jersey/uri/internal/PathTemplateTest.java b/core-common/src/test/java/org/glassfish/jersey/uri/internal/PathTemplateTest.java index 4822e4a709..ec9bc99daa 100644 --- a/core-common/src/test/java/org/glassfish/jersey/uri/internal/PathTemplateTest.java +++ b/core-common/src/test/java/org/glassfish/jersey/uri/internal/PathTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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,8 +18,8 @@ import org.glassfish.jersey.uri.PathTemplate; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -31,14 +31,14 @@ public class PathTemplateTest { public void testBasicOperations() throws Exception { PathTemplate tmpl = new PathTemplate("/{id : \\d+}/test"); assertEquals( - "getNumberOfTemplateVariables() returned invalid number", 1, - tmpl.getNumberOfTemplateVariables() + tmpl.getNumberOfTemplateVariables(), + "getNumberOfTemplateVariables() returned invalid number" ); assertEquals( - "getNumberOfExplicitRegexes() returned invalid number", 1, - tmpl.getNumberOfExplicitRegexes() + tmpl.getNumberOfExplicitRegexes(), + "getNumberOfExplicitRegexes() returned invalid number" ); } } diff --git a/core-common/src/test/resources/surefire-jdk17.policy b/core-common/src/test/resources/surefire-jdk17.policy new file mode 100644 index 0000000000..a960a3dda0 --- /dev/null +++ b/core-common/src/test/resources/surefire-jdk17.policy @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2022 Vladimir Bychkov. 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 + */ + +// JDK 17 and later permissions +grant { + permission java.lang.RuntimePermission "setContextClassLoader"; +}; diff --git a/core-server/pom.xml b/core-server/pom.xml index 0c0689ed3f..8686604648 100644 --- a/core-server/pom.xml +++ b/core-server/pom.xml @@ -214,8 +214,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/core-server/src/test/java/org/glassfish/jersey/server/AnnotatedEntityTest.java b/core-server/src/test/java/org/glassfish/jersey/server/AnnotatedEntityTest.java index 0e3e3a467f..772e32c99f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/AnnotatedEntityTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/AnnotatedEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,10 +29,10 @@ import org.glassfish.jersey.server.model.ModelValidationException; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests entity parameter annotated with non injection annotations. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/ApplicationHandlerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ApplicationHandlerTest.java index 6c267cbfed..b926dc783c 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/ApplicationHandlerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/ApplicationHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -60,12 +60,12 @@ import org.glassfish.jersey.server.internal.process.MappableException; import org.glassfish.jersey.server.model.ModelValidationException; import org.glassfish.jersey.server.spi.ResponseErrorMapper; - -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test basic application behavior. @@ -558,12 +558,14 @@ public void testMapResponseErrorForMbw() throws Exception { /** * Test that un-mapped response errors are tried to be processed only once (MBW). */ - @Test(expected = ExecutionException.class) + @Test public void testMapCyclicResponseErrorForMbw() throws Exception { - final ApplicationHandler handler = new ApplicationHandler(MapResponseErrorApplication.class); + Assertions.assertThrows(ExecutionException.class, () -> { + final ApplicationHandler handler = new ApplicationHandler(MapResponseErrorApplication.class); - final ContainerRequest context = RequestContextBuilder.from("/foobar", "GET").build(); + final ContainerRequest context = RequestContextBuilder.from("/foobar", "GET").build(); - handler.apply(context).get(); + handler.apply(context).get(); + }); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/ApplicationTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ApplicationTest.java index 9765e0e493..781d390eb7 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/ApplicationTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/ApplicationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -23,7 +23,7 @@ import javax.ws.rs.Path; import javax.ws.rs.core.Application; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Pavel Bucek diff --git a/core-server/src/test/java/org/glassfish/jersey/server/AsyncApplicationBuildingTest.java b/core-server/src/test/java/org/glassfish/jersey/server/AsyncApplicationBuildingTest.java index 069996ea9e..dd511e246f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/AsyncApplicationBuildingTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/AsyncApplicationBuildingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -46,9 +46,9 @@ import org.glassfish.jersey.process.Inflector; import org.glassfish.jersey.server.model.Resource; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Unit test for creating an application with asynchronously handled request processing @@ -252,7 +252,7 @@ public void testDeploymentFailsForAmbiguousResource() { final ResourceConfig resourceConfig = new ResourceConfig(ErrornousResource.class); try { ApplicationHandler server = new ApplicationHandler(resourceConfig); - assertTrue("Jersey server initialization should have failed: " + server, false); + assertTrue(false, "Jersey server initialization should have failed: " + server); } catch (Exception e) { } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/AsyncCallbackServerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/AsyncCallbackServerTest.java index cde25bb562..95de589994 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/AsyncCallbackServerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/AsyncCallbackServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,11 +35,11 @@ import javax.inject.Singleton; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests {@link CompletionCallback}. @@ -67,7 +67,7 @@ public void testCompletionCallback() throws ExecutionException, InterruptedExcep final ContainerResponse response = app.apply(req).get(); assertEquals(200, response.getStatus()); - assertTrue("onComplete() was not called.", flags.onCompletionCalled); + assertTrue(flags.onCompletionCalled, "onComplete() was not called."); } @Test @@ -85,7 +85,7 @@ public void testCompletionFail() throws ExecutionException, InterruptedException } catch (Exception e) { // ok - should throw an exception } - assertTrue("onError().", flags.onCompletionCalledWithError); + assertTrue(flags.onCompletionCalledWithError, "onError()."); } @Test @@ -117,8 +117,8 @@ public CheckingCompletionFilter(Flags flags) { @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { - assertFalse("onComplete() callback has already been called.", - flags.onCompletionCalled); + assertFalse(flags.onCompletionCalled, + "onComplete() callback has already been called."); } } @@ -132,8 +132,8 @@ public MyCompletionCallback(Flags flags) { @Override public void onComplete(Throwable throwable) { - assertFalse("onComplete() has already been called.", flags.onCompletionCalled); - assertFalse("onComplete() has already been called with error.", flags.onCompletionCalledWithError); + assertFalse(flags.onCompletionCalled, "onComplete() has already been called."); + assertFalse(flags.onCompletionCalledWithError, "onComplete() has already been called with error."); if (throwable == null) { flags.onCompletionCalled = true; } else { diff --git a/core-server/src/test/java/org/glassfish/jersey/server/AutoDiscoverableServerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/AutoDiscoverableServerTest.java index cfac9de190..6d51742fac 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/AutoDiscoverableServerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/AutoDiscoverableServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.internal.spi.AutoDiscoverable; import org.glassfish.jersey.internal.util.PropertiesHelper; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Note: Auto-discoverables from this test "affects" all other tests in suit. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/ContainerRequestTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ContainerRequestTest.java index 7a479e0ecd..21671540a4 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/ContainerRequestTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/ContainerRequestTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -33,11 +33,12 @@ import javax.ws.rs.core.Variant; import org.glassfish.jersey.internal.MapPropertiesDelegate; - -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Jersey container request context test. @@ -181,22 +182,28 @@ private ContainerRequest getContainerRequestForPreconditionsTest() { new MapPropertiesDelegate(), null); } - @Test(expected = IllegalArgumentException.class) + @Test public void testEvaluatePreconditionsDateNull() { - ContainerRequest r = getContainerRequestForPreconditionsTest(); - r.evaluatePreconditions((Date) null); + assertThrows(IllegalArgumentException.class, () -> { + ContainerRequest r = getContainerRequestForPreconditionsTest(); + r.evaluatePreconditions((Date) null); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testEvaluatePreconditionsEntityTagNull() { - ContainerRequest r = getContainerRequestForPreconditionsTest(); - r.evaluatePreconditions((EntityTag) null); + assertThrows(IllegalArgumentException.class, () -> { + ContainerRequest r = getContainerRequestForPreconditionsTest(); + r.evaluatePreconditions((EntityTag) null); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testEvaluatePreconditionsBothNull() { - ContainerRequest r = getContainerRequestForPreconditionsTest(); - r.evaluatePreconditions(null, null); + assertThrows(IllegalArgumentException.class, () -> { + ContainerRequest r = getContainerRequestForPreconditionsTest(); + r.evaluatePreconditions(null, null); + }); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/ExtendedResourceContextTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ExtendedResourceContextTest.java index 2cdc9240e4..f3f96df85b 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/ExtendedResourceContextTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/ExtendedResourceContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,9 +28,9 @@ import org.glassfish.jersey.server.model.ResourceModel; import org.glassfish.jersey.server.model.ResourceTestUtils; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Test (@link ExtendedResourceContext extended resource context}. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/JaxRsFeatureRegistrationTest.java b/core-server/src/test/java/org/glassfish/jersey/server/JaxRsFeatureRegistrationTest.java index 122ab4508a..4e2fa5307c 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/JaxRsFeatureRegistrationTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/JaxRsFeatureRegistrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -17,8 +17,8 @@ package org.glassfish.jersey.server; import org.glassfish.jersey.CommonProperties; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.container.DynamicFeature; import javax.ws.rs.container.ResourceInfo; @@ -47,8 +47,8 @@ public void featureRegistrationTest() { final ResourceConfig config = new ResourceConfig(); final ApplicationHandler ah = new ApplicationHandler(config); - Assert.assertTrue(ah.getConfiguration().isRegistered(FeatureImpl.class)); - Assert.assertTrue(ah.getConfiguration().isRegistered(DynamicFeatureImpl.class)); + Assertions.assertTrue(ah.getConfiguration().isRegistered(FeatureImpl.class)); + Assertions.assertTrue(ah.getConfiguration().isRegistered(DynamicFeatureImpl.class)); } @Test @@ -58,7 +58,7 @@ public void serviceLoadingPropertyTest() { .property(CommonProperties.JAXRS_SERVICE_LOADING_ENABLE, "false"); final ApplicationHandler ah = new ApplicationHandler(config); - Assert.assertFalse(ah.getConfiguration().isRegistered(FeatureImpl.class)); - Assert.assertFalse(ah.getConfiguration().isRegistered(DynamicFeatureImpl.class)); + Assertions.assertFalse(ah.getConfiguration().isRegistered(FeatureImpl.class)); + Assertions.assertFalse(ah.getConfiguration().isRegistered(DynamicFeatureImpl.class)); } } \ No newline at end of file diff --git a/core-server/src/test/java/org/glassfish/jersey/server/ModelProcessorScopeTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ModelProcessorScopeTest.java index 4f50714e66..3a64bd5e75 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/ModelProcessorScopeTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/ModelProcessorScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.server.model.ResourceModel; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test scope of resources enhanced by model processors. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigBuilderTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigBuilderTest.java index 41e83e9351..9393e57ef9 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigBuilderTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -26,9 +26,9 @@ import javax.ws.rs.ext.ReaderInterceptor; import javax.ws.rs.ext.ReaderInterceptorContext; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** diff --git a/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigTest.java index 197e5fb2f9..0fd7416e48 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,15 +34,15 @@ import org.glassfish.jersey.server.config.toplevel.PublicRootResourceClass; import org.glassfish.jersey.server.config.toplevelinnerstatic.PublicRootResourceInnerStaticClass; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.glassfish.jersey.server.JarUtils.createJarFile; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek @@ -98,8 +98,7 @@ public void testResourceConfigInjection() throws InterruptedException, Execution final ContainerResponse r = handler.apply(RequestContextBuilder.from("/", "/resource?id=" + rcId, "GET").build()).get(); assertEquals(200, r.getStatus()); - assertEquals("Injected application instance not same as used for building the Jersey handler.", - "true", r.getEntity()); + assertEquals("true", r.getEntity(), "Injected application instance not same as used for building the Jersey handler."); } @Test diff --git a/core-server/src/test/java/org/glassfish/jersey/server/ResourceMergeTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ResourceMergeTest.java index 76489a0eb8..2c2a865ab5 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/ResourceMergeTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/ResourceMergeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,10 +29,10 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.server.model.ResourceTestUtils; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test merging of resources and child resources. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/SecurityContextTest.java b/core-server/src/test/java/org/glassfish/jersey/server/SecurityContextTest.java index 713f2accb4..881f7cc3a6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/SecurityContextTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/SecurityContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -28,10 +28,10 @@ import javax.annotation.Priority; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test class for testing security context in the Filter and resource. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/SecurityManagerConfiguredTest.java b/core-server/src/test/java/org/glassfish/jersey/server/SecurityManagerConfiguredTest.java index f30e6fbaa3..b5f18e5485 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/SecurityManagerConfiguredTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/SecurityManagerConfiguredTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.server; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test that verifies that security manager is setup to run the Jersey core server unit tests. @@ -30,7 +30,7 @@ public class SecurityManagerConfiguredTest { */ @Test public void testSecurityManagerIsConfigured() { - assertNotNull("Jersey core server unit tests should run with active security manager", - System.getSecurityManager()); + assertNotNull(System.getSecurityManager(), + "Jersey core server unit tests should run with active security manager"); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/UriInfoMatchedResourcesTest.java b/core-server/src/test/java/org/glassfish/jersey/server/UriInfoMatchedResourcesTest.java index 0f8838bd68..9ef0fbca8a 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/UriInfoMatchedResourcesTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/UriInfoMatchedResourcesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -23,8 +23,8 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test UriInfo content. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/UriInfoMatchedUrisTest.java b/core-server/src/test/java/org/glassfish/jersey/server/UriInfoMatchedUrisTest.java index 8460cf4ae2..7edee54d05 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/UriInfoMatchedUrisTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/UriInfoMatchedUrisTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -23,8 +23,8 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.UriInfo; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test UriInfo content. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/ApplicationFilterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/ApplicationFilterTest.java index 92f3bf746d..a0312aa7a9 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/ApplicationFilterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/ApplicationFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -39,10 +39,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.model.Resource; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for JAX-RS filters. @@ -149,7 +149,7 @@ public void testFilterCalledOn200() throws Exception { final ApplicationHandler application = new ApplicationHandler(resourceConfig); final ContainerResponse response = application.apply(RequestContextBuilder.from("/simple", "GET").build()).get(); assertEquals(200, response.getStatus()); - Assert.assertTrue(simpleFilter.called); + assertTrue(simpleFilter.called); } @Test @@ -160,7 +160,7 @@ public void testFilterNotCalledOn404() throws Exception { final ApplicationHandler application = new ApplicationHandler(resourceConfig); final ContainerResponse response = application.apply(RequestContextBuilder.from("/NOT-FOUND", "GET").build()).get(); assertEquals(404, response.getStatus()); - Assert.assertFalse(simpleFilter.called); + Assertions.assertFalse(simpleFilter.called); } @Test @@ -172,7 +172,7 @@ public void testFilterNotCalledOn405() throws Exception { final ContainerResponse response = application.apply(RequestContextBuilder.from("/simple", "POST").entity("entity") .build()).get(); assertEquals(405, response.getStatus()); - Assert.assertFalse(simpleFilter.called); + Assertions.assertFalse(simpleFilter.called); } @Path("simple") @@ -320,7 +320,7 @@ public Response apply(final ContainerRequestContext request) { final ApplicationHandler application = new ApplicationHandler(resourceConfig); try { application.apply(RequestContextBuilder.from("/test", "GET").build()).get().getStatus(); - Assert.fail("should throw an exception"); + Assertions.fail("should throw an exception"); } catch (final Exception e) { // ok } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/ContainerResponseFilterOrderingTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/ContainerResponseFilterOrderingTest.java index a255467b0b..153bc171df 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/ContainerResponseFilterOrderingTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/ContainerResponseFilterOrderingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,10 +34,10 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/CsrfProtectionFilterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/CsrfProtectionFilterTest.java index 49ff0ff39e..ec7f881bca 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/CsrfProtectionFilterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/CsrfProtectionFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -26,9 +26,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @@ -52,7 +52,7 @@ public String put() { } } - @Before + @BeforeEach public void setUp() { ResourceConfig rc = new ResourceConfig(Resource.class, CsrfProtectionFilter.class); handler = new ApplicationHandler(rc); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/EncodingFilterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/EncodingFilterTest.java index 66980ee74d..a4ba302bb5 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/EncodingFilterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/EncodingFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -23,7 +23,7 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.spi.ContentEncoder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.WebApplicationException; import javax.ws.rs.container.ContainerResponseFilter; @@ -33,11 +33,11 @@ import java.io.InputStream; import java.io.OutputStream; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/EntityTypeFilterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/EntityTypeFilterTest.java index b932c3b254..733b348514 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/EntityTypeFilterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/EntityTypeFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,9 +34,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/FilterSetMethodTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/FilterSetMethodTest.java index c611d3f8b3..295722ecc6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/FilterSetMethodTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/FilterSetMethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -38,9 +38,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests calling {@link ContainerRequestContext#setMethod(String)} in different request/response phases. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/HttpMethodOverrideFilterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/HttpMethodOverrideFilterTest.java index a68c56f794..753a0c66ff 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/HttpMethodOverrideFilterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/HttpMethodOverrideFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,9 +27,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Martin Matula diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/LayeredFiltersTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/LayeredFiltersTest.java index 7117c15bf5..3013f9f535 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/LayeredFiltersTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/LayeredFiltersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -40,11 +40,11 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests layering of filters applied on appropriate methods (using named bindings) on resource method, sub-method, @@ -123,7 +123,7 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont public static class FilterTwo implements ContainerRequestFilter, ContainerResponseFilter { public void filter(ContainerRequestContext requestContext) throws IOException { List xTest = requestContext.getHeaders().get("X-TEST"); - assertNotNull("FilterOne not called", xTest); + assertNotNull(xTest, "FilterOne not called"); assertEquals(1, xTest.size()); assertEquals("one", xTest.get(0)); @@ -140,7 +140,7 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont } @Test - @Ignore("JERSEY-2414 - not yet implemented") + @Disabled("JERSEY-2414 - not yet implemented") public void testResourceMethod() throws ExecutionException, InterruptedException { final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocator.class) .register(FilterOne.class).register(FilterTwo.class); @@ -156,7 +156,7 @@ public void testResourceMethod() throws ExecutionException, InterruptedException } @Test - @Ignore("JERSEY-2414 - not yet implemented") + @Disabled("JERSEY-2414 - not yet implemented") public void testResourceSubresourceMethod() throws ExecutionException, InterruptedException { final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocator.class) .register(FilterOne.class).register(FilterTwo.class); @@ -202,7 +202,7 @@ public String getSubmethod(@Context HttpHeaders hh) { } @Test - @Ignore("JERSEY-2414 - not yet implemented") + @Disabled("JERSEY-2414 - not yet implemented") public void testResourceMethodOnClass() throws ExecutionException, InterruptedException { final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocatorOnClass.class) .register(FilterOne.class).register(FilterTwo.class); @@ -218,7 +218,7 @@ public void testResourceMethodOnClass() throws ExecutionException, InterruptedEx } @Test - @Ignore("JERSEY-2414 - not yet implemented") + @Disabled("JERSEY-2414 - not yet implemented") public void testResourceSubresourceMethodOnClass() throws ExecutionException, InterruptedException { final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocatorOnClass.class) .register(FilterOne.class).register(FilterTwo.class); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/UriConnegFilterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/UriConnegFilterTest.java index aff172115c..daa238cc9d 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/UriConnegFilterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/UriConnegFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -30,9 +30,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @@ -57,7 +57,7 @@ public String getBar() { } } - @Before + @BeforeEach public void setUp() { Map mediaTypes = new HashMap<>(); mediaTypes.put("foo", MediaType.valueOf("application/foo")); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/filter/UriModificationFilterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/filter/UriModificationFilterTest.java index b5cacef5d8..7c8faecf12 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/filter/UriModificationFilterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/filter/UriModificationFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -36,8 +36,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests capability of URI modification during pre-matching filtering. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/BackgroundSchedulerProviderTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/BackgroundSchedulerProviderTest.java index ad7f5ced8b..ae72585ee4 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/BackgroundSchedulerProviderTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/BackgroundSchedulerProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.BackgroundScheduler; import org.glassfish.jersey.spi.ScheduledThreadPoolExecutorProvider; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test basic application behavior. @@ -111,6 +111,6 @@ public void testCustomRuntimeThreadProviderSupport() throws ExecutionException, final ContainerResponse response = ah.apply(RequestContextBuilder.from("/executors-test", "GET").build()).get(); assertEquals(200, response.getStatus()); - assertEquals("Some executor test assertions failed.", 11, response.getEntity()); + assertEquals(11, response.getEntity(), "Some executor test assertions failed."); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/ContainerUtilsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/ContainerUtilsTest.java index d86017ea00..acda39198f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/ContainerUtilsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/ContainerUtilsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,12 +16,11 @@ package org.glassfish.jersey.server.internal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.glassfish.jersey.server.internal.ContainerUtils.getHandlerPath; import static org.glassfish.jersey.server.internal.ContainerUtils.reduceLeadingSlashes; -import static org.junit.Assert.assertNull; - -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests container-oriented utilities functions. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/ResourceContextTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/ResourceContextTest.java index 312db7ca6a..b7901d6453 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/ResourceContextTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/ResourceContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test basic application behavior. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/RuntimeDelegateImplTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/RuntimeDelegateImplTest.java index 57d9668f0b..c717bd9292 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/RuntimeDelegateImplTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/RuntimeDelegateImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -19,9 +19,9 @@ import javax.ws.rs.core.Application; import javax.ws.rs.ext.RuntimeDelegate; -import org.junit.Test; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.fail; /** * Unit test that checks that the right RuntimeDelegateImpl is loaded by JAX-RS. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/ServiceFinderTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/ServiceFinderTest.java index 1acc946b47..b70c4ba582 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/ServiceFinderTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/ServiceFinderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -29,10 +29,10 @@ import org.glassfish.jersey.internal.ServiceFinder; import org.glassfish.jersey.server.JarUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.glassfish.jersey.server.JarUtils.createJarFile; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/AbstractTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/AbstractTest.java index d26743a655..0be4e0ab38 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/AbstractTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/AbstractTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,7 +27,7 @@ import javax.ws.rs.core.Request; import java.util.concurrent.ExecutionException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Class used for {@link ApplicationHandler} initialization and for executing {@link Request}s. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ActiveBindingBindingTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ActiveBindingBindingTest.java index e0b8acb907..f87cbccad6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ActiveBindingBindingTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ActiveBindingBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -46,7 +46,7 @@ import org.jvnet.hk2.internal.ServiceHandleImpl; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/BeanParamMemoryLeakTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/BeanParamMemoryLeakTest.java index b56bde31ce..3d4b4a571f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/BeanParamMemoryLeakTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/BeanParamMemoryLeakTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.hk2.api.Filter; import org.glassfish.hk2.api.ServiceLocator; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Reproducer for JERSEY-2800. We need to make sure diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ConstructorParameterInjectionTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ConstructorParameterInjectionTest.java index 3d1ef54fd0..7886b1ec68 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ConstructorParameterInjectionTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ConstructorParameterInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,9 +24,9 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests injections into constructor parameters. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ContextBasedInjectionTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ContextBasedInjectionTest.java index 5dbddfb3e3..ea01bcdec3 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ContextBasedInjectionTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ContextBasedInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -17,11 +17,10 @@ package org.glassfish.jersey.server.internal.inject; import java.net.URI; -import java.util.Arrays; -import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.stream.Stream; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; @@ -38,11 +37,11 @@ import org.glassfish.jersey.server.AsyncContext; import org.glassfish.jersey.server.model.Resource; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Unit test for creating an application with asynchronously handled request processing @@ -50,25 +49,15 @@ * * @author Marek Potociar */ -@RunWith(Parameterized.class) public class ContextBasedInjectionTest { private static final URI BASE_URI = URI.create("http://localhost:8080/base/"); - @Parameterized.Parameters - public static List testUriSuffixes() { - return Arrays.asList(new String[][]{ - {"a/b/c", "A-B-C"}, - {"a/b/d/", "A-B-D"} - }); - } - - private final String uriSuffix; - private final String expectedResponse; - - public ContextBasedInjectionTest(String uriSuffix, String expectedResponse) { - this.uriSuffix = uriSuffix; - this.expectedResponse = expectedResponse; + public static Stream testUriSuffixes() { + return Stream.of( + Arguments.of("a/b/c", "A-B-C"), + Arguments.of("a/b/d/", "A-B-D") + ); } private static class AsyncInflector implements Inflector { @@ -112,7 +101,7 @@ public void run() { private ApplicationHandler app; - @Before + @BeforeEach public void setupApplication() { ResourceConfig rc = new ResourceConfig(); @@ -128,8 +117,9 @@ public void setupApplication() { app = new ApplicationHandler(rc); } - @Test - public void testAsyncApp() throws InterruptedException, ExecutionException { + @ParameterizedTest + @MethodSource("testUriSuffixes") + public void testAsyncApp(String uriSuffix, String expectedResponse) throws InterruptedException, ExecutionException { ContainerRequest req = RequestContextBuilder.from(BASE_URI, URI.create(BASE_URI.getPath() + uriSuffix), "GET").build(); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsCookieTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsCookieTest.java index 4c35475109..c69afa4b28 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsCookieTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsCookieTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsPrimitiveTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsPrimitiveTest.java index b3519d3c99..48ec83db48 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsPrimitiveTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsPrimitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsStringTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsStringTest.java index 20b8267829..da1e2e6735 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsStringTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamAsStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamStringConstructorTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamStringConstructorTest.java index 0d7e5886f8..1f7063de7c 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamStringConstructorTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/CookieParamStringConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/EncodedParamsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/EncodedParamsTest.java index 1e39b1393e..762a8883fa 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/EncodedParamsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/EncodedParamsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -31,11 +31,11 @@ import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/FormParamTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/FormParamTest.java index 56cf89fe71..d9f659436b 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/FormParamTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/FormParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -39,9 +39,9 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Paul Sandoz diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamAsPrimitiveTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamAsPrimitiveTest.java index ae54b47349..c7bf2a5ad6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamAsPrimitiveTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamAsPrimitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamAsStringTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamAsStringTest.java index f4b1e3d069..8b82eccbd9 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamAsStringTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamAsStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamStringConstructorTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamStringConstructorTest.java index 7589fd3dc3..d0777ea5ab 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamStringConstructorTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/HeaderParamStringConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/InvalidParamsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/InvalidParamsTest.java index c5acca7a55..0415277030 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/InvalidParamsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/InvalidParamsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/JaxRsInjectablesTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/JaxRsInjectablesTest.java index 805c03a75d..6219c21229 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/JaxRsInjectablesTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/JaxRsInjectablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -44,10 +44,10 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Covers JAX-RS defined @Context injectable values including diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamAsPrimitiveTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamAsPrimitiveTest.java index 6d8d501d00..76b2a797ec 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamAsPrimitiveTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamAsPrimitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamAsStringTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamAsStringTest.java index 190720cf40..8a38eaffdb 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamAsStringTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamAsStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamStringConstructorTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamStringConstructorTest.java index b6f4fece18..03b0b73bc1 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamStringConstructorTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/MatrixParamStringConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ContainerResponse; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamConverterDateTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamConverterDateTest.java index b00bd647cf..fd841f1a7b 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamConverterDateTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamConverterDateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -21,7 +21,7 @@ import org.glassfish.jersey.internal.inject.ExtractorException; import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.internal.LocalizationMessages; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -37,7 +37,7 @@ import java.util.Locale; import java.util.concurrent.ExecutionException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ParamConverterDateTest extends AbstractTest { diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamConverterInternalTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamConverterInternalTest.java index e6546de6ca..7ba24c81c7 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamConverterInternalTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamConverterInternalTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 Payara Foundation and/or its affiliates. * * This program and the accompanying materials are made available under the @@ -48,11 +48,11 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests {@link ParamConverter param converters}. @@ -287,8 +287,8 @@ public void testDateParamConverterIsChosenForDateString() { final ParamConverter converter = new ParamConverters.AggregatedProvider(null).getConverter(Date.class, Date.class, null); - assertEquals("Unexpected date converter provider class", - ParamConverters.DateProvider.class, converter.getClass().getEnclosingClass()); + assertEquals(ParamConverters.DateProvider.class, converter.getClass().getEnclosingClass(), + "Unexpected date converter provider class"); } @Path("resource") diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamExceptionMappingTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamExceptionMappingTest.java index bdd148f337..33272e7aed 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamExceptionMappingTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/ParamExceptionMappingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -41,9 +41,9 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.ParamException; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Not sure whether this is relevant anymore. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsPathSegmentTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsPathSegmentTest.java index 73ae61d56e..6dded93802 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsPathSegmentTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsPathSegmentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -27,8 +27,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests: com.sun.jersey.impl.methodparams.PathParamAsPathSegmentTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsPrimitiveTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsPrimitiveTest.java index f23e4e14bb..b929eeafce 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsPrimitiveTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsPrimitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests: com.sun.jersey.impl.methodparams.PathParamAsPrimitiveTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsStringTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsStringTest.java index 0f8a700452..53209591bf 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsStringTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamAsStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -27,8 +27,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamDefaultValueTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamDefaultValueTest.java index 72fec0cc40..71a1427341 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamDefaultValueTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamDefaultValueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.server.ContainerResponse; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Miroslav Fuksa diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamStringConstructorTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamStringConstructorTest.java index 1550146887..e6c42bf873 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamStringConstructorTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/PathParamStringConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.server.ContainerResponse; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsPrimitiveTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsPrimitiveTest.java index d209c17564..8336caabcf 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsPrimitiveTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsPrimitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSetPrimitiveTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSetPrimitiveTest.java index 6be3925ed9..0dc7a013ed 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSetPrimitiveTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSetPrimitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -27,9 +27,9 @@ import org.glassfish.jersey.server.ContainerResponse; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSetStringTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSetStringTest.java index bba6993ba2..a20141e155 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSetStringTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSetStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,9 +25,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSortedSetPrimitiveTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSortedSetPrimitiveTest.java index 3fb41d337f..16cfbf5292 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSortedSetPrimitiveTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSortedSetPrimitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -27,9 +27,9 @@ import org.glassfish.jersey.server.ContainerResponse; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSortedSetStringTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSortedSetStringTest.java index d563d19be1..51be2f867e 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSortedSetStringTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsSortedSetStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,9 +25,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsStringTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsStringTest.java index 0e4fa64ce9..781a3fce1b 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsStringTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamAsStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamEnumTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamEnumTest.java index e442336e5d..c1169badf6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamEnumTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamEnumTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -22,8 +22,8 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamFromStringTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamFromStringTest.java index 6c9f20fa4a..4f1f4d54ac 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamFromStringTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamFromStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -23,8 +23,8 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamSetStringConstructorTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamSetStringConstructorTest.java index f13d264460..4da748a6f3 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamSetStringConstructorTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamSetStringConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,9 +25,9 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamSortedSetStringConstructorTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamSortedSetStringConstructorTest.java index 00d6d111e3..3298f139f5 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamSortedSetStringConstructorTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamSortedSetStringConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,9 +25,9 @@ import javax.ws.rs.Path; import javax.ws.rs.QueryParam; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamStringConstructorTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamStringConstructorTest.java index 78654634ed..70dcdcf603 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamStringConstructorTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/QueryParamStringConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ContainerResponse; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/UriTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/UriTest.java index 3877f877e2..af6586c4b0 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/UriTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/inject/UriTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -32,11 +32,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.Uri; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/AbstractNanosReservoirTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/AbstractNanosReservoirTest.java index abdc102588..9147d5c9da 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/AbstractNanosReservoirTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/AbstractNanosReservoirTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,7 +22,7 @@ import org.glassfish.jersey.server.internal.monitoring.core.TimeReservoir; import org.glassfish.jersey.server.internal.monitoring.core.UniformTimeSnapshot; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Stepan Vavra @@ -65,11 +65,11 @@ protected void checkInNanos(final TimeReservoir reservoir, final double expectedMean, final long expectedInterval) { final UniformTimeSnapshot snapshot = reservoir.getSnapshot(snapshotTime, TimeUnit.NANOSECONDS); - assertEquals("Total count does not match!", expectedSize, snapshot.size()); - assertEquals("Min exec time does not match!", expectedMin, snapshot.getMin()); - assertEquals("Max exec time does not match!", expectedMax, snapshot.getMax()); - assertEquals("Average exec time does not match!", expectedMean, snapshot.getMean(), DELTA); - assertEquals("Expected interval does not match!", expectedInterval, snapshot.getTimeInterval(TimeUnit.NANOSECONDS)); + assertEquals(expectedSize, snapshot.size(), "Total count does not match!"); + assertEquals(expectedMin, snapshot.getMin(), "Min exec time does not match!"); + assertEquals(expectedMax, snapshot.getMax(), "Max exec time does not match!"); + assertEquals(expectedMean, snapshot.getMean(), DELTA, "Average exec time does not match!"); + assertEquals(expectedInterval, snapshot.getTimeInterval(TimeUnit.NANOSECONDS), "Expected interval does not match!"); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/AggregatingTrimmerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/AggregatingTrimmerTest.java index 3dd917eafc..07a735b5e0 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/AggregatingTrimmerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/AggregatingTrimmerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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,8 +18,8 @@ import java.util.concurrent.TimeUnit; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Stepan Vavra @@ -114,12 +114,10 @@ public void testLowerBoundFunction() { for (int startTime = -50; startTime < 50; ++startTime) { for (int i = -50; i < 50; ++i) { long lowerBound = AggregatingTrimmer.lowerBound(i, startTime, chunkSize, power); - Assert.assertTrue("Error occurred for: " + i + " .. lower bound: " + lowerBound + " .. power: " + power - + " .. startTime: " + startTime, - lowerBound <= i); - Assert.assertTrue("Error occurred for: " + i + " .. lower bound: " + lowerBound + " .. power: " + power - + " .. startTime: " + startTime, - i < lowerBound + chunkSize); + Assertions.assertTrue(lowerBound <= i, "Error occurred for: " + i + " .. lower bound: " + + lowerBound + " .. power: " + power + " .. startTime: " + startTime); + Assertions.assertTrue(i < lowerBound + chunkSize, "Error occurred for: " + i + + " .. lower bound: " + lowerBound + " .. power: " + power + " .. startTime: " + startTime); } } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/MonitoringStatisticsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/MonitoringStatisticsTest.java index 54c27c4108..4c41281bf6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/MonitoringStatisticsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/MonitoringStatisticsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -17,12 +17,10 @@ package org.glassfish.jersey.server.internal.monitoring; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -41,8 +39,8 @@ import org.glassfish.jersey.server.monitoring.ResourceMethodStatistics; import org.glassfish.jersey.server.monitoring.ResourceStatistics; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Miroslav Fuksa @@ -108,10 +106,10 @@ public void testSimpleUris() { final MonitoringStatisticsImpl stats = getSimpleStats(); final Set keys = stats.getUriStatistics().keySet(); final Iterator iterator = keys.iterator(); - Assert.assertEquals("/hello", iterator.next()); - Assert.assertEquals("/hello/world", iterator.next()); - Assert.assertEquals("/test-resource", iterator.next()); - Assert.assertEquals("/test-resource/child", iterator.next()); + Assertions.assertEquals("/hello", iterator.next()); + Assertions.assertEquals("/hello/world", iterator.next()); + Assertions.assertEquals("/test-resource", iterator.next()); + Assertions.assertEquals("/test-resource/child", iterator.next()); } private MonitoringStatisticsImpl getSimpleStats() { @@ -145,8 +143,8 @@ public void testSimpleResourceClasses() { final Set> keys = stats.getResourceClassStatistics().keySet(); final Iterator> it = keys.iterator(); - Assert.assertEquals(HelloResource.class, it.next()); - Assert.assertEquals(TestResource.class, it.next()); + Assertions.assertEquals(HelloResource.class, it.next()); + Assertions.assertEquals(TestResource.class, it.next()); } @Test @@ -155,9 +153,9 @@ public void testResourceClassesWithProgrammaticResources() { final Set> keys = stats.getResourceClassStatistics().keySet(); final Iterator> it = keys.iterator(); - Assert.assertEquals(HelloResource.class, it.next()); - Assert.assertEquals(MyInflector.class, it.next()); - Assert.assertEquals(TestResource.class, it.next()); + Assertions.assertEquals(HelloResource.class, it.next()); + Assertions.assertEquals(MyInflector.class, it.next()); + Assertions.assertEquals(TestResource.class, it.next()); } @Test @@ -213,11 +211,11 @@ public void testUrisWithProgrammaticResourcesAndExecution() { final ResourceMethod method = methodStatistics.getResourceMethod(); final ExecutionStatistics st = methodStatistics.getMethodStatistics(); if (method.getHttpMethod().equals("GET")) { - Assert.assertEquals(20, st.getLastStartTime().getTime()); + Assertions.assertEquals(20, st.getLastStartTime().getTime()); } else if (method.getHttpMethod().equals("POST")) { - Assert.assertEquals(30, st.getLastStartTime().getTime()); + Assertions.assertEquals(30, st.getLastStartTime().getTime()); } else { - Assert.fail(); + Assertions.fail(); } } } @@ -226,8 +224,8 @@ public void testUrisWithProgrammaticResourcesAndExecution() { private void check(Iterator> it, String expectedUri, int expectedMethods) { Map.Entry entry = it.next(); - Assert.assertEquals(expectedUri, entry.getKey()); - Assert.assertEquals(expectedMethods, entry.getValue().getResourceMethodStatistics().size()); + Assertions.assertEquals(expectedUri, entry.getKey()); + Assertions.assertEquals(expectedMethods, entry.getValue().getResourceMethodStatistics().size()); } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/MonitoringUtilsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/MonitoringUtilsTest.java index 6d18f0d7fa..322f6d4383 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/MonitoringUtilsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/MonitoringUtilsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.server.model.ResourceMethod; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @@ -61,13 +61,13 @@ public String post() { @Test public void testGetMethodUniqueId() { final Resource resource = Resource.builder(MyResource.class).build(); - Assert.assertEquals("[]|[]|GET|resource|get", + Assertions.assertEquals("[]|[]|GET|resource|get", MonitoringUtils.getMethodUniqueId(getMethod(resource, "get"))); - Assert.assertEquals("[text/html]|[]|GET|resource.sub|subGet", + Assertions.assertEquals("[text/html]|[]|GET|resource.sub|subGet", MonitoringUtils.getMethodUniqueId(getMethod(resource, "subGet"))); - Assert.assertEquals("[text/html]|[]|GET|resource.sub|subGet", + Assertions.assertEquals("[text/html]|[]|GET|resource.sub|subGet", MonitoringUtils.getMethodUniqueId(getMethod(resource, "subGet"))); - Assert.assertEquals("[text/xml]|[text/plain]|POST|resource|post", + Assertions.assertEquals("[text/xml]|[text/plain]|POST|resource|post", MonitoringUtils.getMethodUniqueId(getMethod(resource, "post"))); } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/ResponseStatisticsImplTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/ResponseStatisticsImplTest.java index f98320462d..58e3943e61 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/ResponseStatisticsImplTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/ResponseStatisticsImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,10 +16,8 @@ package org.glassfish.jersey.server.internal.monitoring; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Response statistics tests. @@ -35,49 +33,46 @@ public void testCaching() { builder.addResponseCode(100); // test that caching works - Assert.assertTrue(builder.build() == builder.build()); + Assertions.assertTrue(builder.build() == builder.build()); Object original = builder.build(); builder.addResponseCode(100); - Assert.assertFalse(original == builder.build()); + Assertions.assertFalse(original == builder.build()); } @Test public void testSanity() { ResponseStatisticsImpl.Builder builder = new ResponseStatisticsImpl.Builder(); - Assert.assertNull(builder.build().getLastResponseCode()); + Assertions.assertNull(builder.build().getLastResponseCode()); builder.addResponseCode(100); - Assert.assertEquals(100, (int) builder.build().getLastResponseCode()); - Assert.assertEquals(1, (long) builder.build().getResponseCodes().get(100)); + Assertions.assertEquals(100, (int) builder.build().getLastResponseCode()); + Assertions.assertEquals(1, (long) builder.build().getResponseCodes().get(100)); builder.addResponseCode(200); - Assert.assertEquals(200, (int) builder.build().getLastResponseCode()); - Assert.assertEquals(1, (long) builder.build().getResponseCodes().get(100)); - Assert.assertEquals(1, (long) builder.build().getResponseCodes().get(200)); + Assertions.assertEquals(200, (int) builder.build().getLastResponseCode()); + Assertions.assertEquals(1, (long) builder.build().getResponseCodes().get(100)); + Assertions.assertEquals(1, (long) builder.build().getResponseCodes().get(200)); builder.addResponseCode(100); - Assert.assertEquals(100, (int) builder.build().getLastResponseCode()); - Assert.assertEquals(2, (long) builder.build().getResponseCodes().get(100)); - Assert.assertEquals(1, (long) builder.build().getResponseCodes().get(200)); + Assertions.assertEquals(100, (int) builder.build().getLastResponseCode()); + Assertions.assertEquals(2, (long) builder.build().getResponseCodes().get(100)); + Assertions.assertEquals(1, (long) builder.build().getResponseCodes().get(200)); } - @Rule - public final ExpectedException exception = ExpectedException.none(); - @Test public void testImmutability() { - ResponseStatisticsImpl.Builder builder = new ResponseStatisticsImpl.Builder(); + Assertions.assertThrows(UnsupportedOperationException.class, () -> { + ResponseStatisticsImpl.Builder builder = new ResponseStatisticsImpl.Builder(); - builder.addResponseCode(100); + builder.addResponseCode(100); - // modification is not allowed - exception.expect(UnsupportedOperationException.class); - builder.build().getResponseCodes().put(100, 2L); + builder.build().getResponseCodes().put(100, 2L); + }); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/SlidingWindowTimeReservoirAggregatingTrimmerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/SlidingWindowTimeReservoirAggregatingTrimmerTest.java index ebec4db72b..696b1e8ab1 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/SlidingWindowTimeReservoirAggregatingTrimmerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/SlidingWindowTimeReservoirAggregatingTrimmerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,7 +18,7 @@ import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests of {@link SlidingWindowTimeReservoir}. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/SlidingWindowTimeReservoirTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/SlidingWindowTimeReservoirTest.java index fc02ae7c65..c6f42d7a48 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/SlidingWindowTimeReservoirTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/SlidingWindowTimeReservoirTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,8 +18,8 @@ import java.util.concurrent.TimeUnit; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests of {@link SlidingWindowTimeReservoir}. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/TimeWindowStatisticsImplTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/TimeWindowStatisticsImplTest.java index d8f9a8cf6c..c4ac1934a5 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/TimeWindowStatisticsImplTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/monitoring/TimeWindowStatisticsImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,13 +18,11 @@ import java.util.concurrent.TimeUnit; -import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.server.internal.monitoring.core.ReservoirConstants; import org.glassfish.jersey.server.internal.monitoring.core.UniformTimeReservoir; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests of {@link TimeWindowStatisticsImpl}. @@ -248,11 +246,11 @@ private void check(final TimeWindowStatisticsImpl.Builder builder, final double requestsPerSecond) { final TimeWindowStatisticsImpl stat = builder.build(buildTime); - assertEquals("Total count does not match!", totalCount, stat.getRequestCount()); - assertEquals("Min exec time does not match!", minimumExecTime, stat.getMinimumDuration()); - assertEquals("Max exec time does not match!", maximumExecTime, stat.getMaximumDuration()); - assertEquals("Average exec time does not match!", average, stat.getAverageDuration()); - assertEquals("Requests per seconds does not match!", requestsPerSecond, stat.getRequestsPerSecond(), DELTA); + assertEquals(totalCount, stat.getRequestCount(), "Total count does not match!"); + assertEquals(minimumExecTime, stat.getMinimumDuration(), "Min exec time does not match!"); + assertEquals(maximumExecTime, stat.getMaximumDuration(), "Max exec time does not match!"); + assertEquals(average, stat.getAverageDuration(), "Average exec time does not match!"); + assertEquals(requestsPerSecond, stat.getRequestsPerSecond(), DELTA, "Requests per seconds does not match!"); } @Test diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/process/ProxyInjectablesTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/process/ProxyInjectablesTest.java index e4675ba807..2f334184ff 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/process/ProxyInjectablesTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/process/ProxyInjectablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -39,9 +39,9 @@ import org.glassfish.jersey.server.internal.inject.AbstractTest; import org.glassfish.jersey.server.internal.routing.UriRoutingContext; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; /** * Test if request scoped injection points are injected without using diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/ExtendedUriInfoTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/ExtendedUriInfoTest.java index fa065abdb6..ece29a9443 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/ExtendedUriInfoTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/ExtendedUriInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,10 +34,10 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.server.model.RuntimeResource; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; /** * {@link ExtendedUriInfo} unit tests - testing e.g. getting matched resources, mapped throwable, etc. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/ResponseMediaTypeFromProvidersTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/ResponseMediaTypeFromProvidersTest.java index 4d982aa94f..049b449fe6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/ResponseMediaTypeFromProvidersTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/ResponseMediaTypeFromProvidersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,9 +28,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/SubResourceLocatorCachingTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/SubResourceLocatorCachingTest.java index 6b8e6543b4..3da884d55f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/SubResourceLocatorCachingTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/SubResourceLocatorCachingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -34,10 +34,10 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.server.model.ResourceModel; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test that sub-resource locators (models and routers) are being cached. @@ -147,7 +147,7 @@ public ResourceModel processSubResource(final ResourceModel subResourceModel, fi private CountingModelProcessor processor; private ResourceConfig config; - @Before + @BeforeEach public void setUp() throws Exception { processor = new CountingModelProcessor(); config = new ResourceConfig(RootResource.class).register(processor); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/SubResourceValidationTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/SubResourceValidationTest.java index a7282c2622..3ba5c53149 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/SubResourceValidationTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/SubResourceValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,9 +27,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * This tests disabling of a sub resource locator validation. @@ -81,7 +81,7 @@ public void testEnable() throws ExecutionException, InterruptedException { final ContainerResponse response = applicationHandler.apply( RequestContextBuilder.from("/root/sub", "GET").build()).get(); // should throw an exception or return 500 - Assert.assertEquals(500, response.getStatus()); + Assertions.assertEquals(500, response.getStatus()); } catch (Exception e) { // ok } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/UriRoutingContextTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/UriRoutingContextTest.java index 598b03f1dc..9466b03e74 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/UriRoutingContextTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/routing/UriRoutingContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -27,13 +27,13 @@ import org.glassfish.jersey.server.RequestContextBuilder; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Marek Potociar @@ -43,19 +43,19 @@ public class UriRoutingContextTest { public UriRoutingContextTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { } - @AfterClass + @AfterAll public static void tearDownClass() throws Exception { } - @Before + @BeforeEach public void setUp() { } - @After + @AfterEach public void tearDown() { } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/BundleSchemeScannerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/BundleSchemeScannerTest.java index 5315f69627..ae7e072695 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/BundleSchemeScannerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/BundleSchemeScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -21,9 +21,9 @@ import org.glassfish.jersey.server.ResourceFinder; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @author Stepan Vavra @@ -32,7 +32,7 @@ public class BundleSchemeScannerTest { private ResourceFinder bundleSchemeScanner; - @Before + @BeforeEach public void setUpBundleSchemeScanner() throws Exception { String canonicalName = getClass().getCanonicalName(); URI uri = getClass().getClassLoader().getResource(canonicalName.replace('.', '/') + ".class").toURI(); @@ -41,15 +41,17 @@ public void setUpBundleSchemeScanner() throws Exception { @Test public void hasNextReturnsTrue() throws Exception { - Assert.assertTrue(bundleSchemeScanner.hasNext()); + Assertions.assertTrue(bundleSchemeScanner.hasNext()); } - @Test(expected = NoSuchElementException.class) + @Test public void multipleNextInvocationFails() throws Exception { - bundleSchemeScanner.next(); + Assertions.assertThrows(NoSuchElementException.class, () -> { + bundleSchemeScanner.next(); - Assert.assertFalse(bundleSchemeScanner.hasNext()); - bundleSchemeScanner.next(); // throw NoSuchElementException + Assertions.assertFalse(bundleSchemeScanner.hasNext()); + bundleSchemeScanner.next(); // throw NoSuchElementException + }); } /** @@ -59,12 +61,14 @@ public void multipleNextInvocationFails() throws Exception { * * @throws Exception */ - @Test(expected = NoSuchElementException.class) + @Test public void openFinishesTheIteration() throws Exception { - Assert.assertNotNull(bundleSchemeScanner.open()); - Assert.assertFalse(bundleSchemeScanner.hasNext()); + Assertions.assertThrows(NoSuchElementException.class, () -> { + Assertions.assertNotNull(bundleSchemeScanner.open()); + Assertions.assertFalse(bundleSchemeScanner.hasNext()); - bundleSchemeScanner.next(); // throw NoSuchElementException + bundleSchemeScanner.next(); // throw NoSuchElementException + }); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/CompositeResourceFinderTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/CompositeResourceFinderTest.java index ef817be2cb..d9afad442e 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/CompositeResourceFinderTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/CompositeResourceFinderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,9 +22,9 @@ import org.glassfish.jersey.server.ResourceFinder; import org.glassfish.jersey.server.internal.AbstractResourceFinderAdapter; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/JarFileScannerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/JarFileScannerTest.java index 80f917c9df..603abca5c5 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/JarFileScannerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/JarFileScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,31 +24,23 @@ import java.util.jar.JarFile; import java.util.regex.Pattern; -import org.junit.Before; -import org.junit.Test; -import org.junit.experimental.theories.DataPoint; -import org.junit.experimental.theories.Theories; -import org.junit.experimental.theories.Theory; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Snyder */ -@RunWith(Theories.class) public class JarFileScannerTest { - @DataPoint - public static final boolean RECURSIVE = true; - @DataPoint - public static final boolean NON_RECURSIVE = false; - private String jaxRsApiPath; - @Before + @BeforeEach public void setUp() throws Exception { final String classPath = System.getProperty("java.class.path"); final String[] entries = classPath.split(System.getProperty("path.separator")); @@ -140,19 +132,21 @@ private int countJarEntriesUsingScanner(final String parent, final boolean recur return scannedEntryCount; } - @Theory + @ParameterizedTest + @ValueSource(booleans = {true, false}) public void testClassEnumerationWithNonexistentPackage(final boolean recursive) throws IOException { try (final InputStream jaxRsApi = new FileInputStream(this.jaxRsApiPath)) { final JarFileScanner jarFileScanner = new JarFileScanner(jaxRsApi, "javax/ws/r", recursive); - assertFalse("Unexpectedly found package 'javax.ws.r' in javax.ws.rs-api", jarFileScanner.hasNext()); + assertFalse(jarFileScanner.hasNext(), "Unexpectedly found package 'javax.ws.r' in javax.ws.rs-api"); } } - @Theory + @ParameterizedTest + @ValueSource(booleans = {true, false}) public void testClassEnumerationWithClassPrefix(final boolean recursive) throws IOException { try (final InputStream jaxRsApi = new FileInputStream(this.jaxRsApiPath)) { final JarFileScanner jarFileScanner = new JarFileScanner(jaxRsApi, "javax/ws/rs/GE", recursive); - assertFalse("Unexpectedly found package 'javax.ws.rs.GE' in javax.ws.rs-api", jarFileScanner.hasNext()); + assertFalse(jarFileScanner.hasNext(), "Unexpectedly found package 'javax.ws.rs.GE' in javax.ws.rs-api"); } } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/VFSSchemeResourceFinderTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/VFSSchemeResourceFinderTest.java index 2c50cd7381..493d4bff55 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/VFSSchemeResourceFinderTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/scanning/VFSSchemeResourceFinderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -30,11 +30,11 @@ import org.jboss.vfs.TempFileProvider; import org.jboss.vfs.VFS; import org.jboss.vfs.VirtualFile; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Snyder @@ -44,7 +44,7 @@ public class VFSSchemeResourceFinderTest { private String jaxRsApiPath; - @Before + @BeforeEach public void setUp() throws Exception { final String classPath = System.getProperty("java.class.path"); final String[] entries = classPath.split(System.getProperty("path.separator")); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/internal/sonar/SonarJerseyServerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/internal/sonar/SonarJerseyServerTest.java index 0c0090d4c0..7595dc7524 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/internal/sonar/SonarJerseyServerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/internal/sonar/SonarJerseyServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.server.internal.sonar; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Stepan Vavra @@ -26,6 +26,6 @@ public class SonarJerseyServerTest { @Test public void testUnitTest() { - Assert.assertEquals("server unit test", new SonarJerseyServer().unitTest()); + Assertions.assertEquals("server unit test", new SonarJerseyServer().unitTest()); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptAnnotatedReaderWriterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptAnnotatedReaderWriterTest.java index 7ac59fb19c..de42c6a0ec 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptAnnotatedReaderWriterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptAnnotatedReaderWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -45,10 +45,10 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Jakub Podlesak diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptQsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptQsTest.java index 07e103c752..3b28dd39bc 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptQsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptQsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Jakub Podlesak @@ -170,35 +170,35 @@ private void runTestAcceptMultiple(ApplicationHandler app) throws Exception { MediaType bar = MediaType.valueOf("application/bar"); ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept(foo).build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(foo, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept(bar).build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(bar, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("*/*").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(bar, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/*").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(bar, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.1", "application/bar").build()) .get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(bar, response.getMediaType()); response = app .apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.5", "application/bar;q=0.1").build()) .get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(foo, response.getMediaType()); } @@ -246,42 +246,42 @@ public void testAcceptSubTypeProgrammatic() throws Exception { private void runTestAcceptSubType(ApplicationHandler app) throws Exception { ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("plain", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("image/png, text/plain;q=0.4").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("plain", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5, text/html").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("html", response.getEntity()); assertEquals(MediaType.TEXT_HTML_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain, text/html;q=0.5").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("plain", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/html;q=0.5").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("html", response.getEntity()); assertEquals(MediaType.TEXT_HTML_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/*;q=0.5, text/plain;q=0.6").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("plain", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5, text/gaga;q=0.6").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.valueOf("text/gaga"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/gaga, text/plain").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("plain", response.getEntity()); assertEquals(MediaType.valueOf("text/plain"), response.getMediaType()); } @@ -329,52 +329,52 @@ public void testAcceptSubTypeNotIntuitiveProgrammatic() throws Exception { private void runTestAcceptSubTypeNotIntuitive(ApplicationHandler app) throws Exception { ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("image/png, text/plain").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5, text/html").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.TEXT_HTML_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain, text/html;q=0.5").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/html;q=0.5").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.TEXT_HTML_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/*;q=0.5, text/plain;q=0.6").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5, text/gaga;q=0.6").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.valueOf("text/gaga"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/gaga, text/plain").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("*", response.getEntity()); assertEquals(MediaType.valueOf("text/gaga"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/*").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("plain", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/*;q=0.5, text/html;q=0.1").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("plain", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); } @@ -408,12 +408,12 @@ private void runTestAcceptNoProduces(ApplicationHandler app) throws Exception { // media type order in the accept header does not impose output media type! ContainerResponse response = app .apply(RequestContextBuilder.from("/", "GET").accept("image/png, text/plain;q=0.9").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.valueOf("image/png"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5, text/html").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.TEXT_HTML_TYPE, response.getMediaType()); } @@ -512,24 +512,24 @@ public void testProducesTwoMethodsBarFooResourceDeclarative() throws Exception { private void runTestFooBar(ApplicationHandler app, String fooContent, String barContent) throws Exception { ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals(fooContent, response.getEntity()); assertEquals(MediaType.valueOf("application/foo"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/bar").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals(barContent, response.getEntity()); assertEquals(MediaType.valueOf("application/bar"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo", "application/bar;q=0.5").build()) .get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals(fooContent, response.getEntity()); assertEquals(MediaType.valueOf("application/foo"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/bar", "application/foo;q=0.5").build()) .get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals(barContent, response.getEntity()); assertEquals(MediaType.valueOf("application/bar"), response.getMediaType()); } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptTest.java index 63f36a8cf4..3b29041edf 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -27,9 +27,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Taken from Jersey 1: jersey-tests:com.sun.jersey.impl.resource.AcceptTest.java @@ -105,7 +105,7 @@ public void testAcceptGetWildCard() throws Exception { ContainerResponse response = app .apply(RequestContextBuilder.from("/", "GET").accept("application/wildcard", "application/foo;q=0.6", "application/bar;q=0.4", "application/baz;q=0.2").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); String s = (String) response.getEntity(); assertEquals("wildcard", s); @@ -147,35 +147,35 @@ public void testAcceptMultiple() throws Exception { MediaType bar = MediaType.valueOf("application/bar"); ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept(foo).build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(foo, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept(bar).build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(bar, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("*/*").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(foo, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/*").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(foo, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.1", "application/bar").build()) .get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(bar, response.getMediaType()); response = app .apply(RequestContextBuilder.from("/", "GET").accept("application/foo;q=0.5", "application/bar;q=0.1").build()) .get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(foo, response.getMediaType()); } @@ -189,7 +189,7 @@ public void testAcceptMultiple2() throws Exception { ContainerResponse response; response = app.apply(RequestContextBuilder.from("/", "GET").accept("*/*").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(foo, response.getMediaType()); } @@ -209,22 +209,22 @@ public void testAcceptSubType() throws Exception { ApplicationHandler app = createApplication(SubTypeResource.class); ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("image/png, text/plain").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5, text/html").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.TEXT_HTML_TYPE, response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.TEXT_PLAIN_TYPE, response.getMediaType()); } @@ -245,12 +245,12 @@ public void testAcceptNoProduces() throws Exception { // media type order in the accept header does not impose output media type! ContainerResponse response = app .apply(RequestContextBuilder.from("/", "GET").accept("image/png, text/plain;q=0.9").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.valueOf("image/png"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("text/plain;q=0.5, text/html").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.TEXT_HTML_TYPE, response.getMediaType()); } @@ -316,22 +316,22 @@ private void test(Class c) throws Exception { ApplicationHandler app = createApplication(c); ContainerResponse response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.valueOf("application/foo"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/bar").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.valueOf("application/bar"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/foo", "application/bar").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.valueOf("application/foo"), response.getMediaType()); response = app.apply(RequestContextBuilder.from("/", "GET").accept("application/bar", "application/foo").build()).get(); - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("GET", response.getEntity()); assertEquals(MediaType.valueOf("application/bar"), response.getMediaType()); } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptWriterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptWriterTest.java index 5cb18b9850..b9f4da7dac 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptWriterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/AcceptWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -37,8 +37,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey 1: jersey-tests:com.sun.jersey.impl.resource.AcceptWriterTest.java diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/AmbiguousTemplateTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/AmbiguousTemplateTest.java index 1d50e45d7b..3df21967e5 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/AmbiguousTemplateTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/AmbiguousTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,11 +33,11 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test matching of resources with ambiguous templates. @@ -95,8 +95,8 @@ public void testPathParamOnAmbiguousTemplate() throws ExecutionException, Interr final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceABC.class, ResourceXYZ.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/uuu/a", "GET").build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("a-abc:uuu", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("a-abc:uuu", response.getEntity()); } @Test @@ -104,8 +104,8 @@ public void testPathParamOnAmbiguousTemplate2() throws ExecutionException, Inter final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceABC.class, ResourceXYZ.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/test/x", "GET").build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("x-xyz:test", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("x-xyz:test", response.getEntity()); } @Test @@ -113,8 +113,8 @@ public void testPathParamOnAmbiguousTemplate3() throws ExecutionException, Inter final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceABC.class, ResourceXYZ.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/uuu", "GET").build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("abc:uuu", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("abc:uuu", response.getEntity()); } @Test @@ -123,8 +123,8 @@ public void testPathParamOnAmbiguousTemplate4() throws ExecutionException, Inter ResourceXYZ.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/post", "POST") .entity("entity").build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("xyz:post", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("xyz:post", response.getEntity()); } @Test @@ -132,8 +132,8 @@ public void testPathParamOnAmbiguousTemplate5() throws ExecutionException, Inter final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceABC.class, ResourceXYZ.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/xxx/foo", "GET").build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("subx-xyz:xxx:foo", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("subx-xyz:xxx:foo", response.getEntity()); } @Path("locator") @@ -155,7 +155,7 @@ public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator1() throws E final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/abc/uuu/a", "GET") .build()).get(); - Assert.assertEquals(404, response.getStatus()); + Assertions.assertEquals(404, response.getStatus()); } @Test @@ -163,8 +163,8 @@ public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator2() throws E final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/abc/a", "GET") .build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("a-abc:null", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("a-abc:null", response.getEntity()); } @Test @@ -172,8 +172,8 @@ public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator3() throws E final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/xyz/subxfoo", "GET") .build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("subx-xyz:null:subxfoo", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("subx-xyz:null:subxfoo", response.getEntity()); } @Path("{xyz}") @@ -211,16 +211,16 @@ public String get() { public void testSubResourceLocatorWithPathParams() throws ExecutionException, InterruptedException { final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceWithLocator.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/uuu", "GET").build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("uuu", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("uuu", response.getEntity()); } @Test public void testSubResourceLocatorWithPathParams2() throws ExecutionException, InterruptedException { final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceWithLocator.class)); final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/uuu/test", "GET").build()).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("uuu:test", response.getEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("uuu:test", response.getEntity()); } @Path("{templateA}") @@ -263,7 +263,7 @@ public void testOptionsOnRoot() throws ExecutionException, InterruptedException ApplicationHandler app = new ApplicationHandler(resourceConfig); final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/aaa", "OPTIONS") .accept(MediaType.TEXT_PLAIN).build()).get(); - Assert.assertEquals(200, containerResponse.getStatus()); + Assertions.assertEquals(200, containerResponse.getStatus()); final List methods = Arrays.asList(containerResponse.getEntity().toString().split(", ")); assertThat(methods, hasItems("POST", "GET", "OPTIONS", "HEAD")); @@ -277,8 +277,8 @@ public void testGetOnRoot() throws ExecutionException, InterruptedException { ApplicationHandler app = new ApplicationHandler(resourceConfig); final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/aaa", "GET") .accept(MediaType.TEXT_PLAIN).build()).get(); - Assert.assertEquals(200, containerResponse.getStatus()); - Assert.assertEquals("getA", containerResponse.getEntity()); + Assertions.assertEquals(200, containerResponse.getStatus()); + Assertions.assertEquals("getA", containerResponse.getEntity()); } @Test @@ -287,7 +287,7 @@ public void testOptionsOnChild() throws ExecutionException, InterruptedException ApplicationHandler app = new ApplicationHandler(resourceConfig); final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/resq/c", "OPTIONS") .accept(MediaType.TEXT_PLAIN).build()).get(); - Assert.assertEquals(200, containerResponse.getStatus()); + Assertions.assertEquals(200, containerResponse.getStatus()); final List methods = Arrays.asList(containerResponse.getEntity().toString().split(", ")); assertThat(methods, hasItems("PUT", "GET", "OPTIONS", "HEAD")); @@ -300,7 +300,7 @@ public void testGetOnChild() throws ExecutionException, InterruptedException { ResourceConfig resourceConfig = new ResourceConfig(ResourceA.class, ResourceB.class, ResourceQ.class); ApplicationHandler app = new ApplicationHandler(resourceConfig); final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/resq/a", "GET").build()).get(); - Assert.assertEquals(200, containerResponse.getStatus()); - Assert.assertEquals("getA", containerResponse.getEntity()); + Assertions.assertEquals(200, containerResponse.getStatus()); + Assertions.assertEquals("getA", containerResponse.getEntity()); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/AncestorsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/AncestorsTest.java index 92d6b4bd39..e9b11df847 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/AncestorsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/AncestorsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests:com.sun.jersey.impl.subresources.AncestorsTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/AsyncContentAndEntityTypeTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/AsyncContentAndEntityTypeTest.java index cdb11f8c94..3520c38a52 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/AsyncContentAndEntityTypeTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/AsyncContentAndEntityTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -37,9 +37,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test of fix for issues JERSEY-1088 and JERSEY-1089. @@ -91,7 +91,7 @@ public ContainerResponse call() throws Exception { response = responseFuture.get(); } - assertTrue("Status: " + response.getStatus(), response.getStatus() < 300); + assertTrue(response.getStatus() < 300, "Status: " + response.getStatus()); assertEquals("Foo", response.getEntity()); assertEquals(foo, response.getMediaType()); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ConstrainedToServerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ConstrainedToServerTest.java index 676d091005..7765045347 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ConstrainedToServerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ConstrainedToServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -47,9 +47,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests whether providers are correctly validated in the server runtime (for example if provider constrained to diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceSimpleTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceSimpleTest.java index a67be6c5c4..e7ebb5a60d 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceSimpleTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceSimpleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey 1: jersey-tests:com.sun.jersey.impl.resource.ConsumeProduceSimpleTest.java diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceWildcardTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceWildcardTest.java index ced90e5429..5d6777d9fc 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceWildcardTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ConsumeProduceWildcardTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey 1: jersey-tests:com.sun.jersey.impl.resource.ConsumeProduceWildcardTest.java diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/DynamicFeatureTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/DynamicFeatureTest.java index 5f70aa75c0..2104b906a6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/DynamicFeatureTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/DynamicFeatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -53,12 +53,12 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Assume; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests cases of {@code DynamicFeature} implementation. @@ -293,7 +293,7 @@ public void configure(final ResourceInfo resourceInfo, final FeatureContext cont @Test public void testInjectedConfigurable() throws Exception { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); final ResourceConfig resourceConfig = getTestResourceConfig(InjectConfigurableDynamicFeature.class); resourceConfig.property("hello", "world"); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/GenericMethodListTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/GenericMethodListTest.java index 9a23891b3f..3661ab50bb 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/GenericMethodListTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/GenericMethodListTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -24,8 +24,8 @@ import javax.ws.rs.POST; import javax.ws.rs.core.Context; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/HeadSubResourceMethodTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/HeadSubResourceMethodTest.java index f619b1f245..83e40e574f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/HeadSubResourceMethodTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/HeadSubResourceMethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,9 +28,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * @author Paul Sandoz diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/HeadTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/HeadTest.java index c91ba14d52..69b99c985e 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/HeadTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/HeadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -36,13 +36,13 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Paul Sandoz diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/InnerClassWithGenericTypeTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/InnerClassWithGenericTypeTest.java index 2596011286..d2229dee08 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/InnerClassWithGenericTypeTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/InnerClassWithGenericTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests:com.sun.jersey.impl.subresources.InnerClassWithGenericTypeTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/MethodListTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/MethodListTest.java index 5934f4ac07..b618c5957a 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/MethodListTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/MethodListTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -16,14 +16,14 @@ package org.glassfish.jersey.server.model; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Comparator; import java.util.HashSet; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/MixedResourceConfigurationTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/MixedResourceConfigurationTest.java index db385d2139..9593a1a13f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/MixedResourceConfigurationTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/MixedResourceConfigurationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test of mixed (programmatic and annotation-based) resource configuration. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/OptionsSubResourceMethodTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/OptionsSubResourceMethodTest.java index 8bd12d8cba..de442379f5 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/OptionsSubResourceMethodTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/OptionsSubResourceMethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -36,10 +36,10 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Paul Sandoz diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/OptionsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/OptionsTest.java index 1fca50bd90..e6a304caa4 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/OptionsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/OptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -46,10 +46,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.sun.research.ws.wadl.Application; @@ -194,9 +194,9 @@ public void testRequestNoType() throws ExecutionException, InterruptedException ApplicationHandler application = new ApplicationHandler(new ResourceConfig(WadlResource.class)); final ContainerRequest request = RequestContextBuilder.from("/resource", "OPTIONS").build(); final ContainerResponse response = application.apply(request).get(); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final MediaType type = response.getMediaType(); - Assert.assertTrue(type.equals(MediaTypes.WADL_TYPE) || type.equals(MediaType.TEXT_HTML_TYPE) + Assertions.assertTrue(type.equals(MediaTypes.WADL_TYPE) || type.equals(MediaType.TEXT_HTML_TYPE) || type.equals(MediaType.TEXT_PLAIN)); } @@ -206,7 +206,7 @@ public void testRequestTextPlain() throws ExecutionException, InterruptedExcepti ApplicationHandler application = new ApplicationHandler(new ResourceConfig(WadlResource.class, ResponseTextFilter.class)); final ContainerResponse response = testOptions(MediaType.TEXT_PLAIN_TYPE, application, "/resource"); final String entity = (String) response.getEntity(); - Assert.assertTrue(entity.contains("GET")); + Assertions.assertTrue(entity.contains("GET")); } @Test @@ -214,7 +214,7 @@ public void testRequestTextHtml() throws ExecutionException, InterruptedExceptio ApplicationHandler application = new ApplicationHandler(new ResourceConfig(WadlResource.class, ResponseHtmlFilter.class)); final MediaType requestType = MediaType.TEXT_HTML_TYPE; final ContainerResponse response = testOptions(requestType, application, "/resource"); - Assert.assertTrue(response.getAllowedMethods().contains("GET")); + Assertions.assertTrue(response.getAllowedMethods().contains("GET")); } @Test @@ -229,7 +229,7 @@ private static class ResponseTextFilter implements ContainerResponseFilter { @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { final MediaType type = responseContext.getMediaType(); - Assert.assertEquals(MediaType.TEXT_PLAIN_TYPE, type); + Assertions.assertEquals(MediaType.TEXT_PLAIN_TYPE, type); } } @@ -239,7 +239,7 @@ private static class ResponseHtmlFilter implements ContainerResponseFilter { @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { final MediaType type = responseContext.getMediaType(); - Assert.assertEquals(MediaType.TEXT_HTML_TYPE, type); + Assertions.assertEquals(MediaType.TEXT_HTML_TYPE, type); } } @@ -249,7 +249,7 @@ private static class ResponseWadlFilter implements ContainerResponseFilter { @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { final MediaType type = responseContext.getMediaType(); - Assert.assertEquals(MediaTypes.WADL_TYPE, type); + Assertions.assertEquals(MediaTypes.WADL_TYPE, type); responseContext.getEntity().getClass().equals(Application.class); } @@ -276,7 +276,7 @@ public void testNoHead() throws ExecutionException, InterruptedException { ApplicationHandler application = new ApplicationHandler(new ResourceConfig(ResourceWithoutGetMethod.class)); final ContainerResponse response = testOptions(MediaType.TEXT_PLAIN_TYPE, application, "/no-get"); - Assert.assertFalse(((String) response.getEntity()).contains("HEAD")); + Assertions.assertFalse(((String) response.getEntity()).contains("HEAD")); } @Test @@ -288,11 +288,11 @@ public void testNoHeadWildcard() throws ExecutionException, InterruptedException final ContainerRequest request = RequestContextBuilder.from("/no-get", "OPTIONS").accept(MediaType.MEDIA_TYPE_WILDCARD) .build(); final ContainerResponse response = application.apply(request).get(); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final List strings = response.getStringHeaders().get(HttpHeaders.ALLOW); for (String allow : strings) { - Assert.assertFalse(allow.contains("HEAD")); + Assertions.assertFalse(allow.contains("HEAD")); } } @@ -301,9 +301,9 @@ private ContainerResponse testOptions(MediaType requestType, ApplicationHandler final ContainerRequest request = RequestContextBuilder.from(path, "OPTIONS").accept(requestType) .build(); final ContainerResponse response = application.apply(request).get(); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final MediaType type = response.getMediaType(); - Assert.assertEquals(requestType, type); + Assertions.assertEquals(requestType, type); return response; } @@ -312,6 +312,6 @@ public void testNoHeadInSub() throws ExecutionException, InterruptedException { ApplicationHandler application = new ApplicationHandler(new ResourceConfig(ResourceWithoutGetMethod.class)); final MediaType requestType = MediaType.TEXT_PLAIN_TYPE; final ContainerResponse response = testOptions(requestType, application, "/no-get/sub"); - Assert.assertFalse(((String) response.getEntity()).contains("HEAD")); + Assertions.assertFalse(((String) response.getEntity()).contains("HEAD")); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ParameterTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ParameterTest.java index bf895fedc7..5b01dc698a 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ParameterTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ParameterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,10 +22,10 @@ import java.lang.reflect.Method; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; /** * Parameter model creation test. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ParameterWithMultipleAnnotationsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ParameterWithMultipleAnnotationsTest.java index a8b1adf3f0..d567e4722d 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ParameterWithMultipleAnnotationsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ParameterWithMultipleAnnotationsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -23,8 +23,8 @@ import javax.ws.rs.PathParam; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Checks that Parameters work fine with multiple annotations. @@ -47,9 +47,9 @@ private void checkMyResourceMethod(String methodName) throws Exception { assertEquals(1, parameters.size()); final Parameter parameter = parameters.get(0); - assertEquals(methodName, String.class, parameter.getRawType()); - assertEquals(methodName, String.class, parameter.getType()); - assertEquals(methodName, "correct", parameter.getSourceName()); + assertEquals(String.class, parameter.getRawType(), methodName); + assertEquals(String.class, parameter.getType(), methodName); + assertEquals("correct", parameter.getSourceName(), methodName); } @Target({java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.METHOD, diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/PathAndResourceMethodErrorsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/PathAndResourceMethodErrorsTest.java index 01420f32a2..d82ba0b472 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/PathAndResourceMethodErrorsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/PathAndResourceMethodErrorsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,10 +29,10 @@ import org.glassfish.jersey.server.ApplicationHandler; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Taken from Jersey 1: jersey-tests: com.sun.jersey.impl.errors.PathAndResourceMethodErrorsTest @@ -71,7 +71,7 @@ public Object sub() { } // FIXME - @Ignore + @Disabled @Test public void testPathErrors() { List issues = initiateWebApplication(PathErrorsResource.class); @@ -92,7 +92,7 @@ public static class PathErrorsThreeResource { } @Test - @Ignore + @Disabled // TODO add cross-resource validation & un-ignore the test public void testConflictingRootResourceErrors() { ResourceConfig resourceConfig = new ResourceConfig( @@ -105,7 +105,7 @@ public void testConflictingRootResourceErrors() { } @Test - @Ignore + @Disabled // TODO add cross-resource validation & un-ignore the test public void testConflictingRootResourceErrors2() { ResourceConfig resourceConfig = new ResourceConfig(); @@ -397,7 +397,7 @@ public Object l2() { } // FIXME: trailing slashes should not matter - @Ignore + @Disabled @Test public void testAmbiguousSubResourceLocatorsWithSlashResource() { final List issues = initiateWebApplication(AmbiguousSubResourceLocatorsWithSlashResource.class); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ProgrammaticResourceMethodsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ProgrammaticResourceMethodsTest.java index f8a539d697..3b4e852753 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ProgrammaticResourceMethodsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ProgrammaticResourceMethodsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/RMBuilderTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/RMBuilderTest.java index 70c8eed9ee..e41bd1fcc3 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/RMBuilderTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/RMBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -27,8 +27,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Runtime model builder test. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceInfoTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceInfoTest.java index 24716dfbb1..9116356a29 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceInfoTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,9 +36,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Test cases for injected {@link ResourceInfo} in filters. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceModelTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceModelTest.java index 24713e8160..d717d9728b 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceModelTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceModelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,10 +27,10 @@ import org.glassfish.jersey.uri.internal.UriTemplateParser; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Test {@link ResourceModel} and {@link RuntimeResourceModel}. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceNotFoundTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceNotFoundTest.java index ddc2dcb811..7ba201aa29 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceNotFoundTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceNotFoundTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * test for JERSEY-938 diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourcePathOverrideTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourcePathOverrideTest.java index ee3ccc76af..3b359f10c6 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourcePathOverrideTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourcePathOverrideTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test of resource path overriding via programmatic API. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceTestUtils.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceTestUtils.java index 10e130dcf7..7ba753bd19 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceTestUtils.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ResourceTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,8 +18,8 @@ import java.util.List; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Utils for {@link Resource resource} testing. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceClassDynamicTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceClassDynamicTest.java index 228f4c56bd..ecb7e3d9fb 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceClassDynamicTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceClassDynamicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests:com.sun.jersey.impl.subresources.SubResourceClassDynamicTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicTest.java index 350003523f..87dd25efb9 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests:com.sun.jersey.impl.subresources.SubResourceDynamicTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicWithDuplicateTemplateNamesTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicWithDuplicateTemplateNamesTest.java index 492be69cbc..60f3c5b442 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicWithDuplicateTemplateNamesTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicWithDuplicateTemplateNamesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests:com.sun.jersey.impl.subresources.SubResourceDynamicWithDuplicateTemplateNamesTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicWithParametersTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicWithParametersTest.java index 4d68d36f07..cb5a400153 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicWithParametersTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceDynamicWithParametersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests:com.sun.jersey.impl.subresources.SubResourceDynamicWithParametersTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceHttpMethodsTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceHttpMethodsTest.java index 53910bc4e5..41dc0d635f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceHttpMethodsTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceHttpMethodsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests:com.sun.jersey.impl.subresources.SubResourceHttpMethodsTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceNullTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceNullTest.java index 724511c519..1f4dc4ef7e 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceNullTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceNullTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Taken from Jersey-1: jersey-tests:com.sun.jersey.impl.subresources.SubResourceNullTest diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceProgrammaticTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceProgrammaticTest.java index c26dfbeaba..48ce882e56 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceProgrammaticTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/SubResourceProgrammaticTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,9 +32,9 @@ import org.glassfish.jersey.server.RequestContextBuilder; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Test sub resource locators returning {@link Resource programmatic resources}. diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/ValidatorTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/ValidatorTest.java index 5b7a801373..42bdb0b79f 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/ValidatorTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/ValidatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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,12 +68,12 @@ import org.glassfish.jersey.server.internal.inject.ValueParamProviderConfigurator; import org.glassfish.jersey.server.model.internal.ModelErrors; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Taken from Jersey 1: jersey-server:com.sun.jersey.server.impl.modelapi.validation.ResourceModelValidatorTest.java @@ -374,7 +374,7 @@ public void put(String one, String two) { } @Test - @Ignore("Multiple entity validation not implemented yet.") + @Disabled("Multiple entity validation not implemented yet.") // TODO implement validation public void suspendedTestMoreThanOneEntity() throws Exception { LOGGER.info("An issue should be reported if a resource method takes more than one entity params:"); @@ -1013,7 +1013,7 @@ public String get() { } @Test - @Ignore + @Disabled // TODO: need to add validation to detect ambiguous problems of ResourceSubPathRoot and two other resources. public void testTwoOverlappingSubResourceValidation() throws Exception { List issues = testResourceValidation(ResourceRoot.class, ResourceSubPathRoot.class); @@ -1022,7 +1022,7 @@ public void testTwoOverlappingSubResourceValidation() throws Exception { } @Test - @Ignore + @Disabled public void testTwoOverlappingResourceValidation() throws Exception { List issues = testResourceValidation(ResourceRoot.class, ResourceRootNotUnique.class); assertEquals(1, issues.size()); diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ChildResourceTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ChildResourceTest.java index 3b0a1dc49c..c6839e7877 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ChildResourceTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ChildResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.uri.PathPattern; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Miroslav Fuksa diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ModelHelperTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ModelHelperTest.java index b572affabe..a0e896c2a2 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ModelHelperTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ModelHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -22,8 +22,8 @@ import javax.ws.rs.Path; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Constantino Cronemberger (ccronemberger at yahoo.com.br) @@ -33,16 +33,16 @@ public class ModelHelperTest { @Test public void testClass() { final Class cls = ModelHelper.getAnnotatedResourceClass(MyAnnotatedClass.class); - Assert.assertSame(MyAnnotatedClass.class, cls); + Assertions.assertSame(MyAnnotatedClass.class, cls); } @Test public void testSubClass() { // Spring with CGLIB proxies creates sub-classes final Object obj = new MyAnnotatedClass() {}; - Assert.assertNotSame(MyAnnotatedClass.class, obj.getClass()); + Assertions.assertNotSame(MyAnnotatedClass.class, obj.getClass()); final Class cls = ModelHelper.getAnnotatedResourceClass(obj.getClass()); - Assert.assertSame(MyAnnotatedClass.class, cls); + Assertions.assertSame(MyAnnotatedClass.class, cls); } @Test @@ -56,7 +56,7 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg } }); final Class cls = ModelHelper.getAnnotatedResourceClass(obj.getClass()); - Assert.assertSame(MyServiceInterface.class, cls); + Assertions.assertSame(MyServiceInterface.class, cls); } @Path("test") diff --git a/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ResourceMethodDispatcherFactoryTest.java b/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ResourceMethodDispatcherFactoryTest.java index bb0edd5b56..b307ae38dc 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ResourceMethodDispatcherFactoryTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/model/internal/ResourceMethodDispatcherFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -32,9 +32,9 @@ import org.glassfish.jersey.server.model.ResourceModelComponent; import org.glassfish.jersey.server.spi.internal.ResourceMethodDispatcher; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Jakub Podlesak @@ -44,7 +44,7 @@ public class ResourceMethodDispatcherFactoryTest { private ResourceMethodDispatcherFactory rmdf; private ResourceMethodInvocationHandlerFactory rmihf; - @Before + @BeforeEach public void setupApplication() { TestInjectionManagerFactory.BootstrapResult result = TestInjectionManagerFactory.createInjectionManager(); @@ -73,8 +73,8 @@ public void testBasicDispatchers() throws InterruptedException, ExecutionExcepti for (ResourceModelComponent component : rb.build().getComponents()) { if (component instanceof ResourceMethod) { Invocable invocable = ((ResourceMethod) component).getInvocable(); - assertNotNull("No dispatcher found for invocable " + invocable.toString(), - rmdf.create(invocable, rmihf.create(invocable), null)); + assertNotNull(rmdf.create(invocable, rmihf.create(invocable), null), + "No dispatcher found for invocable " + invocable.toString()); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/modelapi/annotation/IntrospectionModellerTest.java b/core-server/src/test/java/org/glassfish/jersey/server/modelapi/annotation/IntrospectionModellerTest.java index bd929dc143..c5f4f017f2 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/modelapi/annotation/IntrospectionModellerTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/modelapi/annotation/IntrospectionModellerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -38,9 +38,9 @@ import org.glassfish.jersey.server.model.ResourceMethod; import org.hamcrest.Matchers; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Jakub Podlesak @@ -132,38 +132,38 @@ public void testCreateResource() { result = Resource.builder(resourceClass).build(); resourceMethods = result.getResourceMethods(); - assertEquals("Unexpected number of resource methods in the resource model.", 2, resourceMethods.size()); + assertEquals(2, resourceMethods.size(), "Unexpected number of resource methods in the resource model."); resourceMethod = find(resourceMethods, "postA"); - assertEquals("Unexpected number of produced media types in the resource method model", - 3, resourceMethod.getProducedTypes().size()); - assertEquals("Unexpected number of consumed media types in the resource method model", - 2, resourceMethod.getConsumedTypes().size()); - assertEquals("Unexpected number of handler parameters", - 0, resourceMethod.getInvocable().getHandler().getParameters().size()); + assertEquals(3, resourceMethod.getProducedTypes().size(), + "Unexpected number of produced media types in the resource method model"); + assertEquals(2, resourceMethod.getConsumedTypes().size(), + "Unexpected number of consumed media types in the resource method model"); + assertEquals(0, resourceMethod.getInvocable().getHandler().getParameters().size(), + "Unexpected number of handler parameters"); resourceMethod = find(resourceMethods, "postB"); - assertEquals("Unexpected number of inherited produced media types in the resource method model", - 2, resourceMethod.getProducedTypes().size()); - assertEquals("Unexpected number of inherited consumed media types in the resource method model", - 3, resourceMethod.getConsumedTypes().size()); - assertEquals("Unexpected number of handler parameters", - 0, resourceMethod.getInvocable().getHandler().getParameters().size()); + assertEquals(2, resourceMethod.getProducedTypes().size(), + "Unexpected number of inherited produced media types in the resource method model"); + assertEquals(3, resourceMethod.getConsumedTypes().size(), + "Unexpected number of inherited consumed media types in the resource method model"); + assertEquals(0, resourceMethod.getInvocable().getHandler().getParameters().size(), + "Unexpected number of handler parameters"); // OtherResource resourceClass = OtherResource.class; result = Resource.builder(resourceClass).build(); resourceMethods = result.getResourceMethods(); - assertEquals("Unexpected number of resource methods in the resource model.", 2, resourceMethods.size()); + assertEquals(2, resourceMethods.size(), "Unexpected number of resource methods in the resource model."); resourceMethod = find(resourceMethods, "get"); - assertEquals("Unexpected number of produced media types in the resource method model", - 0, resourceMethod.getProducedTypes().size()); - assertEquals("Unexpected number of consumed media types in the resource method model", - 0, resourceMethod.getConsumedTypes().size()); - assertEquals("Unexpected number of handler parameters", - 5, resourceMethod.getInvocable().getHandler().getParameters().size()); + assertEquals(0, resourceMethod.getProducedTypes().size(), + "Unexpected number of produced media types in the resource method model"); + assertEquals(0, resourceMethod.getConsumedTypes().size(), + "Unexpected number of consumed media types in the resource method model"); + assertEquals(5, resourceMethod.getInvocable().getHandler().getParameters().size(), + "Unexpected number of handler parameters"); assertSources(resourceMethod.getInvocable().getHandler().getParameters(), Parameter.Source.CONTEXT, Parameter.Source.PATH, @@ -172,12 +172,12 @@ public void testCreateResource() { Parameter.Source.UNKNOWN); // @Inject on setter resourceMethod = find(resourceMethods, "post"); - assertEquals("Unexpected number of inherited produced media types in the resource method model", - 0, resourceMethod.getProducedTypes().size()); - assertEquals("Unexpected number of inherited consumed media types in the resource method model", - 0, resourceMethod.getConsumedTypes().size()); - assertEquals("Unexpected number of handler parameters", - 5, resourceMethod.getInvocable().getHandler().getParameters().size()); + assertEquals(0, resourceMethod.getProducedTypes().size(), + "Unexpected number of inherited produced media types in the resource method model"); + assertEquals(0, resourceMethod.getConsumedTypes().size(), + "Unexpected number of inherited consumed media types in the resource method model"); + assertEquals(5, resourceMethod.getInvocable().getHandler().getParameters().size(), + "Unexpected number of handler parameters"); assertSources(resourceMethod.getInvocable().getHandler().getParameters(), Parameter.Source.CONTEXT, Parameter.Source.PATH, diff --git a/core-server/src/test/java/org/glassfish/jersey/server/monitoring/MonitoringFeatureTest.java b/core-server/src/test/java/org/glassfish/jersey/server/monitoring/MonitoringFeatureTest.java index e882ce8900..b8ba55c67c 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/monitoring/MonitoringFeatureTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/monitoring/MonitoringFeatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.server.internal.monitoring.MonitoringFeature; import org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test of registration of {@link MonitoringFeature}. @@ -41,9 +41,9 @@ public void testStatisticsEnabled() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -54,9 +54,9 @@ public void testMonitoringDisabled() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertFalse(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertFalse(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertFalse(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertFalse(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -67,9 +67,9 @@ public void testStatisticsDisabled() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertFalse(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertFalse(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -79,9 +79,9 @@ public void testMonitoringEnabledByAutodiscovery() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -92,9 +92,9 @@ public void testMonitoringEnabledStatisticsDisabledByAutodiscovery() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertFalse(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertFalse(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -104,9 +104,9 @@ public void testStatisticsEnabledByAutodiscovery() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -116,9 +116,9 @@ public void testStatisticsDisabledByAutodiscovery() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertFalse(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertFalse(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertFalse(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertFalse(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @@ -131,9 +131,9 @@ public void testStatisticsEnabledMbeansEnabledByInstance() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertTrue(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertTrue(config.isRegistered(MBeanExposer.class)); } @Test @@ -146,9 +146,9 @@ public void testStatisticsEnabledMbeansEnabledByInstance2() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -162,9 +162,9 @@ public void testAllDisabled() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertFalse(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertFalse(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -177,9 +177,9 @@ public void testAllDisabled2() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertFalse(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertFalse(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -190,9 +190,9 @@ public void testAllDisabled3() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertFalse(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertFalse(config.isRegistered(MonitoringEventListener.class)); - Assert.assertFalse(config.isRegistered(MBeanExposer.class)); + Assertions.assertFalse(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertFalse(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertFalse(config.isRegistered(MBeanExposer.class)); } @Test @@ -203,9 +203,9 @@ public void testAllEnabled() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertTrue(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertTrue(config.isRegistered(MBeanExposer.class)); } @Test @@ -219,9 +219,9 @@ public void testAllEnabled2() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertTrue(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertTrue(config.isRegistered(MBeanExposer.class)); } @Test @@ -231,9 +231,9 @@ public void testOnlyMBeansEnabled() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertTrue(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertTrue(config.isRegistered(MBeanExposer.class)); } @Test @@ -244,9 +244,9 @@ public void testOnlyMBeansEnabled2() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertTrue(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertTrue(config.isRegistered(MBeanExposer.class)); } @Test @@ -258,8 +258,8 @@ public void testOnlyMBeansEnabled3() { final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig); final ResourceConfig config = applicationHandler.getConfiguration(); - Assert.assertTrue(config.isRegistered(ApplicationInfoListener.class)); - Assert.assertTrue(config.isRegistered(MonitoringEventListener.class)); - Assert.assertTrue(config.isRegistered(MBeanExposer.class)); + Assertions.assertTrue(config.isRegistered(ApplicationInfoListener.class)); + Assertions.assertTrue(config.isRegistered(MonitoringEventListener.class)); + Assertions.assertTrue(config.isRegistered(MBeanExposer.class)); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorConfigTest.java b/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorConfigTest.java index 5aa59e98c5..ef3cca89b4 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorConfigTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.server.wadl.WadlGenerator; import org.glassfish.jersey.server.wadl.internal.ApplicationDescription; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import com.sun.research.ws.wadl.Application; import com.sun.research.ws.wadl.Method; @@ -64,8 +64,8 @@ public void testBuildWadlGeneratorFromGenerators() { TestInjectionManagerFactory.BootstrapResult result = TestInjectionManagerFactory.createInjectionManager(); WadlGenerator wadlGenerator = config.createWadlGenerator(result.injectionManager); - Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); - Assert.assertEquals(MyWadlGenerator.class, ((MyWadlGenerator2) wadlGenerator).getDelegate().getClass()); + Assertions.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator.class, ((MyWadlGenerator2) wadlGenerator).getDelegate().getClass()); } @Test @@ -76,8 +76,8 @@ public void testBuildWadlGeneratorFromDescriptions() { .prop("foo", propValue) .build(); WadlGenerator wadlGenerator = config.createWadlGenerator(result.injectionManager); - Assert.assertEquals(MyWadlGenerator.class, wadlGenerator.getClass()); - Assert.assertEquals(((MyWadlGenerator) wadlGenerator).getFoo(), propValue); + Assertions.assertEquals(MyWadlGenerator.class, wadlGenerator.getClass()); + Assertions.assertEquals(((MyWadlGenerator) wadlGenerator).getFoo(), propValue); final String propValue2 = "baz"; config = WadlGeneratorConfig.generator(MyWadlGenerator.class) @@ -85,12 +85,12 @@ public void testBuildWadlGeneratorFromDescriptions() { .prop("bar", propValue2) .build(); wadlGenerator = config.createWadlGenerator(result.injectionManager); - Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); final MyWadlGenerator2 wadlGenerator2 = (MyWadlGenerator2) wadlGenerator; - Assert.assertEquals(wadlGenerator2.getBar(), propValue2); + Assertions.assertEquals(wadlGenerator2.getBar(), propValue2); - Assert.assertEquals(MyWadlGenerator.class, wadlGenerator2.getDelegate().getClass()); - Assert.assertEquals(((MyWadlGenerator) wadlGenerator2.getDelegate()).getFoo(), propValue); + Assertions.assertEquals(MyWadlGenerator.class, wadlGenerator2.getDelegate().getClass()); + Assertions.assertEquals(((MyWadlGenerator) wadlGenerator2.getDelegate()).getFoo(), propValue); } @Test @@ -114,12 +114,12 @@ public List configure() { WadlGeneratorConfig config = new MyWadlGeneratorConfig(); WadlGenerator wadlGenerator = config.createWadlGenerator(result.injectionManager); - Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); final MyWadlGenerator2 wadlGenerator2 = (MyWadlGenerator2) wadlGenerator; - Assert.assertEquals(wadlGenerator2.getBar(), propValue2); + Assertions.assertEquals(wadlGenerator2.getBar(), propValue2); - Assert.assertEquals(MyWadlGenerator.class, wadlGenerator2.getDelegate().getClass()); - Assert.assertEquals(((MyWadlGenerator) wadlGenerator2.getDelegate()).getFoo(), propValue); + Assertions.assertEquals(MyWadlGenerator.class, wadlGenerator2.getDelegate().getClass()); + Assertions.assertEquals(((MyWadlGenerator) wadlGenerator2.getDelegate()).getFoo(), propValue); } public abstract static class BaseWadlGenerator implements WadlGenerator { @@ -271,11 +271,11 @@ public void testBuildWadlGeneratorFromDescriptionsWithTypes() { TestInjectionManagerFactory.BootstrapResult result = TestInjectionManagerFactory.createInjectionManager(); WadlGenerator wadlGenerator = config.createWadlGenerator(result.injectionManager); - Assert.assertEquals(MyWadlGenerator3.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator3.class, wadlGenerator.getClass()); MyWadlGenerator3 g = (MyWadlGenerator3) wadlGenerator; - Assert.assertNotNull(g.foo); - Assert.assertEquals(g.foo.s, "string"); - Assert.assertNotNull(g.bar); + Assertions.assertNotNull(g.foo); + Assertions.assertEquals(g.foo.s, "string"); + Assertions.assertNotNull(g.bar); } } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorConfigurationLoaderTest.java b/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorConfigurationLoaderTest.java index 589dc89b0e..88e3bdb120 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorConfigurationLoaderTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorConfigurationLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.wadl.WadlGenerator; import org.glassfish.jersey.server.wadl.internal.ApplicationDescription; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import com.sun.research.ws.wadl.Application; import com.sun.research.ws.wadl.Method; @@ -61,7 +61,7 @@ public void testLoadConfigClass() throws URISyntaxException { TestInjectionManagerFactory.createInjectionManager(resourceConfig); final WadlGenerator wadlGenerator = WadlGeneratorConfigLoader.loadWadlGeneratorsFromConfig(resourceConfig.getProperties()) .createWadlGenerator(result.injectionManager); - Assert.assertEquals(MyWadlGenerator.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator.class, wadlGenerator.getClass()); } @@ -75,7 +75,7 @@ public void testLoadConfigInstance() { TestInjectionManagerFactory.createInjectionManager(resourceConfig); final WadlGenerator wadlGenerator = WadlGeneratorConfigLoader.loadWadlGeneratorsFromConfig(resourceConfig.getProperties()) .createWadlGenerator(result.injectionManager); - Assert.assertTrue(wadlGenerator instanceof MyWadlGenerator); + Assertions.assertTrue(wadlGenerator instanceof MyWadlGenerator); } public static class MyWadlGenerator implements WadlGenerator { diff --git a/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorLoaderTest.java b/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorLoaderTest.java index 06670553e4..c9d774eb4a 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorLoaderTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/wadl/config/WadlGeneratorLoaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -37,8 +37,8 @@ import org.glassfish.jersey.server.wadl.WadlGenerator; import org.glassfish.jersey.server.wadl.internal.ApplicationDescription; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import com.sun.research.ws.wadl.Application; import com.sun.research.ws.wadl.Method; @@ -67,10 +67,10 @@ public void testLoadFileFromClasspathRelative() throws Exception { final WadlGenerator wadlGenerator = WadlGeneratorLoader.loadWadlGeneratorDescriptions(result.injectionManager, description); - Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); final URL resource = getClass().getResource("testfile.xml"); - Assert.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile() + Assertions.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile() .getAbsolutePath()); } @@ -85,10 +85,10 @@ public void testLoadFileFromClasspathAbsolute() throws Exception { final WadlGenerator wadlGenerator = WadlGeneratorLoader.loadWadlGeneratorDescriptions(result.injectionManager, description); - Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); final URL resource = getClass().getResource("testfile.xml"); - Assert.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile() + Assertions.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile() .getAbsolutePath()); } @@ -105,9 +105,9 @@ public void testLoadFileFromAbsolutePath() throws Exception { final WadlGenerator wadlGenerator = WadlGeneratorLoader.loadWadlGeneratorDescriptions(result.injectionManager, description); - Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); - Assert.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile() + Assertions.assertEquals(new File(resource.toURI()).getAbsolutePath(), ((MyWadlGenerator2) wadlGenerator).getTestFile() .getAbsolutePath()); } @@ -121,10 +121,10 @@ public void testLoadStream() throws Exception { final WadlGenerator wadlGenerator = WadlGeneratorLoader.loadWadlGeneratorDescriptions(result.injectionManager, description); - Assert.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); + Assertions.assertEquals(MyWadlGenerator2.class, wadlGenerator.getClass()); final URL resource = getClass().getResource("testfile.xml"); - Assert.assertEquals(new File(resource.toURI()).length(), ((MyWadlGenerator2) wadlGenerator).getTestStreamContent() + Assertions.assertEquals(new File(resource.toURI()).length(), ((MyWadlGenerator2) wadlGenerator).getTestStreamContent() .length()); } diff --git a/core-server/src/test/java/org/glassfish/jersey/server/wadl/generators/resourcedoc/WadlGeneratorResourceDocSupportTest.java b/core-server/src/test/java/org/glassfish/jersey/server/wadl/generators/resourcedoc/WadlGeneratorResourceDocSupportTest.java index e42b397c8e..803d13f325 100644 --- a/core-server/src/test/java/org/glassfish/jersey/server/wadl/generators/resourcedoc/WadlGeneratorResourceDocSupportTest.java +++ b/core-server/src/test/java/org/glassfish/jersey/server/wadl/generators/resourcedoc/WadlGeneratorResourceDocSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -42,7 +42,7 @@ import org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ParamDocType; import org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.model.ResourceDocType; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.sun.research.ws.wadl.Application; diff --git a/docs/src/main/docbook/getting-started.xml b/docs/src/main/docbook/getting-started.xml index 3680d6049c..401d19bf6f 100644 --- a/docs/src/main/docbook/getting-started.xml +++ b/docs/src/main/docbook/getting-started.xml @@ -151,7 +151,7 @@ public class MyResourceTest { private HttpServer server; private WebTarget target; - @Before + @BeforeEach public void setUp() throws Exception { server = Main.startServer(); @@ -159,7 +159,7 @@ public class MyResourceTest { target = c.target(Main.BASE_URI); } - @After + @AfterEach public void tearDown() throws Exception { server.stop(); } diff --git a/examples/bookmark-em/src/test/java/org/glassfish/jersey/examples/bookmark_em/BookmarkTest.java b/examples/bookmark-em/src/test/java/org/glassfish/jersey/examples/bookmark_em/BookmarkTest.java index 5bdba8abed..7b287f9510 100644 --- a/examples/bookmark-em/src/test/java/org/glassfish/jersey/examples/bookmark_em/BookmarkTest.java +++ b/examples/bookmark-em/src/test/java/org/glassfish/jersey/examples/bookmark_em/BookmarkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -25,13 +25,13 @@ import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONObject; -import org.junit.FixMethodOrder; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * TODO un-ignore once Jersey supports @ManagedBean @@ -39,8 +39,8 @@ * @author Pavel Bucek * @author Michal Gajdos */ -@Ignore("un-ignore once Jersey supports @ManagedBean") -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Disabled("un-ignore once Jersey supports @ManagedBean") +@TestMethodOrder(MethodOrderer.MethodName.class) public class BookmarkTest extends JerseyTest { @Override diff --git a/examples/bookmark/src/test/java/org/glassfish/jersey/examples/bookmark/BookmarkTest.java b/examples/bookmark/src/test/java/org/glassfish/jersey/examples/bookmark/BookmarkTest.java index 2ecbfef8a3..2b1e690e70 100644 --- a/examples/bookmark/src/test/java/org/glassfish/jersey/examples/bookmark/BookmarkTest.java +++ b/examples/bookmark/src/test/java/org/glassfish/jersey/examples/bookmark/BookmarkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -26,18 +26,19 @@ import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONObject; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek * @author Michal Gajdos */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) +@TestMethodOrder(MethodOrderer.MethodName.class) public class BookmarkTest extends JerseyTest { @Override diff --git a/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/BookstoreTest.java b/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/BookstoreTest.java index abecf273f8..0b25af3b1a 100644 --- a/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/BookstoreTest.java +++ b/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/BookstoreTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,9 +26,9 @@ package org.glassfish.jersey.examples.bookstore.webapp.resource; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author James Strachan @@ -54,8 +54,8 @@ public void testHappyResourceAsHtml() throws Exception { public void testResourceAsXml() throws Exception { final Bookstore response = target("bookstore-webapp").request("application/xml").get(Bookstore.class); - assertNotNull("Should have returned a bookstore!", response); - assertEquals("bookstore name", "Czech Bookstore", response.getName()); + assertNotNull(response, "Should have returned a bookstore!"); + assertEquals("Czech Bookstore", response.getName(), "bookstore name"); } @Test diff --git a/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/ItemTest.java b/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/ItemTest.java index 8a3e6dcfd8..b61f6c1581 100644 --- a/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/ItemTest.java +++ b/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/ItemTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,9 +28,9 @@ import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author James Strachan @@ -51,8 +51,8 @@ public void testResourceAsXml() throws Exception { System.out.println("Item XML is: " + text); final Book response = item1resource().request("application/xml").get(Book.class); - assertNotNull("Should have returned an item!", response); - assertEquals("item title", "Svejk", response.getTitle()); + assertNotNull(response, "Should have returned an item!"); + assertEquals("Svejk", response.getTitle(), "item title"); } @Test diff --git a/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/TestSupport.java b/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/TestSupport.java index 6a4c22155e..10212c659e 100644 --- a/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/TestSupport.java +++ b/examples/bookstore-webapp/src/test/java/org/glassfish/jersey/examples/bookstore/webapp/resource/TestSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,8 +33,8 @@ import org.glassfish.jersey.servlet.ServletProperties; import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author James Strachan @@ -52,13 +52,13 @@ protected Application configure() { } protected void assertHtmlResponse(String response) { - assertNotNull("No text returned!", response); + assertNotNull(response, "No text returned!"); assertResponseContains(response, ""); assertResponseContains(response, ""); } protected void assertResponseContains(String response, String text) { - assertTrue("Response should contain " + text + " but was: " + response, response.contains(text)); + assertTrue(response.contains(text), "Response should contain " + text + " but was: " + response); } } diff --git a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/CdiTest.java b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/CdiTest.java index bfc60968ad..7f4e0734bf 100644 --- a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/CdiTest.java +++ b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/CdiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -19,8 +19,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; -import org.junit.Assume; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; /** * Test for CDI web application resources. @@ -36,11 +37,12 @@ public class CdiTest extends JerseyTest { Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -48,6 +50,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); diff --git a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/EchoParamBeanTest.java b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/EchoParamBeanTest.java index 195dbc21e1..dcbbe8ed34 100644 --- a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/EchoParamBeanTest.java +++ b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/EchoParamBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,50 +10,35 @@ package org.glassfish.jersey.examples.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for the echo with injected param managed bean resource. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class EchoParamBeanTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"alpha", "beta"}, - {"AAA", "BBB"}, - {"b", "a"}, - {"1$s", "2&d"} - }); + public static Stream testData() { + return Stream.of( + Arguments.of("alpha", "beta"), + Arguments.of("AAA", "BBB"), + Arguments.of("b", "a"), + Arguments.of("1$s", "2&d") + ); } - final String a, b; - - /** - * Create a new test case based on the above defined parameters. - * - * @param a query parameter value - * @param b path parameter value - */ - public EchoParamBeanTest(String a, String b) { - this.a = a; - this.b = b; - } - - @Test - public void testEchoParamResource() { + @ParameterizedTest + @MethodSource("testData") + public void testEchoParamResource(String a, String b) { final WebTarget target = target().path("echofield").path(b); diff --git a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/EchoResourceTest.java b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/EchoResourceTest.java index fd76151aca..97f9645715 100644 --- a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/EchoResourceTest.java +++ b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/EchoResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,48 +10,30 @@ package org.glassfish.jersey.examples.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for the echo resource. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class EchoResourceTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"alpha"}, - {"AAA"}, - {"b"}, - {"1"} - }); - } - - final String a; - - /** - * Create a new test case based on the above defined parameters. - * - * @param a path parameter value - */ - public EchoResourceTest(String a) { - this.a = a; + public static Stream testData() { + return Stream.of("alpha", "AAA", "b", "1"); } - @Test - public void testEchoResource() { + @ParameterizedTest + @MethodSource("testData") + public void testEchoResource(String a) { final WebTarget target = target().path("echo").path(a); @@ -61,8 +43,9 @@ public void testEchoResource() { assertThat(s, containsString(a)); } - @Test - public void testEchoParamCtorResource() { + @ParameterizedTest + @MethodSource("testData") + public void testEchoParamCtorResource(String a) { final WebTarget target = target().path("echoparamconstructor").path(a); diff --git a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/HelloworldTest.java b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/HelloworldTest.java index 006634c73e..3ebf7a7f42 100644 --- a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/HelloworldTest.java +++ b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/HelloworldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,9 +10,9 @@ package org.glassfish.jersey.examples.cdi.resources; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.containsString; /** diff --git a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/PerApplicationBeanTest.java b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/PerApplicationBeanTest.java index 45c4087053..b85c0773dc 100644 --- a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/PerApplicationBeanTest.java +++ b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/PerApplicationBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -13,7 +13,7 @@ import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.containsString; diff --git a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/PerRequestBeanTest.java b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/PerRequestBeanTest.java index a758d15ef5..ed6be52cc3 100644 --- a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/PerRequestBeanTest.java +++ b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/PerRequestBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,51 +10,36 @@ package org.glassfish.jersey.examples.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for the request scoped managed bean resource. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class PerRequestBeanTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"gamma", "delta"}, - {"CC C", "D DD"}, - {"d", "c"}, - {"@^&", "?!:"} - }); + public static Stream testData() { + return Stream.of( + Arguments.of("gamma", "delta"), + Arguments.of("CC C", "D DD"), + Arguments.of("d", "c"), + Arguments.of("@^&", "?!:") + ); } - final String c, d; - - /** - * Create a new test case based on the above defined parameters. - * - * @param c first path parameter value. - * @param d second path parameter value. - */ - public PerRequestBeanTest(String c, String d) { - this.c = c; - this.d = d; - } - - @Test - public void testTheOtherResource() { + @ParameterizedTest + @MethodSource("testData") + public void testTheOtherResource(String c, String d) { final WebTarget target = target().path("other").path(c).path(d); String s = target.request().get(String.class); diff --git a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/ProxyScopeAlignmentTest.java b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/ProxyScopeAlignmentTest.java index 0787114375..43829bec3b 100644 --- a/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/ProxyScopeAlignmentTest.java +++ b/examples/cdi-webapp/src/test/java/org/glassfish/jersey/examples/cdi/resources/ProxyScopeAlignmentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,17 +10,15 @@ package org.glassfish.jersey.examples.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Ensure CDI and JAX-RS scopes are well aligned, so that dynamic proxies @@ -28,31 +26,15 @@ * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class ProxyScopeAlignmentTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"one"}, - {"too"}, - {"much"} - }); + public static Stream testData() { + return Stream.of("one", "too", "much"); } - final String p; - - /** - * Create a new test case based on the above defined parameters. - * - * @param p path parameter value - */ - public ProxyScopeAlignmentTest(String p) { - this.p = p; - } - - @Test - public void testUiInjection() { + @ParameterizedTest + @MethodSource("testData") + public void testUiInjection(String p) { final WebTarget app = target().path("ui-app").path(p); final WebTarget req = target().path("ui-req").path(p); diff --git a/examples/clipboard-programmatic/src/test/java/org/glassfish/jersey/examples/clipboard/ClipboardTest.java b/examples/clipboard-programmatic/src/test/java/org/glassfish/jersey/examples/clipboard/ClipboardTest.java index c7081560d4..e9ae01bd00 100644 --- a/examples/clipboard-programmatic/src/test/java/org/glassfish/jersey/examples/clipboard/ClipboardTest.java +++ b/examples/clipboard-programmatic/src/test/java/org/glassfish/jersey/examples/clipboard/ClipboardTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -18,8 +18,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ClipboardTest extends JerseyTest { diff --git a/examples/clipboard/src/test/java/org/glassfish/jersey/examples/clipboard/ClipboardTest.java b/examples/clipboard/src/test/java/org/glassfish/jersey/examples/clipboard/ClipboardTest.java index 4fdb3b36a8..55c34a0b65 100644 --- a/examples/clipboard/src/test/java/org/glassfish/jersey/examples/clipboard/ClipboardTest.java +++ b/examples/clipboard/src/test/java/org/glassfish/jersey/examples/clipboard/ClipboardTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -20,9 +20,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ClipboardTest extends JerseyTest { @@ -32,7 +32,7 @@ protected ResourceConfig configure() { return App.createApp(); } - @Before + @BeforeEach @Override public void setUp() throws Exception { super.setUp(); diff --git a/examples/declarative-linking/src/test/java/org/glassfish/jersey/examples/linking/LinkWebAppTest.java b/examples/declarative-linking/src/test/java/org/glassfish/jersey/examples/linking/LinkWebAppTest.java index 1ff343515d..df19dd38d3 100644 --- a/examples/declarative-linking/src/test/java/org/glassfish/jersey/examples/linking/LinkWebAppTest.java +++ b/examples/declarative-linking/src/test/java/org/glassfish/jersey/examples/linking/LinkWebAppTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -21,10 +21,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Naresh (Srinivas Bhimisetty) @@ -52,12 +52,12 @@ public void testLinks() throws Exception { .get(Response.class); final Response.StatusType statusInfo = response.getStatusInfo(); - assertEquals("Should have succeeded", 200, statusInfo.getStatusCode()); + assertEquals(200, statusInfo.getStatusCode(), "Should have succeeded"); final String content = response.readEntity(String.class); final List linkHeaders = response.getHeaders().get("Link"); - assertEquals("Should have two link headers", 2, linkHeaders.size()); + assertEquals(2, linkHeaders.size(), "Should have two link headers"); assertThat("Content should contain next link", content, containsString("http://localhost:" + getPort() + "/items?offset=20&limit=10")); diff --git a/examples/entity-filtering-security/src/test/java/org/glassfish/jersey/examples/entityfiltering/security/RestrictedResourceTest.java b/examples/entity-filtering-security/src/test/java/org/glassfish/jersey/examples/entityfiltering/security/RestrictedResourceTest.java index 1a530b7e87..c7c25d776b 100644 --- a/examples/entity-filtering-security/src/test/java/org/glassfish/jersey/examples/entityfiltering/security/RestrictedResourceTest.java +++ b/examples/entity-filtering-security/src/test/java/org/glassfish/jersey/examples/entityfiltering/security/RestrictedResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,8 +10,6 @@ package org.glassfish.jersey.examples.entityfiltering.security; -import java.util.Arrays; - import javax.ws.rs.core.Feature; import javax.ws.rs.core.Response; @@ -23,10 +21,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; @@ -37,111 +32,120 @@ * * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class RestrictedResourceTest extends JerseyTest { - - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } - - public RestrictedResourceTest(final Class filteringProvider) { - super(new ResourceConfig(SecurityEntityFilteringFeature.class) - .packages("org.glassfish.jersey.examples.entityfiltering.security") - .register(filteringProvider)); - - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); - } - - @Test - public void testDenyAll() throws Exception { - assertThat(target("restricted-resource").path("denyAll").request().get().getStatus(), - equalTo(Response.Status.FORBIDDEN.getStatusCode())); - } - - @Test - public void testPermitAll() throws Exception { - final RestrictedEntity entity = target("restricted-resource").path("permitAll").request().get(RestrictedEntity.class); - final RestrictedSubEntity mixedField = entity.getMixedField(); - - // Not null values. - assertThat(entity.getSimpleField(), notNullValue()); - assertThat(entity.getPermitAll(), notNullValue()); - - // Null values. - assertThat(entity.getDenyAll(), nullValue()); - assertThat(mixedField, nullValue()); - } - - @Test - public void testRolesAllowed() throws Exception { - final RestrictedEntity entity = target("restricted-resource").path("rolesAllowed").request().get(RestrictedEntity.class); - final RestrictedSubEntity mixedField = entity.getMixedField(); - - // Not null values. - assertThat(entity.getSimpleField(), notNullValue()); - assertThat(entity.getPermitAll(), notNullValue()); - assertThat(mixedField, notNullValue()); - assertThat(mixedField.getManagerField(), notNullValue()); - - // Null values. - assertThat(entity.getDenyAll(), nullValue()); - assertThat(mixedField.getUserField(), nullValue()); - } - - @Test - public void testRuntimeRolesAllowedUser() throws Exception { - final RestrictedEntity entity = target("restricted-resource") - .path("runtimeRolesAllowed") - .queryParam("roles", "user") - .request().get(RestrictedEntity.class); - final RestrictedSubEntity mixedField = entity.getMixedField(); - - // Not null values. - assertThat(entity.getSimpleField(), notNullValue()); - assertThat(entity.getPermitAll(), notNullValue()); - assertThat(mixedField, notNullValue()); - assertThat(mixedField.getUserField(), notNullValue()); - - // Null values. - assertThat(entity.getDenyAll(), nullValue()); - assertThat(mixedField.getManagerField(), nullValue()); +public class RestrictedResourceTest { + + public abstract static class RestrictedResourceTemplateTest extends JerseyTest { + public RestrictedResourceTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(SecurityEntityFilteringFeature.class) + .packages("org.glassfish.jersey.examples.entityfiltering.security") + .register(filteringProvider)); + + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } + + @Test + public void testDenyAll() throws Exception { + assertThat(target("restricted-resource").path("denyAll").request().get().getStatus(), + equalTo(Response.Status.FORBIDDEN.getStatusCode())); + } + + @Test + public void testPermitAll() throws Exception { + final RestrictedEntity entity = target("restricted-resource").path("permitAll").request().get(RestrictedEntity.class); + final RestrictedSubEntity mixedField = entity.getMixedField(); + + // Not null values. + assertThat(entity.getSimpleField(), notNullValue()); + assertThat(entity.getPermitAll(), notNullValue()); + + // Null values. + assertThat(entity.getDenyAll(), nullValue()); + assertThat(mixedField, nullValue()); + } + + @Test + public void testRolesAllowed() throws Exception { + final RestrictedEntity entity = target("restricted-resource").path("rolesAllowed") + .request().get(RestrictedEntity.class); + final RestrictedSubEntity mixedField = entity.getMixedField(); + + // Not null values. + assertThat(entity.getSimpleField(), notNullValue()); + assertThat(entity.getPermitAll(), notNullValue()); + assertThat(mixedField, notNullValue()); + assertThat(mixedField.getManagerField(), notNullValue()); + + // Null values. + assertThat(entity.getDenyAll(), nullValue()); + assertThat(mixedField.getUserField(), nullValue()); + } + + @Test + public void testRuntimeRolesAllowedUser() throws Exception { + final RestrictedEntity entity = target("restricted-resource") + .path("runtimeRolesAllowed") + .queryParam("roles", "user") + .request().get(RestrictedEntity.class); + final RestrictedSubEntity mixedField = entity.getMixedField(); + + // Not null values. + assertThat(entity.getSimpleField(), notNullValue()); + assertThat(entity.getPermitAll(), notNullValue()); + assertThat(mixedField, notNullValue()); + assertThat(mixedField.getUserField(), notNullValue()); + + // Null values. + assertThat(entity.getDenyAll(), nullValue()); + assertThat(mixedField.getManagerField(), nullValue()); + } + + @Test + public void testRuntimeRolesAllowedManagerUser() throws Exception { + final RestrictedEntity entity = target("restricted-resource") + .path("runtimeRolesAllowed") + .queryParam("roles", "user,manager") + .request().get(RestrictedEntity.class); + final RestrictedSubEntity mixedField = entity.getMixedField(); + + // Not null values. + assertThat(entity.getSimpleField(), notNullValue()); + assertThat(entity.getPermitAll(), notNullValue()); + assertThat(mixedField, notNullValue()); + assertThat(mixedField.getUserField(), notNullValue()); + assertThat(mixedField.getManagerField(), notNullValue()); + + // Null values. + assertThat(entity.getDenyAll(), nullValue()); + } + + @Test + public void testRuntimeRolesAllowedInvalid() throws Exception { + final RestrictedEntity entity = target("restricted-resource") + .path("runtimeRolesAllowed") + .queryParam("roles", "invalid") + .request().get(RestrictedEntity.class); + final RestrictedSubEntity mixedField = entity.getMixedField(); + + // Not null values. + assertThat(entity.getSimpleField(), notNullValue()); + assertThat(entity.getPermitAll(), notNullValue()); + + // Null values. + assertThat(entity.getDenyAll(), nullValue()); + assertThat(mixedField, nullValue()); + } } - @Test - public void testRuntimeRolesAllowedManagerUser() throws Exception { - final RestrictedEntity entity = target("restricted-resource") - .path("runtimeRolesAllowed") - .queryParam("roles", "user,manager") - .request().get(RestrictedEntity.class); - final RestrictedSubEntity mixedField = entity.getMixedField(); - - // Not null values. - assertThat(entity.getSimpleField(), notNullValue()); - assertThat(entity.getPermitAll(), notNullValue()); - assertThat(mixedField, notNullValue()); - assertThat(mixedField.getUserField(), notNullValue()); - assertThat(mixedField.getManagerField(), notNullValue()); - - // Null values. - assertThat(entity.getDenyAll(), nullValue()); + public static class MoxyJsonFeatureRestrictedResourceTest extends RestrictedResourceTemplateTest { + public MoxyJsonFeatureRestrictedResourceTest() { + super(MoxyJsonFeature.class); + } } - @Test - public void testRuntimeRolesAllowedInvalid() throws Exception { - final RestrictedEntity entity = target("restricted-resource") - .path("runtimeRolesAllowed") - .queryParam("roles", "invalid") - .request().get(RestrictedEntity.class); - final RestrictedSubEntity mixedField = entity.getMixedField(); - - // Not null values. - assertThat(entity.getSimpleField(), notNullValue()); - assertThat(entity.getPermitAll(), notNullValue()); - - // Null values. - assertThat(entity.getDenyAll(), nullValue()); - assertThat(mixedField, nullValue()); + public static class JacksonFeatureRestrictedResourceTest extends RestrictedResourceTemplateTest { + public JacksonFeatureRestrictedResourceTest() { + super(JacksonFeature.class); + } } } diff --git a/examples/entity-filtering-security/src/test/java/org/glassfish/jersey/examples/entityfiltering/security/UnrestrictedResourceTest.java b/examples/entity-filtering-security/src/test/java/org/glassfish/jersey/examples/entityfiltering/security/UnrestrictedResourceTest.java index 5b6a838f7f..f7b71260bc 100644 --- a/examples/entity-filtering-security/src/test/java/org/glassfish/jersey/examples/entityfiltering/security/UnrestrictedResourceTest.java +++ b/examples/entity-filtering-security/src/test/java/org/glassfish/jersey/examples/entityfiltering/security/UnrestrictedResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,8 +10,6 @@ package org.glassfish.jersey.examples.entityfiltering.security; -import java.util.Arrays; - import javax.ws.rs.core.Feature; import org.glassfish.jersey.examples.entityfiltering.security.domain.RestrictedEntity; @@ -22,10 +20,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; @@ -35,36 +30,44 @@ * * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class UnrestrictedResourceTest extends JerseyTest { +public class UnrestrictedResourceTest { - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } + public abstract static class UnrestrictedResourceTemplateTest extends JerseyTest { + public UnrestrictedResourceTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(SecurityEntityFilteringFeature.class) + .packages("org.glassfish.jersey.examples.entityfiltering.security") + .register(filteringProvider)); - public UnrestrictedResourceTest(final Class filteringProvider) { - super(new ResourceConfig(SecurityEntityFilteringFeature.class) - .packages("org.glassfish.jersey.examples.entityfiltering.security") - .register(filteringProvider)); + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); - } + @Test + public void testRestrictedEntity() throws Exception { + final RestrictedEntity entity = target("unrestricted-resource").request().get(RestrictedEntity.class); + final RestrictedSubEntity mixedField = entity.getMixedField(); - @Test - public void testRestrictedEntity() throws Exception { - final RestrictedEntity entity = target("unrestricted-resource").request().get(RestrictedEntity.class); - final RestrictedSubEntity mixedField = entity.getMixedField(); + // Not null values. + assertThat(entity.getSimpleField(), notNullValue()); + assertThat(entity.getPermitAll(), notNullValue()); + assertThat(mixedField, notNullValue()); + assertThat(mixedField.getManagerField(), notNullValue()); - // Not null values. - assertThat(entity.getSimpleField(), notNullValue()); - assertThat(entity.getPermitAll(), notNullValue()); - assertThat(mixedField, notNullValue()); - assertThat(mixedField.getManagerField(), notNullValue()); + // Null values. + assertThat(entity.getDenyAll(), nullValue()); + assertThat(mixedField.getUserField(), nullValue()); + } + } + + public static class MoxyJsonFeatureUnrestrictedResourceTest extends UnrestrictedResourceTemplateTest { + public MoxyJsonFeatureUnrestrictedResourceTest() { + super(MoxyJsonFeature.class); + } + } - // Null values. - assertThat(entity.getDenyAll(), nullValue()); - assertThat(mixedField.getUserField(), nullValue()); + public static class JacksonFeatureUnrestrictedResourceTest extends UnrestrictedResourceTemplateTest { + public JacksonFeatureUnrestrictedResourceTest() { + super(JacksonFeature.class); + } } } diff --git a/examples/entity-filtering-selectable/src/test/java/org/glassfish/jersey/examples/entityfiltering/selectable/PersonResourceTest.java b/examples/entity-filtering-selectable/src/test/java/org/glassfish/jersey/examples/entityfiltering/selectable/PersonResourceTest.java index 3dc9acede6..f21cdf4d6d 100644 --- a/examples/entity-filtering-selectable/src/test/java/org/glassfish/jersey/examples/entityfiltering/selectable/PersonResourceTest.java +++ b/examples/entity-filtering-selectable/src/test/java/org/glassfish/jersey/examples/entityfiltering/selectable/PersonResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,7 +10,6 @@ package org.glassfish.jersey.examples.entityfiltering.selectable; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -27,10 +26,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; +import org.junit.jupiter.api.Test; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; @@ -41,164 +38,171 @@ * @author Andy Pemberton (pembertona at gmail.com) * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class PersonResourceTest extends JerseyTest { +public class PersonResourceTest { - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } - - private final Class filteringProvider; + public abstract static class PersonResourceTemplateTest extends JerseyTest { + private final Class filteringProvider; - public PersonResourceTest(final Class filteringProvider) { - super(new ResourceConfig(SelectableEntityFilteringFeature.class) - .packages("org.glassfish.jersey.examples.entityfiltering.selectable") - .property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select") - .register(filteringProvider)); + public PersonResourceTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(SelectableEntityFilteringFeature.class) + .packages("org.glassfish.jersey.examples.entityfiltering.selectable") + .property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select") + .register(filteringProvider)); - this.filteringProvider = filteringProvider; + this.filteringProvider = filteringProvider; - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); - } + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } - @Override - protected void configureClient(final ClientConfig config) { - config.register(filteringProvider); - } + @Override + protected void configureClient(final ClientConfig config) { + config.register(filteringProvider); + } - @Test - public void testNoFilter() throws Exception { - final Person entity = target("people").path("1234").request().get(Person.class); - - // Not null values. - assertThat(entity.getFamilyName(), notNullValue()); - assertThat(entity.getGivenName(), notNullValue()); - assertThat(entity.getHonorificPrefix(), notNullValue()); - assertThat(entity.getHonorificSuffix(), notNullValue()); - assertThat(entity.getRegion(), notNullValue()); - - final List
addresses = entity.getAddresses(); - assertThat(addresses, notNullValue()); - final Address address = addresses.get(0); - assertThat(address, notNullValue()); - assertThat(address.getRegion(), notNullValue()); - assertThat(address.getStreetAddress(), notNullValue()); - PhoneNumber phoneNumber = address.getPhoneNumber(); - assertThat(phoneNumber, notNullValue()); - assertThat(phoneNumber.getAreaCode(), notNullValue()); - assertThat(phoneNumber.getNumber(), notNullValue()); - - final Map phoneNumbers = entity.getPhoneNumbers(); - assertThat(phoneNumbers, notNullValue()); - - // TODO: enable for MOXy as well when JERSEY-2751 gets fixed. - if (JacksonFeature.class.isAssignableFrom(filteringProvider)) { - phoneNumber = phoneNumbers.get("HOME"); + @Test + public void testNoFilter() throws Exception { + final Person entity = target("people").path("1234").request().get(Person.class); + + // Not null values. + assertThat(entity.getFamilyName(), notNullValue()); + assertThat(entity.getGivenName(), notNullValue()); + assertThat(entity.getHonorificPrefix(), notNullValue()); + assertThat(entity.getHonorificSuffix(), notNullValue()); + assertThat(entity.getRegion(), notNullValue()); + + final List
addresses = entity.getAddresses(); + assertThat(addresses, notNullValue()); + final Address address = addresses.get(0); + assertThat(address, notNullValue()); + assertThat(address.getRegion(), notNullValue()); + assertThat(address.getStreetAddress(), notNullValue()); + PhoneNumber phoneNumber = address.getPhoneNumber(); assertThat(phoneNumber, notNullValue()); assertThat(phoneNumber.getAreaCode(), notNullValue()); assertThat(phoneNumber.getNumber(), notNullValue()); + + final Map phoneNumbers = entity.getPhoneNumbers(); + assertThat(phoneNumbers, notNullValue()); + + // TODO: enable for MOXy as well when JERSEY-2751 gets fixed. + if (JacksonFeature.class.isAssignableFrom(filteringProvider)) { + phoneNumber = phoneNumbers.get("HOME"); + assertThat(phoneNumber, notNullValue()); + assertThat(phoneNumber.getAreaCode(), notNullValue()); + assertThat(phoneNumber.getNumber(), notNullValue()); + } } - } - @Test - public void testInvalidFilter() throws Exception { - final Person entity = target("people").path("1234") - .queryParam("select", "invalid").request().get(Person.class); - - // All null values. - assertThat(entity.getFamilyName(), nullValue()); - assertThat(entity.getGivenName(), nullValue()); - assertThat(entity.getHonorificPrefix(), nullValue()); - assertThat(entity.getHonorificSuffix(), nullValue()); - assertThat(entity.getRegion(), nullValue()); - assertThat(entity.getAddresses(), nullValue()); - assertThat(entity.getPhoneNumbers(), nullValue()); - } + @Test + public void testInvalidFilter() throws Exception { + final Person entity = target("people").path("1234") + .queryParam("select", "invalid").request().get(Person.class); + + // All null values. + assertThat(entity.getFamilyName(), nullValue()); + assertThat(entity.getGivenName(), nullValue()); + assertThat(entity.getHonorificPrefix(), nullValue()); + assertThat(entity.getHonorificSuffix(), nullValue()); + assertThat(entity.getRegion(), nullValue()); + assertThat(entity.getAddresses(), nullValue()); + assertThat(entity.getPhoneNumbers(), nullValue()); + } - /** - * Test first level filters. - */ - @Test - public void testFilters() throws Exception { - final Person entity = target("people").path("1234") - .queryParam("select", "familyName,givenName").request() - .get(Person.class); - - // Not null values. - assertThat(entity.getFamilyName(), notNullValue()); - assertThat(entity.getGivenName(), notNullValue()); - - // Null values. - assertThat(entity.getAddresses(), nullValue()); - assertThat(entity.getPhoneNumbers(), nullValue()); - assertThat(entity.getRegion(), nullValue()); - } + /** + * Test first level filters. + */ + @Test + public void testFilters() throws Exception { + final Person entity = target("people").path("1234") + .queryParam("select", "familyName,givenName").request() + .get(Person.class); + + // Not null values. + assertThat(entity.getFamilyName(), notNullValue()); + assertThat(entity.getGivenName(), notNullValue()); + + // Null values. + assertThat(entity.getAddresses(), nullValue()); + assertThat(entity.getPhoneNumbers(), nullValue()); + assertThat(entity.getRegion(), nullValue()); + } - /** - * Test empty (but valid) filters. - * Valid empty filters are: - * . ,. , .. ., - * - * - * result is empty object (nothing is returned) but Jersey will not throw any exception - */ - @Test - public void testEmptyFilters() throws Exception { - final Person entity = target("people").path("1234") - .queryParam("select", ".").request() - .get(Person.class); - - // Null values (all elements). - assertThat(entity.getFamilyName(), nullValue()); - assertThat(entity.getGivenName(), nullValue()); - assertThat(entity.getAddresses(), nullValue()); - assertThat(entity.getPhoneNumbers(), nullValue()); - assertThat(entity.getRegion(), nullValue()); - } + /** + * Test empty (but valid) filters. + * Valid empty filters are: + * . ,. , .. ., + * + * + * result is empty object (nothing is returned) but Jersey will not throw any exception + */ + @Test + public void testEmptyFilters() throws Exception { + final Person entity = target("people").path("1234") + .queryParam("select", ".").request() + .get(Person.class); + + // Null values (all elements). + assertThat(entity.getFamilyName(), nullValue()); + assertThat(entity.getGivenName(), nullValue()); + assertThat(entity.getAddresses(), nullValue()); + assertThat(entity.getPhoneNumbers(), nullValue()); + assertThat(entity.getRegion(), nullValue()); + } + + /** + * Test 2nd and 3rd level filters. + */ + @Test + public void testSubFilters() throws Exception { + final Person entity = target("people") + .path("1234") + .queryParam("select", + "familyName,givenName,addresses.streetAddress,addresses.phoneNumber.areaCode") + .request().get(Person.class); + + // Not null values. + assertThat(entity.getFamilyName(), notNullValue()); + assertThat(entity.getGivenName(), notNullValue()); + assertThat(entity.getAddresses().get(0).getStreetAddress(), notNullValue()); + assertThat(entity.getAddresses().get(0).getPhoneNumber().getAreaCode(), notNullValue()); + + // Null values. + assertThat(entity.getRegion(), nullValue()); + assertThat(entity.getAddresses().get(0).getPhoneNumber().getNumber(), nullValue()); + } - /** - * Test 2nd and 3rd level filters. - */ - @Test - public void testSubFilters() throws Exception { - final Person entity = target("people") - .path("1234") - .queryParam("select", - "familyName,givenName,addresses.streetAddress,addresses.phoneNumber.areaCode") - .request().get(Person.class); - - // Not null values. - assertThat(entity.getFamilyName(), notNullValue()); - assertThat(entity.getGivenName(), notNullValue()); - assertThat(entity.getAddresses().get(0).getStreetAddress(), notNullValue()); - assertThat(entity.getAddresses().get(0).getPhoneNumber().getAreaCode(), notNullValue()); - - // Null values. - assertThat(entity.getRegion(), nullValue()); - assertThat(entity.getAddresses().get(0).getPhoneNumber().getNumber(), nullValue()); + /** + * Test that 1st and 2nd level filters with the same name act as expected. + */ + @Test + public void testFiltersSameName() throws Exception { + final Person firstLevel = target("people").path("1234") + .queryParam("select", "familyName,region").request() + .get(Person.class); + final Person secondLevel = target("people").path("1234") + .queryParam("select", "familyName,addresses.region").request() + .get(Person.class); + + // Not null values. + assertThat(firstLevel.getRegion(), notNullValue()); + assertThat(secondLevel.getAddresses().get(0).getRegion(), notNullValue()); + + // Null values. + assertThat(firstLevel.getAddresses(), nullValue()); //confirms 2nd level region on addresses is null + assertThat(secondLevel.getRegion(), nullValue()); + } } - /** - * Test that 1st and 2nd level filters with the same name act as expected. - */ - @Test - public void testFiltersSameName() throws Exception { - final Person firstLevel = target("people").path("1234") - .queryParam("select", "familyName,region").request() - .get(Person.class); - final Person secondLevel = target("people").path("1234") - .queryParam("select", "familyName,addresses.region").request() - .get(Person.class); - - // Not null values. - assertThat(firstLevel.getRegion(), notNullValue()); - assertThat(secondLevel.getAddresses().get(0).getRegion(), notNullValue()); - - // Null values. - assertThat(firstLevel.getAddresses(), nullValue()); //confirms 2nd level region on addresses is null - assertThat(secondLevel.getRegion(), nullValue()); + public static class MoxyJsonFeaturePersonResourceTest extends PersonResourceTemplateTest { + public MoxyJsonFeaturePersonResourceTest() { + super(MoxyJsonFeature.class); + } } + public static class JacksonFeaturePersonResourceTest extends PersonResourceTemplateTest { + public JacksonFeaturePersonResourceTest() { + super(JacksonFeature.class); + } + } } diff --git a/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/ProjectsResourceTest.java b/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/ProjectsResourceTest.java index 5d51237388..0e28544399 100644 --- a/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/ProjectsResourceTest.java +++ b/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/ProjectsResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,7 +10,6 @@ package org.glassfish.jersey.examples.entityfiltering; -import java.util.Arrays; import java.util.List; import javax.ws.rs.core.Feature; @@ -23,10 +22,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; @@ -36,60 +34,70 @@ * * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class ProjectsResourceTest extends JerseyTest { +public class ProjectsResourceTest { - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } + public abstract static class ProjectsResourceTemplateTest extends JerseyTest { + public ProjectsResourceTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(EntityFilteringFeature.class) + .packages("org.glassfish.jersey.examples.entityfiltering.resource") + .register(filteringProvider)); - public ProjectsResourceTest(final Class filteringProvider) { - super(new ResourceConfig(EntityFilteringFeature.class) - .packages("org.glassfish.jersey.examples.entityfiltering.resource") - .register(filteringProvider)); + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); - } + @Test + public void testProjects() throws Exception { + for (final Project project : target("projects").request().get(new GenericType>() {})) { + testProject(project, false); + } + } - @Test - public void testProjects() throws Exception { - for (final Project project : target("projects").request().get(new GenericType>() {})) { - testProject(project, false); + @Test + public void testProject() throws Exception { + testProject(target("projects").path("1").request().get(Project.class), false); } - } - @Test - public void testProject() throws Exception { - testProject(target("projects").path("1").request().get(Project.class), false); - } + @Test + public void testDetailedProjects() throws Exception { + for (final Project project : target("projects/detailed").request().get(new GenericType>() {})) { + testProject(project, true); + } + } - @Test - public void testDetailedProjects() throws Exception { - for (final Project project : target("projects/detailed").request().get(new GenericType>() {})) { - testProject(project, true); + @Test + public void testDetailedProject() throws Exception { + testProject(target("projects/detailed").path("1").request().get(Project.class), true); + } + + private void testProject(final Project project, final boolean isDetailed) { + // Following properties should be in every returned project. + assertThat(project.getId(), notNullValue()); + assertThat(project.getName(), notNullValue()); + assertThat(project.getDescription(), notNullValue()); + + // Tasks and users should be only in "detailed" view. + if (!isDetailed) { + assertThat("Users present in non-detailed project view", project.getUsers(), nullValue()); + assertThat("Tasks present in non-detailed project view", project.getTasks(), nullValue()); + } else { + assertThat("Users not present in detailed project view", project.getUsers(), notNullValue()); + assertThat("Tasks not present in detailed project view", project.getTasks(), notNullValue()); + } } } - @Test - public void testDetailedProject() throws Exception { - testProject(target("projects/detailed").path("1").request().get(Project.class), true); + @Nested + public static class MoxyJsonFeatureProjectsResourceTest extends ProjectsResourceTemplateTest { + public MoxyJsonFeatureProjectsResourceTest() { + super(MoxyJsonFeature.class); + } } - private void testProject(final Project project, final boolean isDetailed) { - // Following properties should be in every returned project. - assertThat(project.getId(), notNullValue()); - assertThat(project.getName(), notNullValue()); - assertThat(project.getDescription(), notNullValue()); - - // Tasks and users should be only in "detailed" view. - if (!isDetailed) { - assertThat("Users present in non-detailed project view", project.getUsers(), nullValue()); - assertThat("Tasks present in non-detailed project view", project.getTasks(), nullValue()); - } else { - assertThat("Users not present in detailed project view", project.getUsers(), notNullValue()); - assertThat("Tasks not present in detailed project view", project.getTasks(), notNullValue()); + @Nested + public static class JacksonFeatureProjectsResourceTest extends ProjectsResourceTemplateTest { + public JacksonFeatureProjectsResourceTest() { + super(JacksonFeature.class); } } } diff --git a/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/TaskResourceTest.java b/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/TaskResourceTest.java index c7171acdaa..bf1e6dd234 100644 --- a/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/TaskResourceTest.java +++ b/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/TaskResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,7 +10,6 @@ package org.glassfish.jersey.examples.entityfiltering; -import java.util.Arrays; import java.util.List; import javax.ws.rs.core.Feature; @@ -23,10 +22,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; +import org.junit.jupiter.api.Test; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; @@ -36,60 +33,68 @@ * * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class TaskResourceTest extends JerseyTest { +public class TaskResourceTest { - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } + public abstract static class TaskResourceTemplateTest extends JerseyTest { + public TaskResourceTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(EntityFilteringFeature.class) + .packages("org.glassfish.jersey.examples.entityfiltering.resource") + .register(filteringProvider)); - public TaskResourceTest(final Class filteringProvider) { - super(new ResourceConfig(EntityFilteringFeature.class) - .packages("org.glassfish.jersey.examples.entityfiltering.resource") - .register(filteringProvider)); + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); - } + @Test + public void testTasks() throws Exception { + for (final Task task : target("tasks").request().get(new GenericType>() {})) { + testTask(task, false); + } + } - @Test - public void testTasks() throws Exception { - for (final Task task : target("tasks").request().get(new GenericType>() {})) { - testTask(task, false); + @Test + public void testTask() throws Exception { + testTask(target("tasks").path("1").request().get(Task.class), false); } - } - @Test - public void testTask() throws Exception { - testTask(target("tasks").path("1").request().get(Task.class), false); - } + @Test + public void testDetailedTasks() throws Exception { + for (final Task task : target("tasks").path("detailed").request().get(new GenericType>() {})) { + testTask(task, true); + } + } - @Test - public void testDetailedTasks() throws Exception { - for (final Task task : target("tasks").path("detailed").request().get(new GenericType>() {})) { - testTask(task, true); + @Test + public void testDetailedTask() throws Exception { + testTask(target("tasks").path("1").queryParam("detailed", true).request().get(Task.class), true); + } + + private void testTask(final Task task, final boolean isDetailed) { + // Following properties should be in every returned task. + assertThat(task.getId(), notNullValue()); + assertThat(task.getName(), notNullValue()); + assertThat(task.getDescription(), notNullValue()); + + // Tasks and tasks should be in "detailed" view. + if (!isDetailed) { + assertThat(task.getProject(), nullValue()); + assertThat(task.getUser(), nullValue()); + } else { + assertThat(task.getProject(), notNullValue()); + assertThat(task.getUser(), notNullValue()); + } } } - @Test - public void testDetailedTask() throws Exception { - testTask(target("tasks").path("1").queryParam("detailed", true).request().get(Task.class), true); + public static class MoxyJsonFeatureTaskResourceTest extends TaskResourceTemplateTest { + public MoxyJsonFeatureTaskResourceTest() { + super(MoxyJsonFeature.class); + } } - private void testTask(final Task task, final boolean isDetailed) { - // Following properties should be in every returned task. - assertThat(task.getId(), notNullValue()); - assertThat(task.getName(), notNullValue()); - assertThat(task.getDescription(), notNullValue()); - - // Tasks and tasks should be in "detailed" view. - if (!isDetailed) { - assertThat(task.getProject(), nullValue()); - assertThat(task.getUser(), nullValue()); - } else { - assertThat(task.getProject(), notNullValue()); - assertThat(task.getUser(), notNullValue()); + public static class JacksonFeatureTaskResourceTest extends TaskResourceTemplateTest { + public JacksonFeatureTaskResourceTest() { + super(JacksonFeature.class); } } } diff --git a/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/UsersResourceTest.java b/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/UsersResourceTest.java index e85f779e5e..777d110ce1 100644 --- a/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/UsersResourceTest.java +++ b/examples/entity-filtering/src/test/java/org/glassfish/jersey/examples/entityfiltering/UsersResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,7 +10,9 @@ package org.glassfish.jersey.examples.entityfiltering; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import javax.ws.rs.core.Feature; @@ -23,73 +25,84 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * {@link org.glassfish.jersey.examples.entityfiltering.resource.UsersResource} unit tests. * * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class UsersResourceTest extends JerseyTest { +public class UsersResourceTest { - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}}); + public static Iterable> providers() { + return Arrays.asList(MoxyJsonFeature.class, JacksonFeature.class); } - public UsersResourceTest(final Class filteringProvider) { - super(new ResourceConfig(EntityFilteringFeature.class) - .packages("org.glassfish.jersey.examples.entityfiltering.resource") - .register(filteringProvider)); - - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + providers().forEach(feature -> { + UsersResourceTemplateTest test = new UsersResourceTemplateTest(feature) {}; + tests.add(TestHelper.toTestContainer(test, feature.getSimpleName())); + }); + return tests; } - @Test - public void testUsers() throws Exception { - for (final User user : target("users").request().get(new GenericType>() {})) { - testUser(user, false); + public abstract static class UsersResourceTemplateTest extends JerseyTest { + public UsersResourceTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(EntityFilteringFeature.class) + .packages("org.glassfish.jersey.examples.entityfiltering.resource") + .register(filteringProvider)); + + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); } - } - @Test - public void testUser() throws Exception { - testUser(target("users").path("1").request().get(User.class), false); - } + @Test + public void testUsers() throws Exception { + for (final User user : target("users").request().get(new GenericType>() {})) { + testUser(user, false); + } + } - @Test - public void testDetailedUsers() throws Exception { - for (final User user : target("users").queryParam("detailed", true).request().get(new GenericType>() {})) { - testUser(user, true); + @Test + public void testUser() throws Exception { + testUser(target("users").path("1").request().get(User.class), false); } - } - @Test - public void testDetailedUser() throws Exception { - testUser(target("users").path("1").queryParam("detailed", true).request().get(User.class), true); - } + @Test + public void testDetailedUsers() throws Exception { + for (final User user : target("users").queryParam("detailed", true).request().get(new GenericType>() {})) { + testUser(user, true); + } + } + + @Test + public void testDetailedUser() throws Exception { + testUser(target("users").path("1").queryParam("detailed", true).request().get(User.class), true); + } + + private void testUser(final User user, final boolean isDetailed) { + // Following properties should be in every returned user. + assertThat(user.getId(), notNullValue()); + assertThat(user.getName(), notNullValue()); + assertThat(user.getEmail(), notNullValue()); - private void testUser(final User user, final boolean isDetailed) { - // Following properties should be in every returned user. - assertThat(user.getId(), notNullValue()); - assertThat(user.getName(), notNullValue()); - assertThat(user.getEmail(), notNullValue()); - - // Tasks and users should be in "detailed" view. - if (!isDetailed) { - assertThat(user.getProjects(), nullValue()); - assertThat(user.getTasks(), nullValue()); - } else { - assertThat(user.getProjects(), notNullValue()); - assertThat(user.getTasks(), notNullValue()); + // Tasks and users should be in "detailed" view. + if (!isDetailed) { + assertThat(user.getProjects(), nullValue()); + assertThat(user.getTasks(), nullValue()); + } else { + assertThat(user.getProjects(), notNullValue()); + assertThat(user.getTasks(), notNullValue()); + } } } } diff --git a/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingFilterTest.java b/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingFilterTest.java index d509934f72..f95f19156a 100644 --- a/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingFilterTest.java +++ b/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -18,13 +18,13 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.glassfish.jersey.examples.exception.ExceptionResource.MyResponseFilter; import static org.glassfish.jersey.examples.exception.Exceptions.MyExceptionMapper; import static org.glassfish.jersey.examples.exception.Exceptions.MySubExceptionMapper; import static org.glassfish.jersey.examples.exception.Exceptions.WebApplicationExceptionMapper; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * ExceptionMappingFilterTest class. diff --git a/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingTest.java b/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingTest.java index 316631222a..615cd29b22 100644 --- a/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingTest.java +++ b/examples/exception-mapping/src/test/java/org/glassfish/jersey/examples/exception/ExceptionMappingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -18,14 +18,14 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.glassfish.jersey.examples.exception.ExceptionResource.MyResponseFilter; import static org.glassfish.jersey.examples.exception.Exceptions.MyExceptionMapper; import static org.glassfish.jersey.examples.exception.Exceptions.MySubExceptionMapper; import static org.glassfish.jersey.examples.exception.Exceptions.MySubSubException; import static org.glassfish.jersey.examples.exception.Exceptions.WebApplicationExceptionMapper; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * ExceptionMappingTest class. diff --git a/examples/extended-wadl-webapp/pom.xml b/examples/extended-wadl-webapp/pom.xml index 736b9975cb..57b69074eb 100644 --- a/examples/extended-wadl-webapp/pom.xml +++ b/examples/extended-wadl-webapp/pom.xml @@ -90,6 +90,12 @@ pax-exam-link-mvn test + + junit + junit + ${junit4.version} + test + diff --git a/examples/extended-wadl-webapp/src/test/java/org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappOsgiTest.java b/examples/extended-wadl-webapp/src/test/java/org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappOsgiTest.java index e31505211e..584ec0af7d 100644 --- a/examples/extended-wadl-webapp/src/test/java/org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappOsgiTest.java +++ b/examples/extended-wadl-webapp/src/test/java/org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappOsgiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -300,7 +300,7 @@ private void checkWadl(String wadl, URI baseUri) throws Exception { String val = (String) xp.evaluate("/wadl:application/wadl:resources/@base", document, XPathConstants.STRING); assertEquals(baseUri.toString(), val.endsWith("/") ? val.substring(0, val.length() - 1) : val); val = (String) xp.evaluate("count(//wadl:resource)", document, XPathConstants.STRING); - assertEquals("Unexpected number of resource elements.", val, "4"); + assertEquals("Unexpected number of resource elements.", "4", val); val = (String) xp.evaluate("count(//wadl:resource[@path='items'])", document, XPathConstants.STRING); assertEquals("Unexpected number of resource elements with 'items' path.", "1", val); val = (String) xp.evaluate("count(//wadl:resource[@path='{id}'])", document, XPathConstants.STRING); diff --git a/examples/extended-wadl-webapp/src/test/java/org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappTest.java b/examples/extended-wadl-webapp/src/test/java/org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappTest.java index e2050b1b28..918471c9cf 100644 --- a/examples/extended-wadl-webapp/src/test/java/org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappTest.java +++ b/examples/extended-wadl-webapp/src/test/java/org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -120,7 +120,7 @@ private void checkWadl(String wadl, URI baseUri) throws Exception { String val = (String) xp.evaluate("/wadl:application/wadl:resources/@base", document, XPathConstants.STRING); assertEquals(baseUri.toString(), val.endsWith("/") ? val.substring(0, val.length() - 1) : val); val = (String) xp.evaluate("count(//wadl:resource)", document, XPathConstants.STRING); - assertEquals("Unexpected number of resource elements.", val, "4"); + assertEquals("Unexpected number of resource elements.", "4", val); val = (String) xp.evaluate("count(//wadl:resource[@path='items'])", document, XPathConstants.STRING); assertEquals("Unexpected number of resource elements with 'items' path.", "1", val); val = (String) xp.evaluate("count(//wadl:resource[@path='{id}'])", document, XPathConstants.STRING); diff --git a/examples/freemarker-webapp/src/test/java/org/glassfish/jersey/examples/freemarker/FreemarkerTest.java b/examples/freemarker-webapp/src/test/java/org/glassfish/jersey/examples/freemarker/FreemarkerTest.java index 7c8abda147..1fa542ba4f 100644 --- a/examples/freemarker-webapp/src/test/java/org/glassfish/jersey/examples/freemarker/FreemarkerTest.java +++ b/examples/freemarker-webapp/src/test/java/org/glassfish/jersey/examples/freemarker/FreemarkerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -19,8 +19,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/examples/groovy/pom.xml b/examples/groovy/pom.xml index ccc4956d6f..3009cbaa58 100644 --- a/examples/groovy/pom.xml +++ b/examples/groovy/pom.xml @@ -45,6 +45,12 @@ org.glassfish.jersey.inject jersey-hk2 + + org.junit.jupiter + junit-jupiter-engine + 5.8.2 + test + diff --git a/examples/groovy/src/test/groovy/org/glassfish/jersey/examples/groovy/GroovyResourceTest.groovy b/examples/groovy/src/test/groovy/org/glassfish/jersey/examples/groovy/GroovyResourceTest.groovy index 11db4f6ed8..eb0d749561 100644 --- a/examples/groovy/src/test/groovy/org/glassfish/jersey/examples/groovy/GroovyResourceTest.groovy +++ b/examples/groovy/src/test/groovy/org/glassfish/jersey/examples/groovy/GroovyResourceTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -13,10 +13,10 @@ package org.glassfish.jersey.examples.groovy import org.glassfish.jersey.server.ResourceConfig import org.glassfish.jersey.test.JerseyTest import org.glassfish.jersey.test.TestProperties -import org.junit.Test +import org.junit.jupiter.api.Test import javax.ws.rs.core.Response -import static org.junit.Assert.assertEquals +import static org.junit.jupiter.api.Assertions.assertEquals /** * Test the availability of the {@link GroovyResource}. diff --git a/examples/helloworld-benchmark/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java b/examples/helloworld-benchmark/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java index 6e7c046dbb..00ede89920 100644 --- a/examples/helloworld-benchmark/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java +++ b/examples/helloworld-benchmark/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -17,9 +17,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * {@link org.glassfish.jersey.examples.helloworld.HelloWorldResource} tests. diff --git a/examples/helloworld-cdi2-se/src/test/java/org/glassfish/jersey/examples/helloworld/cdi2se/CounterTest.java b/examples/helloworld-cdi2-se/src/test/java/org/glassfish/jersey/examples/helloworld/cdi2se/CounterTest.java index 9017419de7..42f8128620 100644 --- a/examples/helloworld-cdi2-se/src/test/java/org/glassfish/jersey/examples/helloworld/cdi2se/CounterTest.java +++ b/examples/helloworld-cdi2-se/src/test/java/org/glassfish/jersey/examples/helloworld/cdi2se/CounterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -13,8 +13,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests CDI counter resource. diff --git a/examples/helloworld-cdi2-se/src/test/java/org/glassfish/jersey/examples/helloworld/cdi2se/HelloWorldTest.java b/examples/helloworld-cdi2-se/src/test/java/org/glassfish/jersey/examples/helloworld/cdi2se/HelloWorldTest.java index 0bba28a716..2880426adc 100644 --- a/examples/helloworld-cdi2-se/src/test/java/org/glassfish/jersey/examples/helloworld/cdi2se/HelloWorldTest.java +++ b/examples/helloworld-cdi2-se/src/test/java/org/glassfish/jersey/examples/helloworld/cdi2se/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -13,8 +13,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests CDI helloworld resource. diff --git a/examples/helloworld-netty/pom.xml b/examples/helloworld-netty/pom.xml index 99ec59d5a5..b27775df4d 100644 --- a/examples/helloworld-netty/pom.xml +++ b/examples/helloworld-netty/pom.xml @@ -59,6 +59,9 @@ org.glassfish.jersey.examples.helloworld.netty.App + + maven-surefire-plugin + diff --git a/examples/helloworld-netty/src/test/java/org/glassfish/jersey/examples/helloworld/netty/CustomLoggingFilter.java b/examples/helloworld-netty/src/test/java/org/glassfish/jersey/examples/helloworld/netty/CustomLoggingFilter.java index 396abddd7e..219f21996a 100644 --- a/examples/helloworld-netty/src/test/java/org/glassfish/jersey/examples/helloworld/netty/CustomLoggingFilter.java +++ b/examples/helloworld-netty/src/test/java/org/glassfish/jersey/examples/helloworld/netty/CustomLoggingFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -22,7 +22,7 @@ import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Custom logging filter. @@ -40,28 +40,28 @@ public class CustomLoggingFilter implements ContainerRequestFilter, ContainerRes @Override public void filter(ClientRequestContext context) throws IOException { LOGGER.info("CustomLoggingFilter.preFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); preFilterCalled++; } @Override public void filter(ClientRequestContext context, ClientResponseContext clientResponseContext) throws IOException { LOGGER.info("CustomLoggingFilter.postFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); postFilterCalled++; } @Override public void filter(ContainerRequestContext context) throws IOException { LOGGER.info("CustomLoggingFilter.preFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); preFilterCalled++; } @Override public void filter(ContainerRequestContext context, ContainerResponseContext containerResponseContext) throws IOException { LOGGER.info("CustomLoggingFilter.postFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); postFilterCalled++; } } diff --git a/examples/helloworld-netty/src/test/java/org/glassfish/jersey/examples/helloworld/netty/HelloWorldTest.java b/examples/helloworld-netty/src/test/java/org/glassfish/jersey/examples/helloworld/netty/HelloWorldTest.java index 23e8956570..44f5e2f68c 100644 --- a/examples/helloworld-netty/src/test/java/org/glassfish/jersey/examples/helloworld/netty/HelloWorldTest.java +++ b/examples/helloworld-netty/src/test/java/org/glassfish/jersey/examples/helloworld/netty/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -33,15 +33,18 @@ import org.glassfish.jersey.test.netty.NettyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; -import org.glassfish.jersey.test.util.runner.RunSeparately; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -@RunWith(ConcurrentRunner.class) +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.api.parallel.ResourceAccessMode; +import org.junit.jupiter.api.parallel.ResourceLock; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class HelloWorldTest extends JerseyTest { @Override @@ -62,7 +65,9 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc } @Test - @Ignore("not compatible with test framework (doesn't use client())") + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) + @Disabled("not compatible with test framework (doesn't use client())") public void testHelloWorld() throws Exception { URL getUrl = UriBuilder.fromUri(getBaseUri()).path(App.ROOT_PATH).build().toURL(); HttpURLConnection connection = (HttpURLConnection) getUrl.openConnection(); @@ -78,18 +83,24 @@ public void testHelloWorld() throws Exception { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testConnection() { Response response = target().path(App.ROOT_PATH).request("text/plain").get(); assertEquals(200, response.getStatus()); } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testClientStringResponse() { String s = target().path(App.ROOT_PATH).request().get(String.class); assertEquals(HelloWorldResource.CLICHED_MESSAGE, s); } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testAsyncClientRequests() throws InterruptedException { final int REQUESTS = 10; final CountDownLatch latch = new CountDownLatch(REQUESTS); @@ -120,6 +131,8 @@ public void failed(Throwable error) { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testHead() { Response response = target().path(App.ROOT_PATH).request().head(); assertEquals(200, response.getStatus()); @@ -127,6 +140,8 @@ public void testHead() { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testFooBarOptions() { Response response = target().path(App.ROOT_PATH).request().header("Accept", "foo/bar").options(); assertEquals(200, response.getStatus()); @@ -137,6 +152,8 @@ public void testFooBarOptions() { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testTextPlainOptions() { Response response = target().path(App.ROOT_PATH).request().header("Accept", MediaType.TEXT_PLAIN).options(); assertEquals(200, response.getStatus()); @@ -154,6 +171,8 @@ private void _checkAllowContent(final String content) { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testMissingResourceNotFound() { Response response; @@ -165,7 +184,7 @@ public void testMissingResourceNotFound() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testLoggingFilterClientClass() { Client client = client(); client.register(CustomLoggingFilter.class).property("foo", "bar"); @@ -177,7 +196,7 @@ public void testLoggingFilterClientClass() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testLoggingFilterClientInstance() { Client client = client(); client.register(new CustomLoggingFilter()).property("foo", "bar"); @@ -189,7 +208,7 @@ public void testLoggingFilterClientInstance() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testLoggingFilterTargetClass() { WebTarget target = target().path(App.ROOT_PATH); target.register(CustomLoggingFilter.class).property("foo", "bar"); @@ -201,7 +220,7 @@ public void testLoggingFilterTargetClass() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testLoggingFilterTargetInstance() { WebTarget target = target().path(App.ROOT_PATH); target.register(new CustomLoggingFilter()).property("foo", "bar"); @@ -213,7 +232,7 @@ public void testLoggingFilterTargetInstance() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testConfigurationUpdate() { Client client1 = client(); client1.register(CustomLoggingFilter.class).property("foo", "bar"); @@ -227,7 +246,7 @@ public void testConfigurationUpdate() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testQueryParameterGet() { String result = target().path(App.ROOT_PATH + "/query1").queryParam("test1", "expected1") .queryParam("test2", "expected2").request().get(String.class); @@ -235,7 +254,7 @@ public void testQueryParameterGet() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testQueryParameterPost() { String result = target().path(App.ROOT_PATH + "/query2").queryParam("test1", "expected1") .queryParam("test2", "expected2").request("text/plain").post(Entity.entity("entity", "text/plain")) diff --git a/examples/helloworld-programmatic/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java b/examples/helloworld-programmatic/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java index f9596efb8f..a74b18fdc4 100644 --- a/examples/helloworld-programmatic/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java +++ b/examples/helloworld-programmatic/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -18,10 +18,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class HelloWorldTest extends JerseyTest { diff --git a/examples/helloworld-pure-jax-rs/pom.xml b/examples/helloworld-pure-jax-rs/pom.xml index 4bc69166b7..eb09c25c65 100644 --- a/examples/helloworld-pure-jax-rs/pom.xml +++ b/examples/helloworld-pure-jax-rs/pom.xml @@ -40,8 +40,8 @@ jersey-hk2 - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/examples/helloworld-pure-jax-rs/src/test/java/org/glassfish/jersey/examples/helloworld/jaxrs/HelloWorldTest.java b/examples/helloworld-pure-jax-rs/src/test/java/org/glassfish/jersey/examples/helloworld/jaxrs/HelloWorldTest.java index 2562a4fc5d..37e4e9a50e 100644 --- a/examples/helloworld-pure-jax-rs/src/test/java/org/glassfish/jersey/examples/helloworld/jaxrs/HelloWorldTest.java +++ b/examples/helloworld-pure-jax-rs/src/test/java/org/glassfish/jersey/examples/helloworld/jaxrs/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -14,8 +14,8 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.sun.net.httpserver.HttpServer; diff --git a/examples/helloworld-spring-annotations/src/test/java/org/glassfish/jersey/examples/hello/spring/annotations/SpringRequestResourceTest.java b/examples/helloworld-spring-annotations/src/test/java/org/glassfish/jersey/examples/hello/spring/annotations/SpringRequestResourceTest.java index 0f6fd4a10e..3ad9beacd1 100644 --- a/examples/helloworld-spring-annotations/src/test/java/org/glassfish/jersey/examples/hello/spring/annotations/SpringRequestResourceTest.java +++ b/examples/helloworld-spring-annotations/src/test/java/org/glassfish/jersey/examples/hello/spring/annotations/SpringRequestResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -14,8 +14,8 @@ import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -35,16 +35,16 @@ protected Application configure() { @Test public void testGreet() throws Exception { final String greeting = target("spring-resource").request().get(String.class); - Assert.assertEquals("hello, world 1!", greeting); + Assertions.assertEquals("hello, world 1!", greeting); final String greeting2 = target("spring-resource").request().get(String.class); - Assert.assertEquals("hello, world 2!", greeting2); + Assertions.assertEquals("hello, world 2!", greeting2); } @Test public void testGoodbye() { final String goodbye = target("spring-resource").path("goodbye").request().get(String.class); - Assert.assertEquals("goodbye, cruel world!", goodbye); + Assertions.assertEquals("goodbye, cruel world!", goodbye); final String norwegianGoodbye = target("spring-resource").path("norwegian-goodbye").request().get(String.class); - Assert.assertEquals("hadet, på badet!", norwegianGoodbye); + Assertions.assertEquals("hadet, på badet!", norwegianGoodbye); } } diff --git a/examples/helloworld-spring-webapp/pom.xml b/examples/helloworld-spring-webapp/pom.xml index 0610019755..ce322941eb 100644 --- a/examples/helloworld-spring-webapp/pom.xml +++ b/examples/helloworld-spring-webapp/pom.xml @@ -76,8 +76,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/examples/helloworld-webapp/src/test/java/org/glassfish/jersey/examples/helloworld/webapp/HelloWorldTest.java b/examples/helloworld-webapp/src/test/java/org/glassfish/jersey/examples/helloworld/webapp/HelloWorldTest.java index 922816541e..a5b9f9b235 100644 --- a/examples/helloworld-webapp/src/test/java/org/glassfish/jersey/examples/helloworld/webapp/HelloWorldTest.java +++ b/examples/helloworld-webapp/src/test/java/org/glassfish/jersey/examples/helloworld/webapp/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -16,9 +16,9 @@ import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Simple test to check "Hello World!" is being returned from the helloworld resource. diff --git a/examples/helloworld-weld/pom.xml b/examples/helloworld-weld/pom.xml index 64b5befd07..126585fd03 100644 --- a/examples/helloworld-weld/pom.xml +++ b/examples/helloworld-weld/pom.xml @@ -84,6 +84,9 @@ org.glassfish.jersey.examples.helloworld.App + + maven-surefire-plugin + diff --git a/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/AppScopedResourceTest.java b/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/AppScopedResourceTest.java index 4b324633d4..e736acad11 100644 --- a/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/AppScopedResourceTest.java +++ b/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/AppScopedResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -17,10 +17,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; import org.jboss.weld.environment.se.Weld; - -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for the {@link AppScopedResource} JAX-RS resource class. @@ -31,6 +32,7 @@ public class AppScopedResourceTest extends JerseyTest { Weld weld; + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -38,6 +40,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); diff --git a/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java b/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java index 9343440ece..c59b686f6e 100644 --- a/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java +++ b/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -16,9 +16,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; import org.jboss.weld.environment.se.Weld; - -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test for the {@link HelloWorldResource} JAX-RS resource class. @@ -29,6 +30,7 @@ public class HelloWorldTest extends JerseyTest { private Weld weld; + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -36,6 +38,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); @@ -55,8 +58,9 @@ protected ResourceConfig configure() { @Test public void testHelloWorld() { - Response response = target().path("helloworld").queryParam("name", "Josef").request("text/plain").get(); + String name = "Josef"; + Response response = target().path("helloworld").queryParam("name", name).request("text/plain").get(); assertEquals(200, response.getStatus()); - assertEquals(String.format("Hello %s", "Josef"), response.readEntity(String.class)); + assertEquals(String.format("Hello %s", name), response.readEntity(String.class)); } } diff --git a/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/RequestScopeAlignmentTest.java b/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/RequestScopeAlignmentTest.java index e3dfea8e37..365d749e53 100644 --- a/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/RequestScopeAlignmentTest.java +++ b/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/RequestScopeAlignmentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,24 +10,18 @@ package org.glassfish.jersey.examples.helloworld; -import java.util.Arrays; -import java.util.List; - import javax.ws.rs.client.WebTarget; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for the request scoped managed bean resource. @@ -38,13 +32,13 @@ public class RequestScopeAlignmentTest extends JerseyTest { static Weld weld; - @BeforeClass + @BeforeAll public static void before() throws Exception { weld = new Weld(); weld.initialize(); } - @AfterClass + @AfterAll public static void after() throws Exception { weld.shutdown(); } diff --git a/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/RequestScopedResourceTest.java b/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/RequestScopedResourceTest.java index 17213f17bd..b5b7f03214 100644 --- a/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/RequestScopedResourceTest.java +++ b/examples/helloworld-weld/src/test/java/org/glassfish/jersey/examples/helloworld/RequestScopedResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -13,21 +13,25 @@ import java.util.Iterator; import java.util.Random; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; import javax.ws.rs.core.Response; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.test.util.runner.ConcurrentParameterizedRunner; - import org.jboss.weld.environment.se.Weld; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test request scoped resource. Number of various requests will be made in parallel @@ -36,7 +40,7 @@ * * @author Jakub Podlesak */ -@RunWith(ConcurrentParameterizedRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class RequestScopedResourceTest extends JerseyTest { // Total number of requests to make @@ -55,13 +59,11 @@ public class RequestScopedResourceTest extends JerseyTest { * * @return iterable test input data */ - @Parameterized.Parameters - public static Iterable data() { - return new Iterable() { - + public static Stream data() { + Iterable iterable = new Iterable() { @Override - public Iterator iterator() { - return new Iterator() { + public Iterator iterator() { + return new Iterator() { @Override public boolean hasNext() { @@ -69,11 +71,9 @@ public boolean hasNext() { } @Override - public Object[] next() { - Object[] result = new Object[1]; + public Arguments next() { int nextValue = dataFeed.getAndIncrement(); - result[0] = String.format("%02d", nextValue); - return result; + return Arguments.of(String.format("%02d", nextValue)); } @Override @@ -83,26 +83,20 @@ public void remove() { }; } }; + return StreamSupport.stream(iterable.spliterator(), false); } - @BeforeClass + @BeforeAll public static void before() throws Exception { weld = new Weld(); weld.initialize(); } - @AfterClass + @AfterAll public static void after() throws Exception { weld.shutdown(); } - @Override - public void tearDown() throws Exception { - super.tearDown(); - System.out.printf("SYNC: %d, ASYNC: %d, STRAIGHT: %d%n", - parameterizedCounter.intValue(), parameterizedAsyncCounter.intValue(), straightCounter.intValue()); - } - @Override protected ResourceConfig configure() { // enable(TestProperties.LOG_TRAFFIC); @@ -114,7 +108,9 @@ protected ResourceConfig configure() { final AtomicInteger parameterizedAsyncCounter = new AtomicInteger(0); final AtomicInteger straightCounter = new AtomicInteger(0); - @Test + @Execution(ExecutionMode.CONCURRENT) + @ParameterizedTest + @MethodSource("data") public void testRequestScopedResource(final String param) { String path; @@ -139,7 +135,7 @@ public void testRequestScopedResource(final String param) { final Response response = target().path(path).queryParam("q", param).request("text/plain").get(); - assertNotNull(String.format("Request failed for %s", path), response); + assertNotNull(response, String.format("Request failed for %s", path)); assertEquals(200, response.getStatus()); assertEquals(expected, response.readEntity(String.class)); } diff --git a/examples/helloworld/pom.xml b/examples/helloworld/pom.xml index db2aeef24d..d45d38cac5 100644 --- a/examples/helloworld/pom.xml +++ b/examples/helloworld/pom.xml @@ -65,6 +65,9 @@ org.glassfish.jersey.examples.helloworld.App + + maven-surefire-plugin + diff --git a/examples/helloworld/src/test/java/org/glassfish/jersey/examples/helloworld/CustomLoggingFilter.java b/examples/helloworld/src/test/java/org/glassfish/jersey/examples/helloworld/CustomLoggingFilter.java index 4e04d4674f..c37f6bdec6 100644 --- a/examples/helloworld/src/test/java/org/glassfish/jersey/examples/helloworld/CustomLoggingFilter.java +++ b/examples/helloworld/src/test/java/org/glassfish/jersey/examples/helloworld/CustomLoggingFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -21,7 +21,7 @@ import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.ContainerResponseFilter; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Custom logging filter. @@ -37,28 +37,28 @@ public class CustomLoggingFilter implements ContainerRequestFilter, ContainerRes @Override public void filter(ClientRequestContext context) throws IOException { System.out.println("CustomLoggingFilter.preFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); preFilterCalled++; } @Override public void filter(ClientRequestContext context, ClientResponseContext clientResponseContext) throws IOException { System.out.println("CustomLoggingFilter.postFilter called"); - assertEquals(context.getConfiguration().getProperty("foo"), "bar"); + assertEquals("bar", context.getConfiguration().getProperty("foo")); postFilterCalled++; } @Override public void filter(ContainerRequestContext context) throws IOException { System.out.println("CustomLoggingFilter.preFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); preFilterCalled++; } @Override public void filter(ContainerRequestContext context, ContainerResponseContext containerResponseContext) throws IOException { System.out.println("CustomLoggingFilter.postFilter called"); - assertEquals(context.getProperty("foo"), "bar"); + assertEquals("bar", context.getProperty("foo")); postFilterCalled++; } } diff --git a/examples/helloworld/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java b/examples/helloworld/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java index 538c212313..bf0d7d5d7b 100644 --- a/examples/helloworld/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java +++ b/examples/helloworld/src/test/java/org/glassfish/jersey/examples/helloworld/HelloWorldTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -27,17 +27,19 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; -import org.glassfish.jersey.test.util.runner.RunSeparately; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; +import org.junit.jupiter.api.parallel.ResourceAccessMode; +import org.junit.jupiter.api.parallel.ResourceLock; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class HelloWorldTest extends JerseyTest { @Override @@ -58,7 +60,9 @@ protected ResourceConfig configure() { // } @Test - @Ignore("not compatible with test framework (doesn't use client())") + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) + @Disabled("not compatible with test framework (doesn't use client())") public void testHelloWorld() throws Exception { URL getUrl = UriBuilder.fromUri(getBaseUri()).path(App.ROOT_PATH).build().toURL(); HttpURLConnection connection = (HttpURLConnection) getUrl.openConnection(); @@ -74,18 +78,24 @@ public void testHelloWorld() throws Exception { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testConnection() { Response response = target().path(App.ROOT_PATH).request("text/plain").get(); assertEquals(200, response.getStatus()); } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testClientStringResponse() { String s = target().path(App.ROOT_PATH).request().get(String.class); assertEquals(HelloWorldResource.CLICHED_MESSAGE, s); } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testAsyncClientRequests() throws InterruptedException { final int REQUESTS = 10; final CountDownLatch latch = new CountDownLatch(REQUESTS); @@ -116,6 +126,8 @@ public void failed(Throwable error) { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testHead() { Response response = target().path(App.ROOT_PATH).request().head(); assertEquals(200, response.getStatus()); @@ -123,6 +135,8 @@ public void testHead() { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testFooBarOptions() { Response response = target().path(App.ROOT_PATH).request().header("Accept", "foo/bar").options(); assertEquals(200, response.getStatus()); @@ -133,6 +147,8 @@ public void testFooBarOptions() { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testTextPlainOptions() { Response response = target().path(App.ROOT_PATH).request().header("Accept", MediaType.TEXT_PLAIN).options(); assertEquals(200, response.getStatus()); @@ -150,6 +166,8 @@ private void _checkAllowContent(final String content) { } @Test + @Execution(ExecutionMode.CONCURRENT) + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ) public void testMissingResourceNotFound() { Response response; @@ -161,7 +179,7 @@ public void testMissingResourceNotFound() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testLoggingFilterClientClass() { Client client = client(); client.register(CustomLoggingFilter.class).property("foo", "bar"); @@ -173,7 +191,7 @@ public void testLoggingFilterClientClass() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testLoggingFilterClientInstance() { Client client = client(); client.register(new CustomLoggingFilter()).property("foo", "bar"); @@ -185,7 +203,7 @@ public void testLoggingFilterClientInstance() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testLoggingFilterTargetClass() { WebTarget target = target().path(App.ROOT_PATH); target.register(CustomLoggingFilter.class).property("foo", "bar"); @@ -197,7 +215,7 @@ public void testLoggingFilterTargetClass() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testLoggingFilterTargetInstance() { WebTarget target = target().path(App.ROOT_PATH); target.register(new CustomLoggingFilter()).property("foo", "bar"); @@ -209,7 +227,7 @@ public void testLoggingFilterTargetInstance() { } @Test - @RunSeparately + @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ_WRITE) public void testConfigurationUpdate() { Client client1 = client(); client1.register(CustomLoggingFilter.class).property("foo", "bar"); diff --git a/examples/http-patch/src/test/java/org/glassfish/jersey/examples/httppatch/HttpPatchTest.java b/examples/http-patch/src/test/java/org/glassfish/jersey/examples/httppatch/HttpPatchTest.java index 7c4d81ff98..e43a9f5eb7 100644 --- a/examples/http-patch/src/test/java/org/glassfish/jersey/examples/httppatch/HttpPatchTest.java +++ b/examples/http-patch/src/test/java/org/glassfish/jersey/examples/httppatch/HttpPatchTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -22,8 +22,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * HTTP PATCH Example unit tests. diff --git a/examples/http-trace/src/test/java/org/glassfish/jersey/examples/httptrace/TraceSupportTest.java b/examples/http-trace/src/test/java/org/glassfish/jersey/examples/httptrace/TraceSupportTest.java index 4dec416253..c2af58bcbd 100644 --- a/examples/http-trace/src/test/java/org/glassfish/jersey/examples/httptrace/TraceSupportTest.java +++ b/examples/http-trace/src/test/java/org/glassfish/jersey/examples/httptrace/TraceSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -24,10 +24,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class TraceSupportTest extends JerseyTest { @@ -59,9 +59,9 @@ public void testProgrammaticApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsProgrammatic) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } @@ -73,9 +73,9 @@ public void testAnnotatedApp() throws Exception { String responseEntity = response.readEntity(String.class); for (String expectedFragment : expectedFragmentsAnnotated) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // toLowerCase - http header field names are case insensitive - responseEntity.contains(expectedFragment)); + assertTrue(// toLowerCase - http header field names are case insensitive + responseEntity.contains(expectedFragment), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } diff --git a/examples/https-clientserver-grizzly/pom.xml b/examples/https-clientserver-grizzly/pom.xml index c96284fffd..668688acf5 100644 --- a/examples/https-clientserver-grizzly/pom.xml +++ b/examples/https-clientserver-grizzly/pom.xml @@ -54,8 +54,8 @@ jakarta.xml.bind-api - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/examples/https-clientserver-grizzly/src/test/java/org/glassfish/jersey/examples/httpsclientservergrizzly/MainTest.java b/examples/https-clientserver-grizzly/src/test/java/org/glassfish/jersey/examples/httpsclientservergrizzly/MainTest.java index ce21918b81..09cc994c2f 100644 --- a/examples/https-clientserver-grizzly/src/test/java/org/glassfish/jersey/examples/httpsclientservergrizzly/MainTest.java +++ b/examples/https-clientserver-grizzly/src/test/java/org/glassfish/jersey/examples/httpsclientservergrizzly/MainTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -24,11 +24,11 @@ import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider; import org.glassfish.jersey.logging.LoggingFeature; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * This test class starts the grizzly server and then client performs several SSL (https) @@ -48,7 +48,7 @@ public class MainTest { private final Object serverGuard = new Object(); private Server server = null; - @Before + @BeforeEach public void setUp() throws Exception { synchronized (serverGuard) { if (server != null) { @@ -59,7 +59,7 @@ public void setUp() throws Exception { } } - @After + @AfterEach public void tearDown() throws Exception { synchronized (serverGuard) { if (server == null) { diff --git a/examples/java8-webapp/src/test/java/org/glassfish/jersey/examples/java8/DefaultMethodResourceTest.java b/examples/java8-webapp/src/test/java/org/glassfish/jersey/examples/java8/DefaultMethodResourceTest.java index 3515b514da..fd63730eb2 100644 --- a/examples/java8-webapp/src/test/java/org/glassfish/jersey/examples/java8/DefaultMethodResourceTest.java +++ b/examples/java8-webapp/src/test/java/org/glassfish/jersey/examples/java8/DefaultMethodResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -15,8 +15,8 @@ import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test usage of Java8's interface default methods as resource methods. diff --git a/examples/java8-webapp/src/test/java/org/glassfish/jersey/examples/java8/LambdaResourceTest.java b/examples/java8-webapp/src/test/java/org/glassfish/jersey/examples/java8/LambdaResourceTest.java index ce52d78846..96e314500c 100644 --- a/examples/java8-webapp/src/test/java/org/glassfish/jersey/examples/java8/LambdaResourceTest.java +++ b/examples/java8-webapp/src/test/java/org/glassfish/jersey/examples/java8/LambdaResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -15,9 +15,9 @@ import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test usage of Java SE 8 lambdas in JAX-RS resource methods. diff --git a/examples/jaxb/src/test/java/org/glassfish/jersey/examples/jaxb/JaxbTest.java b/examples/jaxb/src/test/java/org/glassfish/jersey/examples/jaxb/JaxbTest.java index c887ae3f9d..ff63be2856 100644 --- a/examples/jaxb/src/test/java/org/glassfish/jersey/examples/jaxb/JaxbTest.java +++ b/examples/jaxb/src/test/java/org/glassfish/jersey/examples/jaxb/JaxbTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -23,9 +23,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Jersey JAXB example test. @@ -49,8 +49,7 @@ protected ResourceConfig configure() { @Test public void testApplicationWadl() { String applicationWadl = target().path("application.wadl").request().get(String.class); - assertTrue("Something wrong. Returned wadl length is not > 0", - applicationWadl.length() > 0); + assertTrue(applicationWadl.length() > 0, "Something wrong. Returned wadl length is not > 0"); } @Test diff --git a/examples/jaxrs-types-injection/src/test/java/org/glassfish/jersey/examples/jaxrstypeinjection/JaxrsTypeInjectionTest.java b/examples/jaxrs-types-injection/src/test/java/org/glassfish/jersey/examples/jaxrstypeinjection/JaxrsTypeInjectionTest.java index d9e87e15df..7c113f5b58 100644 --- a/examples/jaxrs-types-injection/src/test/java/org/glassfish/jersey/examples/jaxrstypeinjection/JaxrsTypeInjectionTest.java +++ b/examples/jaxrs-types-injection/src/test/java/org/glassfish/jersey/examples/jaxrstypeinjection/JaxrsTypeInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -16,8 +16,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; public class JaxrsTypeInjectionTest extends JerseyTest { @@ -91,9 +91,9 @@ public void testProgrammaticApp() throws Exception { .toLowerCase(); for (String expectedFragment : expectedFragmentsProgrammatic) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // http header field names are case insensitive - responseEntity.contains(expectedFragment.toLowerCase())); + assertTrue(// http header field names are case insensitive + responseEntity.contains(expectedFragment.toLowerCase()), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } @@ -103,9 +103,9 @@ public void testAnnotatedInstanceApp() throws Exception { .toLowerCase(); for (String expectedFragment : expectedFragmentsAnnotatedInstance) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // http header field names are case insensitive - responseEntity.contains(expectedFragment.toLowerCase())); + assertTrue(// http header field names are case insensitive + responseEntity.contains(expectedFragment.toLowerCase()), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } @@ -115,9 +115,9 @@ public void testAnnotatedMethodApp() throws Exception { .toLowerCase(); for (String expectedFragment : expectedFragmentsAnnotatedMethod) { - assertTrue("Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity, - // http header field names are case insensitive - responseEntity.contains(expectedFragment.toLowerCase())); + assertTrue(// http header field names are case insensitive + responseEntity.contains(expectedFragment.toLowerCase()), + "Expected fragment '" + expectedFragment + "' not found in response:\n" + responseEntity); } } } diff --git a/examples/jersey-ejb/src/test/java/org/glassfish/jersey/examples/jersey_ejb/test/MessageBoardTest.java b/examples/jersey-ejb/src/test/java/org/glassfish/jersey/examples/jersey_ejb/test/MessageBoardTest.java index 5d5b4550f8..b96640f23f 100644 --- a/examples/jersey-ejb/src/test/java/org/glassfish/jersey/examples/jersey_ejb/test/MessageBoardTest.java +++ b/examples/jersey-ejb/src/test/java/org/glassfish/jersey/examples/jersey_ejb/test/MessageBoardTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -21,10 +21,10 @@ import org.glassfish.jersey.examples.jersey_ejb.resources.MyApplication; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Basic test for adding/removing messages. @@ -56,9 +56,8 @@ protected URI getBaseUri() { public void testListMessages() { Response response = target().path("app/messages").request(MediaType.TEXT_HTML).get(); - assertEquals( - String.format("Response status should be 200. Current value is %d.", response.getStatus()), - 200, response.getStatus()); + assertEquals(200, response.getStatus(), + String.format("Response status should be 200. Current value is %d.", response.getStatus())); } @Test @@ -67,8 +66,8 @@ public void testAddMessage() { Response response = target().path("app/messages").request(MediaType.TEXT_PLAIN) .post(Entity.entity("hello world!", MediaType.TEXT_PLAIN)); - assertEquals("Response status should be CREATED. Current value is \"" + response.getStatus() + "\"", - Response.Status.CREATED.getStatusCode(), response.getStatus()); + assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus(), + "Response status should be CREATED. Current value is \"" + response.getStatus() + "\""); client().target(response.getLocation()).request().delete(); // remove added message } @@ -91,14 +90,14 @@ public void testDeleteMessage() { Response firstDeleteResponse = client().target(u).request().delete(); final int successfulDeleteResponseStatus = firstDeleteResponse.getStatus(); - assertTrue("First DELETE request should return with a 2xx status code", - (200 <= successfulDeleteResponseStatus) && (successfulDeleteResponseStatus < 300)); + assertTrue((200 <= successfulDeleteResponseStatus) && (successfulDeleteResponseStatus < 300), + "First DELETE request should return with a 2xx status code"); Response nonExistentGetResponse = client().target(u).request().get(); - assertEquals("GET request to a non existent resource should return 404", 404, nonExistentGetResponse.getStatus()); + assertEquals(404, nonExistentGetResponse.getStatus(), "GET request to a non existent resource should return 404"); Response nonExistentDeleteResponse = client().target(u).request().delete(); - assertEquals("DELETE request to a non existent resource should return 404", 404, nonExistentDeleteResponse.getStatus()); + assertEquals(404, nonExistentDeleteResponse.getStatus(), "DELETE request to a non existent resource should return 404"); } } diff --git a/examples/json-jackson/src/test/java/org/glassfish/jersey/examples/jackson/JacksonTest.java b/examples/json-jackson/src/test/java/org/glassfish/jersey/examples/jackson/JacksonTest.java index 9bef3a6e40..3e930686e2 100644 --- a/examples/json-jackson/src/test/java/org/glassfish/jersey/examples/jackson/JacksonTest.java +++ b/examples/json-jackson/src/test/java/org/glassfish/jersey/examples/jackson/JacksonTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -21,20 +21,21 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.runner.RunWith; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Jakub Podlesak */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class JacksonTest extends JerseyTest { @Override @@ -51,6 +52,7 @@ protected void configureClient(ClientConfig config) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testEmptyArrayPresent() { WebTarget target = target(); String responseMsg = target.path("emptyArrayResource").request(MediaType.APPLICATION_JSON).get(String.class); @@ -58,6 +60,7 @@ public void testEmptyArrayPresent() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJSONPPresent() { WebTarget target = target(); String responseMsg = target.path("nonJaxbResource").request("application/javascript").get(String.class); @@ -65,6 +68,7 @@ public void testJSONPPresent() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJSONDoesNotReflectJSONPWrapper() { WebTarget target = target(); String responseMsg = target.path("nonJaxbResource").request("application/json").get(String.class); @@ -72,6 +76,7 @@ public void testJSONDoesNotReflectJSONPWrapper() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testCombinedAnnotationResource() { WebTarget target = target(); String responseMsg = target.path("combinedAnnotations").request("application/json").get(String.class); @@ -79,6 +84,7 @@ public void testCombinedAnnotationResource() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testEmptyArrayBean() { WebTarget target = target(); EmptyArrayBean responseMsg = target.path("emptyArrayResource").request(MediaType.APPLICATION_JSON) @@ -87,6 +93,7 @@ public void testEmptyArrayBean() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testCombinedAnnotationBean() { WebTarget target = target(); CombinedAnnotationBean responseMsg = target.path("combinedAnnotations").request("application/json") @@ -95,7 +102,8 @@ public void testCombinedAnnotationBean() { } @Test - @Ignore + @Execution(ExecutionMode.CONCURRENT) + @Disabled // TODO un-ignore once a JSON reader for "application/javascript" is supported public void testJSONPBean() { WebTarget target = target(); @@ -109,6 +117,7 @@ public void testJSONPBean() { *

*/ @Test + @Execution(ExecutionMode.CONCURRENT) public void testApplicationWadl() { WebTarget target = target(); String serviceWadl = target.path("application.wadl").request(MediaTypes.WADL_TYPE).get(String.class); @@ -121,6 +130,7 @@ public void testApplicationWadl() { * 400 - bad request instead of 500 - server error */ @Test + @Execution(ExecutionMode.CONCURRENT) public void testExceptionMapping() { enable(TestProperties.LOG_TRAFFIC); // create a request with invalid json string to cause an exception in Jackson diff --git a/examples/json-jackson1/src/test/java/org/glassfish/jersey/examples/jackson1/Jackson1Test.java b/examples/json-jackson1/src/test/java/org/glassfish/jersey/examples/jackson1/Jackson1Test.java index d2c9be0e84..ff56201323 100644 --- a/examples/json-jackson1/src/test/java/org/glassfish/jersey/examples/jackson1/Jackson1Test.java +++ b/examples/json-jackson1/src/test/java/org/glassfish/jersey/examples/jackson1/Jackson1Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -22,11 +22,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Jakub Podlesak @@ -81,7 +81,7 @@ public void testCombinedAnnotationBean() { } @Test - @Ignore + @Disabled // TODO un-ignore once a JSON reader for "application/javascript" is supported public void testJSONPBean() { assertNotNull(target("nonJaxbResource").request("application/javascript").get(NonJaxbBean.class)); diff --git a/examples/json-jettison/src/test/java/org/glassfish/jersey/examples/jettison/JsonJettisonTest.java b/examples/json-jettison/src/test/java/org/glassfish/jersey/examples/jettison/JsonJettisonTest.java index 0f36b6b037..4943e6cc19 100644 --- a/examples/json-jettison/src/test/java/org/glassfish/jersey/examples/jettison/JsonJettisonTest.java +++ b/examples/json-jettison/src/test/java/org/glassfish/jersey/examples/jettison/JsonJettisonTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -21,10 +21,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Jakub Podlesak @@ -44,7 +44,7 @@ protected void configureClient(ClientConfig config) { config.register(new JettisonFeature()).register(JaxbContextResolver.class); } - @Before + @BeforeEach @Override public void setUp() throws Exception { super.setUp(); @@ -60,7 +60,7 @@ public void setUp() throws Exception { @Test public void testApplicationWadl() { String applicationWadl = target().path("application.wadl").request().get(String.class); - assertTrue("Something wrong. Returned wadl length is not > 0", applicationWadl.length() > 0); + assertTrue(applicationWadl.length() > 0, "Something wrong. Returned wadl length is not > 0"); } /** @@ -71,7 +71,7 @@ public void testGetOnFlightsJSONFormat() { // get the initial representation Flights flights = target().path("flights").request("application/json").get(Flights.class); // check that there are two flight entries - assertEquals("Expected number of initial entries not found", 2, flights.getFlight().size()); + assertEquals(2, flights.getFlight().size(), "Expected number of initial entries not found"); } /** @@ -83,7 +83,7 @@ public void testPutOnFlightsJSONFormat() { Flights flights = target().path("flights") .request("application/json").get(Flights.class); // check that there are two flight entries - assertEquals("Expected number of initial entries not found", 2, flights.getFlight().size()); + assertEquals(2, flights.getFlight().size(), "Expected number of initial entries not found"); // remove the second flight entry if (flights.getFlight().size() > 1) { @@ -100,10 +100,10 @@ public void testPutOnFlightsJSONFormat() { // get the updated list out from the server: Flights updatedFlights = target().path("flights").request("application/json").get(Flights.class); //check that there is only one flight entry - assertEquals("Remaining number of flight entries do not match the expected value", 1, updatedFlights.getFlight().size()); + assertEquals(1, updatedFlights.getFlight().size(), "Remaining number of flight entries do not match the expected value"); // check that the flight entry in retrieved list has FlightID OK!@% - assertEquals("Retrieved flight ID doesn't match the expected value", "OK125", - updatedFlights.getFlight().get(0).getFlightId()); + assertEquals("OK125", updatedFlights.getFlight().get(0).getFlightId(), + "Retrieved flight ID doesn't match the expected value"); } /** @@ -114,7 +114,7 @@ public void testGetOnFlightsXMLFormat() { // get the initial representation Flights flights = target().path("flights").request("application/xml").get(Flights.class); // check that there are two flight entries - assertEquals("Expected number of initial entries not found", 2, flights.getFlight().size()); + assertEquals(2, flights.getFlight().size(), "Expected number of initial entries not found"); } /** @@ -125,7 +125,7 @@ public void testPutOnFlightsXMLFormat() { // get the initial representation Flights flights = target().path("flights").request("application/XML").get(Flights.class); // check that there are two flight entries - assertEquals("Expected number of initial entries not found", 2, flights.getFlight().size()); + assertEquals(2, flights.getFlight().size(), "Expected number of initial entries not found"); // remove the second flight entry if (flights.getFlight().size() > 1) { @@ -142,10 +142,10 @@ public void testPutOnFlightsXMLFormat() { // get the updated list out from the server: Flights updatedFlights = target().path("flights").request("application/XML").get(Flights.class); //check that there is only one flight entry - assertEquals("Remaining number of flight entries do not match the expected value", 1, updatedFlights.getFlight().size()); + assertEquals(1, updatedFlights.getFlight().size(), "Remaining number of flight entries do not match the expected value"); // check that the flight entry in retrieved list has FlightID OK!@% - assertEquals("Retrieved flight ID doesn't match the expected value", "OK125", - updatedFlights.getFlight().get(0).getFlightId()); + assertEquals("OK125", updatedFlights.getFlight().get(0).getFlightId(), + "Retrieved flight ID doesn't match the expected value"); } /** @@ -158,6 +158,6 @@ public void testGetOnAircraftsJSONFormat() { // get the initial representation List aircraftTypes = target().path("aircrafts").request("application/json").get(listOfAircrafts); // check that there are two aircraft type entries - assertEquals("Expected number of initial aircraft types not found", 2, aircraftTypes.size()); + assertEquals(2, aircraftTypes.size(), "Expected number of initial aircraft types not found"); } } diff --git a/examples/json-moxy/src/test/java/org/glassfish/jersey/examples/jsonmoxy/JsonResourceTest.java b/examples/json-moxy/src/test/java/org/glassfish/jersey/examples/jsonmoxy/JsonResourceTest.java index 8ea7611d99..86af7ae9a7 100644 --- a/examples/json-moxy/src/test/java/org/glassfish/jersey/examples/jsonmoxy/JsonResourceTest.java +++ b/examples/json-moxy/src/test/java/org/glassfish/jersey/examples/jsonmoxy/JsonResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -19,8 +19,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/examples/json-processing-webapp/src/test/java/org/glassfish/jersey/examples/jsonp/JsonProcessingResourceTest.java b/examples/json-processing-webapp/src/test/java/org/glassfish/jersey/examples/jsonp/JsonProcessingResourceTest.java index 9b686c1633..f8566fd6f0 100644 --- a/examples/json-processing-webapp/src/test/java/org/glassfish/jersey/examples/jsonp/JsonProcessingResourceTest.java +++ b/examples/json-processing-webapp/src/test/java/org/glassfish/jersey/examples/jsonp/JsonProcessingResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -32,9 +32,9 @@ import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos diff --git a/examples/json-with-padding/src/test/java/org/glassfish/jersey/examples/jsonp/JsonWithPaddingTest.java b/examples/json-with-padding/src/test/java/org/glassfish/jersey/examples/jsonp/JsonWithPaddingTest.java index c674923d1b..79a508e1c3 100644 --- a/examples/json-with-padding/src/test/java/org/glassfish/jersey/examples/jsonp/JsonWithPaddingTest.java +++ b/examples/json-with-padding/src/test/java/org/glassfish/jersey/examples/jsonp/JsonWithPaddingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -19,9 +19,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Jakub Podlesak @@ -44,7 +44,7 @@ protected ResourceConfig configure() { public void testApplicationWadl() { WebTarget target = target(); String applicationWadl = target.path("application.wadl").request().get(String.class); - assertTrue("Something wrong. Returned wadl length is not > 0", applicationWadl.length() > 0); + assertTrue(applicationWadl.length() > 0, "Something wrong. Returned wadl length is not > 0"); } /** @@ -57,7 +57,7 @@ public void testGetOnChangesJSONFormat() { // get the initial representation List changes = target.path("changes").request("application/json").get(genericType); // check that there are two changes entries - assertEquals("Expected number of initial changes not found", 5, changes.size()); + assertEquals(5, changes.size(), "Expected number of initial changes not found"); } /** diff --git a/examples/managed-beans-webapp/src/test/java/org/glassfish/jersey/examples/managedbeans/ManagedBeanWebAppTest.java b/examples/managed-beans-webapp/src/test/java/org/glassfish/jersey/examples/managedbeans/ManagedBeanWebAppTest.java index 662685c086..f6ea9461b6 100644 --- a/examples/managed-beans-webapp/src/test/java/org/glassfish/jersey/examples/managedbeans/ManagedBeanWebAppTest.java +++ b/examples/managed-beans-webapp/src/test/java/org/glassfish/jersey/examples/managedbeans/ManagedBeanWebAppTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -22,7 +22,7 @@ import org.glassfish.jersey.message.internal.MediaTypes; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; diff --git a/examples/managed-client-simple-webapp/src/test/java/org/glassfish/jersey/examples/managedclientsimple/ManagedClientSimpleTest.java b/examples/managed-client-simple-webapp/src/test/java/org/glassfish/jersey/examples/managedclientsimple/ManagedClientSimpleTest.java index 8610f890f5..d49a024755 100644 --- a/examples/managed-client-simple-webapp/src/test/java/org/glassfish/jersey/examples/managedclientsimple/ManagedClientSimpleTest.java +++ b/examples/managed-client-simple-webapp/src/test/java/org/glassfish/jersey/examples/managedclientsimple/ManagedClientSimpleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Miroslav Fuksa diff --git a/examples/managed-client-webapp/src/test/java/org/glassfish/jersey/examples/managedclient/ManagedClientTest.java b/examples/managed-client-webapp/src/test/java/org/glassfish/jersey/examples/managedclient/ManagedClientTest.java index bc5a38e457..68fcabdcc4 100644 --- a/examples/managed-client-webapp/src/test/java/org/glassfish/jersey/examples/managedclient/ManagedClientTest.java +++ b/examples/managed-client-webapp/src/test/java/org/glassfish/jersey/examples/managedclient/ManagedClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -21,8 +21,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Jersey managed client example tests. diff --git a/examples/managed-client/src/test/java/org/glassfish/jersey/examples/managedclient/ManagedClientTest.java b/examples/managed-client/src/test/java/org/glassfish/jersey/examples/managedclient/ManagedClientTest.java index dc6a1bee60..25de43c0d1 100644 --- a/examples/managed-client/src/test/java/org/glassfish/jersey/examples/managedclient/ManagedClientTest.java +++ b/examples/managed-client/src/test/java/org/glassfish/jersey/examples/managedclient/ManagedClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -18,8 +18,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Jersey managed client example tests. diff --git a/examples/multipart-webapp/src/test/java/org/glassfish/jersey/examples/multipart/webapp/MultiPartWebAppTest.java b/examples/multipart-webapp/src/test/java/org/glassfish/jersey/examples/multipart/webapp/MultiPartWebAppTest.java index ad1a346688..677ff22de3 100644 --- a/examples/multipart-webapp/src/test/java/org/glassfish/jersey/examples/multipart/webapp/MultiPartWebAppTest.java +++ b/examples/multipart-webapp/src/test/java/org/glassfish/jersey/examples/multipart/webapp/MultiPartWebAppTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -35,9 +35,9 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for {@code MultipartResource} class. diff --git a/examples/osgi-helloworld-webapp/functional-test/pom.xml b/examples/osgi-helloworld-webapp/functional-test/pom.xml index dc12eaab08..038517f0b5 100644 --- a/examples/osgi-helloworld-webapp/functional-test/pom.xml +++ b/examples/osgi-helloworld-webapp/functional-test/pom.xml @@ -123,6 +123,7 @@ junit junit + ${junit4.version} test diff --git a/examples/osgi-http-service/functional-test/pom.xml b/examples/osgi-http-service/functional-test/pom.xml index 2777ad5dbd..60f5a0ad3f 100644 --- a/examples/osgi-http-service/functional-test/pom.xml +++ b/examples/osgi-http-service/functional-test/pom.xml @@ -122,6 +122,7 @@ junit junit + ${junit4.version} test @@ -218,7 +219,7 @@ org.glassfish.jersey.examples.osgihttpservice.test.GrizzlyHttpServiceFelixTest diff --git a/examples/reload/src/test/java/org/glassfish/jersey/examples/reload/ReloadTest.java b/examples/reload/src/test/java/org/glassfish/jersey/examples/reload/ReloadTest.java index 81079e4bce..bb5763ffcf 100644 --- a/examples/reload/src/test/java/org/glassfish/jersey/examples/reload/ReloadTest.java +++ b/examples/reload/src/test/java/org/glassfish/jersey/examples/reload/ReloadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -19,9 +19,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * This is to test the reload feature without updating the resources text file. @@ -65,7 +65,7 @@ public void testReload() { // check stats response = target().path("stats").request(MediaType.TEXT_PLAIN).get(); assertEquals(200, response.getStatus()); - assertTrue("1 expected as number of arrivals hits in stats", response.readEntity(String.class).contains("1")); + assertTrue(response.readEntity(String.class).contains("1"), "1 expected as number of arrivals hits in stats"); // another arrivals hit response = target().path("arrivals").request(MediaType.TEXT_PLAIN).get(); @@ -74,7 +74,7 @@ public void testReload() { // check updated stats response = target().path("stats").request(MediaType.TEXT_PLAIN).get(); assertEquals(200, response.getStatus()); - assertTrue("2 expected as number of arrivals hits in stats", response.readEntity(String.class).contains("2")); + assertTrue(response.readEntity(String.class).contains("2"), "2 expected as number of arrivals hits in stats"); // remove stats container.reload(new ResourceConfig(ArrivalsResource.class)); diff --git a/examples/rx-client-webapp/src/test/java/org/glassfish/jersey/examples/rx/RxClientsTest.java b/examples/rx-client-webapp/src/test/java/org/glassfish/jersey/examples/rx/RxClientsTest.java index 271d91f328..737a28c223 100644 --- a/examples/rx-client-webapp/src/test/java/org/glassfish/jersey/examples/rx/RxClientsTest.java +++ b/examples/rx-client-webapp/src/test/java/org/glassfish/jersey/examples/rx/RxClientsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -17,7 +17,7 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.ServletDeploymentContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/examples/server-async-managed/src/test/java/org/glassfish/jersey/examples/server/async/managed/ManagedAsyncResourceTest.java b/examples/server-async-managed/src/test/java/org/glassfish/jersey/examples/server/async/managed/ManagedAsyncResourceTest.java index c8f54ebaa2..07032f09b5 100644 --- a/examples/server-async-managed/src/test/java/org/glassfish/jersey/examples/server/async/managed/ManagedAsyncResourceTest.java +++ b/examples/server-async-managed/src/test/java/org/glassfish/jersey/examples/server/async/managed/ManagedAsyncResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -34,10 +34,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test for the asynchronous managed resources example. @@ -149,9 +149,8 @@ private void get() { LOGGER.info(messageBuilder.toString()); for (Map.Entry entry : getResponses.entrySet()) { - assertTrue( - "Unexpected GET notification response for message " + entry.getKey(), - entry.getValue().contains(expectedResponse)); + assertTrue(entry.getValue().contains(expectedResponse), + "Unexpected GET notification response for message " + entry.getKey()); } assertEquals(MAX_MESSAGES, getResponses.size()); } @@ -293,9 +292,8 @@ private void get() { LOGGER.info(messageBuilder.toString()); for (Map.Entry postResponseEntry : postResponses.entrySet()) { - assertEquals( - "Unexpected POST notification response for message " + postResponseEntry.getKey(), - 200, postResponseEntry.getValue().intValue()); + assertEquals(200, postResponseEntry.getValue().intValue(), + "Unexpected POST notification response for message " + postResponseEntry.getKey()); } final List lost = new LinkedList(); diff --git a/examples/server-async-standalone/client/pom.xml b/examples/server-async-standalone/client/pom.xml index 567abdcc6e..b03d5baf9b 100644 --- a/examples/server-async-standalone/client/pom.xml +++ b/examples/server-async-standalone/client/pom.xml @@ -46,8 +46,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/examples/server-async-standalone/client/src/test/java/org/glassfish/jersey/examples/server/async/MainTest.java b/examples/server-async-standalone/client/src/test/java/org/glassfish/jersey/examples/server/async/MainTest.java index 2826e44eb1..240b53a112 100644 --- a/examples/server-async-standalone/client/src/test/java/org/glassfish/jersey/examples/server/async/MainTest.java +++ b/examples/server-async-standalone/client/src/test/java/org/glassfish/jersey/examples/server/async/MainTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -10,8 +10,8 @@ package org.glassfish.jersey.examples.server.async; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test whether cases described in {@code README} are passing. diff --git a/examples/server-async/src/test/java/org/glassfish/jersey/examples/server/async/AsyncResourceTest.java b/examples/server-async/src/test/java/org/glassfish/jersey/examples/server/async/AsyncResourceTest.java index 1e7c8dce62..b66ff6416e 100644 --- a/examples/server-async/src/test/java/org/glassfish/jersey/examples/server/async/AsyncResourceTest.java +++ b/examples/server-async/src/test/java/org/glassfish/jersey/examples/server/async/AsyncResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -34,10 +34,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class AsyncResourceTest extends JerseyTest { @@ -197,9 +197,8 @@ private void get() { LOGGER.info(messageBuilder.toString()); for (Map.Entry postResponseEntry : postResponses.entrySet()) { - assertEquals( - String.format("Unexpected POST notification response for message %02d", postResponseEntry.getKey()), - expectedPostResponse, postResponseEntry.getValue()); + assertEquals(expectedPostResponse, postResponseEntry.getValue(), + String.format("Unexpected POST notification response for message %02d", postResponseEntry.getKey())); } final List lost = new LinkedList(); @@ -309,9 +308,8 @@ public int compare(Map.Entry o1, Map.Entry o2) LOGGER.info(messageBuilder.toString()); for (Map.Entry entry : responseEntryList) { - assertEquals( - String.format("Unexpected GET notification response for message %02d", entry.getKey()), - expectedResponse, entry.getValue()); + assertEquals(expectedResponse, entry.getValue(), + String.format("Unexpected GET notification response for message %02d", entry.getKey())); } assertEquals(MAX_MESSAGES, getResponses.size()); } diff --git a/examples/server-sent-events-jaxrs/src/test/java/org/glassfish/jersey/examples/sse/jaxrs/ServerSentEventsTest.java b/examples/server-sent-events-jaxrs/src/test/java/org/glassfish/jersey/examples/sse/jaxrs/ServerSentEventsTest.java index 7078512dbb..8ae98c38be 100644 --- a/examples/server-sent-events-jaxrs/src/test/java/org/glassfish/jersey/examples/sse/jaxrs/ServerSentEventsTest.java +++ b/examples/server-sent-events-jaxrs/src/test/java/org/glassfish/jersey/examples/sse/jaxrs/ServerSentEventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -30,12 +30,12 @@ import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; - -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * SSE example resources test. @@ -61,6 +61,7 @@ protected Client getClient() { return client; } + @AfterEach @Override public void tearDown() throws Exception { super.tearDown(); @@ -89,8 +90,8 @@ public void testEventSource() throws Exception { target().path(App.ROOT_PATH).request().post(Entity.text("message")).close(); try { - assertTrue("Waiting for message to be delivered has timed out.", - latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS)); + assertTrue(latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), + "Waiting for message to be delivered has timed out."); } finally { target().path(App.ROOT_PATH).request().delete().close(); eventSource.close(); diff --git a/examples/server-sent-events-jersey/src/test/java/org/glassfish/jersey/examples/sse/jersey/ServerSentEventsTest.java b/examples/server-sent-events-jersey/src/test/java/org/glassfish/jersey/examples/sse/jersey/ServerSentEventsTest.java index 56ee494c36..9da0021edd 100644 --- a/examples/server-sent-events-jersey/src/test/java/org/glassfish/jersey/examples/sse/jersey/ServerSentEventsTest.java +++ b/examples/server-sent-events-jersey/src/test/java/org/glassfish/jersey/examples/sse/jersey/ServerSentEventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -39,12 +39,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * SSE example resources test. @@ -93,8 +93,8 @@ public void onEvent(InboundEvent inboundEvent) { target().path(App.ROOT_PATH).request().post(Entity.text("message")); try { - assertTrue("Waiting for message to be delivered has timed out.", - latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS)); + assertTrue(latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), + "Waiting for message to be delivered has timed out."); } finally { eventSource.close(); } @@ -139,8 +139,8 @@ public List call() throws Exception { } }); - assertTrue("Waiting for receiver thread to start has timed out.", - startLatch.await(5, TimeUnit.SECONDS)); + assertTrue(startLatch.await(5, TimeUnit.SECONDS), + "Waiting for receiver thread to start has timed out."); for (int i = 0; i < MAX_MESSAGES; i++) { target(App.ROOT_PATH).request().post(Entity.text("message " + i)); diff --git a/examples/servlet3-webapp/src/test/java/Servlet3WebappITCase.java b/examples/servlet3-webapp/src/test/java/Servlet3WebappITCase.java index 0bf859b48f..a2b6d9c832 100644 --- a/examples/servlet3-webapp/src/test/java/Servlet3WebappITCase.java +++ b/examples/servlet3-webapp/src/test/java/Servlet3WebappITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -14,14 +14,14 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.UriBuilder; import java.net.URI; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests the servlet3-webapp example. diff --git a/examples/simple-console/src/test/java/org/glassfish/jersey/examples/console/MainTest.java b/examples/simple-console/src/test/java/org/glassfish/jersey/examples/console/MainTest.java index f5a58a73c1..3a5c2b5bec 100644 --- a/examples/simple-console/src/test/java/org/glassfish/jersey/examples/console/MainTest.java +++ b/examples/simple-console/src/test/java/org/glassfish/jersey/examples/console/MainTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -29,9 +29,9 @@ import org.glassfish.jersey.test.TestProperties; import org.codehaus.jettison.json.JSONArray; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Naresh (Srinivas Bhimisetty) @@ -66,8 +66,8 @@ public void testApplicationWadl() { @Test public void testGetOnForm() { Response response = target().path("form").request(MediaType.TEXT_HTML).get(); - assertEquals("GET on the 'form' resource doesn't give expected response", Response.Status.OK.getStatusCode(), - response.getStatusInfo().getStatusCode()); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusInfo().getStatusCode(), + "GET on the 'form' resource doesn't give expected response"); } /** @@ -105,17 +105,17 @@ public void testPostOnForm() { public void testGetColoursAsPlainText() { // without the query param "match" Response response = target().path("form").path("colours").request(MediaType.TEXT_PLAIN).get(); - assertEquals("GET on path '/form/colours' with mime type 'text/html' doesn't give expected response", - Response.Status.OK.getStatusCode(), response.getStatusInfo().getStatusCode()); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusInfo().getStatusCode(), + "GET on path '/form/colours' with mime type 'text/html' doesn't give expected response"); String responseMsg = target().path("form").path("colours").request(MediaType.TEXT_PLAIN).get(String.class); - assertEquals("Response content doesn't match the expected value", "red\norange\nyellow\ngreen\nblue\nindigo\nviolet\n", - responseMsg); + assertEquals("red\norange\nyellow\ngreen\nblue\nindigo\nviolet\n", responseMsg, + "Response content doesn't match the expected value"); // with the query param "match" value "re" responseMsg = target("form/colours").queryParam("match", "re").request(MediaType.TEXT_PLAIN).get(String.class); - assertEquals("Response content doesn't match the expected value with the query param 'match=re'", "red\ngreen\n", - responseMsg); + assertEquals("red\ngreen\n", responseMsg, + "Response content doesn't match the expected value with the query param 'match=re'"); } /** @@ -125,16 +125,17 @@ public void testGetColoursAsPlainText() { @Test public void testGetColoursAsJson() { Response response = target().path("form").path("colours").request(MediaType.APPLICATION_JSON).get(); - assertEquals("GET on path '/form/colours' with mime type 'application/json' doesn't give expected response", - Response.Status.OK.getStatusCode(), response.getStatusInfo().getStatusCode()); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusInfo().getStatusCode(), + "GET on path '/form/colours' with mime type 'application/json' doesn't give expected response"); JSONArray jsonArray = target().path("form").path("colours").request(MediaType.APPLICATION_JSON).get(JSONArray.class); - assertEquals("Returned JSONArray doesn't have expected number of entries", 7, jsonArray.length()); + assertEquals(7, jsonArray.length(), + "Returned JSONArray doesn't have expected number of entries"); // with the query param "match" value "re" jsonArray = target("form/colours").queryParam("match", "re").request(MediaType.APPLICATION_JSON).get(JSONArray.class); - assertEquals("Returned JSONArray doesn't have expected number of entries with the query param 'match=re'", 2, - jsonArray.length()); + assertEquals(2, jsonArray.length(), + "Returned JSONArray doesn't have expected number of entries with the query param 'match=re'"); } } diff --git a/examples/sse-item-store-jaxrs-webapp/src/test/java/org/glassfish/jersey/examples/sseitemstore/jaxrs/JaxrsItemStoreResourceTest.java b/examples/sse-item-store-jaxrs-webapp/src/test/java/org/glassfish/jersey/examples/sseitemstore/jaxrs/JaxrsItemStoreResourceTest.java index 87c85c5bd6..02ca76851d 100644 --- a/examples/sse-item-store-jaxrs-webapp/src/test/java/org/glassfish/jersey/examples/sseitemstore/jaxrs/JaxrsItemStoreResourceTest.java +++ b/examples/sse-item-store-jaxrs-webapp/src/test/java/org/glassfish/jersey/examples/sseitemstore/jaxrs/JaxrsItemStoreResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -45,15 +45,16 @@ import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.describedAs; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.hasItems; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Item store test. @@ -103,6 +104,7 @@ protected Client getClient() { return client.get(); } + @AfterEach @Override public void tearDown() throws Exception { super.tearDown(); @@ -161,9 +163,8 @@ public void testItemsStore() throws Exception { open(sources); items.forEach((item) -> postItem(itemsTarget, item)); - assertTrue("Waiting to receive all events has timed out.", - latch.await((1000 + MAX_LISTENERS * RECONNECT_DEFAULT) * getAsyncTimeoutMultiplier(), - TimeUnit.MILLISECONDS)); + assertTrue(latch.await((1000 + MAX_LISTENERS * RECONNECT_DEFAULT) * getAsyncTimeoutMultiplier(), + TimeUnit.MILLISECONDS), "Waiting to receive all events has timed out."); // need to force disconnect on server in order for EventSource.close(...) to succeed with HttpUrlConnection sendCommand(itemsTarget, "disconnect"); @@ -172,18 +173,18 @@ public void testItemsStore() throws Exception { } String postedItems = itemsTarget.request().get(String.class); - items.forEach((item) -> assertTrue("Item '" + item + "' not stored on server.", postedItems.contains(item))); + items.forEach((item) -> assertTrue(postedItems.contains(item), "Item '" + item + "' not stored on server.")); final AtomicInteger queueId = new AtomicInteger(0); indexQueues.forEach((indexes) -> { for (int i = 0; i < items.size(); i++) { - assertTrue("Event for '" + items.get(i) + "' not received in queue " + queueId.get(), indexes.contains(i)); + assertTrue(indexes.contains(i), "Event for '" + items.get(i) + "' not received in queue " + queueId.get()); } - assertEquals("Not received the expected number of events in queue " + queueId.get(), items.size(), indexes.size()); + assertEquals(items.size(), indexes.size(), "Not received the expected number of events in queue " + queueId.get()); queueId.incrementAndGet(); }); - assertEquals("Number of received 'size' events does not match.", items.size() * MAX_LISTENERS, sizeEventsCount.get()); + assertEquals(items.size() * MAX_LISTENERS, sizeEventsCount.get(), "Number of received 'size' events does not match."); } /** @@ -248,9 +249,8 @@ public void testEventSourceReconnect() throws Exception { sendCommand(itemsTarget, "reconnect now"); - assertTrue("Waiting to receive all events has timed out.", - latch.await((1 + MAX_LISTENERS * (MAX_ITEMS + 1) * reconnectDelay) * getAsyncTimeoutMultiplier(), - TimeUnit.SECONDS)); + assertTrue(latch.await((1 + MAX_LISTENERS * (MAX_ITEMS + 1) * reconnectDelay) * getAsyncTimeoutMultiplier(), + TimeUnit.SECONDS), "Waiting to receive all events has timed out."); // need to force disconnect on server in order for EventSource.close(...) to succeed with HttpUrlConnection sendCommand(itemsTarget, "disconnect"); @@ -274,7 +274,7 @@ public void testEventSourceReconnect() throws Exception { private static void postItem(final WebTarget itemsTarget, final String item) { final Response response = itemsTarget.request().post(Entity.form(new Form("name", item))); - assertEquals("Posting new item has failed.", 204, response.getStatus()); + assertEquals(204, response.getStatus(), "Posting new item has failed."); LOGGER.info("[-i-] POSTed item: '" + item + "'"); } @@ -286,7 +286,7 @@ private static void close(final SseEventSource[] sources) { int i = 0; for (SseEventSource source : sources) { if (source.isOpen()) { - assertTrue("Waiting to close a source has timed out.", source.close(1, TimeUnit.SECONDS)); + assertTrue(source.close(1, TimeUnit.SECONDS), "Waiting to close a source has timed out."); // source.close(100, TimeUnit.MILLISECONDS); LOGGER.info("[<--] SOURCE " + i++ + " closed."); } @@ -295,7 +295,7 @@ private static void close(final SseEventSource[] sources) { private static void sendCommand(final WebTarget itemsTarget, final String command) { final Response response = itemsTarget.path("commands").request().post(Entity.text(command)); - assertEquals("'" + command + "' command has failed.", 200, response.getStatus()); + assertEquals(200, response.getStatus(), "'" + command + "' command has failed."); LOGGER.info("[-!-] COMMAND '" + command + "' has been processed."); } } diff --git a/examples/sse-item-store-jersey-webapp/src/test/java/org/glassfish/jersey/examples/sseitemstore/jersey/JerseyItemStoreResourceTest.java b/examples/sse-item-store-jersey-webapp/src/test/java/org/glassfish/jersey/examples/sseitemstore/jersey/JerseyItemStoreResourceTest.java index a561f71113..08f18cf11a 100644 --- a/examples/sse-item-store-jersey-webapp/src/test/java/org/glassfish/jersey/examples/sseitemstore/jersey/JerseyItemStoreResourceTest.java +++ b/examples/sse-item-store-jersey-webapp/src/test/java/org/glassfish/jersey/examples/sseitemstore/jersey/JerseyItemStoreResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -40,15 +40,15 @@ import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.describedAs; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.hasItems; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Item store test. @@ -140,9 +140,8 @@ public void testItemsStore() throws Exception { postItem(itemsTarget, item); } - assertTrue("Waiting to receive all events has timed out.", - latch.await((1000 + MAX_LISTENERS * EventSource.RECONNECT_DEFAULT) * getAsyncTimeoutMultiplier(), - TimeUnit.MILLISECONDS)); + assertTrue(latch.await((1000 + MAX_LISTENERS * EventSource.RECONNECT_DEFAULT) * getAsyncTimeoutMultiplier(), + TimeUnit.MILLISECONDS), "Waiting to receive all events has timed out."); // need to force disconnect on server in order for EventSource.close(...) to succeed with HttpUrlConnection sendCommand(itemsTarget, "disconnect"); @@ -152,19 +151,19 @@ public void testItemsStore() throws Exception { String postedItems = itemsTarget.request().get(String.class); for (String item : items) { - assertTrue("Item '" + item + "' not stored on server.", postedItems.contains(item)); + assertTrue(postedItems.contains(item), "Item '" + item + "' not stored on server."); } int queueId = 0; for (Queue indexes : indexQueues) { for (int i = 0; i < items.size(); i++) { - assertTrue("Event for '" + items.get(i) + "' not received in queue " + queueId, indexes.contains(i)); + assertTrue(indexes.contains(i), "Event for '" + items.get(i) + "' not received in queue " + queueId); } - assertEquals("Not received the expected number of events in queue " + queueId, items.size(), indexes.size()); + assertEquals(items.size(), indexes.size(), "Not received the expected number of events in queue " + queueId); queueId++; } - assertEquals("Number of received 'size' events does not match.", items.size() * MAX_LISTENERS, sizeEventsCount.get()); + assertEquals(items.size() * MAX_LISTENERS, sizeEventsCount.get(), "Number of received 'size' events does not match."); } /** @@ -228,9 +227,8 @@ public void testEventSourceReconnect() throws Exception { sendCommand(itemsTarget, "reconnect now"); - assertTrue("Waiting to receive all events has timed out.", - latch.await((1 + MAX_LISTENERS * (MAX_ITEMS + 1) * reconnectDelay) * getAsyncTimeoutMultiplier(), - TimeUnit.SECONDS)); + assertTrue(latch.await((1 + MAX_LISTENERS * (MAX_ITEMS + 1) * reconnectDelay) * getAsyncTimeoutMultiplier(), + TimeUnit.SECONDS), "Waiting to receive all events has timed out."); // need to force disconnect on server in order for EventSource.close(...) to succeed with HttpUrlConnection sendCommand(itemsTarget, "disconnect"); @@ -254,7 +252,7 @@ public void testEventSourceReconnect() throws Exception { private static void postItem(final WebTarget itemsTarget, final String item) { final Response response = itemsTarget.request().post(Entity.form(new Form("name", item))); - assertEquals("Posting new item has failed.", 204, response.getStatus()); + assertEquals(204, response.getStatus(), "Posting new item has failed."); LOGGER.info("[-i-] POSTed item: '" + item + "'"); } @@ -270,7 +268,7 @@ private static void close(final EventSource[] sources) { int i = 0; for (EventSource source : sources) { if (source.isOpen()) { - assertTrue("Waiting to close a source has timed out.", source.close(1, TimeUnit.SECONDS)); + assertTrue(source.close(1, TimeUnit.SECONDS), "Waiting to close a source has timed out."); // source.close(100, TimeUnit.MILLISECONDS); LOGGER.info("[<--] SOURCE " + i++ + " closed."); } @@ -279,7 +277,7 @@ private static void close(final EventSource[] sources) { private static void sendCommand(final WebTarget itemsTarget, final String command) { final Response response = itemsTarget.path("commands").request().post(Entity.text(command)); - assertEquals("'" + command + "' command has failed.", 200, response.getStatus()); + assertEquals(200, response.getStatus(), "'" + command + "' command has failed."); LOGGER.info("[-!-] COMMAND '" + command + "' has been processed."); } } diff --git a/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java b/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java index 21887fc80a..54c9607694 100644 --- a/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java +++ b/examples/system-properties-example/src/test/java/org/glassfish/jersey/examples/sysprops/SysPropsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -18,8 +18,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * System properties example unit test. diff --git a/examples/xml-moxy/src/test/java/org/glassfish/jersey/examples/xmlmoxy/MoxyAppTest.java b/examples/xml-moxy/src/test/java/org/glassfish/jersey/examples/xmlmoxy/MoxyAppTest.java index d154e1a17f..d8fd49eba0 100644 --- a/examples/xml-moxy/src/test/java/org/glassfish/jersey/examples/xmlmoxy/MoxyAppTest.java +++ b/examples/xml-moxy/src/test/java/org/glassfish/jersey/examples/xmlmoxy/MoxyAppTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0, which is available at @@ -21,8 +21,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/ext/cdi/jersey-cdi1x-ban-custom-hk2-binding/src/test/java/org/glassfish/jersey/ext/cdi1x/hk2ban/EmptyHk2CustomInjectionTypeProviderTest.java b/ext/cdi/jersey-cdi1x-ban-custom-hk2-binding/src/test/java/org/glassfish/jersey/ext/cdi1x/hk2ban/EmptyHk2CustomInjectionTypeProviderTest.java index 4b6e83a07e..5e379a9e68 100644 --- a/ext/cdi/jersey-cdi1x-ban-custom-hk2-binding/src/test/java/org/glassfish/jersey/ext/cdi1x/hk2ban/EmptyHk2CustomInjectionTypeProviderTest.java +++ b/ext/cdi/jersey-cdi1x-ban-custom-hk2-binding/src/test/java/org/glassfish/jersey/ext/cdi1x/hk2ban/EmptyHk2CustomInjectionTypeProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -21,7 +21,7 @@ import org.glassfish.jersey.ext.cdi1x.spi.Hk2CustomBoundTypesProvider; import org.glassfish.jersey.internal.ServiceFinder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.emptyCollectionOf; import static org.hamcrest.Matchers.instanceOf; diff --git a/ext/cdi/jersey-cdi1x/pom.xml b/ext/cdi/jersey-cdi1x/pom.xml index 61c5971980..234bb1a4e5 100644 --- a/ext/cdi/jersey-cdi1x/pom.xml +++ b/ext/cdi/jersey-cdi1x/pom.xml @@ -59,6 +59,12 @@ jmockit test + + + org.hamcrest + hamcrest + test + diff --git a/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProviderTest.java b/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProviderTest.java index 479d349d54..4a14b8e5e9 100644 --- a/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProviderTest.java +++ b/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiComponentProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,9 +33,9 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyReader; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test for {@link CdiComponentProvider}. diff --git a/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiUtilTest.java b/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiUtilTest.java index 0f9fa518cd..fb839f0fb2 100644 --- a/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiUtilTest.java +++ b/ext/cdi/jersey-cdi1x/src/test/java/org/glassfish/jersey/ext/cdi1x/internal/CdiUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -23,10 +23,10 @@ import org.glassfish.jersey.ext.cdi1x.internal.spi.InjectionManagerStore; import org.glassfish.jersey.internal.inject.InjectionManager; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import mockit.Mock; import mockit.MockUp; diff --git a/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityAnnotationsTest.java b/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityAnnotationsTest.java index 8c5fa49ec9..19112b90b8 100644 --- a/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityAnnotationsTest.java +++ b/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityAnnotationsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,7 +16,7 @@ package org.glassfish.jersey.message.filtering; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityEntityProcessorTest.java b/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityEntityProcessorTest.java index 21edda41c8..46c7bee946 100644 --- a/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityEntityProcessorTest.java +++ b/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityEntityProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,8 +27,8 @@ import org.glassfish.jersey.message.filtering.spi.FilteringHelper; import org.glassfish.jersey.message.filtering.spi.ScopeProvider; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; @@ -42,7 +42,7 @@ public class SecurityEntityProcessorTest { private SecurityEntityProcessor processor; - @Before + @BeforeEach public void setUp() throws Exception { processor = new SecurityEntityProcessor(); } diff --git a/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityHelperTest.java b/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityHelperTest.java index e86b1d3eeb..75ce7d839e 100644 --- a/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityHelperTest.java +++ b/ext/entity-filtering/src/test/java/org/glassfish/jersey/message/filtering/SecurityHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,7 +29,7 @@ import org.glassfish.jersey.internal.inject.CustomAnnotationLiteral; import org.glassfish.jersey.message.filtering.spi.FilteringHelper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/ext/metainf-services/src/test/java/org/glassfish/jersey/message/MetaInfServicesTest.java b/ext/metainf-services/src/test/java/org/glassfish/jersey/message/MetaInfServicesTest.java index e764ef5b67..f1ad7da2f4 100644 --- a/ext/metainf-services/src/test/java/org/glassfish/jersey/message/MetaInfServicesTest.java +++ b/ext/metainf-services/src/test/java/org/glassfish/jersey/message/MetaInfServicesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -42,18 +42,14 @@ import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.jupiter.api.Test; + import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -@RunWith(Suite.class) -@Suite.SuiteClasses({MetaInfServicesTest.Enable.class, MetaInfServicesTest.DisableServer.class, - MetaInfServicesTest.DisableClient.class}) public class MetaInfServicesTest { public static class MetaInf { diff --git a/ext/microprofile/mp-config/pom.xml b/ext/microprofile/mp-config/pom.xml index dba9f6c6b3..151dbb5930 100644 --- a/ext/microprofile/mp-config/pom.xml +++ b/ext/microprofile/mp-config/pom.xml @@ -70,8 +70,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/ext/microprofile/mp-config/src/test/java/org/glassfish/jersey/microprofile/config/ConfigurationProviderTest.java b/ext/microprofile/mp-config/src/test/java/org/glassfish/jersey/microprofile/config/ConfigurationProviderTest.java index 6b2aecdd0a..f269cff8ce 100644 --- a/ext/microprofile/mp-config/src/test/java/org/glassfish/jersey/microprofile/config/ConfigurationProviderTest.java +++ b/ext/microprofile/mp-config/src/test/java/org/glassfish/jersey/microprofile/config/ConfigurationProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -16,9 +16,9 @@ package org.glassfish.jersey.microprofile.config; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.Map; @@ -26,7 +26,7 @@ public class ConfigurationProviderTest { private static final String EMPTY_PROPERTY_NAME = "EMPTY_PROPERTY"; - @Before + @BeforeEach public void before() { System.setProperty(EMPTY_PROPERTY_NAME, ""); } @@ -36,7 +36,7 @@ public void getEmptyPropertiesTest() { final ConfigurationProvider provider = new ConfigurationProvider(); final Map properties = provider.getProperties(); - Assert.assertNull(properties.get(EMPTY_PROPERTY_NAME)); + Assertions.assertNull(properties.get(EMPTY_PROPERTY_NAME)); } } \ No newline at end of file diff --git a/ext/microprofile/mp-config/src/test/java/org/glassfish/jersey/microprofile/config/ExternalPropertiesConfigurationFactoryTest.java b/ext/microprofile/mp-config/src/test/java/org/glassfish/jersey/microprofile/config/ExternalPropertiesConfigurationFactoryTest.java index 2c4e70b179..8662d2dc46 100644 --- a/ext/microprofile/mp-config/src/test/java/org/glassfish/jersey/microprofile/config/ExternalPropertiesConfigurationFactoryTest.java +++ b/ext/microprofile/mp-config/src/test/java/org/glassfish/jersey/microprofile/config/ExternalPropertiesConfigurationFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.test.jetty.JettyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.inject.Singleton; import javax.ws.rs.GET; @@ -84,7 +84,7 @@ public void readConfigTest() { final Boolean responce = target("getPropertyValue/{key}") .resolveTemplate("key", "jersey.config.disableMetainfServicesLookup").request().get(Boolean.class); - Assert.assertEquals(Boolean.TRUE, responce); + Assertions.assertEquals(Boolean.TRUE, responce); } @Test @@ -92,13 +92,13 @@ public void smallRyeConfigTest() { final String responce = target("readProperty/{key}") .resolveTemplate("key", "jersey.config.disableAutoDiscovery").request().get(String.class); - Assert.assertEquals("1", responce); + Assertions.assertEquals("1", responce); } @Test public void defaultHeaderValueTest() { final String responce = target("readProperty/{key}") .resolveTemplate("key", "jersey.config.disableJsonProcessing").request().get(String.class); - Assert.assertEquals("true", responce); + Assertions.assertEquals("true", responce); } } \ No newline at end of file diff --git a/ext/microprofile/mp-rest-client/src/test/java/org/glassfish/jersey/microprofile/restclient/RestClientBuilderImplTest.java b/ext/microprofile/mp-rest-client/src/test/java/org/glassfish/jersey/microprofile/restclient/RestClientBuilderImplTest.java index 685e53a32a..bd4bf9cfb9 100644 --- a/ext/microprofile/mp-rest-client/src/test/java/org/glassfish/jersey/microprofile/restclient/RestClientBuilderImplTest.java +++ b/ext/microprofile/mp-rest-client/src/test/java/org/glassfish/jersey/microprofile/restclient/RestClientBuilderImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 Payara Foundation 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.microprofile.restclient; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import static org.glassfish.jersey.microprofile.restclient.RestClientBuilderImpl.createProxyString; @@ -25,9 +25,9 @@ public class RestClientBuilderImplTest { @Test public void createProxyStringTest() { - Assert.assertTrue(createProxyString("localhost", 8765).equals("http://localhost:8765")); - Assert.assertTrue(createProxyString("http://localhost", 8765).equals("http://localhost:8765")); - Assert.assertTrue(createProxyString("127.0.0.1", 8765).equals("http://127.0.0.1:8765")); - Assert.assertTrue(createProxyString("http://192.168.1.1", 8765).equals("http://192.168.1.1:8765")); + Assertions.assertTrue(createProxyString("localhost", 8765).equals("http://localhost:8765")); + Assertions.assertTrue(createProxyString("http://localhost", 8765).equals("http://localhost:8765")); + Assertions.assertTrue(createProxyString("127.0.0.1", 8765).equals("http://127.0.0.1:8765")); + Assertions.assertTrue(createProxyString("http://192.168.1.1", 8765).equals("http://192.168.1.1:8765")); } } diff --git a/ext/pom.xml b/ext/pom.xml index f4109a6aeb..104352590b 100644 --- a/ext/pom.xml +++ b/ext/pom.xml @@ -65,8 +65,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/WebResourceFactoryTest.java b/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/WebResourceFactoryTest.java index 1f51f17d5c..3a05b8eb67 100644 --- a/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/WebResourceFactoryTest.java +++ b/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/WebResourceFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,13 +34,13 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; - -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Martin Matula @@ -62,6 +62,7 @@ protected ResourceConfig configure() { return new ResourceConfig(MyResource.class); } + @BeforeEach @Override public void setUp() throws Exception { super.setUp(); @@ -161,7 +162,7 @@ public void testQueryParamsAsSortedSet() { } @Test - @Ignore("See issue JERSEY-2441") + @Disabled("See issue JERSEY-2441") public void testHeaderCookieAsList() { final List list = new ArrayList<>(); list.add("a"); @@ -172,7 +173,7 @@ public void testHeaderCookieAsList() { } @Test - @Ignore("See issue JERSEY-2441") + @Disabled("See issue JERSEY-2441") public void testHeaderCookieAsSet() { final Set set = new HashSet<>(); set.add("a"); @@ -184,7 +185,7 @@ public void testHeaderCookieAsSet() { } @Test - @Ignore("See issue JERSEY-2441") + @Disabled("See issue JERSEY-2441") public void testHeaderCookieAsSortedSet() { final SortedSet set = new TreeSet<>(); set.add("a"); @@ -200,7 +201,7 @@ public void testHeaderCookieAsSortedSet() { * lines in the request. Jersey has currently no possibility to do so. See JERSEY-2263. */ @Test - @Ignore("See issue JERSEY-2263") + @Disabled("See issue JERSEY-2263") public void testHeaderParamsAsList() { final List list = new ArrayList<>(); list.add("a"); @@ -211,7 +212,7 @@ public void testHeaderParamsAsList() { } @Test - @Ignore("See issue JERSEY-2263") + @Disabled("See issue JERSEY-2263") public void testHeaderParamsAsSet() { final Set set = new HashSet<>(); set.add("a"); @@ -223,7 +224,7 @@ public void testHeaderParamsAsSet() { } @Test - @Ignore("See issue JERSEY-2263") + @Disabled("See issue JERSEY-2263") public void testHeaderParamsAsSortedSet() { final SortedSet set = new TreeSet<>(); set.add("a"); @@ -267,10 +268,10 @@ public void testMatrixParamsAsSortedSet() { } private void checkSet(final String result) { - assertTrue("Set does not contain 3 items.", result.startsWith("3:[")); - assertTrue("Set does not contain 'a' item.", result.contains("a")); - assertTrue("Set does not contain 'bb' item.", result.contains("bb")); - assertTrue("Set does not contain 'ccc' item.", result.contains("ccc")); + assertTrue(result.startsWith("3:["), "Set does not contain 3 items."); + assertTrue(result.contains("a"), "Set does not contain 'a' item."); + assertTrue(result.contains("bb"), "Set does not contain 'bb' item."); + assertTrue(result.contains("ccc"), "Set does not contain 'ccc' item."); } @Test @@ -307,13 +308,13 @@ public void testFormParamsAsSortedSet() { @Test public void testAcceptHeader() { - assertTrue("Accept HTTP header does not match @Produces annotation", resource.isAcceptHeaderValid(null)); + assertTrue(resource.isAcceptHeaderValid(null), "Accept HTTP header does not match @Produces annotation"); } @Test public void testPutWithExplicitContentType() { - assertEquals("Content-Type HTTP header does not match explicitly provided type", resourceWithXML.putIt(new MyBean()), - MediaType.APPLICATION_XML); + assertEquals(resourceWithXML.putIt(new MyBean()), MediaType.APPLICATION_XML, + "Content-Type HTTP header does not match explicitly provided type"); } @Test @@ -328,11 +329,11 @@ public void testToString() throws Exception { public void testHashCode() throws Exception { int h1 = resource.hashCode(); int h2 = resource2.hashCode(); - assertNotEquals("The hash codes should not match", h1, h2); + assertNotEquals(h1, h2, "The hash codes should not match"); } @Test public void testEquals() { - assertFalse("The two resource instances should not be considered equals as they are unique", resource.equals(resource2)); + assertFalse(resource.equals(resource2), "The two resource instances should not be considered equals as they are unique"); } } diff --git a/ext/rx/pom.xml b/ext/rx/pom.xml index 83f755b2b6..b17d74161d 100644 --- a/ext/rx/pom.xml +++ b/ext/rx/pom.xml @@ -44,8 +44,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/ext/rx/rx-client-guava/src/test/java/org/glassfish/jersey/client/rx/guava/RxListenableFutureTest.java b/ext/rx/rx-client-guava/src/test/java/org/glassfish/jersey/client/rx/guava/RxListenableFutureTest.java index 43a97cf1ea..9b27487c65 100644 --- a/ext/rx/rx-client-guava/src/test/java/org/glassfish/jersey/client/rx/guava/RxListenableFutureTest.java +++ b/ext/rx/rx-client-guava/src/test/java/org/glassfish/jersey/client/rx/guava/RxListenableFutureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -29,13 +29,14 @@ import org.glassfish.jersey.process.JerseyProcessingUncaughtExceptionHandler; import org.hamcrest.Matcher; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; import static org.hamcrest.core.Is.is; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author Michal Gajdos @@ -45,7 +46,7 @@ public class RxListenableFutureTest { private Client client; private ExecutorService executor; - @Before + @BeforeEach public void setUp() throws Exception { client = ClientBuilder.newClient().register(TerminalClientRequestFilter.class); executor = new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder() @@ -54,7 +55,7 @@ public void setUp() throws Exception { .build()); } - @After + @AfterEach public void tearDown() throws Exception { executor.shutdown(); client = null; @@ -72,47 +73,51 @@ public void testNotFoundResponse() throws Exception { testInvoker(invoker, 404, false); } - @Test(expected = NotFoundException.class) + @Test public void testNotFoundReadEntityViaClass() throws Throwable { - client.register(RxListenableFutureInvokerProvider.class); - - try { - client.target("http://jersey.java.net") - .request() - .header("Response-Status", 404) - .rx(RxListenableFutureInvoker.class) - .get(String.class) - .get(); - } catch (final Exception expected) { - - // java.util.concurrent.ExecutionException - throw expected - // javax.ws.rs.NotFoundException - .getCause(); - } + assertThrows(NotFoundException.class, () -> { + client.register(RxListenableFutureInvokerProvider.class); + + try { + client.target("http://jersey.java.net") + .request() + .header("Response-Status", 404) + .rx(RxListenableFutureInvoker.class) + .get(String.class) + .get(); + } catch (final Exception expected) { + + // java.util.concurrent.ExecutionException + throw expected + // javax.ws.rs.NotFoundException + .getCause(); + } + }); } - @Test(expected = NotFoundException.class) + @Test public void testNotFoundReadEntityViaGenericType() throws Throwable { - client.register(RxListenableFutureInvokerProvider.class); - - try { - client.target("http://jersey.java.net") - .request() - .header("Response-Status", 404) - .rx(RxListenableFutureInvoker.class) - .get(new GenericType() { - }) - .get(); - } catch (final Exception expected) { - - expected.printStackTrace(); - - // java.util.concurrent.ExecutionException - throw expected - // javax.ws.rs.NotFoundException - .getCause(); - } + assertThrows(NotFoundException.class, () -> { + client.register(RxListenableFutureInvokerProvider.class); + + try { + client.target("http://jersey.java.net") + .request() + .header("Response-Status", 404) + .rx(RxListenableFutureInvoker.class) + .get(new GenericType() { + }) + .get(); + } catch (final Exception expected) { + + expected.printStackTrace(); + + // java.util.concurrent.ExecutionException + throw expected + // javax.ws.rs.NotFoundException + .getCause(); + } + }); } @Test diff --git a/ext/rx/rx-client-rxjava/src/test/java/org/glassfish/jersey/client/rx/rxjava/RxObservableTest.java b/ext/rx/rx-client-rxjava/src/test/java/org/glassfish/jersey/client/rx/rxjava/RxObservableTest.java index 0a6644b96b..29fb0e55f0 100644 --- a/ext/rx/rx-client-rxjava/src/test/java/org/glassfish/jersey/client/rx/rxjava/RxObservableTest.java +++ b/ext/rx/rx-client-rxjava/src/test/java/org/glassfish/jersey/client/rx/rxjava/RxObservableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -30,12 +30,13 @@ import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder; import org.glassfish.jersey.process.JerseyProcessingUncaughtExceptionHandler; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.core.Is.is; +import static org.junit.jupiter.api.Assertions.assertThrows; import rx.Subscriber; @@ -49,7 +50,7 @@ public class RxObservableTest { private Client clientWithExecutor; private ExecutorService executor; - @Before + @BeforeEach public void setUp() throws Exception { client = ClientBuilder.newClient().register(TerminalClientRequestFilter.class); client.register(RxObservableInvokerProvider.class); @@ -63,7 +64,7 @@ public void setUp() throws Exception { clientWithExecutor.register(RxObservableInvokerProvider.class); } - @After + @AfterEach public void tearDown() throws Exception { executor.shutdown(); @@ -91,47 +92,51 @@ public void testNotFoundWithCustomExecutor() throws Exception { testInvoker(invoker, 404, true); } - @Test(expected = NotFoundException.class) + @Test public void testNotFoundReadEntityViaClass() throws Throwable { - try { - client.target("http://jersey.java.net") - .request() - .header("Response-Status", 404) - .rx(RxObservableInvoker.class) - .get(String.class) - .toBlocking() - .toFuture() - .get(); - } catch (final Exception expected) { - // java.util.concurrent.ExecutionException - throw expected - // javax.ws.rs.ProcessingException - // .getCause() - // javax.ws.rs.NotFoundException - .getCause(); - } + assertThrows(NotFoundException.class, () -> { + try { + client.target("http://jersey.java.net") + .request() + .header("Response-Status", 404) + .rx(RxObservableInvoker.class) + .get(String.class) + .toBlocking() + .toFuture() + .get(); + } catch (final Exception expected) { + // java.util.concurrent.ExecutionException + throw expected + // javax.ws.rs.ProcessingException + // .getCause() + // javax.ws.rs.NotFoundException + .getCause(); + } + }); } - @Test(expected = NotFoundException.class) + @Test public void testNotFoundReadEntityViaGenericType() throws Throwable { - try { - client.target("http://jersey.java.net") - .request() - .header("Response-Status", 404) - .rx(RxObservableInvoker.class) - .get(new GenericType() { }) - .toBlocking() - .toFuture() - .get(); - } catch (final Exception expected) { - - expected.printStackTrace(); - - // java.util.concurrent.ExecutionException - throw expected - // javax.ws.rs.NotFoundException - .getCause(); - } + assertThrows(NotFoundException.class, () -> { + try { + client.target("http://jersey.java.net") + .request() + .header("Response-Status", 404) + .rx(RxObservableInvoker.class) + .get(new GenericType() { }) + .toBlocking() + .toFuture() + .get(); + } catch (final Exception expected) { + + expected.printStackTrace(); + + // java.util.concurrent.ExecutionException + throw expected + // javax.ws.rs.NotFoundException + .getCause(); + } + }); } @Test diff --git a/ext/rx/rx-client-rxjava2/src/test/java/org/glassfish/jersey/client/rx/rxjava2/RxFlowableTest.java b/ext/rx/rx-client-rxjava2/src/test/java/org/glassfish/jersey/client/rx/rxjava2/RxFlowableTest.java index 9151f0fac2..1a7532443b 100644 --- a/ext/rx/rx-client-rxjava2/src/test/java/org/glassfish/jersey/client/rx/rxjava2/RxFlowableTest.java +++ b/ext/rx/rx-client-rxjava2/src/test/java/org/glassfish/jersey/client/rx/rxjava2/RxFlowableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -30,14 +30,15 @@ import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder; import org.glassfish.jersey.process.JerseyProcessingUncaughtExceptionHandler; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.core.Is.is; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author Pavel Bucek @@ -48,7 +49,7 @@ public class RxFlowableTest { private Client clientWithExecutor; private ExecutorService executor; - @Before + @BeforeEach public void setUp() throws Exception { client = ClientBuilder.newClient().register(TerminalClientRequestFilter.class); client.register(RxFlowableInvokerProvider.class); @@ -62,7 +63,7 @@ public void setUp() throws Exception { clientWithExecutor.register(RxFlowableInvokerProvider.class); } - @After + @AfterEach public void tearDown() throws Exception { executor.shutdown(); @@ -90,33 +91,37 @@ public void testNotFoundWithCustomExecutor() throws Exception { testInvoker(invoker, 404, true); } - @Test(expected = NotFoundException.class) + @Test public void testNotFoundReadEntityViaClass() throws Throwable { - try { - client.target("http://jersey.java.net") - .request() - .header("Response-Status", 404) - .rx(RxFlowableInvoker.class) - .get(String.class) - .blockingFirst(); - } catch (final Exception expected) { - throw expected; - } + assertThrows(NotFoundException.class, () -> { + try { + client.target("http://jersey.java.net") + .request() + .header("Response-Status", 404) + .rx(RxFlowableInvoker.class) + .get(String.class) + .blockingFirst(); + } catch (final Exception expected) { + throw expected; + } + }); } - @Test(expected = NotFoundException.class) + @Test public void testNotFoundReadEntityViaGenericType() throws Throwable { - try { - client.target("http://jersey.java.net") - .request() - .header("Response-Status", 404) - .rx(RxFlowableInvoker.class) - .get(new GenericType() { - }) - .blockingFirst(); - } catch (final Exception expected) { - throw expected; - } + assertThrows(NotFoundException.class, () -> { + try { + client.target("http://jersey.java.net") + .request() + .header("Response-Status", 404) + .rx(RxFlowableInvoker.class) + .get(new GenericType() { + }) + .blockingFirst(); + } catch (final Exception expected) { + throw expected; + } + }); } @Test diff --git a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java index 6b64034a1f..246763d2ac 100644 --- a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java +++ b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,11 +19,11 @@ import javax.ws.rs.core.Application; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class Aspect4JTest extends JerseyTest { @@ -31,7 +31,7 @@ public class Aspect4JTest extends JerseyTest { private TestAspect testAspect; - @Before + @BeforeEach public void before() { testAspect.reset(); } diff --git a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java index 9ec3a54c54..4b34936417 100644 --- a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java +++ b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,11 +20,11 @@ import org.glassfish.jersey.server.spring.SpringTestConfiguration; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SpringFieldInjectionTest extends JerseyTest { diff --git a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java index 539b633ed7..1a30131b00 100644 --- a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java +++ b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,11 +20,11 @@ import org.glassfish.jersey.server.spring.SpringTestConfiguration; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FilterTest extends JerseyTest { diff --git a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java index 5ce4fec7e4..6bf586c83a 100644 --- a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java +++ b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,10 +16,10 @@ package org.glassfish.jersey.server.spring.methodinjection; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.glassfish.jersey.server.spring.SpringTestConfiguration; diff --git a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java index 35caa9885f..451de46a79 100644 --- a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java +++ b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,13 +19,13 @@ import org.glassfish.jersey.server.spring.SpringTestConfiguration; import org.glassfish.jersey.server.spring.fieldinjection.SpringFieldInjectionJerseyTestConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import javax.ws.rs.core.Application; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SpringParameterInjectionTest extends JerseyTest { @Override diff --git a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java index f390c5c95a..fc90449fd9 100644 --- a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java +++ b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.server.spring.scope.RequestContextFilter; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -44,6 +44,6 @@ protected Application configure() { @Test public void shouldUseDefaultComponent() { final String result = target("spring-resource").request().get(String.class); - Assert.assertEquals("default", result); + Assertions.assertEquals("default", result); } } diff --git a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java index 6c8450c2aa..0a84fa8e51 100644 --- a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java +++ b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.server.spring.scope.RequestContextFilter; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class SpringDevProfileResourceTest extends JerseyTest { @@ -44,6 +44,6 @@ protected Application configure() { @Test public void shouldUseDevProfileBean() { final String result = target("spring-resource").request().get(String.class); - Assert.assertEquals("dev", result); + Assertions.assertEquals("dev", result); } } diff --git a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java index 8bccbe379c..e871afb8c8 100644 --- a/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java +++ b/ext/spring4/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,9 +16,9 @@ package org.glassfish.jersey.server.spring.profiles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SpringProfilesTest { diff --git a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java index 0831c1e833..246763d2ac 100644 --- a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java +++ b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,11 +19,11 @@ import javax.ws.rs.core.Application; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class Aspect4JTest extends JerseyTest { @@ -31,7 +31,7 @@ public class Aspect4JTest extends JerseyTest { private TestAspect testAspect; - @Before + @BeforeEach public void before() { testAspect.reset(); } diff --git a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java index ccdd34b231..4b34936417 100644 --- a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java +++ b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,11 +20,11 @@ import org.glassfish.jersey.server.spring.SpringTestConfiguration; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SpringFieldInjectionTest extends JerseyTest { diff --git a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java index 026a0a6b28..1a30131b00 100644 --- a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java +++ b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,11 +20,11 @@ import org.glassfish.jersey.server.spring.SpringTestConfiguration; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FilterTest extends JerseyTest { diff --git a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java index cf79272c38..6bf586c83a 100644 --- a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java +++ b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,10 +16,10 @@ package org.glassfish.jersey.server.spring.methodinjection; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.glassfish.jersey.server.spring.SpringTestConfiguration; diff --git a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java index 9af9049a37..451de46a79 100644 --- a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java +++ b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,13 +19,13 @@ import org.glassfish.jersey.server.spring.SpringTestConfiguration; import org.glassfish.jersey.server.spring.fieldinjection.SpringFieldInjectionJerseyTestConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import javax.ws.rs.core.Application; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SpringParameterInjectionTest extends JerseyTest { @Override diff --git a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java index e95257f51f..fc90449fd9 100644 --- a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java +++ b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.server.spring.scope.RequestContextFilter; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -44,6 +44,6 @@ protected Application configure() { @Test public void shouldUseDefaultComponent() { final String result = target("spring-resource").request().get(String.class); - Assert.assertEquals("default", result); + Assertions.assertEquals("default", result); } } diff --git a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java index 4ccb36a6c7..0a84fa8e51 100644 --- a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java +++ b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.server.spring.scope.RequestContextFilter; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class SpringDevProfileResourceTest extends JerseyTest { @@ -44,6 +44,6 @@ protected Application configure() { @Test public void shouldUseDevProfileBean() { final String result = target("spring-resource").request().get(String.class); - Assert.assertEquals("dev", result); + Assertions.assertEquals("dev", result); } } diff --git a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java index be0ac479ae..e871afb8c8 100644 --- a/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java +++ b/ext/spring5/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,9 +16,9 @@ package org.glassfish.jersey.server.spring.profiles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SpringProfilesTest { diff --git a/incubator/cdi-inject-weld/pom.xml b/incubator/cdi-inject-weld/pom.xml index 599099f584..36cf9100d6 100644 --- a/incubator/cdi-inject-weld/pom.xml +++ b/incubator/cdi-inject-weld/pom.xml @@ -81,8 +81,13 @@ - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.hamcrest + hamcrest test diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/injector/CachedConstructorAnalyzerTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/injector/CachedConstructorAnalyzerTest.java index eebc20decc..10e10aecd0 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/injector/CachedConstructorAnalyzerTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/injector/CachedConstructorAnalyzerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -23,11 +23,13 @@ import javax.enterprise.inject.InjectionException; import javax.ws.rs.MatrixParam; +import javax.ws.rs.NotFoundException; import javax.ws.rs.PathParam; import javax.ws.rs.core.Context; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Tests {@link CachedConstructorAnalyzer}. @@ -127,14 +129,16 @@ public void testMultiAnnotatedConstructor() { assertEquals(2, analyzer.getConstructor().getParameterCount()); } - @Test(expected = InjectionException.class) + @Test public void testUnknownAnnotatedConstructor() { - new CachedConstructorAnalyzer<>(UnknownAnnotatedConstructor.class, ANNOTATIONS).getConstructor(); + assertThrows(InjectionException.class, + () -> new CachedConstructorAnalyzer<>(UnknownAnnotatedConstructor.class, ANNOTATIONS).getConstructor()); } - @Test(expected = InjectionException.class) + @Test public void testSingleNonAnnotatedConstructor() { - new CachedConstructorAnalyzer<>(SingleNonAnnotatedConstructor.class, ANNOTATIONS).getConstructor(); + assertThrows(InjectionException.class, + () -> new CachedConstructorAnalyzer<>(SingleNonAnnotatedConstructor.class, ANNOTATIONS).getConstructor()); } public static class DefaultConstructor { diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/injector/JerseyProxyResolverTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/injector/JerseyProxyResolverTest.java index 76fcd88e6f..521b8056e4 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/injector/JerseyProxyResolverTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/injector/JerseyProxyResolverTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -32,11 +32,11 @@ import org.glassfish.jersey.internal.inject.InjecteeImpl; import org.glassfish.jersey.internal.inject.InjectionResolver; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests Jersey Proxy Resolver. diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ClientInstanceInjectionTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ClientInstanceInjectionTest.java index 37ec79f53e..7a7b9dc6fe 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ClientInstanceInjectionTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ClientInstanceInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.inject.weld.managed.CdiInjectionManagerFactory; import org.glassfish.jersey.internal.inject.InjectionManager; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; @@ -49,16 +49,16 @@ public void testInject() { }); InjectedBean bean = injectionManager.getInstance(InjectedBean.class); - Assert.assertNotNull(bean); - Assert.assertEquals("6", bean.get()); + Assertions.assertNotNull(bean); + Assertions.assertEquals("6", bean.get()); InjectedBean bean1 = clientInjectionManager1.getInstance(InjectedBean.class); - Assert.assertNotNull(bean1); - Assert.assertEquals("11", bean1.get()); + Assertions.assertNotNull(bean1); + Assertions.assertEquals("11", bean1.get()); InjectedBean bean2 = clientInjectionManager2.getInstance(InjectedBean.class); - Assert.assertNotNull(bean2); - Assert.assertEquals("16", bean2.get()); + Assertions.assertNotNull(bean2); + Assertions.assertEquals("16", bean2.get()); injectionManager.shutdown(); clientInjectionManager1.shutdown(); @@ -104,16 +104,16 @@ public void testSupplierInject() { }); InjectedSupplierBean bean = injectionManager.getInstance(InjectedSupplierBean.class); - Assert.assertNotNull(bean); - Assert.assertEquals("6", bean.get()); + Assertions.assertNotNull(bean); + Assertions.assertEquals("6", bean.get()); InjectedSupplierBean bean1 = clientInjectionManager1.getInstance(InjectedSupplierBean.class); - Assert.assertNotNull(bean1); - Assert.assertEquals("11", bean1.get()); + Assertions.assertNotNull(bean1); + Assertions.assertEquals("11", bean1.get()); InjectedSupplierBean bean2 = clientInjectionManager2.getInstance(InjectedSupplierBean.class); - Assert.assertNotNull(bean2); - Assert.assertEquals("16", bean2.get()); + Assertions.assertNotNull(bean2); + Assertions.assertEquals("16", bean2.get()); } @Dependent @@ -173,12 +173,12 @@ public void testSupplierClassBeanOnClientAndServer() { }); InjectedClientServerSupplierBean beanServer = injectionManager.getInstance(InjectedClientServerSupplierBean.class); - Assert.assertNotNull(beanServer); - Assert.assertEquals("SERVER", beanServer.get()); + Assertions.assertNotNull(beanServer); + Assertions.assertEquals("SERVER", beanServer.get()); InjectedClientServerSupplierBean beanClient = clientInjectionManager.getInstance(InjectedClientServerSupplierBean.class); - Assert.assertNotNull(beanClient); - Assert.assertEquals("CLIENT", beanClient.get()); + Assertions.assertNotNull(beanClient); + Assertions.assertEquals("CLIENT", beanClient.get()); } @Dependent diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/DisposableSupplierTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/DisposableSupplierTest.java index 4ba137b8b6..478d49307c 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/DisposableSupplierTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/DisposableSupplierTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -31,13 +31,13 @@ import org.glassfish.jersey.internal.inject.DisposableSupplier; import org.glassfish.jersey.process.internal.RequestScope; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Tests that {@link DisposableSupplier} is properly processed by {@link BeanHelper}. @@ -58,7 +58,7 @@ public class DisposableSupplierTest extends TestParent { private static AtomicBoolean onlyOnceGuard = new AtomicBoolean(false); - @Before + @BeforeEach public void bindInit() { if (!onlyOnceGuard.getAndSet(true)) { BindingTestHelper.bind(injectionManager, binder -> binder.bindFactory(new DisposableSupplierImpl()) diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/InjectionManagerTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/InjectionManagerTest.java index 6cf1053604..db3390cb10 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/InjectionManagerTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/InjectionManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.inject.weld.managed.CdiInjectionManagerFactory; import org.glassfish.jersey.internal.inject.InjectionManager; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class InjectionManagerTest extends TestParent { @@ -31,16 +31,16 @@ public class InjectionManagerTest extends TestParent { public void injectionManagerTest() { injectionManager.completeRegistration(); final InjectionManagerInjectedBean bean = injectionManager.getInstance(InjectionManagerInjectedBean.class); - Assert.assertNotNull(bean); + Assertions.assertNotNull(bean); InjectionManager got = bean.getInjectionManager(); - Assert.assertEquals(injectionManager, got); + Assertions.assertEquals(injectionManager, got); final InjectionManager clientInjectionManager = new CdiInjectionManagerFactory().create(null, RuntimeType.CLIENT); clientInjectionManager.completeRegistration(); final InjectionManagerInjectedBean clientBean = clientInjectionManager.getInstance(InjectionManagerInjectedBean.class); - Assert.assertNotNull(clientBean); + Assertions.assertNotNull(clientBean); InjectionManager gotClient = clientBean.getInjectionManager(); - Assert.assertEquals(clientInjectionManager, gotClient); + Assertions.assertEquals(clientInjectionManager, gotClient); } @Dependent diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ProviderInjectionTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ProviderInjectionTest.java index 3fe20cfbe6..74da492b91 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ProviderInjectionTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ProviderInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -29,17 +29,17 @@ import org.glassfish.jersey.internal.inject.AbstractBinder; import org.hamcrest.core.StringStartsWith; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import java.util.function.Supplier; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class ProviderInjectionTest extends TestParent { - @BeforeClass + @BeforeAll public static void setup() { SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance(); containerInitializer.addExtensions(new ProviderInjectionTestExtension()); @@ -55,7 +55,7 @@ public void testProviderInject() { // }); Greeting greeting = injectionManager.getInstance(Greeting.class); - Assert.assertNotNull(greeting); + Assertions.assertNotNull(greeting); ProviderInject instance = injectionManager.getInstance(ProviderInject.class); assertThat(instance.greeting.get().getGreeting(), StringStartsWith.startsWith(CzechGreeting.GREETING)); diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierClassBindingTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierClassBindingTest.java index bf10029457..3ab057101f 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierClassBindingTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierClassBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -30,11 +30,11 @@ import org.glassfish.jersey.internal.inject.AbstractBinder; import org.hamcrest.core.StringStartsWith; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests that {@link Supplier} can be registered as a class-factory. @@ -44,7 +44,7 @@ public class SupplierClassBindingTest extends TestParent { public static final String GREET = "Hi"; - @BeforeClass + @BeforeAll public static void setup() { SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance(); containerInitializer.addExtensions(new SupplierClassBindingTestExtension()); diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierContractsTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierContractsTest.java index 8f576e11d3..9c399bd7ec 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierContractsTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierContractsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -30,14 +30,15 @@ import org.glassfish.jersey.internal.inject.Injections; import org.jboss.weld.exceptions.DeploymentException; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import java.util.function.Consumer; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Tests that {@link java.util.function.Supplier} can contain multiple contracts. @@ -69,7 +70,7 @@ protected void configure() { injectionManager = Injections.createInjectionManager(); } - @After + @AfterEach public void tearDown() throws Exception { if (container != null && container.isRunning()) { container.close(); @@ -275,48 +276,54 @@ public void testInstanceFactoryMultipleContractsSingleton() { assertSame(conversation.greetingSupplier, conversation.printableSupplier); } - @Test(expected = DeploymentException.class) + @Test public void testClassFactoryFailedWrongImplementation() { -// BindingTestHelper.bind(injectionManager, binder -> { -// binder.bindFactory(SupplierGreeting.class).to(EnglishGreeting.class); -// binder.bindAsContract(Conversation.class); -// }); + assertThrows(DeploymentException.class, () -> { +// BindingTestHelper.bind(injectionManager, binder -> { +// binder.bindFactory(SupplierGreeting.class).to(EnglishGreeting.class); +// binder.bindAsContract(Conversation.class); +// }); - setup((binder) -> { - binder.bindFactory(SupplierGreeting.class).to(EnglishGreeting.class); - binder.bindAsContract(Conversation.class); - }); + setup((binder) -> { + binder.bindFactory(SupplierGreeting.class).to(EnglishGreeting.class); + binder.bindAsContract(Conversation.class); + }); - injectionManager.getInstance(Conversation.class); + injectionManager.getInstance(Conversation.class); + }); } - @Test(expected = DeploymentException.class) + @Test public void testInstanceFactoryFailsWrongImplementation() { - setup((binder) -> { - binder.bindFactory(new SupplierGreeting()).to(EnglishGreeting.class); - binder.bindAsContract(Conversation.class); - }); + assertThrows(DeploymentException.class, () -> { + setup((binder) -> { + binder.bindFactory(new SupplierGreeting()).to(EnglishGreeting.class); + binder.bindAsContract(Conversation.class); + }); + + BindingTestHelper.bind(injectionManager, binder -> { + binder.bindFactory(new SupplierGreeting()).to(EnglishGreeting.class); +// binder.bindAsContract(Conversation.class); + }); - BindingTestHelper.bind(injectionManager, binder -> { - binder.bindFactory(new SupplierGreeting()).to(EnglishGreeting.class); -// binder.bindAsContract(Conversation.class); + injectionManager.getInstance(Conversation.class); }); - - injectionManager.getInstance(Conversation.class); } - @Test(expected = DeploymentException.class) + @Test public void testFailsImplementationButInterfaceExpected() { - setup((binder) -> { - binder.bindFactory(new SupplierGreeting()).to(CzechGreeting.class); - binder.bindAsContract(Conversation.class); - }); + assertThrows(DeploymentException.class, () -> { + setup((binder) -> { + binder.bindFactory(new SupplierGreeting()).to(CzechGreeting.class); + binder.bindAsContract(Conversation.class); + }); + + BindingTestHelper.bind(injectionManager, binder -> { + binder.bindFactory(new SupplierGreeting()).to(CzechGreeting.class); +// binder.bindAsContract(Conversation.class); + }); - BindingTestHelper.bind(injectionManager, binder -> { - binder.bindFactory(new SupplierGreeting()).to(CzechGreeting.class); -// binder.bindAsContract(Conversation.class); + injectionManager.getInstance(Conversation.class); }); - - injectionManager.getInstance(Conversation.class); } } diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierInstanceBindingTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierInstanceBindingTest.java index eb90843edd..2e1f2607a9 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierInstanceBindingTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/SupplierInstanceBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -31,14 +31,14 @@ import org.glassfish.jersey.internal.inject.AbstractBinder; import org.hamcrest.core.StringStartsWith; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests that {@link Supplier} can be registered as a instance-factory. @@ -51,14 +51,14 @@ public class SupplierInstanceBindingTest extends TestParent { private static long supplierHit = 2; private static AtomicBoolean runOnlyOnceGuard = new AtomicBoolean(false); - @BeforeClass + @BeforeAll public static void setup() { SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance(); containerInitializer.addExtensions(new SupplierInstanceBindingTestExtension()); container = containerInitializer.initialize(); } - @Before + @BeforeEach public void initBinding() { if (!runOnlyOnceGuard.getAndSet(true)) { MyVetoedLongSupplier supplier = new MyVetoedLongSupplier(); diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/TestParent.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/TestParent.java index 0938dd239d..0dfc70dd40 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/TestParent.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/TestParent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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,27 +20,27 @@ import javax.enterprise.inject.se.SeContainerInitializer; import org.glassfish.jersey.internal.inject.InjectionManager; import org.glassfish.jersey.internal.inject.Injections; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; public class TestParent { protected static SeContainer container; protected InjectionManager injectionManager; - @BeforeClass + @BeforeAll public static void setup() { SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance(); container = containerInitializer.initialize(); } - @Before + @BeforeEach public void init() { injectionManager = Injections.createInjectionManager(); } - @AfterClass + @AfterAll public static void tearDown() throws Exception { container.close(); } diff --git a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ThreadScopeTest.java b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ThreadScopeTest.java index e3fc4d2864..a87f8f985d 100644 --- a/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ThreadScopeTest.java +++ b/incubator/cdi-inject-weld/src/test/java/org/glassfish/jersey/inject/weld/internal/managed/ThreadScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -29,13 +29,13 @@ import org.glassfish.jersey.process.internal.RequestScope; import org.hamcrest.core.StringStartsWith; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.hamcrest.MatcherAssert.assertThat; /** * Testing thread scope integration. @@ -46,7 +46,7 @@ public class ThreadScopeTest extends TestParent { private static AtomicBoolean runOnlyOnceGuard = new AtomicBoolean(false); - @Before + @BeforeEach public void initOnce() { if (!runOnlyOnceGuard.getAndSet(true)) { BindingTestHelper.bind(injectionManager, binder -> { diff --git a/incubator/declarative-linking/pom.xml b/incubator/declarative-linking/pom.xml index 56d220814e..f0ea7647b7 100644 --- a/incubator/declarative-linking/pom.xml +++ b/incubator/declarative-linking/pom.xml @@ -63,8 +63,8 @@ provided - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/EntityDescriptorTest.java b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/EntityDescriptorTest.java index 5ed63fd489..2cecb5552e 100644 --- a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/EntityDescriptorTest.java +++ b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/EntityDescriptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.linking.mapping.ResourceMappingContext; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/FieldProcessorTest.java b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/FieldProcessorTest.java index e0afebaec1..17d42437f7 100644 --- a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/FieldProcessorTest.java +++ b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/FieldProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -49,9 +49,9 @@ import org.glassfish.jersey.server.model.RuntimeResource; import org.glassfish.jersey.uri.UriTemplate; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Mark Hadley diff --git a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/HeaderProcessorTest.java b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/HeaderProcessorTest.java index cf360ab0fd..ef08c177db 100644 --- a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/HeaderProcessorTest.java +++ b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/HeaderProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -34,9 +34,9 @@ import org.glassfish.jersey.server.model.RuntimeResource; import org.glassfish.jersey.uri.UriTemplate; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/LinkELContextTest.java b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/LinkELContextTest.java index 89bf3f4d81..03d3aacd75 100644 --- a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/LinkELContextTest.java +++ b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/LinkELContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -19,9 +19,9 @@ import javax.el.ExpressionFactory; import javax.el.ValueExpression; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * diff --git a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/integration/LinkingManualTest.java b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/integration/LinkingManualTest.java index 6375042797..cf75afe0d3 100644 --- a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/integration/LinkingManualTest.java +++ b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/integration/LinkingManualTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -25,7 +25,7 @@ import org.glassfish.jersey.linking.integration.app.LinkingManualApplication; import org.glassfish.jersey.linking.integration.representations.OrderRequest; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; public class LinkingManualTest extends JerseyTest { diff --git a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/integration/LinkingTest.java b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/integration/LinkingTest.java index 4c0e95883b..d2996036a1 100644 --- a/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/integration/LinkingTest.java +++ b/incubator/declarative-linking/src/test/java/org/glassfish/jersey/linking/integration/LinkingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -25,7 +25,7 @@ import org.glassfish.jersey.linking.integration.app.LinkingApplication; import org.glassfish.jersey.linking.integration.representations.OrderRequest; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; public class LinkingTest extends JerseyTest { diff --git a/incubator/html-json/pom.xml b/incubator/html-json/pom.xml index 1714b3401f..af73db3a13 100644 --- a/incubator/html-json/pom.xml +++ b/incubator/html-json/pom.xml @@ -70,8 +70,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/AbstractTypeTester.java b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/AbstractTypeTester.java index 4e5c7711bc..764ac2bc86 100644 --- a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/AbstractTypeTester.java +++ b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/AbstractTypeTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -41,7 +41,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Abstract entity type tester base class. @@ -145,7 +145,7 @@ protected static void _verify(byte[] in, byte[] out) { assertEquals(in.length, out.length); for (int i = 0; i < in.length; i++) { if (in[i] != out[i]) { - assertEquals("Index: " + i, in[i], out[i]); + assertEquals(in[i], out[i], "Index: " + i); } } } diff --git a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ComputedPropertyTest.java b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ComputedPropertyTest.java index eb5a839543..13023871ec 100644 --- a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ComputedPropertyTest.java +++ b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ComputedPropertyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -23,8 +23,8 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import net.java.html.json.ComputedProperty; import net.java.html.json.Model; diff --git a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityOnArrayTest.java b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityOnArrayTest.java index a1e01c7fb3..8a548fe07b 100644 --- a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityOnArrayTest.java +++ b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityOnArrayTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import net.java.html.json.Model; @@ -113,9 +113,9 @@ public void doReadWrite() throws Exception { final Class c = arr.getClass(); Object ret = new HtmlJsonProvider().readFrom(c, null, null, MediaType.APPLICATION_JSON_TYPE, null, is); - assertTrue("It is array: " + ret, ret instanceof MyBean[]); + assertTrue(ret instanceof MyBean[], "It is array: " + ret); MyBean[] res = (MyBean[]) ret; - assertEquals("Two items: ", 2, res.length); + assertEquals(2, res.length, "Two items: "); assertEquals(arr[0], res[0]); assertEquals(arr[1], res[1]); } @@ -127,6 +127,6 @@ public void myBeanAndGet() { assertEquals(200, response.getStatus()); final MyBean[] teb = response.readEntity(MyBean[].class); - assertEquals("value", "hello", teb[0].getValue()); + assertEquals("hello", teb[0].getValue(), "value"); } } diff --git a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityOnListTest.java b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityOnListTest.java index 2dffdb7fde..e742adef80 100644 --- a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityOnListTest.java +++ b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityOnListTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import net.java.html.json.Model; @@ -104,7 +104,7 @@ public void myBeanAndGet() { GenericType> ge = new GenericType>() {}; List teb = response.readEntity(ge); - assertEquals("one element in list: " + teb, 1, teb.size()); - assertEquals("value", "hello", teb.get(0).getValue()); + assertEquals(1, teb.size(), "one element in list: " + teb); + assertEquals("hello", teb.get(0).getValue(), "value"); } } diff --git a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityTest.java b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityTest.java index dfc996f599..af23c64938 100644 --- a/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityTest.java +++ b/incubator/html-json/src/test/java/org/glassfish/jersey/media/htmljson/ModelEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import net.java.html.json.Model; import net.java.html.json.Property; @@ -88,6 +88,6 @@ public void myBeanAndGet() { assertEquals(200, response.getStatus()); final MyBean teb = response.readEntity(MyBean.class); - assertEquals("value", "hello", teb.getValue()); + assertEquals("hello", teb.getValue(), "value"); } } diff --git a/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceBaseTest.java b/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceBaseTest.java index 2bbedf80d8..76ad72a6c8 100644 --- a/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceBaseTest.java +++ b/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceBaseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -17,12 +17,12 @@ package org.glassfish.jersey.kryo; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public abstract class PersonResourceBaseTest extends JerseyTest { diff --git a/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceTest.java b/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceTest.java index dbbcbd64b8..39b4247b0b 100644 --- a/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceTest.java +++ b/incubator/kryo/src/test/java/org/glassfish/jersey/kryo/PersonResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test for kryo resource. diff --git a/incubator/open-tracing/pom.xml b/incubator/open-tracing/pom.xml index 6e7450270c..1178cbc15c 100644 --- a/incubator/open-tracing/pom.xml +++ b/incubator/open-tracing/pom.xml @@ -60,8 +60,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/inject/cdi2-se/pom.xml b/inject/cdi2-se/pom.xml index da9dcdc466..a9e0e25a16 100644 --- a/inject/cdi2-se/pom.xml +++ b/inject/cdi2-se/pom.xml @@ -50,8 +50,13 @@ - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.hamcrest + hamcrest test diff --git a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/DisposableSupplierTest.java b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/DisposableSupplierTest.java index ed8215824c..69d68eb247 100644 --- a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/DisposableSupplierTest.java +++ b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/DisposableSupplierTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -33,14 +33,14 @@ import org.glassfish.jersey.process.internal.RequestScope; import org.glassfish.jersey.process.internal.RequestScoped; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Tests that {@link DisposableSupplier} is properly processed by {@link BeanHelper}. @@ -58,12 +58,12 @@ public class DisposableSupplierTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } diff --git a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/ProviderInjectionTest.java b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/ProviderInjectionTest.java index 60cd4b294a..d8315d4215 100644 --- a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/ProviderInjectionTest.java +++ b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/ProviderInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -24,21 +24,21 @@ import org.glassfish.jersey.internal.inject.InjectionManager; import org.hamcrest.core.StringStartsWith; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; public class ProviderInjectionTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } diff --git a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierClassBindingTest.java b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierClassBindingTest.java index e85a558664..f20c20e24d 100644 --- a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierClassBindingTest.java +++ b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierClassBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -24,12 +24,12 @@ import org.glassfish.jersey.internal.inject.InjectionManager; import org.hamcrest.core.StringStartsWith; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests that {@link Supplier} can be registered as a class-factory. @@ -41,12 +41,12 @@ public class SupplierClassBindingTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } diff --git a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierContractsTest.java b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierContractsTest.java index 3831e860c0..0e5cde93f1 100644 --- a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierContractsTest.java +++ b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierContractsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -22,12 +22,13 @@ import org.glassfish.jersey.internal.inject.InjectionManager; import org.jboss.weld.exceptions.DeploymentException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Tests that {@link java.util.function.Supplier} can contain multiple contracts. @@ -39,12 +40,12 @@ public class SupplierContractsTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } @@ -195,33 +196,39 @@ public void testInstanceFactoryMultipleContractsSingleton() { assertSame(conversation.greetingSupplier, conversation.printableSupplier); } - @Test(expected = DeploymentException.class) + @Test public void testClassFactoryFailedWrongImplementation() { - BindingTestHelper.bind(injectionManager, binder -> { - binder.bindFactory(SupplierGreeting.class).to(EnglishGreeting.class); - binder.bindAsContract(Conversation.class); - }); + assertThrows(DeploymentException.class, () -> { + BindingTestHelper.bind(injectionManager, binder -> { + binder.bindFactory(SupplierGreeting.class).to(EnglishGreeting.class); + binder.bindAsContract(Conversation.class); + }); - injectionManager.getInstance(Conversation.class); + injectionManager.getInstance(Conversation.class); + }); } - @Test(expected = DeploymentException.class) + @Test public void testInstanceFactoryFailsWrongImplementation() { - BindingTestHelper.bind(injectionManager, binder -> { - binder.bindFactory(new SupplierGreeting()).to(EnglishGreeting.class); - binder.bindAsContract(Conversation.class); - }); + assertThrows(DeploymentException.class, () -> { + BindingTestHelper.bind(injectionManager, binder -> { + binder.bindFactory(new SupplierGreeting()).to(EnglishGreeting.class); + binder.bindAsContract(Conversation.class); + }); - injectionManager.getInstance(Conversation.class); + injectionManager.getInstance(Conversation.class); + }); } - @Test(expected = DeploymentException.class) + @Test public void testFailsImplementationButInterfaceExpected() { - BindingTestHelper.bind(injectionManager, binder -> { - binder.bindFactory(new SupplierGreeting()).to(CzechGreeting.class); - binder.bindAsContract(Conversation.class); - }); + assertThrows(DeploymentException.class, () -> { + BindingTestHelper.bind(injectionManager, binder -> { + binder.bindFactory(new SupplierGreeting()).to(CzechGreeting.class); + binder.bindAsContract(Conversation.class); + }); - injectionManager.getInstance(Conversation.class); + injectionManager.getInstance(Conversation.class); + }); } } diff --git a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierInstanceBindingTest.java b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierInstanceBindingTest.java index 9c2575da80..9a0151451a 100644 --- a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierInstanceBindingTest.java +++ b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/SupplierInstanceBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -25,13 +25,13 @@ import org.glassfish.jersey.internal.inject.InjectionManager; import org.hamcrest.core.StringStartsWith; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests that {@link Supplier} can be registered as a instance-factory. @@ -43,12 +43,12 @@ public class SupplierInstanceBindingTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } diff --git a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/ThreadScopeTest.java b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/ThreadScopeTest.java index 0a667bbba6..1c3ded4c20 100644 --- a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/ThreadScopeTest.java +++ b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/ThreadScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -29,12 +29,12 @@ import org.glassfish.jersey.process.internal.RequestScope; import org.hamcrest.core.StringStartsWith; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.hamcrest.MatcherAssert.assertThat; /** * Testing thread scope integration. diff --git a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/injector/CachedConstructorAnalyzerTest.java b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/injector/CachedConstructorAnalyzerTest.java index 6f5e863de7..8fa714bbff 100644 --- a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/injector/CachedConstructorAnalyzerTest.java +++ b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/injector/CachedConstructorAnalyzerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -27,8 +27,9 @@ import javax.enterprise.inject.InjectionException; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Tests {@link CachedConstructorAnalyzer}. @@ -128,14 +129,16 @@ public void testMultiAnnotatedConstructor() { assertEquals(2, analyzer.getConstructor().getParameterCount()); } - @Test(expected = InjectionException.class) + @Test public void testUnknownAnnotatedConstructor() { - new CachedConstructorAnalyzer<>(UnknownAnnotatedConstructor.class, ANNOTATIONS).getConstructor(); + assertThrows(InjectionException.class, + () -> new CachedConstructorAnalyzer<>(UnknownAnnotatedConstructor.class, ANNOTATIONS).getConstructor()); } - @Test(expected = InjectionException.class) + @Test public void testSingleNonAnnotatedConstructor() { - new CachedConstructorAnalyzer<>(SingleNonAnnotatedConstructor.class, ANNOTATIONS).getConstructor(); + assertThrows(InjectionException.class, + () -> new CachedConstructorAnalyzer<>(SingleNonAnnotatedConstructor.class, ANNOTATIONS).getConstructor()); } public static class DefaultConstructor { diff --git a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/injector/JerseyProxyResolverTest.java b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/injector/JerseyProxyResolverTest.java index 6726c8a942..5f071b1010 100644 --- a/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/injector/JerseyProxyResolverTest.java +++ b/inject/cdi2-se/src/test/java/org/glassfish/jersey/inject/cdi/se/injector/JerseyProxyResolverTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -33,11 +33,11 @@ import org.glassfish.jersey.internal.inject.InjecteeImpl; import org.glassfish.jersey.internal.inject.InjectionResolver; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests Jersey Proxy Resolver. diff --git a/inject/hk2/pom.xml b/inject/hk2/pom.xml index 195b4ecfa0..f33f72d2c4 100644 --- a/inject/hk2/pom.xml +++ b/inject/hk2/pom.xml @@ -61,8 +61,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/DisposableSupplierTest.java b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/DisposableSupplierTest.java index c3bb507fc4..9eefe4889a 100644 --- a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/DisposableSupplierTest.java +++ b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/DisposableSupplierTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -31,14 +31,14 @@ import org.glassfish.jersey.process.internal.RequestScope; import org.glassfish.jersey.process.internal.RequestScoped; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Tests that {@link org.glassfish.jersey.internal.inject.DisposableSupplier} is properly processed by {@link Hk2Helper}. @@ -52,12 +52,12 @@ public class DisposableSupplierTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } diff --git a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/InjectionManagerTest.java b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/InjectionManagerTest.java index 02be49fbfc..57a5d49d10 100644 --- a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/InjectionManagerTest.java +++ b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/InjectionManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -26,10 +26,11 @@ import org.glassfish.hk2.utilities.ServiceLocatorUtilities; import org.glassfish.hk2.utilities.binding.AbstractBinder; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Petr Bouda @@ -63,9 +64,11 @@ public void testInjectionManagerParent() { assertNotNull(injectionManager.getInstance(EnglishGreeting.class)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testUnknownParent() { - Injections.createInjectionManager(new Object()); + assertThrows(IllegalArgumentException.class, () -> { + Injections.createInjectionManager(new Object()); + }); } @Test @@ -92,9 +95,11 @@ protected void configure() { assertNotNull(injectionManager.getInstance(EnglishGreeting.class)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testRegisterUnknownProvider() { - InjectionManager injectionManager = Injections.createInjectionManager(); - injectionManager.register(new Object()); + assertThrows(IllegalArgumentException.class, () -> { + InjectionManager injectionManager = Injections.createInjectionManager(); + injectionManager.register(new Object()); + }); } } diff --git a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierClassBindingTest.java b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierClassBindingTest.java index 02a7938266..0c538ac1a4 100644 --- a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierClassBindingTest.java +++ b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierClassBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -22,12 +22,12 @@ import org.glassfish.jersey.internal.inject.InjectionManager; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Tests that {@link java.util.function.Supplier} can be registered as a class-factory. @@ -38,12 +38,12 @@ public class SupplierClassBindingTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } diff --git a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierContractsTest.java b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierContractsTest.java index a43c04e333..15101adbad 100644 --- a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierContractsTest.java +++ b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierContractsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -22,12 +22,13 @@ import org.glassfish.hk2.api.MultiException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Tests that {@link java.util.function.Supplier} can contain multiple contracts. @@ -38,12 +39,12 @@ public class SupplierContractsTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } @@ -194,33 +195,39 @@ public void testInstanceFactoryMultipleContractsSingleton() { assertSame(conversation.greetingSupplier, conversation.printableSupplier); } - @Test(expected = MultiException.class) + @Test public void testClassFactoryFailedWrongImplementation() { - BindingTestHelper.bind(injectionManager, binder -> { - binder.bindFactory(SupplierGreeting.class).to(EnglishGreeting.class); - binder.bindAsContract(Conversation.class); - }); + assertThrows(MultiException.class, () -> { + BindingTestHelper.bind(injectionManager, binder -> { + binder.bindFactory(SupplierGreeting.class).to(EnglishGreeting.class); + binder.bindAsContract(Conversation.class); + }); - injectionManager.getInstance(Conversation.class); + injectionManager.getInstance(Conversation.class); + }); } - @Test(expected = MultiException.class) + @Test public void testInstanceFactoryFailsWrongImplementation() { - BindingTestHelper.bind(injectionManager, binder -> { - binder.bindFactory(new SupplierGreeting()).to(EnglishGreeting.class); - binder.bindAsContract(Conversation.class); - }); + assertThrows(MultiException.class, () -> { + BindingTestHelper.bind(injectionManager, binder -> { + binder.bindFactory(new SupplierGreeting()).to(EnglishGreeting.class); + binder.bindAsContract(Conversation.class); + }); - injectionManager.getInstance(Conversation.class); + injectionManager.getInstance(Conversation.class); + }); } - @Test(expected = MultiException.class) + @Test public void testFailsImplementationButInterfaceExpected() { - BindingTestHelper.bind(injectionManager, binder -> { - binder.bindFactory(new SupplierGreeting()).to(CzechGreeting.class); - binder.bindAsContract(Conversation.class); - }); + assertThrows(MultiException.class, () -> { + BindingTestHelper.bind(injectionManager, binder -> { + binder.bindFactory(new SupplierGreeting()).to(CzechGreeting.class); + binder.bindAsContract(Conversation.class); + }); - injectionManager.getInstance(Conversation.class); + injectionManager.getInstance(Conversation.class); + }); } } diff --git a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierInstanceBindingTest.java b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierInstanceBindingTest.java index 93ccc1053e..5fdf2a0c61 100644 --- a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierInstanceBindingTest.java +++ b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierInstanceBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -23,12 +23,12 @@ import org.glassfish.jersey.internal.inject.InjectionManager; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Tests that {@link java.util.function.Supplier} can be registered as a instance-factory. @@ -49,12 +49,12 @@ public Integer get() { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } diff --git a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierProxyTest.java b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierProxyTest.java index 2604d27729..79e9c9f26f 100644 --- a/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierProxyTest.java +++ b/inject/hk2/src/test/java/org/glassfish/jersey/inject/hk2/SupplierProxyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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,11 +18,11 @@ import org.glassfish.jersey.internal.inject.InjectionManager; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests that {@link java.util.function.Supplier} can contain proxies. @@ -33,12 +33,12 @@ public class SupplierProxyTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setup() { injectionManager = BindingTestHelper.createInjectionManager(); } - @After + @AfterEach public void teardown() { injectionManager.shutdown(); } diff --git a/media/jaxb/pom.xml b/media/jaxb/pom.xml index 61fae82b49..b2d691da00 100644 --- a/media/jaxb/pom.xml +++ b/media/jaxb/pom.xml @@ -144,8 +144,13 @@ - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.hamcrest + hamcrest test diff --git a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/AbstractJaxbProviderTest.java b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/AbstractJaxbProviderTest.java index 232c9d721a..8be1403d43 100644 --- a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/AbstractJaxbProviderTest.java +++ b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/AbstractJaxbProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -30,13 +30,13 @@ import org.glassfish.jersey.internal.inject.InjectionManager; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class AbstractJaxbProviderTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setUp() { injectionManager = SaxParserFactoryInjectionProviderTest.createInjectionManager(); } diff --git a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/FeatureAndPropertySupplierTest.java b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/FeatureAndPropertySupplierTest.java index bc28e3a7d0..74148fe94f 100644 --- a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/FeatureAndPropertySupplierTest.java +++ b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/FeatureAndPropertySupplierTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -23,10 +23,11 @@ import org.glassfish.jersey.jaxb.PropertySupplier; import org.glassfish.jersey.message.MessageProperties; import org.hamcrest.CoreMatchers; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; @@ -44,7 +45,6 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.util.Collections; import java.util.Map; @@ -56,13 +56,13 @@ public class FeatureAndPropertySupplierTest { private static PrintStream systemErrorStream; private static ByteArrayOutputStream errorStream = new ByteArrayOutputStream(); - @BeforeClass + @BeforeAll public static void setup() { systemErrorStream = System.err; System.setErr(new PrintStream(errorStream)); } - @AfterClass + @AfterAll public static void tearDown() { System.setErr(systemErrorStream); } @@ -85,7 +85,7 @@ protected void configure() { try { injectionManager.getInstance(SAXParserFactory.class).newSAXParser().getXMLReader() .parse(new InputSource(new ByteArrayInputStream(content.getBytes("us-ascii")))); - Assert.fail("DOCTYPE is NOT disallowed when the feature \"disallow-doctype-decl\" is true"); + Assertions.fail("DOCTYPE is NOT disallowed when the feature \"disallow-doctype-decl\" is true"); } catch (SAXParseException saxe) { //expected } @@ -105,7 +105,7 @@ protected void configure() { injectionManager.getInstance(SAXParserFactory.class).newSAXParser(); String warning = new String(errorStream.toByteArray()); errorStream.reset(); - Assert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); + MatcherAssert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); } @Test @@ -132,7 +132,7 @@ protected void configure() { injectionManager.getInstance(SAXParserFactory.class).newSAXParser(); String warning = new String(errorStream.toByteArray()); errorStream.reset(); - Assert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); + MatcherAssert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); } @Test @@ -151,7 +151,7 @@ protected void configure() { LogManager.getLogManager().reset(); String warning = new String(errorStream.toByteArray()); errorStream.reset(); - Assert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); + MatcherAssert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); } @Test @@ -169,7 +169,7 @@ protected void configure() { injectionManager.getInstance(TransformerFactory.class); String warning = new String(errorStream.toByteArray()); errorStream.reset(); - Assert.assertThat(warning, CoreMatchers.containsString("Cannot set feature \"Unknown-Feature\"")); + MatcherAssert.assertThat(warning, CoreMatchers.containsString("Cannot set feature \"Unknown-Feature\"")); } @Test @@ -187,7 +187,7 @@ protected void configure() { injectionManager.getInstance(XMLInputFactory.class); String warning = new String(errorStream.toByteArray()); errorStream.reset(); - Assert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); + MatcherAssert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); } @Test @@ -205,7 +205,7 @@ protected void configure() { injectionManager.getInstance(DocumentBuilderFactory.class); String warning = new String(errorStream.toByteArray()); errorStream.reset(); - Assert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); + MatcherAssert.assertThat(warning, CoreMatchers.containsString("Cannot set property \"Unknown-Property\"")); } diff --git a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/JaxbStringReaderProviderTest.java b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/JaxbStringReaderProviderTest.java index d906232044..38793d85f0 100644 --- a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/JaxbStringReaderProviderTest.java +++ b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/JaxbStringReaderProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -40,7 +40,7 @@ import org.glassfish.jersey.model.internal.CommonConfig; import org.glassfish.jersey.model.internal.ComponentBag; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class JaxbStringReaderProviderTest { diff --git a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/SaxParserFactoryInjectionProviderTest.java b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/SaxParserFactoryInjectionProviderTest.java index 5a79737e04..67e6e556fa 100644 --- a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/SaxParserFactoryInjectionProviderTest.java +++ b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/SaxParserFactoryInjectionProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -43,13 +43,13 @@ import org.glassfish.jersey.internal.inject.PerThread; import org.glassfish.jersey.jaxb.FeatureSupplier; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; /** * @author Martin Matula @@ -61,7 +61,7 @@ public class SaxParserFactoryInjectionProviderTest { private SAXParserFactory ff1; private SAXParserFactory ff2; - @Before + @BeforeEach public void setUp() { injectionManager = createInjectionManager(); } diff --git a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/SourceProviderTest.java b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/SourceProviderTest.java index 81e9cfe7d6..9f4fa5b195 100644 --- a/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/SourceProviderTest.java +++ b/media/jaxb/src/test/java/org/glassfish/jersey/jaxb/internal/SourceProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -32,14 +32,14 @@ import org.glassfish.jersey.internal.inject.InjectionManager; import org.glassfish.jersey.message.internal.SourceProvider; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SourceProviderTest { private InjectionManager injectionManager; - @Before + @BeforeEach public void setUp() { injectionManager = SaxParserFactoryInjectionProviderTest.createInjectionManager(new AbstractBinder() { @Override diff --git a/media/json-binding/pom.xml b/media/json-binding/pom.xml index 899e682bfd..b83373cade 100644 --- a/media/json-binding/pom.xml +++ b/media/json-binding/pom.xml @@ -113,8 +113,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/media/json-binding/src/test/java/org/glassfish/jersey/jsonb/internal/JsonBindingProviderTest.java b/media/json-binding/src/test/java/org/glassfish/jersey/jsonb/internal/JsonBindingProviderTest.java index 1a8cf00bc1..b373b2e340 100644 --- a/media/json-binding/src/test/java/org/glassfish/jersey/jsonb/internal/JsonBindingProviderTest.java +++ b/media/json-binding/src/test/java/org/glassfish/jersey/jsonb/internal/JsonBindingProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Markus KARG + * Copyright (c) 2020, 2022 Markus KARG * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -38,7 +38,8 @@ import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Providers; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Unit Test for {@link JsonBindingProvider}. @@ -47,18 +48,20 @@ */ public final class JsonBindingProviderTest { - @Test(expected = NoContentException.class) + @Test public final void shouldThrowNoContentException() throws IOException { - // given - final Providers providers = new EmptyProviders(); - final MessageBodyReader mbr = (MessageBodyReader) new JsonBindingProvider(providers); - - // when - mbr.readFrom(Foo.class, Foo.class, new Annotation[0], APPLICATION_JSON_TYPE, - new MultivaluedHashMap<>(), new ByteArrayInputStream(new byte[0])); - - // then - // should throw NoContentException + assertThrows(NoContentException.class, () -> { + // given + final Providers providers = new EmptyProviders(); + final MessageBodyReader mbr = (MessageBodyReader) new JsonBindingProvider(providers); + + // when + mbr.readFrom(Foo.class, Foo.class, new Annotation[0], APPLICATION_JSON_TYPE, + new MultivaluedHashMap<>(), new ByteArrayInputStream(new byte[0])); + + // then + // should throw NoContentException + }); } private static final class Foo { diff --git a/media/json-gson/pom.xml b/media/json-gson/pom.xml index 157e84f224..374f13d33f 100644 --- a/media/json-gson/pom.xml +++ b/media/json-gson/pom.xml @@ -73,8 +73,8 @@ gson - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/media/json-gson/src/test/java/org/glassfish/jersey/gson/internal/JsonGsonProviderTest.java b/media/json-gson/src/test/java/org/glassfish/jersey/gson/internal/JsonGsonProviderTest.java index c7884d6299..db765f21bd 100644 --- a/media/json-gson/src/test/java/org/glassfish/jersey/gson/internal/JsonGsonProviderTest.java +++ b/media/json-gson/src/test/java/org/glassfish/jersey/gson/internal/JsonGsonProviderTest.java @@ -32,16 +32,19 @@ import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Providers; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; public class JsonGsonProviderTest { - @Test(expected = NoContentException.class) + @Test public void shouldThrowNoContentException() throws IOException { - Providers providers = new EmptyProviders(); - MessageBodyReader mbr = (MessageBodyReader) new JsonGsonProvider(providers); - mbr.readFrom(Foo.class, Foo.class, new Annotation[0], APPLICATION_JSON_TYPE, - new MultivaluedHashMap<>(), new ByteArrayInputStream(new byte[0])); + assertThrows(NoContentException.class, () -> { + Providers providers = new EmptyProviders(); + MessageBodyReader mbr = (MessageBodyReader) new JsonGsonProvider(providers); + mbr.readFrom(Foo.class, Foo.class, new Annotation[0], APPLICATION_JSON_TYPE, + new MultivaluedHashMap<>(), new ByteArrayInputStream(new byte[0])); + }); } private static final class Foo { diff --git a/media/json-jackson/pom.xml b/media/json-jackson/pom.xml index d99b90067e..d51aa86272 100644 --- a/media/json-jackson/pom.xml +++ b/media/json-jackson/pom.xml @@ -135,8 +135,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProviderTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProviderTest.java index 281d4c404d..388ca2abc2 100644 --- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProviderTest.java +++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -19,11 +19,11 @@ import org.glassfish.jersey.jackson.internal.model.ServiceTest; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public final class DefaultJacksonJaxbJsonProviderTest extends JerseyTest { diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java index d8d43c0fe6..9d86b842b2 100644 --- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java +++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java @@ -19,11 +19,11 @@ import org.glassfish.jersey.jackson.internal.model.ServiceTest; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DefaultJsonJacksonProviderForBothModulesTest extends JerseyTest { @Override diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java index 3a1bbe6876..8d8075cbfc 100644 --- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java +++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java @@ -23,7 +23,7 @@ import org.glassfish.jersey.jackson.internal.model.ServiceTest; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.annotation.PostConstruct; import javax.inject.Inject; @@ -31,8 +31,8 @@ import javax.ws.rs.core.Configuration; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class DefaultJsonJacksonProviderForDisabledModulesTest extends JerseyTest { @Override diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java index 76b7dd9fc2..77092f6fb1 100644 --- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java +++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java @@ -19,11 +19,11 @@ import org.glassfish.jersey.jackson.internal.model.ServiceTest; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; public class DefaultJsonJacksonProviderForEnabledModulesTest extends JerseyTest { @Override diff --git a/media/json-jackson1/pom.xml b/media/json-jackson1/pom.xml index ada3eaead0..571a162249 100644 --- a/media/json-jackson1/pom.xml +++ b/media/json-jackson1/pom.xml @@ -86,8 +86,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/media/json-jettison/pom.xml b/media/json-jettison/pom.xml index 2436a5e32e..c475ffd907 100644 --- a/media/json-jettison/pom.xml +++ b/media/json-jettison/pom.xml @@ -83,8 +83,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/media/json-processing/pom.xml b/media/json-processing/pom.xml index f98abe3a69..3e62429728 100644 --- a/media/json-processing/pom.xml +++ b/media/json-processing/pom.xml @@ -86,8 +86,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableClientTest.java b/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableClientTest.java index ffcde89d9f..e309e5ab68 100644 --- a/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableClientTest.java +++ b/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.ClientProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableServerTest.java b/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableServerTest.java index 58da0e1741..5806b6bdd4 100644 --- a/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableServerTest.java +++ b/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,8 +35,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/media/moxy/pom.xml b/media/moxy/pom.xml index 64ee029adc..9f6599e8d6 100644 --- a/media/moxy/pom.xml +++ b/media/moxy/pom.xml @@ -120,8 +120,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/media/multipart/pom.xml b/media/multipart/pom.xml index 9d6113c370..d101439a22 100644 --- a/media/multipart/pom.xml +++ b/media/multipart/pom.xml @@ -100,8 +100,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/BodyPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/BodyPartTest.java index 509d297485..f5e721a0af 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/BodyPartTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/BodyPartTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,13 +22,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test case for {@link BodyPart}. @@ -40,12 +40,12 @@ */ public class BodyPartTest { - @Before + @BeforeEach public void setUp() throws Exception { bodyPart = new BodyPart(); } - @After + @AfterEach public void tearDown() throws Exception { bodyPart = null; } diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataBodyPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataBodyPartTest.java index 40932f97d7..79a222c9cb 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataBodyPartTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataBodyPartTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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,14 +18,14 @@ import javax.ws.rs.core.MediaType; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test case for {@link FormDataBodyPart}. @@ -38,14 +38,14 @@ public class FormDataBodyPartTest extends BodyPartTest { @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); bodyPart = new FormDataBodyPart(); } @Override - @After + @AfterEach public void tearDown() throws Exception { bodyPart = null; super.tearDown(); diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataMultiPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataMultiPartTest.java index 7cf196a843..1c48a39591 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataMultiPartTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataMultiPartTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,11 +16,11 @@ package org.glassfish.jersey.media.multipart; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test case for {@link FormDataMultiPart}. @@ -31,14 +31,14 @@ public class FormDataMultiPartTest extends MultiPartTest { @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); multiPart = new FormDataMultiPart(); } @Override - @After + @AfterEach public void tearDown() throws Exception { multiPart = null; super.tearDown(); diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartMediaTypesTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartMediaTypesTest.java index 7b5d3a90c0..41b759c408 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartMediaTypesTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartMediaTypesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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,9 +18,9 @@ import javax.ws.rs.core.MediaType; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test case for {@link MultiPartMediaTypes}. diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartTest.java index 91cf08d67e..fbfa600cf7 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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,11 +18,11 @@ import javax.ws.rs.core.MediaType; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Test case for {@link MultiPart}. @@ -34,12 +34,12 @@ public class MultiPartTest { protected MultiPart multiPart = null; - @Before + @BeforeEach public void setUp() throws Exception { multiPart = new MultiPart(); } - @After + @AfterEach public void tearDown() throws Exception { multiPart = null; } diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultipartMixedWithApacheClientTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultipartMixedWithApacheClientTest.java index 586749424e..30748b8f4a 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultipartMixedWithApacheClientTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultipartMixedWithApacheClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -35,8 +35,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/ParameterizedHeadersMapTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/ParameterizedHeadersMapTest.java index dee6da0d89..647100c930 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/ParameterizedHeadersMapTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/ParameterizedHeadersMapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -26,14 +26,14 @@ import org.glassfish.jersey.message.internal.ParameterizedHeader; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Unit tests for {@link ParameterizedHeadersMap}. @@ -45,12 +45,12 @@ public class ParameterizedHeadersMapTest { private ParameterizedHeadersMap map; - @Before + @BeforeEach public void setUp() throws Exception { map = new ParameterizedHeadersMap(); } - @After + @AfterEach public void tearDown() throws Exception { map = null; } diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/StringKeyIgnoreCaseMultivaluedMapAsHeadersMapTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/StringKeyIgnoreCaseMultivaluedMapAsHeadersMapTest.java index 40eaeefc8a..39683682b0 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/StringKeyIgnoreCaseMultivaluedMapAsHeadersMapTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/StringKeyIgnoreCaseMultivaluedMapAsHeadersMapTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -26,14 +26,14 @@ import org.glassfish.jersey.internal.util.collection.StringKeyIgnoreCaseMultivaluedMap; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Unit tests for {@link StringKeyIgnoreCaseMultivaluedMap}. @@ -43,12 +43,12 @@ */ public class StringKeyIgnoreCaseMultivaluedMapAsHeadersMapTest { - @Before + @BeforeEach public void setUp() throws Exception { map = new StringKeyIgnoreCaseMultivaluedMap(); } - @After + @AfterEach public void tearDown() throws Exception { map = null; } diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/FileDataBodyPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/FileDataBodyPartTest.java index 9d55e7d2b4..3721193f10 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/FileDataBodyPartTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/FileDataBodyPartTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,12 +22,12 @@ import org.glassfish.jersey.media.multipart.BodyPartTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test case for {@link FileDataBodyPart}. @@ -39,14 +39,14 @@ public class FileDataBodyPartTest extends BodyPartTest { @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); bodyPart = new FileDataBodyPart(); } @Override - @After + @AfterEach public void tearDown() throws Exception { bodyPart = null; super.tearDown(); diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/StreamDataBodyPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/StreamDataBodyPartTest.java index 7da702b50d..2b0d72b92f 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/StreamDataBodyPartTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/StreamDataBodyPartTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,13 +24,13 @@ import org.glassfish.jersey.media.multipart.BodyPartTest; import org.glassfish.jersey.media.multipart.ContentDisposition; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests for the {@link StreamDataBodyPart} class which checks the class' main @@ -50,7 +50,7 @@ public class StreamDataBodyPartTest extends BodyPartTest { private StreamDataBodyPart cut; @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); cut = new StreamDataBodyPart(); @@ -60,7 +60,7 @@ public void setUp() throws Exception { } @Override - @After + @AfterEach public void tearDown() throws Exception { bodyPart = null; super.tearDown(); diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartBufferTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartBufferTest.java index 2eb6b1444b..7222690fdf 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartBufferTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartBufferTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -37,10 +37,10 @@ import org.glassfish.jersey.server.ContainerRequest; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Test cases for inspecting an {@code FormDataMultiPart} entity in a {@code RequestFilter} and following injection of this diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartReaderWriterTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartReaderWriterTest.java index 693007ea4e..9dcddf1825 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartReaderWriterTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartReaderWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -57,17 +57,15 @@ import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.MultiPart; -import org.junit.Test; -import org.jvnet.mimepull.MIMEMessage; -import org.jvnet.mimepull.MIMEParsingException; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests for multipart {@code MessageBodyReader} and {@code MessageBodyWriter} as well as {@code FormDataMultiPart} and {@code @@ -754,7 +752,7 @@ private void checkEntity(final String expected, final BodyPartEntity entity) thr } private void checkMediaType(final MediaType expected, final MediaType actual) { - assertEquals("Expected MediaType=" + expected, expected.getType(), actual.getType()); - assertEquals("Expected MediaType=" + expected, expected.getSubtype(), actual.getSubtype()); + assertEquals(expected.getType(), actual.getType(), "Expected MediaType=" + expected); + assertEquals(expected.getSubtype(), actual.getSubtype(), "Expected MediaType=" + expected); } } diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartHeaderModificationTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartHeaderModificationTest.java index e8cb04a98b..c37065b75f 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartHeaderModificationTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartHeaderModificationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,7 +16,9 @@ package org.glassfish.jersey.media.multipart.internal; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -37,16 +39,17 @@ import org.glassfish.jersey.jetty.connector.JettyConnectorProvider; import org.glassfish.jersey.media.multipart.MultiPart; import org.glassfish.jersey.test.TestProperties; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JERSEY-2123 reproducer. @@ -55,81 +58,88 @@ * * @author Libor Kramolis */ -@RunWith(Parameterized.class) -public class MultiPartHeaderModificationTest extends MultiPartJerseyTest { +public class MultiPartHeaderModificationTest { - private final ConnectorProvider connectorProvider; - private final boolean messageLogged; - - public MultiPartHeaderModificationTest(Class connectorProviderClass, - boolean messageLogged) - throws InstantiationException, IllegalAccessException { - this.connectorProvider = connectorProviderClass.newInstance(); - this.messageLogged = messageLogged; - } - - @Parameterized.Parameters(name = "{index}: {0} / {1}") public static List testData() { return Arrays.asList(new Object[][] { - {HttpUrlConnectorProvider.class, false}, - {GrizzlyConnectorProvider.class, true}, - {JettyConnectorProvider.class, true}, - {ApacheConnectorProvider.class, true}, + {new HttpUrlConnectorProvider(), false}, + {new GrizzlyConnectorProvider(), true}, + {new JettyConnectorProvider(), true}, + {new ApacheConnectorProvider(), true}, }); } - @Override - protected Set> getResourceClasses() { - final HashSet> classes = new HashSet>(); - classes.add(MultiPartResource.class); - return classes; + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + testData().forEach(arr -> { + MultiPartJerseyTemplateTest test = new MultiPartJerseyTemplateTest((ConnectorProvider) arr[0], (boolean) arr[1]) {}; + tests.add(TestHelper.toTestContainer(test, arr[0].getClass().getSimpleName() + ", " + arr[1])); + }); + return tests; } - @Override - protected Application configure() { - set(TestProperties.RECORD_LOG_LEVEL, Level.WARNING.intValue()); - return super.configure(); - } + public abstract static class MultiPartJerseyTemplateTest extends MultiPartJerseyTest { - @Override - protected void configureClient(ClientConfig clientConfig) { - super.configureClient(clientConfig); - clientConfig.connectorProvider(connectorProvider); - } + private final ConnectorProvider connectorProvider; + private final boolean messageLogged; - @Test - public void testLogMessage() { - final WebTarget target = target().path("multipart/ten"); - - MultiPartBean bean = new MultiPartBean("myname", "myvalue"); - MultiPart entity = new MultiPart() - .bodyPart(bean, new MediaType("x-application", "x-format")) - .bodyPart("", MediaType.APPLICATION_OCTET_STREAM_TYPE); - - final String UNSENT_HEADER_CHANGES = "Unsent header changes"; - try { - target.request("text/plain").put(Entity.entity(entity, "multipart/mixed"), String.class); - assertFalse("BadRequestException can not be thrown just in case JERSEY-2341 is not fixed.", - messageLogged); - LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES); - assertNull(logRecord); - } catch (BadRequestException brex) { - assertTrue("BadRequestException can be thrown just in case JERSEY-2341 is not fixed.", - messageLogged); - LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES); - assertNotNull("Missing LogRecord for message '" + UNSENT_HEADER_CHANGES + "'.", logRecord); - assertThat(logRecord.getMessage(), containsString("MIME-Version")); - assertThat(logRecord.getMessage(), containsString("Content-Type")); + public MultiPartJerseyTemplateTest(ConnectorProvider connectorProvider, boolean messageLogged) { + this.connectorProvider = connectorProvider; + this.messageLogged = messageLogged; + } + + @Override + protected Set> getResourceClasses() { + final HashSet> classes = new HashSet>(); + classes.add(MultiPartResource.class); + return classes; } - } - private LogRecord findLogRecord(String messageContains) { - for (final LogRecord record : getLoggedRecords()) { - if (record.getMessage().contains(messageContains)) { - return record; + @Override + protected Application configure() { + set(TestProperties.RECORD_LOG_LEVEL, Level.WARNING.intValue()); + return super.configure(); + } + + @Override + protected void configureClient(ClientConfig clientConfig) { + super.configureClient(clientConfig); + clientConfig.connectorProvider(connectorProvider); + } + + @Test + public void testLogMessage() { + final WebTarget target = target().path("multipart/ten"); + + MultiPartBean bean = new MultiPartBean("myname", "myvalue"); + MultiPart entity = new MultiPart() + .bodyPart(bean, new MediaType("x-application", "x-format")) + .bodyPart("", MediaType.APPLICATION_OCTET_STREAM_TYPE); + + final String UNSENT_HEADER_CHANGES = "Unsent header changes"; + try { + target.request("text/plain").put(Entity.entity(entity, "multipart/mixed"), String.class); + assertFalse(messageLogged, "BadRequestException can not be thrown just in case JERSEY-2341 is not fixed."); + LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES); + assertNull(logRecord); + } catch (BadRequestException brex) { + assertTrue(messageLogged, + "BadRequestException can be thrown just in case JERSEY-2341 is not fixed."); + LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES); + assertNotNull(logRecord, "Missing LogRecord for message '" + UNSENT_HEADER_CHANGES + "'."); + assertThat(logRecord.getMessage(), containsString("MIME-Version")); + assertThat(logRecord.getMessage(), containsString("Content-Type")); } } - return null; - } + private LogRecord findLogRecord(String messageContains) { + for (final LogRecord record : getLoggedRecords()) { + if (record.getMessage().contains(messageContains)) { + return record; + } + } + return null; + } + } } diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartReaderWriterTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartReaderWriterTest.java index 32b02f3dc3..a718780386 100644 --- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartReaderWriterTest.java +++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartReaderWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,11 +34,12 @@ import org.glassfish.jersey.media.multipart.BodyPartEntity; import org.glassfish.jersey.media.multipart.MultiPart; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Unit tests for {@link org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide} (in the client) and @@ -49,7 +50,7 @@ public class MultiPartReaderWriterTest extends MultiPartJerseyTest { private static Path TMP_DIRECTORY; private static String ORIGINAL_TMP_DIRECTORY; - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); @@ -59,7 +60,7 @@ public void setUp() throws Exception { System.setProperty("java.io.tmpdir", TMP_DIRECTORY.toString()); } - @After + @AfterEach public void tearDown() throws Exception { super.tearDown(); @@ -201,14 +202,15 @@ public void testFourBiz() { /** * Test sending a completely empty MultiPart. */ - @Test(expected = ProcessingException.class) + @Test public void testSix() { - target() - .path("multipart/six") - .request("text/plain") - .post(Entity.entity(new MultiPart(), "multipart/mixed"), String.class); - - fail("Should have thrown an exception about zero body parts"); + assertThrows(ProcessingException.class, () -> { + target() + .path("multipart/six") + .request("text/plain") + .post(Entity.entity(new MultiPart(), "multipart/mixed"), String.class); + fail("Should have thrown an exception about zero body parts"); + }); } /** @@ -312,14 +314,14 @@ private void checkEleven(final String seed, final int multiplier) throws Excepti final MultiPart response = target.request("multipart/mixed") .put(Entity.entity(entity, "multipart/mixed"), MultiPart.class); final String actual = response.getBodyParts().get(0).getEntityAs(String.class); - assertEquals("Length for multiplier " + multiplier, expected.length(), actual.length()); - assertEquals("Content for multiplier " + multiplier, expected, actual); + assertEquals(expected.length(), actual.length(), "Length for multiplier " + multiplier); + assertEquals(expected, actual, "Content for multiplier " + multiplier); response.cleanup(); } private void checkMediaType(final MediaType expected, final MediaType actual) { - assertEquals("Expected MediaType=" + expected, expected.getType(), actual.getType()); - assertEquals("Expected MediaType=" + expected, expected.getSubtype(), actual.getSubtype()); + assertEquals(expected.getType(), actual.getType(), "Expected MediaType=" + expected); + assertEquals(expected.getSubtype(), actual.getSubtype(), "Expected MediaType=" + expected); } } diff --git a/media/sse/pom.xml b/media/sse/pom.xml index ce434af377..57f6b62fda 100644 --- a/media/sse/pom.xml +++ b/media/sse/pom.xml @@ -45,8 +45,8 @@ ${project.version} - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/ClientCloseTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/ClientCloseTest.java index 996d32e946..ebd0792bdc 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/ClientCloseTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/ClientCloseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -33,10 +33,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.Assert.assertEquals; -import static junit.framework.TestCase.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Petr Janouch diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/EmptyEventsTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/EmptyEventsTest.java index c405777168..2c99079deb 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/EmptyEventsTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/EmptyEventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests handling of empty SSE events. diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/EventSourceTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/EventSourceTest.java index 842ae17ec1..d544746fd2 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/EventSourceTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/EventSourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -34,10 +34,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.Assert.assertEquals; -import static junit.framework.TestCase.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/InboundEventReaderTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/InboundEventReaderTest.java index ae522aef05..bc9f05799f 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/InboundEventReaderTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/InboundEventReaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -37,9 +37,9 @@ import org.glassfish.jersey.model.internal.CommonConfig; import org.glassfish.jersey.model.internal.ComponentBag; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Petr Bouda @@ -56,7 +56,7 @@ public class InboundEventReaderTest { HEADERS.put("Content-Type", Collections.singletonList("text/event-stream")); } - @Before + @BeforeEach public void setup() { injectionManager = Injections.createInjectionManager(); injectionManager.register(new TestBinder()); diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/OutboundEventTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/OutboundEventTest.java index c5af425e4e..001d123298 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/OutboundEventTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/OutboundEventTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,11 +24,11 @@ import org.glassfish.jersey.internal.util.ReflectionHelper; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Basic set of unit tests for OutboundEvent creation. diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkCloseTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkCloseTest.java index f6afa45c3b..5706eb5b92 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkCloseTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkCloseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -39,9 +39,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test, that {@code SseEventSink} and the connection is closed eventually after closing {@code SseEventSource} on client side. @@ -99,9 +99,9 @@ public void testClose() throws InterruptedException { } // ... and wait for the events to be processed by the client side, then close the eventSource - assertTrue("EventLatch timed out.", eventLatch.await(5, TimeUnit.SECONDS)); + assertTrue(eventLatch.await(5, TimeUnit.SECONDS), "EventLatch timed out."); eventSource.close(); - assertEquals("SseEventSource should have been already closed", false, eventSource.isOpen()); + assertEquals(false, eventSource.isOpen(), "SseEventSource should have been already closed"); ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); @@ -121,7 +121,7 @@ public void testClose() throws InterruptedException { assertTrue(closeLatch.await(10000, TimeUnit.MILLISECONDS)); executor.shutdown(); - assertTrue("SseEventOutput should have been already closed.", output.isClosed()); + assertTrue(output.isClosed(), "SseEventOutput should have been already closed."); } @Override diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkTest.java index b6059ff0d2..77211056ad 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseyEventSinkTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseyEventSinkTest.java index 6b7da0d6cf..98fbfff74a 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseyEventSinkTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseyEventSinkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -17,24 +17,21 @@ package org.glassfish.jersey.media.sse.internal; import org.glassfish.jersey.media.sse.OutboundEvent; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Pavel Bucek */ public class JerseyEventSinkTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void test() throws Exception { - JerseyEventSink eventSink = new JerseyEventSink(null); + Assertions.assertThrows(IllegalStateException.class, () -> { + JerseyEventSink eventSink = new JerseyEventSink(null); - eventSink.close(); - thrown.expect(IllegalStateException.class); - eventSink.send(null); + eventSink.close(); + eventSink.send(null); + }); } } diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseBroadcasterTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseBroadcasterTest.java index 0e5c635c3e..5fdeac2408 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseBroadcasterTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseBroadcasterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -23,10 +23,8 @@ import javax.ws.rs.sse.OutboundSseEvent; import javax.ws.rs.sse.SseEventSink; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * {@link javax.ws.rs.sse.SseBroadcaster} test. @@ -35,27 +33,26 @@ */ public class JerseySseBroadcasterTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - private static final String TEST_EXCEPTION_MSG = "testException"; @Test public void testOnErrorNull() { - try (JerseySseBroadcaster broadcaster = new JerseySseBroadcaster()) { + Assertions.assertThrows(IllegalArgumentException.class, () -> { + try (JerseySseBroadcaster broadcaster = new JerseySseBroadcaster()) { - thrown.expect(IllegalArgumentException.class); - broadcaster.onError(null); - } + broadcaster.onError(null); + } + }); } @Test public void testOnCloseNull() { - try (JerseySseBroadcaster jerseySseBroadcaster = new JerseySseBroadcaster()) { + Assertions.assertThrows(IllegalArgumentException.class, () -> { + try (JerseySseBroadcaster jerseySseBroadcaster = new JerseySseBroadcaster()) { - thrown.expect(IllegalArgumentException.class); - jerseySseBroadcaster.onClose(null); - } + jerseySseBroadcaster.onClose(null); + } + }); } @Test @@ -89,7 +86,7 @@ public void close() { }); broadcaster.broadcast(new JerseySse().newEvent("ping")); - Assert.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS)); + Assertions.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS)); } } @@ -124,7 +121,7 @@ public void close() { }); broadcaster.close(); - Assert.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS)); + Assertions.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS)); } } diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseEventSourceTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseEventSourceTest.java index 238ba82778..5509d7ed62 100644 --- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseEventSourceTest.java +++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseEventSourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022 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 @@ -16,20 +16,15 @@ package org.glassfish.jersey.media.sse.internal; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.sse.SseEventSource; public class JerseySseEventSourceTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void testNPEOnNull() { - thrown.expect(NullPointerException.class); - SseEventSource.target(null); + Assertions.assertThrows(NullPointerException.class, () -> SseEventSource.target(null)); } } diff --git a/pom.xml b/pom.xml index 2ed2d538e5..bf6aca5760 100644 --- a/pom.xml +++ b/pom.xml @@ -421,6 +421,14 @@ -Xmx${surefire.maxmem.argline}m -Dfile.encoding=UTF8 ${surefire.security.argline} ${surefire.coverage.argline} ${skip.tests} + + + junit.jupiter.execution.parallel.enabled=true + junit.jupiter.execution.parallel.mode.classes.default=same_thread + junit.jupiter.execution.parallel.mode.default=same_thread + + + 124 @@ -2014,12 +2022,6 @@ test - - junit - junit - 4.13.1 - test - org.junit.jupiter junit-jupiter @@ -2035,7 +2037,7 @@ org.testng testng - 6.9.6 + 6.9.13.6 test @@ -2058,8 +2060,8 @@ test - xmlunit - xmlunit + org.xmlunit + xmlunit-core ${xmlunit.version} test @@ -2164,7 +2166,7 @@ 31.1-jre 2.2 1.0.3 - 1.6 + 2.9.0 4.5.13 5.1.2 2.13.3 @@ -2175,10 +2177,12 @@ ${jersey1.version} 1.3.7 1.10.2 - 1.44 - 5.6.0 + 1.49 + 5.9.1 + 1.9.1 + 4.13.2 4.0.1 - 3.9.0 + 3.12.4 0.8.17 4.1.75.Final 1.6.7 @@ -2186,7 +2190,7 @@ 6.0.0 1.10.0 5.0.0 - 4.13.4 + 4.13.4 0.7.4 1.2.4 1.2.5 @@ -2196,7 +2200,7 @@ 2.0.3 4.3.20.RELEASE 5.3.18 - 3.0.0-M5 + 3.0.0-M7 6.2.0.Final 2.2.14.Final 3.1.7.SP1 diff --git a/security/oauth1-client/pom.xml b/security/oauth1-client/pom.xml index 8da420c97e..e0911083e2 100644 --- a/security/oauth1-client/pom.xml +++ b/security/oauth1-client/pom.xml @@ -67,8 +67,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/security/oauth1-server/pom.xml b/security/oauth1-server/pom.xml index 777d8aa07d..ca56a0bae6 100644 --- a/security/oauth1-server/pom.xml +++ b/security/oauth1-server/pom.xml @@ -46,8 +46,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/security/oauth1-server/src/test/java/org/glassfish/jersey/server/oauth1/NonceManagerTest.java b/security/oauth1-server/src/test/java/org/glassfish/jersey/server/oauth1/NonceManagerTest.java index 25069ea5ff..7d40786ce9 100644 --- a/security/oauth1-server/src/test/java/org/glassfish/jersey/server/oauth1/NonceManagerTest.java +++ b/security/oauth1-server/src/test/java/org/glassfish/jersey/server/oauth1/NonceManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -19,11 +19,11 @@ import java.util.concurrent.TimeUnit; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Thomas Meire diff --git a/security/oauth1-server/src/test/java/org/glassfish/jersey/server/oauth1/OAuth1ExceptionTest.java b/security/oauth1-server/src/test/java/org/glassfish/jersey/server/oauth1/OAuth1ExceptionTest.java index aee7db558e..591e572576 100644 --- a/security/oauth1-server/src/test/java/org/glassfish/jersey/server/oauth1/OAuth1ExceptionTest.java +++ b/security/oauth1-server/src/test/java/org/glassfish/jersey/server/oauth1/OAuth1ExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,9 +19,9 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * {@link OAuth1Exception} unit tests. diff --git a/security/oauth1-signature/pom.xml b/security/oauth1-signature/pom.xml index 3a3d7a155f..845c180011 100644 --- a/security/oauth1-signature/pom.xml +++ b/security/oauth1-signature/pom.xml @@ -53,8 +53,8 @@ ${project.version} - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/OAuth1SignatureTest.java b/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/OAuth1SignatureTest.java index 3540eb4372..2714c99ffd 100644 --- a/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/OAuth1SignatureTest.java +++ b/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/OAuth1SignatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/OAuthBase64Test.java b/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/OAuthBase64Test.java index f72b023817..3f0cb79682 100644 --- a/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/OAuthBase64Test.java +++ b/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/OAuthBase64Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,8 +18,8 @@ import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @@ -35,17 +35,17 @@ public void test() throws IOException { final String encodedUtilStr = java.util.Base64.getEncoder().encodeToString(str.getBytes()); System.out.println(encoded); - Assert.assertEquals(encoded, encodedUtil); - Assert.assertEquals(encoded, encodedUtilStr); + Assertions.assertEquals(encoded, encodedUtil); + Assertions.assertEquals(encoded, encodedUtilStr); final String decoded = new String(Base64.decode(encoded)); final String decodedUtil = new String(java.util.Base64.getDecoder().decode(encoded.getBytes())); final String decodedUtilStr = new String(java.util.Base64.getDecoder().decode(encoded.getBytes())); final String decodedUtilStr2 = new String(java.util.Base64.getDecoder().decode(encoded)); - Assert.assertEquals(decoded, decodedUtil); - Assert.assertEquals(decoded, decodedUtilStr); - Assert.assertEquals(decoded, decodedUtilStr2); - Assert.assertEquals(decoded, str); + Assertions.assertEquals(decoded, decodedUtil); + Assertions.assertEquals(decoded, decodedUtilStr); + Assertions.assertEquals(decoded, decodedUtilStr2); + Assertions.assertEquals(decoded, str); } } diff --git a/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/SignatureTest.java b/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/SignatureTest.java index a433015b13..058975a90c 100644 --- a/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/SignatureTest.java +++ b/security/oauth1-signature/src/test/java/org/glassfish/jersey/oauth1/signature/SignatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,10 +20,10 @@ import org.glassfish.jersey.internal.inject.Injections; import org.glassfish.jersey.uri.UriComponent; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Paul C. Bryan diff --git a/test-framework/core/pom.xml b/test-framework/core/pom.xml index fe07d92bac..1c9a2e4656 100644 --- a/test-framework/core/pom.xml +++ b/test-framework/core/pom.xml @@ -70,8 +70,9 @@ provided - org.junit.jupiter - junit-jupiter + junit + junit + ${junit4.version} provided diff --git a/test-framework/core/src/main/java/org/glassfish/jersey/test/JerseyTest.java b/test-framework/core/src/main/java/org/glassfish/jersey/test/JerseyTest.java index de3ce0cbd8..1c94be1946 100644 --- a/test-framework/core/src/main/java/org/glassfish/jersey/test/JerseyTest.java +++ b/test-framework/core/src/main/java/org/glassfish/jersey/test/JerseyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -28,6 +28,7 @@ import java.util.Optional; import java.util.Properties; import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Handler; import java.util.logging.Level; @@ -52,7 +53,6 @@ import org.glassfish.jersey.test.spi.TestContainer; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; - import org.junit.After; import org.junit.Before; import org.junit.jupiter.api.AfterEach; @@ -122,7 +122,6 @@ * @author Michal Gajdos * @author Marek Potociar */ -@SuppressWarnings("UnusedDeclaration") public abstract class JerseyTest { private static final Logger LOGGER = Logger.getLogger(JerseyTest.class.getName()); @@ -169,6 +168,7 @@ public abstract class JerseyTest { private JerseyTestLogHandler logHandler; private final Map logLevelMap = new IdentityHashMap<>(); + private final AtomicInteger activeThreadCount = new AtomicInteger(0); /** * Initialize JerseyTest instance. @@ -187,7 +187,6 @@ public JerseyTest() { // not be set soon enough this.context = configureDeployment(); this.testContainerFactory = getTestContainerFactory(); - registerLogHandlerIfEnabled(); } /** @@ -209,7 +208,6 @@ public JerseyTest(final TestContainerFactory testContainerFactory) { // not be set soon enough this.context = configureDeployment(); this.testContainerFactory = testContainerFactory; - registerLogHandlerIfEnabled(); } /** @@ -234,7 +232,6 @@ public JerseyTest(final TestContainerFactory testContainerFactory) { public JerseyTest(final Application jaxrsApplication) { this.context = DeploymentContext.newInstance(jaxrsApplication); this.testContainerFactory = getTestContainerFactory(); - registerLogHandlerIfEnabled(); } /** @@ -618,14 +615,19 @@ public final Client client() { @Before @BeforeEach public void setUp() throws Exception { - final TestContainer testContainer = createTestContainer(context); + synchronized (this) { + if (activeThreadCount.getAndIncrement() == 0) { + registerLogHandlerIfEnabled(); + final TestContainer testContainer = createTestContainer(context); - // Set current instance of test container and start it. - setTestContainer(testContainer); - testContainer.start(); + // Set current instance of test container and start it. + setTestContainer(testContainer); + testContainer.start(); - // Create an set new client. - setClient(getClient(testContainer.getClientConfig())); + // Create an set new client. + setClient(getClient(testContainer.getClientConfig())); + } + } } /** @@ -639,17 +641,21 @@ public void setUp() throws Exception { @After @AfterEach public void tearDown() throws Exception { - if (isLogRecordingEnabled()) { - unregisterLogHandler(); - } + synchronized (this) { + if (activeThreadCount.decrementAndGet() == 0) { + if (isLogRecordingEnabled()) { + unregisterLogHandler(); + } - try { - TestContainer oldContainer = setTestContainer(null); - if (oldContainer != null) { - oldContainer.stop(); + try { + TestContainer oldContainer = setTestContainer(null); + if (oldContainer != null) { + oldContainer.stop(); + } + } finally { + closeIfNotNull(setClient(null)); + } } - } finally { - closeIfNotNull(setClient(null)); } } diff --git a/test-framework/core/src/main/java/org/glassfish/jersey/test/package-info.java b/test-framework/core/src/main/java/org/glassfish/jersey/test/package-info.java index 60b810511c..1d2457d222 100644 --- a/test-framework/core/src/main/java/org/glassfish/jersey/test/package-info.java +++ b/test-framework/core/src/main/java/org/glassfish/jersey/test/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -51,7 +51,7 @@ * WebTarget t = target("root"); * * String s = t.request().get(String.class); - * Assert.assertEquals("GET", s); + * Assertions.assertEquals("GET", s); * } * } * @@ -86,7 +86,7 @@ * WebTarget t = target("root"); * * String s = t.request().get(String.class); - * Assert.assertEquals("GET", s); + * Assertions.assertEquals("GET", s); * } * } * diff --git a/test-framework/core/src/main/java/org/glassfish/jersey/test/spi/TestHelper.java b/test-framework/core/src/main/java/org/glassfish/jersey/test/spi/TestHelper.java index 23809f6306..0aabca53a8 100644 --- a/test-framework/core/src/main/java/org/glassfish/jersey/test/spi/TestHelper.java +++ b/test-framework/core/src/main/java/org/glassfish/jersey/test/spi/TestHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,7 +16,15 @@ package org.glassfish.jersey.test.spi; +import java.lang.reflect.Method; import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.DynamicTest; +import org.junit.platform.commons.util.ReflectionUtils; /** * Helper class for Jersey Test Framework. @@ -43,4 +51,31 @@ public static String zeroPortToAvailablePort(final URI uri) { */ private TestHelper() { } + + public static DynamicContainer toTestContainer(Object test, String displayName) { + Class klass = test.getClass(); + List testMethods = ReflectionUtils.findMethods(klass, + method -> method.isAnnotationPresent(org.junit.jupiter.api.Test.class) + && !method.isAnnotationPresent(org.junit.jupiter.api.Disabled.class)); + List beforeEachMethods = ReflectionUtils.findMethods(klass, + method -> method.isAnnotationPresent(org.junit.jupiter.api.BeforeEach.class)); + List afterEachMethods = ReflectionUtils.findMethods(klass, + method -> method.isAnnotationPresent(org.junit.jupiter.api.AfterEach.class)); + Collection children = new ArrayList<>(); + for (Method method : testMethods) { + children.add(DynamicTest.dynamicTest(method.getName(), () -> { + try { + for (Method beforeEachMethod : beforeEachMethods) { + beforeEachMethod.invoke(test); + } + method.invoke(test); + } finally { + for (Method afterEachMethod : afterEachMethods) { + afterEachMethod.invoke(test); + } + } + })); + } + return DynamicContainer.dynamicContainer(displayName, children); + } } diff --git a/test-framework/core/src/test/java/org/glassfish/jersey/test/JerseyTestTest.java b/test-framework/core/src/test/java/org/glassfish/jersey/test/JerseyTestTest.java index 08e873e5f8..ecbdf25cf6 100644 --- a/test-framework/core/src/test/java/org/glassfish/jersey/test/JerseyTestTest.java +++ b/test-framework/core/src/test/java/org/glassfish/jersey/test/JerseyTestTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * {@link org.glassfish.jersey.test.JerseyTest} unit tests. diff --git a/test-framework/maven/container-runner-maven-plugin/pom.xml b/test-framework/maven/container-runner-maven-plugin/pom.xml index c7571c35b7..efa0af1a1c 100644 --- a/test-framework/maven/container-runner-maven-plugin/pom.xml +++ b/test-framework/maven/container-runner-maven-plugin/pom.xml @@ -160,6 +160,8 @@ junit junit + ${junit4.version} + test diff --git a/test-framework/maven/custom-enforcer-rules/pom.xml b/test-framework/maven/custom-enforcer-rules/pom.xml index 46b9a43524..e42e347fd8 100644 --- a/test-framework/maven/custom-enforcer-rules/pom.xml +++ b/test-framework/maven/custom-enforcer-rules/pom.xml @@ -70,8 +70,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter compile diff --git a/test-framework/maven/custom-enforcer-rules/src/test/java/org/glassfish/jersey/test/maven/rule/FilePatternDoesNotExistRuleTest.java b/test-framework/maven/custom-enforcer-rules/src/test/java/org/glassfish/jersey/test/maven/rule/FilePatternDoesNotExistRuleTest.java index 301369af13..0c2d91ad22 100644 --- a/test-framework/maven/custom-enforcer-rules/src/test/java/org/glassfish/jersey/test/maven/rule/FilePatternDoesNotExistRuleTest.java +++ b/test-framework/maven/custom-enforcer-rules/src/test/java/org/glassfish/jersey/test/maven/rule/FilePatternDoesNotExistRuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -21,7 +21,8 @@ import java.net.URISyntaxException; import org.apache.maven.enforcer.rule.api.EnforcerRuleException; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Basic sanity test of {@link FilePatternDoesNotExistRule} enforcer rule. @@ -30,17 +31,19 @@ */ public class FilePatternDoesNotExistRuleTest { - @Test(expected = EnforcerRuleException.class) + @Test public void testMatchedPath() throws URISyntaxException, EnforcerRuleException { - final FilePatternDoesNotExistRule filePatternDoesNotExistRule = new FilePatternDoesNotExistRule(); + assertThrows(EnforcerRuleException.class, () -> { + final FilePatternDoesNotExistRule filePatternDoesNotExistRule = new FilePatternDoesNotExistRule(); - final URI uri = getClass() - .getResource("/org/glassfish/jersey/test/maven/rule/FilePatternDoesNotExistRule.class").toURI(); - final File file = new File(uri); - final String pattern = file.getAbsolutePath().replace("PatternDoes", "*"); - filePatternDoesNotExistRule.files = new File[] {new File(pattern)}; + final URI uri = getClass() + .getResource("/org/glassfish/jersey/test/maven/rule/FilePatternDoesNotExistRule.class").toURI(); + final File file = new File(uri); + final String pattern = file.getAbsolutePath().replace("PatternDoes", "*"); + filePatternDoesNotExistRule.files = new File[] {new File(pattern)}; - filePatternDoesNotExistRule.execute(null); + filePatternDoesNotExistRule.execute(null); + }); } @Test diff --git a/test-framework/maven/custom-enforcer-rules/src/test/java/org/glassfish/jersey/test/maven/rule/PatternNotMatchedInFileRuleTest.java b/test-framework/maven/custom-enforcer-rules/src/test/java/org/glassfish/jersey/test/maven/rule/PatternNotMatchedInFileRuleTest.java index 1897a2b1bc..681106a4f8 100644 --- a/test-framework/maven/custom-enforcer-rules/src/test/java/org/glassfish/jersey/test/maven/rule/PatternNotMatchedInFileRuleTest.java +++ b/test-framework/maven/custom-enforcer-rules/src/test/java/org/glassfish/jersey/test/maven/rule/PatternNotMatchedInFileRuleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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,7 +20,8 @@ import java.net.URISyntaxException; import org.apache.maven.enforcer.rule.api.EnforcerRuleException; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Basic sanity test of {@link PatternNotMatchedInFileRule} enforcer rule. @@ -29,9 +30,9 @@ */ public class PatternNotMatchedInFileRuleTest { - @Test(expected = EnforcerRuleException.class) + @Test public void testMatchedPath() throws URISyntaxException, EnforcerRuleException { - testFilePatternLineMatcher("/out_of_memory.dat"); + assertThrows(EnforcerRuleException.class, () -> testFilePatternLineMatcher("/out_of_memory.dat")); } @Test diff --git a/test-framework/memleak-test-common/pom.xml b/test-framework/memleak-test-common/pom.xml index c51ef21c18..f63a583dd6 100644 --- a/test-framework/memleak-test-common/pom.xml +++ b/test-framework/memleak-test-common/pom.xml @@ -37,8 +37,13 @@ compile - junit - junit + org.junit.jupiter + junit-jupiter + compile + + + org.hamcrest + hamcrest compile diff --git a/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/AbstractMemoryLeakSimpleTest.java b/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/AbstractMemoryLeakSimpleTest.java index 149405fee9..0388c39f7e 100644 --- a/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/AbstractMemoryLeakSimpleTest.java +++ b/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/AbstractMemoryLeakSimpleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -19,7 +19,7 @@ import java.io.File; import java.lang.management.ManagementFactory; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; /** * An abstract test class that adds support for dump heap at the beginning of the test execution. @@ -28,7 +28,7 @@ */ public class AbstractMemoryLeakSimpleTest { - @Before + @BeforeEach public void dumpTheHeap() throws Exception { final String heapDumpPath = System.getProperty(MemoryLeakUtils.JERSEY_CONFIG_TEST_MEMLEAK_HEAP_DUMP_PATH); String heapDumpFile = "java_start_pid" + guessPid() + ".hprof"; diff --git a/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/AbstractMemoryLeakWebAppTest.java b/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/AbstractMemoryLeakWebAppTest.java index faede8145c..d1879bad4c 100644 --- a/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/AbstractMemoryLeakWebAppTest.java +++ b/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/AbstractMemoryLeakWebAppTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -23,7 +23,7 @@ import org.glassfish.jersey.test.DeploymentContext; import org.glassfish.jersey.test.JerseyTest; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; /** * Adds support for web application testing and memory leak detection in target JVM. @@ -42,7 +42,7 @@ public class AbstractMemoryLeakWebAppTest extends JerseyTest { * * @throws IOException */ - @After + @AfterEach public void verifyNoOutOfMemoryOccurred() throws IOException { MemoryLeakUtils.verifyNoOutOfMemoryOccurred(); } diff --git a/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/MemoryLeakSucceedingTimeout.java b/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/MemoryLeakSucceedingTimeout.java index 200b10a0d1..3398707488 100644 --- a/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/MemoryLeakSucceedingTimeout.java +++ b/test-framework/memleak-test-common/src/main/java/org/glassfish/jersey/test/memleak/common/MemoryLeakSucceedingTimeout.java @@ -1,60 +1,57 @@ -/* - * Copyright (c) 2015, 2019 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.memleak.common; - -import org.junit.internal.runners.statements.FailOnTimeout; -import org.junit.rules.Timeout; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * @author Stepan Vavra - */ -public class MemoryLeakSucceedingTimeout extends Timeout { - - private static final int DEFAULT_TIMEOUT_MILLIS = 300_000; - private int millis; - - public MemoryLeakSucceedingTimeout() { - this(DEFAULT_TIMEOUT_MILLIS); - } - - public MemoryLeakSucceedingTimeout(final int defaultMillisTimeout) { - super(defaultMillisTimeout); - - this.millis = Integer.getInteger(MemoryLeakUtils.JERSEY_CONFIG_TEST_MEMLEAK_TIMEOUT, defaultMillisTimeout); - } - - @Override - public Statement apply(final Statement base, final Description description) { - return new FailOnTimeout(base, millis) { - @Override - public void evaluate() throws Throwable { - try { - super.evaluate(); - } catch (Throwable throwable) { - if (throwable.getMessage().startsWith("test timed out after")) { - MemoryLeakUtils.verifyNoOutOfMemoryOccurred(); - System.out.println("Test timed out after " + millis + " ms. Successfully ending."); - } else { - throw throwable; - } - } - } - }; - } -} +/* + * Copyright (c) 2015, 2022 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.memleak.common; + +import java.lang.reflect.Method; +import java.time.Duration; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.InvocationInterceptor; +import org.junit.jupiter.api.extension.ReflectiveInvocationContext; + +/** + * @author Stepan Vavra + */ +public class MemoryLeakSucceedingTimeout implements InvocationInterceptor { + + private static final int DEFAULT_TIMEOUT_MILLIS = 300_000; + private int millis; + + public MemoryLeakSucceedingTimeout() { + this(DEFAULT_TIMEOUT_MILLIS); + } + + public MemoryLeakSucceedingTimeout(final int defaultMillisTimeout) { + this.millis = Integer.getInteger(MemoryLeakUtils.JERSEY_CONFIG_TEST_MEMLEAK_TIMEOUT, defaultMillisTimeout); + } + + @Override + public void interceptTestMethod(Invocation invocation, ReflectiveInvocationContext invocationContext, + ExtensionContext extensionContext) throws Throwable { + try { + Assertions.assertTimeoutPreemptively(Duration.ofMillis(millis), invocation::proceed); + } catch (Throwable throwable) { + if (throwable.getMessage().startsWith("execution timed out after")) { + MemoryLeakUtils.verifyNoOutOfMemoryOccurred(); + System.out.println("Test timed out after " + millis + " ms. Successfully ending."); + } else { + throw throwable; + } + } + } +} diff --git a/test-framework/pom.xml b/test-framework/pom.xml index 638b3c1e61..6cb762af90 100644 --- a/test-framework/pom.xml +++ b/test-framework/pom.xml @@ -42,8 +42,13 @@ - junit - junit + org.junit.jupiter + junit-jupiter + compile + + + org.hamcrest + hamcrest compile diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/AvailablePortGrizzlyTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/AvailablePortGrizzlyTest.java index 264dc865c8..af8163f45e 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/AvailablePortGrizzlyTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/AvailablePortGrizzlyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/BaseUriTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/BaseUriTest.java index e08821d450..4ba7aea6ba 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/BaseUriTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/BaseUriTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Grizzly test container base URI tests. @@ -67,7 +67,7 @@ public void testGet() { final WebTarget target = target("root"); final String s = target.request().get(String.class); - Assert.assertEquals("GET", s); + Assertions.assertEquals("GET", s); } @Test @@ -75,7 +75,7 @@ public void testGetSub() { final WebTarget target = target("root/sub"); final String s = target.request().get(String.class); - Assert.assertEquals("sub", s); + Assertions.assertEquals("sub", s); } } diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/pckg/GrizzlyPackageTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/pckg/GrizzlyPackageTest.java index cd2e4c7dda..9c10b96638 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/pckg/GrizzlyPackageTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/pckg/GrizzlyPackageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/AvailablePortGrizzlyWebTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/AvailablePortGrizzlyWebTest.java index c84db7ee82..5bbf0df3f3 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/AvailablePortGrizzlyWebTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/AvailablePortGrizzlyWebTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -28,7 +28,7 @@ import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyRequestDispatchFilterTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyRequestDispatchFilterTest.java index 603dccff48..51518c8265 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyRequestDispatchFilterTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyRequestDispatchFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -42,8 +42,8 @@ import org.glassfish.grizzly.servlet.HttpServletRequestImpl; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Reproducer for JERSEY-1893. @@ -214,22 +214,22 @@ public void testGet() { // check that the regular filter gets involved s = target.path("direct").request().get(String.class); - Assert.assertEquals("[DIRECT]", s); + Assertions.assertEquals("[DIRECT]", s); // the regular filter should work for directly requested forward resource as well. s = target.path("forward").request().get(String.class); - Assert.assertEquals("[FORWARD]", s); + Assertions.assertEquals("[FORWARD]", s); // forward action should enforce forward filter to be invoked s = target.queryParam("action", "forward").request().get(String.class); - Assert.assertEquals(">>FORWARD", s); + Assertions.assertEquals(">>FORWARD", s); // direct call to the include resource s = target.path("included").request().get(String.class); - Assert.assertEquals("[INCLUDED]", s); + Assertions.assertEquals("[INCLUDED]", s); // include call should involve both regular and include filter s = target.path("included").queryParam("action", "include").request().get(String.class); - Assert.assertEquals("[SOMETHING INCLUDED]", s); + Assertions.assertEquals("[SOMETHING INCLUDED]", s); } } diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebFixedRequestSizeTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebFixedRequestSizeTest.java index e786dce211..05f3d2cd2f 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebFixedRequestSizeTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebFixedRequestSizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Marek Potociar diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebInjectionTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebInjectionTest.java index 74f18a45dc..351e005369 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebInjectionTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -34,9 +34,9 @@ import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test injection support in the {@link org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory}. diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebServletAndFilterTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebServletAndFilterTest.java index 2bfca388dc..eeccea3d0e 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebServletAndFilterTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebServletAndFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -39,8 +39,8 @@ import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test {@link org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory} support for @@ -130,10 +130,10 @@ public void testGet() { WebTarget target = target("GrizzlyWebServletAndFilterTest"); String s = target.request().get(String.class); - Assert.assertEquals("GET", s); + Assertions.assertEquals("GET", s); - Assert.assertTrue(MyServlet.visited); - Assert.assertTrue(MyFilter1.visited); - Assert.assertTrue(MyFilter2.visited); + Assertions.assertTrue(MyServlet.visited); + Assertions.assertTrue(MyFilter1.visited); + Assertions.assertTrue(MyFilter2.visited); } } diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebTest.java index 66199d8e68..f0824897bd 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/GrizzlyWebTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Basic GrizzlyWebTestContainerFactory unit tests. @@ -69,7 +69,7 @@ public void testGet() { WebTarget target = target("root"); String s = target.request().get(String.class); - Assert.assertEquals("GET", s); + Assertions.assertEquals("GET", s); } @Test @@ -77,6 +77,6 @@ public void testGetSub() { WebTarget target = target("root/sub"); String s = target.request().get(String.class); - Assert.assertEquals("sub", s); + Assertions.assertEquals("sub", s); } } diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/context/GrizzlyWebContextPathTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/context/GrizzlyWebContextPathTest.java index 3caf4a162e..0d107c6175 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/context/GrizzlyWebContextPathTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/context/GrizzlyWebContextPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test support for context path in {@link org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory}. diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/ssl/GrizzlyOneWaySslWebTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/ssl/GrizzlyOneWaySslWebTest.java index cad2b1d499..af0c2e3175 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/ssl/GrizzlyOneWaySslWebTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/ssl/GrizzlyOneWaySslWebTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,10 +20,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; @@ -53,9 +51,6 @@ public class GrizzlyOneWaySslWebTest extends JerseyTest { private SSLContext serverSslContext; private SSLParameters serverSslParameters; - @Rule - public final ExpectedException exception = ExpectedException.none(); - @Override protected TestContainerFactory getTestContainerFactory() { return new GrizzlyTestContainerFactory(); @@ -112,33 +107,33 @@ public void testGet() { WebTarget target = client.target(getBaseUri()).path("secure"); String s = target.request().get(String.class); - Assert.assertEquals("GET", s); + Assertions.assertEquals("GET", s); } @Test public void testGetFailsWhenClientDoesNotTrustsServer() { - SSLContext clientSslContext = SslUtils.createClientSslContext(false, false); - - Client client = ClientBuilder.newBuilder() - .sslContext(clientSslContext) - .build(); + Assertions.assertThrows(ProcessingException.class, () -> { + SSLContext clientSslContext = SslUtils.createClientSslContext(false, false); - WebTarget target = client.target(getBaseUri()).path("secure"); + Client client = ClientBuilder.newBuilder() + .sslContext(clientSslContext) + .build(); - exception.expect(ProcessingException.class); + WebTarget target = client.target(getBaseUri()).path("secure"); - target.request().get(String.class); + target.request().get(String.class); + }); } @Test public void testGetFailsWhenClientExecutesRequestWithoutHavingSslConfigured() { - Client client = ClientBuilder.newClient(); - - WebTarget target = client.target(getBaseUri()).path("secure"); + Assertions.assertThrows(ProcessingException.class, () -> { + Client client = ClientBuilder.newClient(); - exception.expect(ProcessingException.class); + WebTarget target = client.target(getBaseUri()).path("secure"); - target.request().get(String.class); + target.request().get(String.class); + }); } } diff --git a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/ssl/GrizzlyTwoWaySslWebTest.java b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/ssl/GrizzlyTwoWaySslWebTest.java index a085095b33..2b0992e0f0 100644 --- a/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/ssl/GrizzlyTwoWaySslWebTest.java +++ b/test-framework/providers/grizzly2/src/test/java/org/glassfish/jersey/test/grizzly/web/ssl/GrizzlyTwoWaySslWebTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,10 +20,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLParameters; @@ -54,9 +52,6 @@ public class GrizzlyTwoWaySslWebTest extends JerseyTest { private SSLContext serverSslContext; private SSLParameters serverSslParameters; - @Rule - public final ExpectedException exception = ExpectedException.none(); - @Override protected TestContainerFactory getTestContainerFactory() { return new GrizzlyTestContainerFactory(); @@ -113,48 +108,48 @@ public void testGet() { WebTarget target = client.target(getBaseUri()).path("more-secure"); String s = target.request().get(String.class); - Assert.assertEquals("GET", s); + Assertions.assertEquals("GET", s); } @Test public void testGetFailsWhenClientDoesNotTrustsServer() { - SSLContext clientSslContext = SslUtils.createClientSslContext(true, false); + Assertions.assertThrows(ProcessingException.class, () -> { + SSLContext clientSslContext = SslUtils.createClientSslContext(true, false); - Client client = ClientBuilder.newBuilder() - .sslContext(clientSslContext) - .build(); + Client client = ClientBuilder.newBuilder() + .sslContext(clientSslContext) + .build(); - WebTarget target = client.target(getBaseUri()).path("more-secure"); - - exception.expect(ProcessingException.class); + WebTarget target = client.target(getBaseUri()).path("more-secure"); - target.request().get(String.class); + target.request().get(String.class); + }); } @Test public void testGetFailsWhenClientCanNotIdentifyItselfToTheServer() { - SSLContext clientSslContext = SslUtils.createClientSslContext(false, true); + Assertions.assertThrows(ProcessingException.class, () -> { + SSLContext clientSslContext = SslUtils.createClientSslContext(false, true); - Client client = ClientBuilder.newBuilder() - .sslContext(clientSslContext) - .build(); - - WebTarget target = client.target(getBaseUri()).path("more-secure"); + Client client = ClientBuilder.newBuilder() + .sslContext(clientSslContext) + .build(); - exception.expect(ProcessingException.class); + WebTarget target = client.target(getBaseUri()).path("more-secure"); - target.request().get(String.class); + target.request().get(String.class); + }); } @Test public void testGetFailsWhenClientExecutesRequestWithoutHavingSslConfigured() { - Client client = ClientBuilder.newClient(); - - WebTarget target = client.target(getBaseUri()).path("more-secure"); + Assertions.assertThrows(ProcessingException.class, () -> { + Client client = ClientBuilder.newClient(); - exception.expect(ProcessingException.class); + WebTarget target = client.target(getBaseUri()).path("more-secure"); - target.request().get(String.class); + target.request().get(String.class); + }); } } diff --git a/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/InMemoryContainerPackageTest.java b/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/InMemoryContainerPackageTest.java index bcbd308789..247545b140 100644 --- a/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/InMemoryContainerPackageTest.java +++ b/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/InMemoryContainerPackageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -22,10 +22,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Package scanning test for {@link org.glassfish.jersey.test.inmemory.InMemoryConnector}. diff --git a/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/InMemoryContainerTest.java b/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/InMemoryContainerTest.java index 59ecfada70..1072e8da67 100644 --- a/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/InMemoryContainerTest.java +++ b/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/InMemoryContainerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -32,12 +32,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test class for {@link InMemoryConnector}. diff --git a/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/internal/FollowRedirectsTest.java b/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/internal/FollowRedirectsTest.java index 511cd420f9..5049dc48dc 100644 --- a/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/internal/FollowRedirectsTest.java +++ b/test-framework/providers/inmemory/src/test/java/org/glassfish/jersey/test/inmemory/internal/FollowRedirectsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * In-memory connector follow redirect tests. diff --git a/test-framework/providers/jdk-http/src/test/java/org/glassfish/jersey/test/jdkhttp/AvailablePortJdkHttpServerTest.java b/test-framework/providers/jdk-http/src/test/java/org/glassfish/jersey/test/jdkhttp/AvailablePortJdkHttpServerTest.java index 70fc98d1cb..dea8e95726 100644 --- a/test-framework/providers/jdk-http/src/test/java/org/glassfish/jersey/test/jdkhttp/AvailablePortJdkHttpServerTest.java +++ b/test-framework/providers/jdk-http/src/test/java/org/glassfish/jersey/test/jdkhttp/AvailablePortJdkHttpServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -25,7 +25,7 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/test-framework/providers/jdk-http/src/test/java/org/glassfish/jersey/test/jdkhttp/JdkHttpServerContainerTest.java b/test-framework/providers/jdk-http/src/test/java/org/glassfish/jersey/test/jdkhttp/JdkHttpServerContainerTest.java index b79dde932a..ed5e3beeac 100644 --- a/test-framework/providers/jdk-http/src/test/java/org/glassfish/jersey/test/jdkhttp/JdkHttpServerContainerTest.java +++ b/test-framework/providers/jdk-http/src/test/java/org/glassfish/jersey/test/jdkhttp/JdkHttpServerContainerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test class for {@link JdkHttpHandlerContainer}. @@ -70,7 +70,7 @@ public String getSomething() { public void testJdkHttpServerContainerTarget() { final Response response = target().path("one").request().get(); - assertEquals("Response status unexpected.", 200, response.getStatus()); - assertEquals("Response entity unexpected.", "get", response.readEntity(String.class)); + assertEquals(200, response.getStatus(), "Response status unexpected."); + assertEquals("get", response.readEntity(String.class), "Response entity unexpected."); } } diff --git a/test-framework/providers/jetty/src/test/java/org/glassfish/jersey/test/jetty/AvailablePortJettyTest.java b/test-framework/providers/jetty/src/test/java/org/glassfish/jersey/test/jetty/AvailablePortJettyTest.java index 7ff587df09..ff13cd0c1d 100644 --- a/test-framework/providers/jetty/src/test/java/org/glassfish/jersey/test/jetty/AvailablePortJettyTest.java +++ b/test-framework/providers/jetty/src/test/java/org/glassfish/jersey/test/jetty/AvailablePortJettyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -25,7 +25,7 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/test-framework/providers/jetty/src/test/java/org/glassfish/jersey/test/jetty/JettyContainerTest.java b/test-framework/providers/jetty/src/test/java/org/glassfish/jersey/test/jetty/JettyContainerTest.java index 4c1a9513d5..2e427ca2cc 100644 --- a/test-framework/providers/jetty/src/test/java/org/glassfish/jersey/test/jetty/JettyContainerTest.java +++ b/test-framework/providers/jetty/src/test/java/org/glassfish/jersey/test/jetty/JettyContainerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -35,9 +35,9 @@ import org.jvnet.hk2.internal.ServiceLocatorImpl; import org.eclipse.jetty.server.Server; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test class for {@link JettyHttpContainer}. @@ -83,8 +83,8 @@ public String getSomething() { public void testJettyContainerTarget() { final Response response = target().path("one").request().get(); - assertEquals("Response status unexpected.", 200, response.getStatus()); - assertEquals("Response entity unexpected.", "get", response.readEntity(String.class)); + assertEquals(200, response.getStatus(), "Response status unexpected."); + assertEquals("get", response.readEntity(String.class), "Response entity unexpected."); } /** @@ -106,7 +106,7 @@ public void testParentServiceLocator() { } else { throw new RuntimeException("Invalid Hk2 InjectionManager"); } - assertTrue("Application injection manager was expected to have defined parent locator", - serviceLocator.getParent() == locator); + assertTrue(serviceLocator.getParent() == locator, + "Application injection manager was expected to have defined parent locator"); } } diff --git a/test-framework/providers/simple/src/test/java/org/glassfish/jersey/test/simple/AvailablePortSimpleTest.java b/test-framework/providers/simple/src/test/java/org/glassfish/jersey/test/simple/AvailablePortSimpleTest.java index 09d2bb8a7d..1e58dd4a80 100644 --- a/test-framework/providers/simple/src/test/java/org/glassfish/jersey/test/simple/AvailablePortSimpleTest.java +++ b/test-framework/providers/simple/src/test/java/org/glassfish/jersey/test/simple/AvailablePortSimpleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -25,7 +25,7 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/test-framework/providers/simple/src/test/java/org/glassfish/jersey/test/simple/SimpleContainerTest.java b/test-framework/providers/simple/src/test/java/org/glassfish/jersey/test/simple/SimpleContainerTest.java index e396257e97..4a32a60b4a 100644 --- a/test-framework/providers/simple/src/test/java/org/glassfish/jersey/test/simple/SimpleContainerTest.java +++ b/test-framework/providers/simple/src/test/java/org/glassfish/jersey/test/simple/SimpleContainerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.simple.SimpleContainer; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test class for {@link SimpleContainer}. @@ -71,7 +71,7 @@ public String getSomething() { public void testSimpleContainerTarget() { final Response response = target().path("one").request().get(); - assertEquals("Response status unexpected.", 200, response.getStatus()); - assertEquals("Response entity unexpected.", "get", response.readEntity(String.class)); + assertEquals(200, response.getStatus(), "Response status unexpected."); + assertEquals("get", response.readEntity(String.class), "Response entity unexpected."); } } diff --git a/test-framework/util/pom.xml b/test-framework/util/pom.xml index 2118bbd59b..00f19b8dd1 100644 --- a/test-framework/util/pom.xml +++ b/test-framework/util/pom.xml @@ -43,5 +43,15 @@ jersey-client ${project.version} + + junit + junit + ${junit4.version} + + + org.hamcrest + hamcrest + test + diff --git a/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/ConcurrentParameterizedRunner.java b/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/ConcurrentParameterizedRunner.java index a62a586f62..38133806b2 100644 --- a/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/ConcurrentParameterizedRunner.java +++ b/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/ConcurrentParameterizedRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -44,8 +44,13 @@ * be merged into {@link ConcurrentRunner} in the future. * * @author Jakub Podlesak + * + * @deprecated in connection with transition to JUnit 5 usage of this class is obsolete. Alternatively can be used + * specific junit 5 + * executions tools. */ @Beta +@Deprecated public class ConcurrentParameterizedRunner extends BlockJUnit4ClassRunner { public final int FINISH_WAIT_CYCLE_MS = 2000; diff --git a/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/ConcurrentRunner.java b/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/ConcurrentRunner.java index f4f4d5fc21..9540560d51 100644 --- a/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/ConcurrentRunner.java +++ b/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/ConcurrentRunner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -55,9 +55,14 @@ * as if no special concurrent runner was involved. * * @author Jakub Podlesak + * + * @deprecated in connection with transition to JUnit 5 usage of this class is obsolete. Alternatively can be used + * specific junit 5 + * executions tools. */ @Beta +@Deprecated public class ConcurrentRunner extends BlockJUnit4ClassRunner { public final int FINISH_WAIT_CYCLE_MS = 2000; diff --git a/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/RunSeparately.java b/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/RunSeparately.java index 9dee038565..49a474f816 100644 --- a/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/RunSeparately.java +++ b/test-framework/util/src/main/java/org/glassfish/jersey/test/util/runner/RunSeparately.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -27,8 +27,13 @@ * by any of Jersey provided parallel test runner {@link ConcurrentRunner}. * * @author Jakub Podlesak + * + * @deprecated in connection with transition to JUnit 5 usage of this class is obsolete. Alternatively can be used + * specific junit 5 + * executions tools. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) +@Deprecated public @interface RunSeparately { } diff --git a/test-framework/util/src/test/java/org/glassfish/jersey/test/util/client/LoopBackConnectorTest.java b/test-framework/util/src/test/java/org/glassfish/jersey/test/util/client/LoopBackConnectorTest.java index 98b40ed89f..040112c6a8 100644 --- a/test-framework/util/src/test/java/org/glassfish/jersey/test/util/client/LoopBackConnectorTest.java +++ b/test-framework/util/src/test/java/org/glassfish/jersey/test/util/client/LoopBackConnectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -28,12 +28,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Basic {@link org.glassfish.jersey.test.util.client.LoopBackConnector} unit tests. @@ -44,12 +45,12 @@ public class LoopBackConnectorTest { private Client client; - @Before + @BeforeEach public void setUp() throws Exception { client = ClientBuilder.newClient(LoopBackConnectorProvider.getClientConfig()); } - @After + @AfterEach public void tearDown() throws Exception { if (client != null) { client.close(); @@ -83,10 +84,12 @@ public void testEntityMediaType() throws Exception { assertThat("Invalid content-type received", response.getMediaType(), is(new MediaType("foo", "bar"))); } - @Test(expected = IllegalStateException.class) + @Test public void testClose() throws Exception { - client.close(); - client.target("baz").request().get(); + Assertions.assertThrows(IllegalStateException.class, () -> { + client.close(); + client.target("baz").request().get(); + }); } @Test @@ -112,8 +115,9 @@ public void failed(final Throwable t) { assertThat("Async request failed", throwable.get(), nullValue()); } - @Test(expected = ProcessingException.class) + @Test public void testInvalidEntity() throws Exception { - client.target("baz").request().post(Entity.json(Arrays.asList("foo", "bar"))); + Assertions.assertThrows(ProcessingException.class, + () -> client.target("baz").request().post(Entity.json(Arrays.asList("foo", "bar")))); } } diff --git a/tests/e2e-client/pom.xml b/tests/e2e-client/pom.xml index 4395a8cbbb..9c17e491bd 100644 --- a/tests/e2e-client/pom.xml +++ b/tests/e2e-client/pom.xml @@ -189,12 +189,6 @@ hamcrest test - - - xmlunit - xmlunit - test - diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/AbortResponseClientTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/AbortResponseClientTest.java index b3e1863f5f..1be8789a30 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/AbortResponseClientTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/AbortResponseClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -42,11 +42,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests aborting the request on the client side. @@ -106,7 +106,7 @@ public void filter(ClientRequestContext requestContext, assertEquals("123465", r.getEntityTag().getValue()); assertEquals("language", r.getLanguage().toString()); assertEquals(date.getTime(), r.getLastModified().getTime()); - // Assert.assertEquals("uri", r.getLink("link")); TODO: not supported yet + // Assertions.assertEquals("uri", r.getLink("link")); TODO: not supported yet assertEquals("www.oracle.com", r.getLocation().toString()); assertEquals(MediaType.TEXT_HTML_TYPE, r.getMediaType()); assertEquals(99, r.getLength()); diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/BasicClientTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/BasicClientTest.java index 47267078da..8d141a44a2 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/BasicClientTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/BasicClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -53,11 +53,11 @@ import org.glassfish.jersey.spi.ThreadPoolExecutorProvider; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static javax.ws.rs.client.Entity.text; diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/BufferingTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/BufferingTest.java index 3688755134..6963634baa 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/BufferingTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/BufferingTest.java @@ -38,8 +38,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests chunk encoding and possibility of buffering the entity. @@ -135,8 +135,8 @@ private void makeRequest(ClientConfig cc, String entity, String expected) { WebTarget target = client.target(UriBuilder.fromUri(getBaseUri()).path("resource").build()); Response response = target.request().post(Entity.entity(entity, MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(expected, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(expected, response.readEntity(String.class)); } private void testWithChunkEncodingWithPropertyDefinition(ClientConfig cc) { @@ -168,13 +168,13 @@ private void testWithChunkEncodingPerRequest(ClientConfig cc) { String entity = getVeryLongString(); Response response = target.request().post(Entity.entity(entity, MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("chunked", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("chunked", response.readEntity(String.class)); response = target.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED) .request().post(Entity.entity(entity, MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(String.valueOf(entity.length()), response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(String.valueOf(entity.length()), response.readEntity(String.class)); } public String getVeryLongString() { diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/CancelFutureClientTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/CancelFutureClientTest.java index bd9990f971..652e834460 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/CancelFutureClientTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/CancelFutureClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests the behaviour of the Async client when the {@link java.util.concurrent.Future} is cancelled. diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ChunkedInputStreamClosedPrematurelyTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ChunkedInputStreamClosedPrematurelyTest.java index 5c74b8d122..0e15ff07aa 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ChunkedInputStreamClosedPrematurelyTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ChunkedInputStreamClosedPrematurelyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -50,12 +50,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.common.util.concurrent.SettableFuture; @@ -161,15 +161,14 @@ public void testUninterrupted() { Response testResponse = target("test").queryParam(REQ_ID_PARAM_NAME, testReqId) .request().post(Entity.entity("0123456789ABCDEF", MediaType.APPLICATION_OCTET_STREAM)); - assertEquals("Unexpected response status code.", 200, testResponse.getStatus()); - assertEquals("Unexpected response entity.", "16", testResponse.readEntity(String.class)); - - assertTrue("POST request " + testReqId + " has not reached the server.", - target("test").path("requestWasMade").queryParam(REQ_ID_PARAM_NAME, testReqId) - .request().get(Boolean.class)); - assertFalse("POST request " + testReqId + " has caused an unexpected exception on the server.", - target("test").path("requestCausedException").queryParam(REQ_ID_PARAM_NAME, testReqId) - .request().get(Boolean.class)); + assertEquals(200, testResponse.getStatus(), "Unexpected response status code."); + assertEquals("16", testResponse.readEntity(String.class), "Unexpected response entity."); + + assertTrue(target("test").path("requestWasMade").queryParam(REQ_ID_PARAM_NAME, testReqId).request().get(Boolean.class), + "POST request " + testReqId + " has not reached the server."); + assertFalse(target("test").path("requestCausedException").queryParam(REQ_ID_PARAM_NAME, testReqId) + .request().get(Boolean.class), "POST request " + testReqId + + " has caused an unexpected exception on the server."); } /** @@ -192,24 +191,23 @@ public void testInterruptedJerseyHttpUrlConnection() throws Exception { connection.setChunkedStreamingMode(1024); OutputStream entityStream = connection.getOutputStream(); ReaderWriter.writeTo(new ExceptionThrowingInputStream(BYTES_TO_SEND), entityStream); - Assert.fail("Expected ProcessingException has not been thrown."); + Assertions.fail("Expected ProcessingException has not been thrown."); } catch (IOException expected) { // so far so good } finally { connection.disconnect(); } // we should make it to the server, but there the exceptional behaviour should get noticed - assertTrue("POST request " + testReqId + " has not reached the server.", - target("test").path("requestWasMade").queryParam(REQ_ID_PARAM_NAME, testReqId).request().get(Boolean.class)); - assertTrue("POST request " + testReqId + " did not cause an expected exception on the server.", - target("test").path("requestCausedException").queryParam(REQ_ID_PARAM_NAME, testReqId) - .request().get(Boolean.class)); + assertTrue(target("test").path("requestWasMade").queryParam(REQ_ID_PARAM_NAME, testReqId).request().get(Boolean.class), + "POST request " + testReqId + " has not reached the server."); + assertTrue(target("test").path("requestCausedException").queryParam(REQ_ID_PARAM_NAME, testReqId).request() + .get(Boolean.class), "POST request " + testReqId + " did not cause an expected exception on the server."); } /** * This test reproduces the Jersey Client behavior reported in JERSEY-2705. */ - @Ignore + @Disabled @Test public void testInterruptedJerseyClient() { final String testReqId = nextRequestId("testInterruptedJerseyClient"); @@ -217,16 +215,15 @@ public void testInterruptedJerseyClient() { try { target("test").queryParam(REQ_ID_PARAM_NAME, testReqId).request() .post(Entity.entity(new ExceptionThrowingInputStream(BYTES_TO_SEND), MediaType.APPLICATION_OCTET_STREAM)); - Assert.fail("Expected ProcessingException has not been thrown."); + Assertions.fail("Expected ProcessingException has not been thrown."); } catch (ProcessingException expected) { // so far so good } // we should make it to the server, but there the exceptional behaviour should get noticed - assertTrue("POST request " + testReqId + " has not reached the server.", - target("test").path("requestWasMade").queryParam(REQ_ID_PARAM_NAME, testReqId).request().get(Boolean.class)); - assertTrue("POST request " + testReqId + " did not cause an expected exception on the server.", - target("test").path("requestCausedException").queryParam(REQ_ID_PARAM_NAME, testReqId) - .request().get(Boolean.class)); + assertTrue(target("test").path("requestWasMade").queryParam(REQ_ID_PARAM_NAME, testReqId).request().get(Boolean.class), + "POST request " + testReqId + " has not reached the server."); + assertTrue(target("test").path("requestCausedException").queryParam(REQ_ID_PARAM_NAME, testReqId) + .request().get(Boolean.class), "POST request " + testReqId + " did not cause an expected exception on the server."); } private static String nextRequestId(String testMethodName) { diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientBufferingDisabledTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientBufferingDisabledTest.java index f9c6adfa87..97676a3bc0 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientBufferingDisabledTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientBufferingDisabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,12 +36,12 @@ import org.glassfish.jersey.client.HttpUrlConnectorProvider; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; - -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; /** * Tests possibility of disabling buffering of outgoing entity in @@ -50,7 +50,7 @@ * @author Miroslav Fuksa * @author Marek Potociar */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ClientBufferingDisabledTest extends JerseyTest { private static final long LENGTH = 200000000L; @@ -92,6 +92,7 @@ public long post(InputStream is) throws IOException { * fix length streaming on {@code HttpURLConnection}. */ @Test + @Execution(ExecutionMode.CONCURRENT) public void testDisableBufferingWithFixedLengthViaProperty() { postLatch = new CountDownLatch(1); @@ -107,9 +108,9 @@ public void testDisableBufferingWithFixedLengthViaProperty() { = client.target(getBaseUri()).path("resource") .request().header(HttpHeaders.CONTENT_LENGTH, LENGTH).post( Entity.entity(is, MediaType.APPLICATION_OCTET_STREAM)); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final long count = response.readEntity(long.class); - Assert.assertEquals("Unexpected content length received.", LENGTH, count); + Assertions.assertEquals(LENGTH, count, "Unexpected content length received."); } /** @@ -121,6 +122,7 @@ public void testDisableBufferingWithFixedLengthViaProperty() { * fix length streaming on {@code HttpURLConnection}. */ @Test + @Execution(ExecutionMode.CONCURRENT) public void testDisableBufferingWithFixedLengthViaMethod() { postLatch = new CountDownLatch(1); @@ -136,9 +138,9 @@ public void testDisableBufferingWithFixedLengthViaMethod() { = client.target(getBaseUri()).path("resource") .request().header(HttpHeaders.CONTENT_LENGTH, LENGTH).post( Entity.entity(is, MediaType.APPLICATION_OCTET_STREAM)); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final long count = response.readEntity(long.class); - Assert.assertEquals("Unexpected content length received.", LENGTH, count); + Assertions.assertEquals(LENGTH, count, "Unexpected content length received."); } /** @@ -152,7 +154,8 @@ public void testDisableBufferingWithFixedLengthViaMethod() { *

*/ @Test - @Ignore("fails unpredictable (see javadoc)") + @Execution(ExecutionMode.CONCURRENT) + @Disabled("fails unpredictable (see javadoc)") public void testDisableBufferingWithChunkEncoding() { postLatch = new CountDownLatch(1); @@ -168,9 +171,9 @@ public void testDisableBufferingWithChunkEncoding() { final Response response = client.target(getBaseUri()).path("resource") .request().post(Entity.entity(is, MediaType.APPLICATION_OCTET_STREAM)); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final long count = response.readEntity(long.class); - Assert.assertEquals("Unexpected content length received.", LENGTH, count); + Assertions.assertEquals(LENGTH, count, "Unexpected content length received."); } private InputStream getInputStream() { @@ -183,7 +186,7 @@ public int read() throws IOException { if (cnt > CHUNK * 10) { try { postLatch.await(3 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS); - Assert.assertEquals("waiting for chunk on the server side time-outed", 0, postLatch.getCount()); + Assertions.assertEquals(0, postLatch.getCount(), "waiting for chunk on the server side time-outed"); } catch (InterruptedException e) { throw new RuntimeException(e); } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientDestroyTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientDestroyTest.java index afb4134d8d..d9d5956d5f 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientDestroyTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientDestroyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -42,12 +42,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; /** * Assert that pre destroy method on providers is invoked. @@ -59,7 +59,7 @@ public class ClientDestroyTest extends JerseyTest { private static final Map destroyed = new HashMap<>(); @Override - @Before + @BeforeEach public void setUp() throws Exception { destroyed.clear(); destroyed.put("filter", false); @@ -228,22 +228,22 @@ public void testLifecycleListenerProvider() { client.register(filterOnTarget); // instance registered into client client.target(getBaseUri()).register(filterOnClient).request().get(String.class); // instance registration into target - assertTrue("Filter registered on Client was expected to be already initialized.", filterOnClient.isInitialized()); - assertTrue("Filter registered on Target was expected to be already initialized.", filterOnTarget.isInitialized()); + assertTrue(filterOnClient.isInitialized(), "Filter registered on Client was expected to be already initialized."); + assertTrue(filterOnTarget.isInitialized(), "Filter registered on Target was expected to be already initialized."); client.target(getBaseUri()).register(FooListener.class).request().get(String.class); // class registration into target - assertTrue("Class-registered filter was expected to be already initialized", FooListener.isInitialized()); + assertTrue(FooListener.isInitialized(), "Class-registered filter was expected to be already initialized"); - assertFalse("Class-registered filter was expected to be still open.", FooListener.isClosed()); - assertFalse("Filter registered on Client was expected to be still open.", filterOnClient.isClosedByClientClose()); - assertFalse("Filter registered on Target was expected to be still open.", filterOnTarget.isClosedByClientClose()); + assertFalse(FooListener.isClosed(), "Class-registered filter was expected to be still open."); + assertFalse(filterOnClient.isClosedByClientClose(), "Filter registered on Client was expected to be still open."); + assertFalse(filterOnTarget.isClosedByClientClose(), "Filter registered on Target was expected to be still open."); client.close(); - assertTrue("Class-registered filter was expected to be closed.", FooListener.isClosed()); - assertTrue("Filter registered on Client was expected to be closed.", filterOnClient.isClosed()); - assertTrue("Filter registered on Target was expected to be closed.", filterOnTarget.isClosed()); + assertTrue(FooListener.isClosed(), "Class-registered filter was expected to be closed."); + assertTrue(filterOnClient.isClosed(), "Filter registered on Client was expected to be closed."); + assertTrue(filterOnTarget.isClosed(), "Filter registered on Target was expected to be closed."); } private static boolean isCalledFromFinalizer() { diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientEntityAnnotationTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientEntityAnnotationTest.java index 79288c73bf..26c619121c 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientEntityAnnotationTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientEntityAnnotationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests annotations of entity on the client side. @@ -59,8 +59,8 @@ public void test() { Entity post = Entity.entity("test", MediaType.WILDCARD_TYPE, annotations); final Response response = target().path("resource").request().post(post); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("test", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("test", response.readEntity(String.class)); } @@ -69,8 +69,8 @@ public static class ClientFilter implements ClientRequestFilter { @Override public void filter(ClientRequestContext requestContext) throws IOException { final Annotation[] entityAnnotations = requestContext.getEntityAnnotations(); - Assert.assertEquals(1, entityAnnotations.length); - Assert.assertEquals(MyProvider.class.getAnnotation(Provider.class), entityAnnotations[0]); + Assertions.assertEquals(1, entityAnnotations.length); + Assertions.assertEquals(MyProvider.class.getAnnotation(Provider.class), entityAnnotations[0]); } } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientExecutorCloseTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientExecutorCloseTest.java index e6a09b6198..70d583f307 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientExecutorCloseTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientExecutorCloseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -29,11 +29,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Petr Janouch @@ -46,7 +46,7 @@ public class ClientExecutorCloseTest extends JerseyTest { * Tests that closing a client shuts down a corresponding client async executor service. */ @Test - @Ignore("Jersey uses ForkJoin common pool by default, which shouldn't be closed when client closes.") + @Disabled("Jersey uses ForkJoin common pool by default, which shouldn't be closed when client closes.") public void testCloseAsyncExecutor() throws InterruptedException { assertFalse(clientExecutorThreadPresent()); target("resource").request().async().get(); @@ -56,14 +56,14 @@ public void testCloseAsyncExecutor() throws InterruptedException { .build(); eventSource.register(System.out::println); eventSource.open(); - assertTrue("Waiting for eventSource to open time-outed", cdl.await(5000, TimeUnit.MILLISECONDS)); - assertTrue("Client async executor thread not found.", clientExecutorThreadPresent()); - assertTrue("Scheduler thread not found.", schedulerFound); + assertTrue(cdl.await(5000, TimeUnit.MILLISECONDS), "Waiting for eventSource to open time-outed"); + assertTrue(clientExecutorThreadPresent(), "Client async executor thread not found."); + assertTrue(schedulerFound, "Scheduler thread not found."); client().close(); - assertFalse("Client async executor thread should have been already removed.", - clientExecutorThreadPresent()); - assertFalse("Client background scheduler thread should have been already removed.", - clientSchedulerThreadPresent()); + assertFalse(clientExecutorThreadPresent(), + "Client async executor thread should have been already removed."); + assertFalse(clientSchedulerThreadPresent(), + "Client background scheduler thread should have been already removed."); } private boolean clientExecutorThreadPresent() { diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientExecutorTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientExecutorTest.java index e1230cd785..a20b28afbd 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientExecutorTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientExecutorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -43,8 +43,8 @@ import org.glassfish.jersey.spi.ExecutorServiceProvider; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; @@ -73,7 +73,7 @@ protected Application configure() { private volatile StringBuilder threadName; private volatile CountDownLatch latch; - @Before + @BeforeEach public void setUpThreadNameHolder() { threadName = new StringBuilder(); latch = new CountDownLatch(1); diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientFilterTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientFilterTest.java index 9918ad4776..f68f5415d6 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientFilterTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -38,10 +38,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPathTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPathTest.java index ee07bd7f0f..85f74111e3 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPathTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test definition of path in client invocation. diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPreInitTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPreInitTest.java index ad4d687b28..b930cf2400 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPreInitTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ClientPreInitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -43,11 +43,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test pre initialization of the client. @@ -110,7 +110,7 @@ public Integer readFrom(Class type, Type genericType, Annotation[] anno } } - @Before + @BeforeEach public void before() { TestReader.initialized = false; } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/FollowRedirectHeadTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/FollowRedirectHeadTest.java index 204ca15726..fb85c61ed9 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/FollowRedirectHeadTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/FollowRedirectHeadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -32,8 +32,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests that configuration of {@link ClientProperties#FOLLOW_REDIRECTS} works when HEAD method is used. @@ -73,28 +73,28 @@ private WebTarget getTarget(boolean followRedirect) { @Test public void testDontFollowRedirectHead() throws Exception { Response response = getTarget(false).request().head(); - Assert.assertEquals(303, response.getStatus()); - Assert.assertTrue(response.getLocation().toString().endsWith("/final")); + Assertions.assertEquals(303, response.getStatus()); + Assertions.assertTrue(response.getLocation().toString().endsWith("/final")); } @Test public void testDontFollowRedirectGet() throws Exception { Response response = getTarget(false).request().get(); - Assert.assertEquals(303, response.getStatus()); - Assert.assertTrue(response.getLocation().toString().endsWith("/final")); + Assertions.assertEquals(303, response.getStatus()); + Assertions.assertTrue(response.getLocation().toString().endsWith("/final")); } @Test public void testFollowRedirectHead() throws Exception { Response response = getTarget(true).request().head(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertFalse(response.hasEntity()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertFalse(response.hasEntity()); } @Test public void testFollowRedirectGet() throws Exception { Response response = getTarget(true).request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("final-entity", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("final-entity", response.readEntity(String.class)); } } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/FollowRedirectsTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/FollowRedirectsTest.java index 12610b12f6..07a6faf47b 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/FollowRedirectsTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/FollowRedirectsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,8 +27,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/GenericResponseTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/GenericResponseTest.java index 14dadcdb8f..6dca5e7343 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/GenericResponseTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/GenericResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test {@link GenericType} with {@link Response}. @@ -71,8 +71,8 @@ public void testPost() { SyncInvoker sync = target.request(); Response response = sync.post(entity, generic); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("entity", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("entity", response.readEntity(String.class)); } @Test @@ -84,8 +84,8 @@ public void testAsyncPost() throws ExecutionException, InterruptedException { final AsyncInvoker async = target.request().async(); Response response = async.post(entity, generic).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("entity", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("entity", response.readEntity(String.class)); } @Test @@ -95,8 +95,8 @@ public void testGet() { WebTarget target = target("resource"); SyncInvoker sync = target.request(); Response response = sync.get(generic); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); } @Test @@ -106,8 +106,8 @@ public void testAsyncGet() throws ExecutionException, InterruptedException { WebTarget target = target("resource"); final AsyncInvoker async = target.request().async(); Response response = async.get(generic).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); } @Test @@ -117,6 +117,6 @@ public void testGetGenericString() { WebTarget target = target("resource"); SyncInvoker sync = target.request(); final String entity = sync.get(generic); - Assert.assertEquals("get", entity); + Assertions.assertEquals("get", entity); } } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpAuthorizationTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpAuthorizationTest.java index 57419880af..753ecd9eb7 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpAuthorizationTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpAuthorizationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -43,18 +43,18 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; /** * Tests {@link org.glassfish.jersey.client.authentication.HttpAuthenticationFeature}. * * @author Miroslav Fuksa */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class HttpAuthorizationTest extends JerseyTest { @NameBinding @@ -253,6 +253,7 @@ public String alternating() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBasicPreemptive() { Response response = target().path("resource").path("basic") .register(HttpAuthenticationFeature.basicBuilder().credentials("homer", "Homer").build()) @@ -261,6 +262,7 @@ public void testBasicPreemptive() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBasicNonPreemptive() { Response response = target().path("resource").path("basic") .register(HttpAuthenticationFeature.basicBuilder().nonPreemptive().credentials("homer", "Homer").build()) @@ -269,6 +271,7 @@ public void testBasicNonPreemptive() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBasicNonPreemptiveWithEmptyPassword() { final WebTarget target = target().path("resource") .register(HttpAuthenticationFeature.basicBuilder().nonPreemptive().build()); @@ -279,7 +282,7 @@ public void testBasicNonPreemptiveWithEmptyPassword() { response = target().path("resource").path("basic") .register(HttpAuthenticationFeature.basicBuilder().nonPreemptive().build()) .request().get(); - Assert.fail("should throw an exception as credentials are missing"); + Assertions.fail("should throw an exception as credentials are missing"); } catch (Exception e) { // ok } @@ -292,6 +295,7 @@ public void testBasicNonPreemptiveWithEmptyPassword() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testUniversalBasic() { Response response = target().path("resource").path("basic") .register(HttpAuthenticationFeature.universalBuilder().credentials("homer", "Homer").build()) @@ -304,6 +308,7 @@ public void testUniversalBasic() { * insensitve. */ @Test + @Execution(ExecutionMode.CONCURRENT) public void testUniversalBasicCaseSensitivity() { Response response; @@ -330,6 +335,7 @@ public void testUniversalBasicCaseSensitivity() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testUniversalBasicWrongPassword() { Response response = target().path("resource").path("basic") .register(HttpAuthenticationFeature.universalBuilder().credentials("homer", "FOO").build()) @@ -338,6 +344,7 @@ public void testUniversalBasicWrongPassword() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBasicWithDifferentCredentials() { final WebTarget target = target().path("resource").path("basic") .register(HttpAuthenticationFeature.basicBuilder().credentials("marge", "Marge").build()); @@ -346,6 +353,7 @@ public void testBasicWithDifferentCredentials() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBasicUniversalWithDifferentCredentials() { final WebTarget target = target().path("resource").path("basic") .register(HttpAuthenticationFeature.universalBuilder().credentials("marge", "Marge").build()); @@ -378,6 +386,7 @@ public void _testBasicWithDifferentCredentials(WebTarget target) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDigest() { Response response = target().path("resource").path("digest") .register(HttpAuthenticationFeature.digest("homer", "Homer")) @@ -386,6 +395,7 @@ public void testDigest() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDigestWithPasswords() { final WebTarget target = target().path("resource").path("digest") .register(HttpAuthenticationFeature.digest("homer", "Homer")); @@ -393,6 +403,7 @@ public void testDigestWithPasswords() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testUniversalDigestWithPasswords() { final WebTarget target = target().path("resource").path("digest") .register(HttpAuthenticationFeature.universalBuilder().credentials("homer", "Homer").build()); @@ -420,6 +431,7 @@ public void _testDigestWithPasswords(WebTarget target) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDigestWithEmptyDefaultPassword() { final WebTarget target = target().path("resource") .register(HttpAuthenticationFeature.digest()); @@ -427,6 +439,7 @@ public void testDigestWithEmptyDefaultPassword() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDigestUniversalWithEmptyDefaultPassword() { final WebTarget target = target().path("resource") .register(HttpAuthenticationFeature.universalBuilder().build()); @@ -452,7 +465,7 @@ public void _testDigestWithEmptyDefaultPassword(WebTarget target) { .property(HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_USERNAME, "bart") .property(HttpAuthenticationFeature.HTTP_AUTHENTICATION_BASIC_PASSWORD, "Bart") .get(); - Assert.fail("should throw an exception as no credentials were supplied for digest auth"); + Assertions.fail("should throw an exception as no credentials were supplied for digest auth"); } catch (Exception e) { // ok } @@ -464,15 +477,16 @@ public void _testDigestWithEmptyDefaultPassword(WebTarget target) { } private void check(Response response, int status, String entity) { - Assert.assertEquals(status, response.getStatus()); - Assert.assertEquals(entity, response.readEntity(String.class)); + Assertions.assertEquals(status, response.getStatus()); + Assertions.assertEquals(entity, response.readEntity(String.class)); } private void check(Response response, int status) { - Assert.assertEquals(status, response.getStatus()); + Assertions.assertEquals(status, response.getStatus()); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDigestUniversalSimple() { Response response = target().path("resource").path("digest") .register(HttpAuthenticationFeature.universalBuilder().credentials("homer", "Homer").build()) @@ -481,6 +495,7 @@ public void testDigestUniversalSimple() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDigestUniversalSimple2() { Response response = target().path("resource").path("digest") .register(HttpAuthenticationFeature.universalBuilder().credentialsForDigest("homer", "Homer").build()) @@ -489,6 +504,7 @@ public void testDigestUniversalSimple2() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDigestUniversalSimple3() { Response response = target().path("resource").path("digest") .register(HttpAuthenticationFeature.universalBuilder() @@ -500,6 +516,7 @@ public void testDigestUniversalSimple3() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDigestUniversalSimple4() { Response response = target().path("resource").path("digest") .register(HttpAuthenticationFeature.universal("homer", "Homer")) @@ -508,6 +525,7 @@ public void testDigestUniversalSimple4() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testUniversal() { final WebTarget target = target().path("resource") .register(HttpAuthenticationFeature.universal("homer", "Homer")); diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpDigestAuthFilterTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpDigestAuthFilterTest.java index 8e6bfd905c..f959cf68fa 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpDigestAuthFilterTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpDigestAuthFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -38,8 +38,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.uri.UriComponent; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @@ -117,7 +117,7 @@ private Response verify() { ha2); // this generates INTERNAL_SERVER_ERROR if not matching - Assert.assertEquals(ncExpected, Integer.parseInt(getDigestAuthHeaderValue(authHeader, "nc="))); + Assertions.assertEquals(ncExpected, Integer.parseInt(getDigestAuthHeaderValue(authHeader, "nc="))); if (response.equals(getDigestAuthHeaderValue(authHeader, "response="))) { return Response.ok().build(); @@ -238,7 +238,7 @@ private void testRequest(final String path, final boolean addParams) { ncExpected = 1; final Response r1 = resource.request().get(); - Assert.assertEquals(Response.Status.fromStatusCode(r1.getStatus()), Response.Status.OK); + Assertions.assertEquals(Response.Status.fromStatusCode(r1.getStatus()), Response.Status.OK); } @@ -250,15 +250,15 @@ public void testPreemptive() { ncExpected = 1; final Response r1 = resource.request().get(); - Assert.assertEquals(Response.Status.fromStatusCode(r1.getStatus()), Response.Status.OK); + Assertions.assertEquals(Response.Status.fromStatusCode(r1.getStatus()), Response.Status.OK); ncExpected = 2; final Response r2 = resource.request().get(); - Assert.assertEquals(Response.Status.fromStatusCode(r2.getStatus()), Response.Status.OK); + Assertions.assertEquals(Response.Status.fromStatusCode(r2.getStatus()), Response.Status.OK); ncExpected = 3; final Response r3 = resource.request().get(); - Assert.assertEquals(Response.Status.fromStatusCode(r3.getStatus()), Response.Status.OK); + Assertions.assertEquals(Response.Status.fromStatusCode(r3.getStatus()), Response.Status.OK); } @@ -270,6 +270,6 @@ public void testAuthentication() { ncExpected = 1; final Response r1 = resource.request().get(); - Assert.assertEquals(Response.Status.fromStatusCode(r1.getStatus()), Response.Status.UNAUTHORIZED); + Assertions.assertEquals(Response.Status.fromStatusCode(r1.getStatus()), Response.Status.UNAUTHORIZED); } } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpHeadersInjectionTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpHeadersInjectionTest.java index b2ff0c73d9..65b86f0e55 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpHeadersInjectionTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpHeadersInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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,7 +18,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.Consumes; import javax.ws.rs.POST; diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpMethodEntityTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpMethodEntityTest.java index 3a81437d0c..ed51569ac3 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpMethodEntityTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/HttpMethodEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,10 +35,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests HTTP methods and entity presence. diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/IgnoreExceptionResponseTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/IgnoreExceptionResponseTest.java index 88125d8a21..f331878ad6 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/IgnoreExceptionResponseTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/IgnoreExceptionResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -27,16 +27,16 @@ import java.net.URI; import java.util.concurrent.atomic.AtomicReference; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; import org.glassfish.jersey.CommonProperties; import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; /** * Tests ignoring of client responses in exceptions. @@ -61,7 +61,7 @@ public IgnoreExceptionResponseTest() { /** * Sets ignore exception response as system property after enabling the provider. */ - @BeforeClass + @BeforeAll public static void startUp() { lastAllowSystemProperties = System.setProperty(CommonProperties.ALLOW_SYSTEM_PROPERTIES_PROVIDER, "true"); lastIgnoreExceptionResponse = System.setProperty(ClientProperties.IGNORE_EXCEPTION_RESPONSE, "true"); @@ -70,7 +70,7 @@ public static void startUp() { /** * Restores state after completion. */ - @AfterClass + @AfterAll public static void cleanUp() { if (lastIgnoreExceptionResponse != null) { System.setProperty(ClientProperties.IGNORE_EXCEPTION_RESPONSE, lastIgnoreExceptionResponse); diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InjectedClientBodyWorker.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InjectedClientBodyWorker.java index d747cd8e9e..1414887acd 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InjectedClientBodyWorker.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InjectedClientBodyWorker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -43,7 +43,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InjectionManagerProviderTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InjectionManagerProviderTest.java index 6ee393e82c..9aa31da25a 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InjectionManagerProviderTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InjectionManagerProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -46,8 +46,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests {@link InjectionManagerClientProvider}. diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InvocationBuilderRxTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InvocationBuilderRxTest.java index 6c43026289..a10359a8c7 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InvocationBuilderRxTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/InvocationBuilderRxTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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,9 +20,9 @@ import org.glassfish.jersey.client.JerseyInvocation; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -46,7 +46,7 @@ public class InvocationBuilderRxTest extends JerseyTest { private static final String ECHO = "ECHO"; private CountDownLatch latch; - @Before + @BeforeEach public void beforeEach() { latch = new CountDownLatch(1); } @@ -95,8 +95,8 @@ public void testMethodCallback() throws InterruptedException, ExecutionException .method("GET", new TestCallback(latch)); latch.await(AWAIT_TIME, TimeUnit.MILLISECONDS); - Assert.assertEquals(ECHO, future.get()); - Assert.assertEquals(0, latch.getCount()); + Assertions.assertEquals(ECHO, future.get()); + Assertions.assertEquals(0, latch.getCount()); } @Test @@ -105,8 +105,8 @@ public void testMethodEntityCallback() throws InterruptedException, ExecutionExc .method("POST", Entity.entity(ECHO, MediaType.TEXT_PLAIN), new TestCallback(latch)); latch.await(AWAIT_TIME, TimeUnit.MILLISECONDS); - Assert.assertEquals(ECHO + ECHO, future.get()); - Assert.assertEquals(0, latch.getCount()); + Assertions.assertEquals(ECHO + ECHO, future.get()); + Assertions.assertEquals(0, latch.getCount()); } @Test @@ -115,7 +115,7 @@ public void testMethodEntityResponseType() throws InterruptedException, Executio .method("POST", Entity.entity(ECHO, MediaType.TEXT_PLAIN), Response.class); try (Response response = stage.toCompletableFuture().get()) { - Assert.assertEquals(ECHO + ECHO, response.readEntity(String.class)); + Assertions.assertEquals(ECHO + ECHO, response.readEntity(String.class)); } } @@ -125,7 +125,7 @@ public void testMethodEntityGenericType() throws InterruptedException, Execution .method("POST", Entity.entity(ECHO, MediaType.TEXT_PLAIN), new GenericType(){}); try (Response response = stage.toCompletableFuture().get()) { - Assert.assertEquals(ECHO + ECHO, response.readEntity(String.class)); + Assertions.assertEquals(ECHO + ECHO, response.readEntity(String.class)); } } } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/JaxRsTimeoutTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/JaxRsTimeoutTest.java index ebff0ea608..987de6a11d 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/JaxRsTimeoutTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/JaxRsTimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Pavel Bucek diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/NonSuccessfulResponseTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/NonSuccessfulResponseTest.java index 9075628beb..a01a1798a8 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/NonSuccessfulResponseTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/NonSuccessfulResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,8 +32,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test no successful (3XX, 4XX, 5XX) responses with no empty body. @@ -106,8 +106,8 @@ private void generalTestGet(int status) { WebTarget target = target("resource").path(Integer.toString(status)); SyncInvoker sync = target.request(); Response response = sync.get(Response.class); - Assert.assertEquals(status, response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); + Assertions.assertEquals(status, response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); } private void generalTestPost(int status) { @@ -115,8 +115,8 @@ private void generalTestPost(int status) { WebTarget target = target("resource").path(Integer.toString(status)); SyncInvoker sync = target.request(); Response response = sync.post(entity, Response.class); - Assert.assertEquals(status, response.getStatus()); - Assert.assertEquals("entity", response.readEntity(String.class)); + Assertions.assertEquals(status, response.getStatus()); + Assertions.assertEquals("entity", response.readEntity(String.class)); } } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/RequestScopedReadEntityTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/RequestScopedReadEntityTest.java index 9f5c926cfc..f8bd405fcf 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/RequestScopedReadEntityTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/RequestScopedReadEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -40,8 +40,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * TODO: javadoc. diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseCloseTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseCloseTest.java index 69bdeda208..44412ab8e3 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseCloseTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseCloseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.fail; /** * Test for Response.close() method. diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseReadAndBufferEntityTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseReadAndBufferEntityTest.java index b90b1296af..e9aa6d0c14 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseReadAndBufferEntityTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ResponseReadAndBufferEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -40,12 +40,12 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * Buffered response entity tests. @@ -267,13 +267,13 @@ public void filter(final ClientRequestContext requestContext, final ClientRespon // Read entity should not fail - we silently consume the underlying IOException from closed input stream. final String entity = response.readEntity(String.class, null); assertThat("Unexpected response.", entity.toString(), equalTo(Resource.ENTITY)); - assertEquals("Close not invoked on underlying input stream.", 1, entityStream.getCloseCount()); + assertEquals(1, entityStream.getCloseCount(), "Close not invoked on underlying input stream."); // Close should not fail and should be idempotent response.close(); response.close(); response.close(); - assertEquals("Close invoked too many times on underlying input stream.", 1, entityStream.getCloseCount()); + assertEquals(1, entityStream.getCloseCount(), "Close invoked too many times on underlying input stream."); try { // UC-1.1 : Try to read an unbuffered entity from a closed context @@ -307,7 +307,7 @@ public void filter(final ClientRequestContext requestContext, final ClientRespon entityStream.setCorruptClose(true); response.bufferEntity(); - assertEquals("Close not invoked on underlying input stream.", 1, entityStream.getCloseCount()); + assertEquals(1, entityStream.getCloseCount(), "Close not invoked on underlying input stream."); String entity; entity = response.readEntity(String.class, null); @@ -319,7 +319,7 @@ public void filter(final ClientRequestContext requestContext, final ClientRespon response.close(); response.close(); response.close(); - assertEquals("Close invoked too many times on underlying input stream.", 1, entityStream.getCloseCount()); + assertEquals(1, entityStream.getCloseCount(), "Close invoked too many times on underlying input stream."); try { // UC-2.1 : Try to read a buffered entity from a closed context diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ShutdownHookMemoryLeakTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ShutdownHookMemoryLeakTest.java index 14220dc1d8..85a63bdd98 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ShutdownHookMemoryLeakTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/ShutdownHookMemoryLeakTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -17,6 +17,7 @@ package org.glassfish.jersey.tests.e2e.client; import java.lang.reflect.Field; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -38,15 +39,15 @@ import org.glassfish.jersey.jetty.connector.JettyConnectorProvider; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Ensure Jersey connectors do not leak resources @@ -57,27 +58,28 @@ * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) -public class ShutdownHookMemoryLeakTest extends JerseyTest { +public class ShutdownHookMemoryLeakTest { private static final String PATH = "test"; private static final int ITERATIONS = 1000; - private final ConnectorProvider connectorProvider; - - public ShutdownHookMemoryLeakTest(final ConnectorProvider cp) { - connectorProvider = cp; + public static List connectionProviders() { + return Arrays.asList( + new GrizzlyConnectorProvider(), + new JettyConnectorProvider(), + new ApacheConnectorProvider(), + new HttpUrlConnectorProvider() + ); } - - @Parameterized.Parameters - public static List connectionProviders() { - return Arrays.asList(new ConnectorProvider[][] { - {new GrizzlyConnectorProvider()}, - {new JettyConnectorProvider()}, - {new ApacheConnectorProvider()}, - {new HttpUrlConnectorProvider()} + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + connectionProviders().forEach(connectionProvider -> { + ShutdownHookMemoryLeakTemplateTest test = new ShutdownHookMemoryLeakTemplateTest(connectionProvider) {}; + tests.add(TestHelper.toTestContainer(test, connectionProvider.getClass().getSimpleName())); }); + return tests; } @Path(PATH) @@ -89,63 +91,72 @@ public String get() { } } - @Override - protected Application configure() { - return new ResourceConfig(TestResource.class); - } + public abstract static class ShutdownHookMemoryLeakTemplateTest extends JerseyTest { + private final ConnectorProvider connectorProvider; - @Override - protected void configureClient(ClientConfig config) { - config.connectorProvider(connectorProvider); - } - - @Test - @Ignore("Unstable, ignored for now") - public void testClientDoesNotLeakResources() throws Exception { - - final AtomicInteger listenersInitialized = new AtomicInteger(0); - final AtomicInteger listenersClosed = new AtomicInteger(0); - - for (int i = 0; i < ITERATIONS; i++) { - final Response response = target(PATH).property("another", "runtime").register(new ClientLifecycleListener() { - @Override - public void onInit() { - listenersInitialized.incrementAndGet(); - } - - @Override - public void onClose() { - listenersClosed.incrementAndGet(); - } - }).register(LoggingFeature.class).request().get(); - assertEquals("GET", response.readEntity(String.class)); + public ShutdownHookMemoryLeakTemplateTest(final ConnectorProvider cp) { + connectorProvider = cp; } - Collection shutdownHooks = getShutdownHooks(client()); - - assertThat(String.format( - "%s: number of initialized listeners should be the same as number of total request count", - connectorProvider.getClass()), - listenersInitialized.get(), is(ITERATIONS)); - -// the following check is fragile, as GC could break it easily -// assertThat(String.format( -// "%s: number of closed listeners should correspond to the number of missing hooks", -// connectorProvider.getClass()), -// listenersClosed.get(), is(ITERATIONS - shutdownHooks.size())); + @Override + protected Application configure() { + return new ResourceConfig(TestResource.class); + } - client().close(); // clean up the rest + @Override + protected void configureClient(ClientConfig config) { + config.connectorProvider(connectorProvider); + } - assertThat(String.format( - "%s: number of closed listeners should be the same as the number of total requests made", - connectorProvider.getClass()), - listenersClosed.get(), is(ITERATIONS)); - } + @Test + @Disabled("Unstable, ignored for now") + public void testClientDoesNotLeakResources() throws Exception { + + final AtomicInteger listenersInitialized = new AtomicInteger(0); + final AtomicInteger listenersClosed = new AtomicInteger(0); + + for (int i = 0; i < ITERATIONS; i++) { + final Response response = target(PATH).property("another", "runtime").register(new ClientLifecycleListener() { + @Override + public void onInit() { + listenersInitialized.incrementAndGet(); + } + + @Override + public void onClose() { + listenersClosed.incrementAndGet(); + } + }).register(LoggingFeature.class).request().get(); + assertEquals("GET", response.readEntity(String.class)); + } + + Collection shutdownHooks = getShutdownHooks(client()); + + assertThat(String.format( + "%s: number of initialized listeners should be the same as number of total request count", + connectorProvider.getClass()), + listenersInitialized.get(), is(ITERATIONS)); + +// the following check is fragile, as GC could break it easily +// assertThat(String.format( +// "%s: number of closed listeners should correspond to the number of missing hooks", +// connectorProvider.getClass()), +// listenersClosed.get(), is(ITERATIONS - shutdownHooks.size())); + + client().close(); // clean up the rest + + assertThat(String.format( + "%s: number of closed listeners should be the same as the number of total requests made", + connectorProvider.getClass()), + listenersClosed.get(), is(ITERATIONS)); + } - private Collection getShutdownHooks(javax.ws.rs.client.Client client) throws NoSuchFieldException, IllegalAccessException { - JerseyClient jerseyClient = (JerseyClient) client; - Field shutdownHooksField = JerseyClient.class.getDeclaredField("shutdownHooks"); - shutdownHooksField.setAccessible(true); - return (Collection) shutdownHooksField.get(jerseyClient); + private Collection getShutdownHooks(javax.ws.rs.client.Client client) + throws NoSuchFieldException, IllegalAccessException { + JerseyClient jerseyClient = (JerseyClient) client; + Field shutdownHooksField = JerseyClient.class.getDeclaredField("shutdownHooks"); + shutdownHooksField.setAccessible(true); + return (Collection) shutdownHooksField.get(jerseyClient); + } } } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/TimeoutTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/TimeoutTest.java index 507321ff70..559258d730 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/TimeoutTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/TimeoutTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,10 +29,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Martin Matula diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/HttpPatchTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/HttpPatchTest.java index e9429ac14d..3bca471561 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/HttpPatchTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/HttpPatchTest.java @@ -16,7 +16,9 @@ package org.glassfish.jersey.tests.e2e.client.connector; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.concurrent.CompletionStage; import java.util.concurrent.Future; @@ -42,121 +44,133 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek */ -@RunWith(Parameterized.class) -public class HttpPatchTest extends JerseyTest { +public class HttpPatchTest { private static final Logger LOGGER = Logger.getLogger(RequestHeaderModificationsTest.class.getName()); - @Parameterized.Parameters(name = "{index}: {0}") - public static List testData() { - return Arrays.asList(new Object[][]{ + public static List testData() { + return Arrays.asList( // {HttpUrlConnectorProvider.class}, // cannot process PATCH without additional configuration - {GrizzlyConnectorProvider.class}, - {JettyConnectorProvider.class}, // unstable. - {ApacheConnectorProvider.class}, - {Apache5ConnectorProvider.class}, - {NettyConnectorProvider.class}, - {JdkConnectorProvider.class}, - }); + new GrizzlyConnectorProvider(), + new JettyConnectorProvider(), // unstable. + new ApacheConnectorProvider(), + new Apache5ConnectorProvider(), + new NettyConnectorProvider(), + new JdkConnectorProvider() + ); } - private final ConnectorProvider connectorProvider; - - public HttpPatchTest(Class connectorProviderClass) - throws IllegalAccessException, InstantiationException { - this.connectorProvider = connectorProviderClass.newInstance(); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + for (ConnectorProvider provider : testData()) { + HttpPatchTemplateTest test = new HttpPatchTemplateTest(provider) {}; + DynamicContainer container = TestHelper.toTestContainer(test, + String.format("httpPatchTest (%s)", provider.getClass().getSimpleName())); + tests.add(container); + } + return tests; } - @Override - protected Application configure() { - set(TestProperties.RECORD_LOG_LEVEL, Level.WARNING.intValue()); - enable(TestProperties.LOG_TRAFFIC); - return new ResourceConfig(PatchResource.class) - .register(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.HEADERS_ONLY)); - } + public abstract static class HttpPatchTemplateTest extends JerseyTest { + private final ConnectorProvider connectorProvider; - @Override - protected void configureClient(ClientConfig clientConfig) { - clientConfig.connectorProvider(connectorProvider); - } + public HttpPatchTemplateTest(ConnectorProvider connectorProvider) { + this.connectorProvider = connectorProvider; + } - @Test - public void testPatchResponse() throws Exception { - Response response = target().request().method("PATCH", Entity.text("patch")); + @Override + protected Application configure() { + set(TestProperties.RECORD_LOG_LEVEL, Level.WARNING.intValue()); + enable(TestProperties.LOG_TRAFFIC); + return new ResourceConfig(PatchResource.class) + .register(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.HEADERS_ONLY)); + } - assertEquals(200, response.getStatus()); - assertEquals("patch", response.readEntity(String.class)); - } + @Override + protected void configureClient(ClientConfig clientConfig) { + clientConfig.connectorProvider(connectorProvider); + } - @Test - public void testPatchEntity() throws Exception { - String response = target().request().method("PATCH", Entity.text("patch"), String.class); + @Test + public void testPatchResponse() throws Exception { + Response response = target().request().method("PATCH", Entity.text("patch")); - assertEquals("patch", response); - } + assertEquals(200, response.getStatus()); + assertEquals("patch", response.readEntity(String.class)); + } - @Test - public void testPatchGenericType() throws Exception { - String response = target().request().method("PATCH", Entity.text("patch"), new GenericType() { - }); + @Test + public void testPatchEntity() throws Exception { + String response = target().request().method("PATCH", Entity.text("patch"), String.class); - assertEquals("patch", response); - } + assertEquals("patch", response); + } - @Test - public void testAsyncPatchResponse() throws Exception { - Future response = target().request().async().method("PATCH", Entity.text("patch")); + @Test + public void testPatchGenericType() throws Exception { + String response = target().request().method("PATCH", Entity.text("patch"), new GenericType() { + }); - assertEquals(200, response.get().getStatus()); - assertEquals("patch", response.get().readEntity(String.class)); - } + assertEquals("patch", response); + } - @Test - public void testAsyncPatchEntity() throws Exception { - Future response = target().request().async().method("PATCH", Entity.text("patch"), String.class); + @Test + public void testAsyncPatchResponse() throws Exception { + Future response = target().request().async().method("PATCH", Entity.text("patch")); - assertEquals("patch", response.get()); - } + assertEquals(200, response.get().getStatus()); + assertEquals("patch", response.get().readEntity(String.class)); + } - @Test - public void testAsyncPatchGenericType() throws Exception { - Future response = target().request().async().method("PATCH", Entity.text("patch"), new GenericType() { - }); + @Test + public void testAsyncPatchEntity() throws Exception { + Future response = target().request().async().method("PATCH", Entity.text("patch"), String.class); - assertEquals("patch", response.get()); - } + assertEquals("patch", response.get()); + } - @Test - public void testRxPatchResponse() throws Exception { - CompletionStage response = target().request().rx().method("PATCH", Entity.text("patch")); + @Test + public void testAsyncPatchGenericType() throws Exception { + Future response = target().request().async().method("PATCH", Entity.text("patch"), new GenericType() { + }); - assertEquals(200, response.toCompletableFuture().get().getStatus()); - assertEquals("patch", response.toCompletableFuture().get().readEntity(String.class)); - } + assertEquals("patch", response.get()); + } - @Test - public void testRxPatchEntity() throws Exception { - CompletionStage response = target().request().rx().method("PATCH", Entity.text("patch"), String.class); + @Test + public void testRxPatchResponse() throws Exception { + CompletionStage response = target().request().rx().method("PATCH", Entity.text("patch")); - assertEquals("patch", response.toCompletableFuture().get()); - } + assertEquals(200, response.toCompletableFuture().get().getStatus()); + assertEquals("patch", response.toCompletableFuture().get().readEntity(String.class)); + } + + @Test + public void testRxPatchEntity() throws Exception { + CompletionStage response = target().request().rx().method("PATCH", Entity.text("patch"), String.class); - @Test - public void testRxPatchGenericType() throws Exception { - CompletionStage response = target().request().rx() - .method("PATCH", Entity.text("patch"), new GenericType() { - }); + assertEquals("patch", response.toCompletableFuture().get()); + } + + @Test + public void testRxPatchGenericType() throws Exception { + CompletionStage response = target().request().rx() + .method("PATCH", Entity.text("patch"), new GenericType() { + }); - assertEquals("patch", response.toCompletableFuture().get()); + assertEquals("patch", response.toCompletableFuture().get()); + } } @Path("/") diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/RequestHeaderModificationsTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/RequestHeaderModificationsTest.java index f030077859..3d63a59c3b 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/RequestHeaderModificationsTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/RequestHeaderModificationsTest.java @@ -21,7 +21,9 @@ import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.Scanner; import java.util.concurrent.Future; @@ -62,23 +64,23 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.hamcrest.MatcherAssert.assertThat; /** * JERSEY-2206 reproducer * * @author Libor Kramolis */ -@RunWith(Parameterized.class) -public class RequestHeaderModificationsTest extends JerseyTest { +public class RequestHeaderModificationsTest { private static final Logger LOGGER = Logger.getLogger(RequestHeaderModificationsTest.class.getName()); private static final boolean GZIP = false; // change to true when JERSEY-2341 fixed @@ -97,103 +99,117 @@ public class RequestHeaderModificationsTest extends JerseyTest { private static final String REQUEST_HEADER_MODIFICATION_SUPPORTED = "modificationSupported"; private static final String PATH = "/resource"; - @Parameterized.Parameters(name = "{index}: {0} / modificationSupported= {1} / addHeader= {2}") public static List testData() { return Arrays.asList(new Object[][] { - {HttpUrlConnectorProvider.class, true, false}, - {GrizzlyConnectorProvider.class, false, false}, // change to true when JERSEY-2341 fixed - {JettyConnectorProvider.class, false, false}, // change to true when JERSEY-2341 fixed - {ApacheConnectorProvider.class, false, false}, // change to true when JERSEY-2341 fixed - {Apache5ConnectorProvider.class, false, false}, // change to true when JERSEY-2341 fixed - {HttpUrlConnectorProvider.class, true, true}, - {GrizzlyConnectorProvider.class, false, true}, // change to true when JERSEY-2341 fixed - {JettyConnectorProvider.class, false, true}, // change to true when JERSEY-2341 fixed - {ApacheConnectorProvider.class, false, true}, // change to true when JERSEY-2341 fixed - {Apache5ConnectorProvider.class, false, true}, // change to true when JERSEY-2341 fixed + {new HttpUrlConnectorProvider(), true, false}, + {new GrizzlyConnectorProvider(), false, false}, // change to true when JERSEY-2341 fixed + {new JettyConnectorProvider(), false, false}, // change to true when JERSEY-2341 fixed + {new ApacheConnectorProvider(), false, false}, // change to true when JERSEY-2341 fixed + {new Apache5ConnectorProvider(), false, false}, // change to true when JERSEY-2341 fixed + {new HttpUrlConnectorProvider(), true, true}, + {new GrizzlyConnectorProvider(), false, true}, // change to true when JERSEY-2341 fixed + {new JettyConnectorProvider(), false, true}, // change to true when JERSEY-2341 fixed + {new ApacheConnectorProvider(), false, true}, // change to true when JERSEY-2341 fixed + {new Apache5ConnectorProvider(), false, true}, // change to true when JERSEY-2341 fixed }); } - private final ConnectorProvider connectorProvider; - private final boolean modificationSupported; // remove when JERSEY-2341 fixed - private final boolean addHeader; - - public RequestHeaderModificationsTest(Class connectorProviderClass, - boolean modificationSupported, boolean addHeader) - throws IllegalAccessException, InstantiationException { - this.connectorProvider = connectorProviderClass.newInstance(); - this.modificationSupported = modificationSupported; - this.addHeader = addHeader; + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + testData().forEach(arr -> { + RequestHeaderModificationsTemplateTest test = new RequestHeaderModificationsTemplateTest( + (ConnectorProvider) arr[0], (boolean) arr[1], (boolean) arr[2]) {}; + tests.add(TestHelper.toTestContainer(test, String.format("%s (%s, %s, %s)", + RequestHeaderModificationsTemplateTest.class.getSimpleName(), + arr[0].getClass().getSimpleName(), arr[1], arr[2]))); + }); + return tests; } - @Override - protected Application configure() { - set(TestProperties.RECORD_LOG_LEVEL, Level.WARNING.intValue()); + public abstract static class RequestHeaderModificationsTemplateTest extends JerseyTest { + private final ConnectorProvider connectorProvider; + private final boolean modificationSupported; // remove when JERSEY-2341 fixed + private final boolean addHeader; - enable(TestProperties.LOG_TRAFFIC); - if (DUMP_ENTITY) { - enable(TestProperties.DUMP_ENTITY); + public RequestHeaderModificationsTemplateTest(ConnectorProvider connectorProvider, + boolean modificationSupported, boolean addHeader) { + this.connectorProvider = connectorProvider; + this.modificationSupported = modificationSupported; + this.addHeader = addHeader; } - return new ResourceConfig(TestResource.class).register(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.HEADERS_ONLY)); - } - @Override - protected void configureClient(ClientConfig clientConfig) { - clientConfig.register(MyClientRequestFilter.class); - clientConfig.register(new MyWriterInterceptor(addHeader)); - clientConfig.register(new MyMessageBodyWriter(addHeader)); - clientConfig.connectorProvider(connectorProvider); - } + @Override + protected Application configure() { + set(TestProperties.RECORD_LOG_LEVEL, Level.WARNING.intValue()); - @Test - public void testWarningLogged() throws Exception { - Response response = requestBuilder().post(requestEntity()); - assertResponse(response); - } + enable(TestProperties.LOG_TRAFFIC); + if (DUMP_ENTITY) { + enable(TestProperties.DUMP_ENTITY); + } + return new ResourceConfig(TestResource.class) + .register(new LoggingFeature(LOGGER, LoggingFeature.Verbosity.HEADERS_ONLY)); + } - @Test - public void testWarningLoggedAsync() throws Exception { - AsyncInvoker asyncInvoker = requestBuilder().async(); - Future responseFuture = asyncInvoker.post(requestEntity()); - Response response = responseFuture.get(); - assertResponse(response); - } + @Override + protected void configureClient(ClientConfig clientConfig) { + clientConfig.register(MyClientRequestFilter.class); + clientConfig.register(new MyWriterInterceptor(addHeader)); + clientConfig.register(new MyMessageBodyWriter(addHeader)); + clientConfig.connectorProvider(connectorProvider); + } - private Invocation.Builder requestBuilder() { - return target(PATH) - .request() - .header(REQUEST_HEADER_NAME_CLIENT, REQUEST_HEADER_VALUE_CLIENT) - .header(REQUEST_HEADER_MODIFICATION_SUPPORTED, modificationSupported && addHeader) - .header("hello", "double").header("hello", "value"); - } + @Test + public void testWarningLogged() throws Exception { + Response response = requestBuilder().post(requestEntity()); + assertResponse(response); + } - private Entity requestEntity() { - return Entity.text(new MyEntity(QUESTION)); - } + @Test + public void testWarningLoggedAsync() throws Exception { + AsyncInvoker asyncInvoker = requestBuilder().async(); + Future responseFuture = asyncInvoker.post(requestEntity()); + Response response = responseFuture.get(); + assertResponse(response); + } - private void assertResponse(Response response) { - if (!modificationSupported) { - final String UNSENT_HEADER_CHANGES = "Unsent header changes"; - LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES); - if (addHeader) { - assertNotNull("Missing LogRecord for message '" + UNSENT_HEADER_CHANGES + "'.", logRecord); - assertThat(logRecord.getMessage(), containsString(REQUEST_HEADER_NAME_INTERCEPTOR)); - assertThat(logRecord.getMessage(), containsString(REQUEST_HEADER_NAME_MBW)); - } else { - assertNull("Unexpected LogRecord for message '" + UNSENT_HEADER_CHANGES + "'.", logRecord); - } + private Invocation.Builder requestBuilder() { + return target(PATH) + .request() + .header(REQUEST_HEADER_NAME_CLIENT, REQUEST_HEADER_VALUE_CLIENT) + .header(REQUEST_HEADER_MODIFICATION_SUPPORTED, modificationSupported && addHeader) + .header("hello", "double").header("hello", "value"); } - assertEquals(200, response.getStatus()); - assertEquals(ANSWER, response.readEntity(String.class)); - } + private Entity requestEntity() { + return Entity.text(new MyEntity(QUESTION)); + } + + private void assertResponse(Response response) { + if (!modificationSupported) { + final String UNSENT_HEADER_CHANGES = "Unsent header changes"; + LogRecord logRecord = findLogRecord(UNSENT_HEADER_CHANGES); + if (addHeader) { + assertNotNull(logRecord, "Missing LogRecord for message '" + UNSENT_HEADER_CHANGES + "'."); + assertThat(logRecord.getMessage(), containsString(REQUEST_HEADER_NAME_INTERCEPTOR)); + assertThat(logRecord.getMessage(), containsString(REQUEST_HEADER_NAME_MBW)); + } else { + assertNull(logRecord, "Unexpected LogRecord for message '" + UNSENT_HEADER_CHANGES + "'."); + } + } + + assertEquals(200, response.getStatus()); + assertEquals(ANSWER, response.readEntity(String.class)); + } - private LogRecord findLogRecord(String messageContains) { - for (final LogRecord record : getLoggedRecords()) { - if (record.getMessage().contains(messageContains)) { - return record; + private LogRecord findLogRecord(String messageContains) { + for (final LogRecord record : getLoggedRecords()) { + if (record.getMessage().contains(messageContains)) { + return record; + } } + return null; } - return null; } @Path(PATH) diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/proxy/ProxySelectorTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/proxy/ProxySelectorTest.java index a813e545c6..cb714f3c32 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/proxy/ProxySelectorTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/proxy/ProxySelectorTest.java @@ -21,19 +21,13 @@ import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; -import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; -import org.glassfish.jersey.apache5.connector.Apache5ConnectorProvider; import org.glassfish.jersey.client.ClientConfig; -import org.glassfish.jersey.client.spi.ConnectorProvider; -import org.glassfish.jersey.jetty.connector.JettyConnectorProvider; import org.glassfish.jersey.netty.connector.NettyConnectorProvider; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -42,40 +36,20 @@ import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; import java.util.HashSet; -import java.util.List; import java.util.Set; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Moved from jetty-connector * @author Marcelo Rubim */ -@RunWith(Parameterized.class) public class ProxySelectorTest { private static final String NO_PASS = "no-pass"; - @Parameterized.Parameters(name = "{index}: {0}") - public static List testData() { - return Arrays.asList(new Object[][]{ - // Apache, Grizzly, Jetty have the proxy set on constructor, i.e. ProxySelector cannot choose based on URI. - // HttpUrlConnector ignores proxy on localhost. - {NettyConnectorProvider.class}, - }); - } - - private final ConnectorProvider connectorProvider; - - public ProxySelectorTest(Class connectorProviderClass) - throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { - this.connectorProvider = connectorProviderClass.getConstructor().newInstance(); - } - protected void configureClient(ClientConfig config) { - config.connectorProvider(connectorProvider); + config.connectorProvider(new NettyConnectorProvider()); } @Test @@ -90,12 +64,12 @@ public void testGet407() { try (Response response = target("proxyTest").request().get()) { assertEquals(407, response.getStatus()); } catch (ProcessingException pe) { - Assert.assertTrue(pe.getMessage().contains("407")); // netty + Assertions.assertTrue(pe.getMessage().contains("407")); // netty } } private static Server server; - @BeforeClass + @BeforeAll public static void startFakeProxy() { server = new Server(9997); server.setHandler(new ProxyHandler()); @@ -109,7 +83,7 @@ public static void startFakeProxy() { System.setProperty("http.proxyPort", "9997"); } - @AfterClass + @AfterAll public static void tearDownProxy() { try { server.stop(); @@ -122,7 +96,7 @@ public static void tearDownProxy() { } private static Client client; - @Before + @BeforeEach public void beforeEach() { ClientConfig config = new ClientConfig(); this.configureClient(config); diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/proxy/ProxyTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/proxy/ProxyTest.java index 69be5f6591..cdd1bbe2a4 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/proxy/ProxyTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/proxy/ProxyTest.java @@ -30,13 +30,11 @@ import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider; import org.glassfish.jersey.jetty.connector.JettyConnectorProvider; import org.glassfish.jersey.netty.connector.NettyConnectorProvider; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -47,19 +45,16 @@ import javax.ws.rs.core.Response; import java.lang.reflect.InvocationTargetException; import java.nio.charset.Charset; -import java.util.Arrays; import java.util.Base64; import java.util.HashSet; -import java.util.List; import java.util.Set; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Moved from jetty-connector * @author Marcelo Rubim */ -@RunWith(Parameterized.class) public class ProxyTest { private static final Charset CHARACTER_SET = Charset.forName("iso-8859-1"); private static final String PROXY_URI = "http://127.0.0.1:9997"; @@ -67,94 +62,133 @@ public class ProxyTest { private static final String PROXY_PASSWORD = "proxy-password"; private static final String NO_PASS = "no-pass"; - @Parameterized.Parameters(name = "{index}: {0}") - public static List testData() { - return Arrays.asList(new Object[][]{ - {ApacheConnectorProvider.class}, - {Apache5ConnectorProvider.class}, - {GrizzlyConnectorProvider.class}, - {JettyConnectorProvider.class}, - {NettyConnectorProvider.class}, - {HttpUrlConnectorProvider.class}, - }); + public static class ApacheConnectorProviderProxyTest extends ProxyTemplateTest { + public ApacheConnectorProviderProxyTest() + throws NoSuchMethodException, InvocationTargetException, InstantiationException, + IllegalAccessException { + super(ApacheConnectorProvider.class); + } } - private final ConnectorProvider connectorProvider; - - public ProxyTest(Class connectorProviderClass) - throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { - this.connectorProvider = connectorProviderClass.getConstructor().newInstance(); + public static class Apache5ConnectorProviderProxyTest extends ProxyTemplateTest { + public Apache5ConnectorProviderProxyTest() + throws NoSuchMethodException, InvocationTargetException, InstantiationException, + IllegalAccessException { + super(Apache5ConnectorProvider.class); + } } - protected void configureClient(ClientConfig config) { - config.connectorProvider(connectorProvider); + public static class GrizzlyConnectorProviderProxyTest extends ProxyTemplateTest { + public GrizzlyConnectorProviderProxyTest() + throws NoSuchMethodException, InvocationTargetException, InstantiationException, + IllegalAccessException { + super(GrizzlyConnectorProvider.class); + } } - @Test - public void testGetNoPass() { - client().property(ClientProperties.PROXY_URI, ProxyTest.PROXY_URI); - try (Response response = target("proxyTest").request().header(NO_PASS, 200).get()) { - assertEquals(200, response.getStatus()); + public static class JettyConnectorProviderProxyTest extends ProxyTemplateTest { + public JettyConnectorProviderProxyTest() + throws NoSuchMethodException, InvocationTargetException, InstantiationException, + IllegalAccessException { + super(JettyConnectorProvider.class); } } - @Test - public void testGet407() { - // Grizzly sends (String)null password and username - int expected = GrizzlyConnectorProvider.class.isInstance(connectorProvider) ? 400 : 407; - client().property(ClientProperties.PROXY_URI, ProxyTest.PROXY_URI); - try (Response response = target("proxyTest").request().get()) { - assertEquals(expected, response.getStatus()); - } catch (ProcessingException pe) { - Assert.assertTrue(pe.getMessage().contains("407")); // netty + public static class NettyConnectorProviderProxyTest extends ProxyTemplateTest { + public NettyConnectorProviderProxyTest() + throws NoSuchMethodException, InvocationTargetException, InstantiationException, + IllegalAccessException { + super(NettyConnectorProvider.class); } } - @Test - public void testGetSuccess() { - client().property(ClientProperties.PROXY_URI, ProxyTest.PROXY_URI); - client().property(ClientProperties.PROXY_USERNAME, ProxyTest.PROXY_USERNAME); - client().property(ClientProperties.PROXY_PASSWORD, ProxyTest.PROXY_PASSWORD); - Response response = target("proxyTest").request().get(); - response.bufferEntity(); - assertEquals(response.readEntity(String.class), 200, response.getStatus()); + public static class HttpUrlConnectorProviderProxyTest extends ProxyTemplateTest { + public HttpUrlConnectorProviderProxyTest() + throws NoSuchMethodException, InvocationTargetException, InstantiationException, + IllegalAccessException { + super(HttpUrlConnectorProvider.class); + } } - private static Server server; - @BeforeClass - public static void startFakeProxy() { - server = new Server(9997); - server.setHandler(new ProxyHandler()); - try { - server.start(); - } catch (Exception e) { + public abstract static class ProxyTemplateTest { + private final ConnectorProvider connectorProvider; + public ProxyTemplateTest(Class connectorProviderClass) + throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { + this.connectorProvider = connectorProviderClass.getConstructor().newInstance(); } - } - @AfterClass - public static void tearDownProxy() { - try { - server.stop(); - } catch (Exception e) { + protected void configureClient(ClientConfig config) { + config.connectorProvider(connectorProvider); } - } - private static Client client; - @Before - public void beforeEach() { - ClientConfig config = new ClientConfig(); - this.configureClient(config); - client = ClientBuilder.newClient(config); - } + @Test + public void testGetNoPass() { + client().property(ClientProperties.PROXY_URI, ProxyTest.PROXY_URI); + try (Response response = target("proxyTest").request().header(NO_PASS, 200).get()) { + assertEquals(200, response.getStatus()); + } + } - private Client client() { - return client; - } + @Test + public void testGet407() { + // Grizzly sends (String)null password and username + int expected = GrizzlyConnectorProvider.class.isInstance(connectorProvider) ? 400 : 407; + client().property(ClientProperties.PROXY_URI, ProxyTest.PROXY_URI); + try (Response response = target("proxyTest").request().get()) { + assertEquals(expected, response.getStatus()); + } catch (ProcessingException pe) { + Assertions.assertTrue(pe.getMessage().contains("407")); // netty + } + } + + @Test + public void testGetSuccess() { + client().property(ClientProperties.PROXY_URI, ProxyTest.PROXY_URI); + client().property(ClientProperties.PROXY_USERNAME, ProxyTest.PROXY_USERNAME); + client().property(ClientProperties.PROXY_PASSWORD, ProxyTest.PROXY_PASSWORD); + Response response = target("proxyTest").request().get(); + response.bufferEntity(); + assertEquals(200, response.getStatus(), response.readEntity(String.class)); + } + + private static Server server; + @BeforeAll + public static void startFakeProxy() { + server = new Server(9997); + server.setHandler(new ProxyHandler()); + try { + server.start(); + } catch (Exception e) { + + } + } + + @AfterAll + public static void tearDownProxy() { + try { + server.stop(); + } catch (Exception e) { + + } + } + + private static Client client; + @BeforeEach + public void beforeEach() { + ClientConfig config = new ClientConfig(); + this.configureClient(config); + client = ClientBuilder.newClient(config); + } - private WebTarget target(String path) { - return client().target("http://localhost:9998").path(path); + private Client client() { + return client; + } + + private WebTarget target(String path) { + return client().target("http://localhost:9998").path(path); + } } static class ProxyHandler extends AbstractHandler { diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/AbstractConnectorServerTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/AbstractConnectorServerTest.java index bc8ad45981..512e9fc428 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/AbstractConnectorServerTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/AbstractConnectorServerTest.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; +import java.util.stream.Stream; import javax.net.ssl.SSLContext; @@ -30,10 +31,8 @@ import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider; import org.glassfish.jersey.jetty.connector.JettyConnectorProvider; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import com.google.common.io.ByteStreams; @@ -42,7 +41,6 @@ * * @author Petr Bouda */ -@RunWith(Parameterized.class) public abstract class AbstractConnectorServerTest { // Default truststore and keystore @@ -55,24 +53,20 @@ public abstract class AbstractConnectorServerTest { * * @return test parameters. */ - @Parameterized.Parameters(name = "{index}: {0}") - public static Iterable testData() { - return Arrays.asList(new Object[][] { - {new HttpUrlConnectorProvider()}, - {new GrizzlyConnectorProvider()}, - {new JettyConnectorProvider()}, - {new ApacheConnectorProvider()}, - {new Apache5ConnectorProvider()} - }); + public static Stream testData() { + return Stream.of( + new HttpUrlConnectorProvider(), + new GrizzlyConnectorProvider(), + new JettyConnectorProvider(), + new ApacheConnectorProvider(), + new Apache5ConnectorProvider() + ); } - @Parameterized.Parameter(0) - public ConnectorProvider connectorProvider; - private final Object serverGuard = new Object(); private Server server = null; - @Before + @BeforeEach public void setUp() throws Exception { synchronized (serverGuard) { if (server != null) { @@ -83,7 +77,7 @@ public void setUp() throws Exception { } } - @After + @AfterEach public void tearDown() throws Exception { synchronized (serverGuard) { if (server == null) { diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorConfigurationTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorConfigurationTest.java index 608ba06334..d81b88aae3 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorConfigurationTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorConfigurationTest.java @@ -25,13 +25,13 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.glassfish.jersey.client.spi.ConnectorProvider; import org.glassfish.jersey.logging.LoggingFeature; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * SSL connector tests. @@ -40,7 +40,6 @@ * @author Arul Dhesiaseelan (aruld at acm.org) * @author Marek Potociar */ -@RunWith(Parameterized.class) public class SslConnectorConfigurationTest extends AbstractConnectorServerTest { /** @@ -48,8 +47,9 @@ public class SslConnectorConfigurationTest extends AbstractConnectorServerTest { * * @throws Exception in case of a test failure. */ - @Test - public void testSSLWithAuth() throws Exception { + @ParameterizedTest + @MethodSource("testData") + public void testSSLWithAuth(ConnectorProvider connectorProvider) throws Exception { final SSLContext sslContext = getSslContext(); final ClientConfig cc = new ClientConfig().connectorProvider(connectorProvider); @@ -73,8 +73,9 @@ public void testSSLWithAuth() throws Exception { * * @throws Exception in case of a test failure. */ - @Test - public void testHTTPBasicAuth1() throws Exception { + @ParameterizedTest + @MethodSource("testData") + public void testHTTPBasicAuth1(ConnectorProvider connectorProvider) throws Exception { final SSLContext sslContext = getSslContext(); final ClientConfig cc = new ClientConfig().connectorProvider(connectorProvider); @@ -96,8 +97,9 @@ public void testHTTPBasicAuth1() throws Exception { * * @throws Exception in case of a test failure. */ - @Test - public void testSSLAuth1() throws Exception { + @ParameterizedTest + @MethodSource("testData") + public void testSSLAuth1(ConnectorProvider connectorProvider) throws Exception { final SSLContext sslContext = getSslContext(); final ClientConfig cc = new ClientConfig().connectorProvider(connectorProvider); @@ -121,8 +123,9 @@ public void testSSLAuth1() throws Exception { /** * Test that a response to an authentication challenge has the same SSL configuration as the original request. */ - @Test - public void testSSLWithNonPreemptiveAuth() throws Exception { + @ParameterizedTest + @MethodSource("testData") + public void testSSLWithNonPreemptiveAuth(ConnectorProvider connectorProvider) throws Exception { final SSLContext sslContext = getSslContext(); final ClientConfig cc = new ClientConfig().connectorProvider(connectorProvider); diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorHostnameVerifierTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorHostnameVerifierTest.java index a41f2187e8..bf4f948138 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorHostnameVerifierTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslConnectorHostnameVerifierTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -33,18 +33,16 @@ import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider; import org.glassfish.jersey.jetty.connector.JettyConnectorProvider; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * SSL connector hostname verification tests. * * @author Petr Bouda */ -@RunWith(Parameterized.class) public class SslConnectorHostnameVerifierTest extends AbstractConnectorServerTest { private static final String CLIENT_TRUST_STORE = "truststore-example_com-client"; @@ -65,10 +63,11 @@ protected String clientTrustStore() { * * @throws Exception in case of a test failure. */ - @Test - public void testHostnameVerifierApplied() throws Exception { + @ParameterizedTest + @MethodSource("testData") + public void testHostnameVerifierApplied(ConnectorProvider connectorProvider) throws Exception { // Grizzly and Jetty connectors don't support Hostname Verification - if (isExcluded(Arrays.asList(GrizzlyConnectorProvider.class, JettyConnectorProvider.class))) { + if (isExcluded(Arrays.asList(GrizzlyConnectorProvider.class, JettyConnectorProvider.class), connectorProvider)) { return; } @@ -93,7 +92,7 @@ public void testHostnameVerifierApplied() throws Exception { } } - private boolean isExcluded(List> excluded) { + private boolean isExcluded(List> excluded, ConnectorProvider connectorProvider) { for (Class clazz : excluded) { if (clazz.isAssignableFrom(connectorProvider.getClass())) { return true; diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslHttpUrlConnectorTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslHttpUrlConnectorTest.java index df3f1dcd4e..9b22f48a14 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslHttpUrlConnectorTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/ssl/SslHttpUrlConnectorTest.java @@ -43,11 +43,15 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.HttpUrlConnectorProvider; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; +import org.glassfish.jersey.client.spi.ConnectorProvider; import org.glassfish.jersey.logging.LoggingFeature; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test custom socket factory in HttpUrlConnection using SSL @@ -94,8 +98,9 @@ public HttpURLConnection getConnection(final URL url) throws IOException { * * @author Kevin Conaway */ - @Test - public void testConcurrentRequestsWithCustomSSLContext() throws Exception { + @ParameterizedTest + @MethodSource("testData") + public void testConcurrentRequestsWithCustomSSLContext(ConnectorProvider connectorProvider) throws Exception { if (HttpUrlConnectorProvider.class.isInstance(connectorProvider) || (ApacheConnectorProvider.class.isInstance(connectorProvider)) || (Apache5ConnectorProvider.class.isInstance(connectorProvider))) { @@ -132,14 +137,9 @@ public void testConcurrentRequestsWithCustomSSLContext() throws Exception { service.shutdown(); - assertTrue( - service.awaitTermination(1, TimeUnit.MINUTES) - ); + assertTrue(service.awaitTermination(1, TimeUnit.MINUTES)); - assertTrue( - toString(exceptions), - exceptions.isEmpty() - ); + assertTrue(exceptions.isEmpty(), toString(exceptions)); } private String toString(List exceptions) { diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/grizzlyconnector/NonBlockingTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/grizzlyconnector/NonBlockingTest.java index 5006b190b2..66414de9a3 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/grizzlyconnector/NonBlockingTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/grizzlyconnector/NonBlockingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Grizzly connector non blocking test. @@ -82,9 +82,9 @@ public void failed(Throwable throwable) { String response = future.get(); assertNotNull(response); - assertTrue("Invocation callback was not invoked", - countDownLatch.await(5, TimeUnit.SECONDS)); - assertTrue("Invocation callback is not executed on the NIO pool thread.", - !invocationCallbackThreadName.contains("jersey-client-async-executor")); + assertTrue(countDownLatch.await(5, TimeUnit.SECONDS), + "Invocation callback was not invoked"); + assertTrue(!invocationCallbackThreadName.contains("jersey-client-async-executor"), + "Invocation callback is not executed on the NIO pool thread."); } } diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/httpurlconnector/AsyncTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/httpurlconnector/AsyncTest.java index a67f40937d..43a8172de4 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/httpurlconnector/AsyncTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/httpurlconnector/AsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -43,14 +43,14 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.hamcrest.Matchers; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThanOrEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Asynchronous connector test. @@ -228,7 +228,7 @@ private void sleep() { } @Test - @Ignore("Unstable test.") + @Disabled("Unstable test.") public void testClientThreadPool() throws Exception { final AsyncInvoker invoker = ClientBuilder .newClient(new ClientConfig().property(ClientProperties.ASYNC_THREADPOOL_SIZE, 9)) diff --git a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/httpurlconnector/Expect100ContinueTest.java b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/httpurlconnector/Expect100ContinueTest.java index 1616824478..e80fabdf69 100644 --- a/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/httpurlconnector/Expect100ContinueTest.java +++ b/tests/e2e-client/src/test/java/org/glassfish/jersey/tests/e2e/client/httpurlconnector/Expect100ContinueTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -23,7 +23,7 @@ import org.glassfish.jersey.client.http.Expect100ContinueFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; @@ -33,7 +33,7 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class Expect100ContinueTest extends JerseyTest { @@ -72,7 +72,7 @@ protected Application configure() { @Test public void testExpect100Continue() { final Response response = target(RESOURCE_PATH).request().post(Entity.text(ENTITY_STRING)); - assertEquals("Expected 200", 200, response.getStatus()); //no Expect header sent - responce OK + assertEquals(200, response.getStatus(), "Expected 200"); //no Expect header sent - responce OK } @Test @@ -80,7 +80,7 @@ public void testExpect100ContinueChunked() { final Response response = target(RESOURCE_PATH).register(Expect100ContinueFeature.basic()) .property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.CHUNKED).request().post(Entity.text(ENTITY_STRING)); - assertEquals("Expected 204", 204, response.getStatus()); //Expect header sent - No Content response + assertEquals(204, response.getStatus(), "Expected 204"); //Expect header sent - No Content response } @Test @@ -89,7 +89,7 @@ public void testExpect100ContinueBuffered() { .property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED).request().header(HttpHeaders.CONTENT_LENGTH, 67000L) .post(Entity.text(ENTITY_STRING)); - assertEquals("Expected 204", 204, response.getStatus()); //Expect header sent - No Content response + assertEquals(204, response.getStatus(), "Expected 204"); //Expect header sent - No Content response } @Test @@ -97,7 +97,7 @@ public void testExpect100ContinueCustomLength() { final Response response = target(RESOURCE_PATH).register(Expect100ContinueFeature.withCustomThreshold(100L)) .request().header(HttpHeaders.CONTENT_LENGTH, 101L) .post(Entity.text(ENTITY_STRING)); - assertEquals("Expected 204", 204, response.getStatus()); //Expect header sent - No Content response + assertEquals(204, response.getStatus(), "Expected 204"); //Expect header sent - No Content response } @Test @@ -105,7 +105,7 @@ public void testExpect100ContinueCustomLengthWrong() { final Response response = target(RESOURCE_PATH).register(Expect100ContinueFeature.withCustomThreshold(100L)) .request().header(HttpHeaders.CONTENT_LENGTH, 99L) .post(Entity.text(ENTITY_STRING)); - assertEquals("Expected 200", 200, response.getStatus()); //Expect header NOT sent - low request size + assertEquals(200, response.getStatus(), "Expected 200"); //Expect header NOT sent - low request size } @Test @@ -115,7 +115,7 @@ public void testExpect100ContinueCustomLengthProperty() { .register(Expect100ContinueFeature.basic()) .request().header(HttpHeaders.CONTENT_LENGTH, 666L) .post(Entity.text(ENTITY_STRING)); - assertEquals("Expected 204", 204, response.getStatus()); //Expect header sent - No Content response + assertEquals(204, response.getStatus(), "Expected 204"); //Expect header sent - No Content response } @Test @@ -125,6 +125,6 @@ public void testExpect100ContinueRegisterViaCustomProperty() { .property(ClientProperties.EXPECT_100_CONTINUE, Boolean.TRUE) .request().header(HttpHeaders.CONTENT_LENGTH, 44L) .post(Entity.text(ENTITY_STRING)); - assertEquals("Expected 204", 204, response.getStatus()); //Expect header sent - No Content response + assertEquals(204, response.getStatus(), "Expected 204"); //Expect header sent - No Content response } } diff --git a/tests/e2e-core-common/pom.xml b/tests/e2e-core-common/pom.xml index fb49a82ab5..4163e869b8 100644 --- a/tests/e2e-core-common/pom.xml +++ b/tests/e2e-core-common/pom.xml @@ -39,8 +39,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/TestRuntimeDelegate.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/TestRuntimeDelegate.java index 4e5403d4fa..a4d3736353 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/TestRuntimeDelegate.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/TestRuntimeDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -28,7 +28,7 @@ import org.glassfish.jersey.internal.AbstractRuntimeDelegate; import org.glassfish.jersey.message.internal.MessagingBinders; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** * Test runtime delegate. @@ -49,31 +49,31 @@ public T createEndpoint(Application application, Class endpointType) public void testMediaType() { MediaType m = new MediaType("text", "plain"); - Assert.assertNotNull(m); + Assertions.assertNotNull(m); } public void testUriBuilder() { UriBuilder ub = RuntimeDelegate.getInstance().createUriBuilder(); - Assert.assertNotNull(ub); + Assertions.assertNotNull(ub); } public void testResponseBuilder() { Response.ResponseBuilder rb = RuntimeDelegate.getInstance().createResponseBuilder(); - Assert.assertNotNull(rb); + Assertions.assertNotNull(rb); } public void testVariantListBuilder() { Variant.VariantListBuilder vlb = RuntimeDelegate.getInstance().createVariantListBuilder(); - Assert.assertNotNull(vlb); + Assertions.assertNotNull(vlb); } public void testLinkBuilder() { final Link.Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder(); - Assert.assertNotNull(linkBuilder); + Assertions.assertNotNull(linkBuilder); } public void testWebApplicationException() { WebApplicationException wae = new WebApplicationException(); - Assert.assertNotNull(wae); + Assertions.assertNotNull(wae); } } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/config/ServiceFinderBinderTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/config/ServiceFinderBinderTest.java index 15b031ffd1..2663dd9b38 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/config/ServiceFinderBinderTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/config/ServiceFinderBinderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -28,11 +28,11 @@ import org.glassfish.jersey.internal.inject.Injections; import org.glassfish.jersey.internal.inject.Providers; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Service finder injection binder unit test. @@ -46,7 +46,7 @@ public class ServiceFinderBinderTest { public ServiceFinderBinderTest() { } - @BeforeClass + @BeforeAll public static void setUpClass() throws Exception { AbstractBinder binder = new AbstractBinder() { @Override @@ -60,7 +60,7 @@ protected void configure() { injectionManager.completeRegistration(); } - @AfterClass + @AfterAll public static void tearDownClass() throws Exception { } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ContextResolverFactoryTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ContextResolverFactoryTest.java index d69b010b07..d8d5dd6073 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ContextResolverFactoryTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ContextResolverFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -32,10 +32,10 @@ import org.glassfish.jersey.internal.inject.ProviderBinder; import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Context resolvers factory unit test. @@ -107,7 +107,7 @@ public ContextResolverFactoryTest() { RuntimeDelegate.setInstance(new TestRuntimeDelegate()); } - @Before + @BeforeEach public void setUp() { InjectionManager injectionManager = Injections.createInjectionManager(); ProviderBinder providerBinder = new ProviderBinder(injectionManager); diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ExceptionMapperFactoryTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ExceptionMapperFactoryTest.java index 24b4ffac3e..530662dd78 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ExceptionMapperFactoryTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ExceptionMapperFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -27,8 +27,8 @@ import org.glassfish.jersey.internal.inject.Injections; import org.glassfish.jersey.spi.ExtendedExceptionMapper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Unit test of {@link ExceptionMapperFactory}. @@ -85,8 +85,8 @@ public void testFindMappingExtendedExceptions() throws Exception { final ExceptionMapper mapper = mapperFactory.findMapping(new IllegalArgumentException()); - Assert.assertTrue("IllegalArgumentExceptionMapper should be returned", - mapper instanceof IllegalArgumentExceptionMapper); + Assertions.assertTrue(mapper instanceof IllegalArgumentExceptionMapper, + "IllegalArgumentExceptionMapper should be returned"); } /** @@ -116,7 +116,7 @@ public void testFindMapping() throws Exception { final ExceptionMapper mapper = mapperFactory.findMapping(new RuntimeException()); - Assert.assertTrue("RuntimeExceptionMapper should be returned", mapper instanceof RuntimeExceptionMapper); + Assertions.assertTrue(mapper instanceof RuntimeExceptionMapper, "RuntimeExceptionMapper should be returned"); } /** @@ -147,8 +147,7 @@ public void testFindExtendedExceptions() throws Exception { final ExceptionMapper mapper = mapperFactory.find(IllegalArgumentException.class); - Assert.assertTrue("IllegalStateExceptionMapper should be returned", - mapper instanceof IllegalStateExceptionMapper); + Assertions.assertTrue(mapper instanceof IllegalStateExceptionMapper, "IllegalStateExceptionMapper should be returned"); } /** diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/JaxrsProvidersTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/JaxrsProvidersTest.java index 49f6cc482c..37746780c9 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/JaxrsProvidersTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/JaxrsProvidersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -44,9 +44,9 @@ import org.glassfish.jersey.process.internal.RequestScope; import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; /**® * @author Marek Potociar diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/LocalizationMessagesTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/LocalizationMessagesTest.java index 22c679f37b..e05696435a 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/LocalizationMessagesTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/LocalizationMessagesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,8 +19,8 @@ import org.glassfish.jersey.internal.LocalizationMessages; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests {@link org.glassfish.jersey.internal.LocalizationMessages}. @@ -30,7 +30,7 @@ public class LocalizationMessagesTest { @Test public void test() { - Assert.assertTrue(LocalizationMessages.COMPONENT_CONTRACTS_EMPTY_OR_NULL("TYPE") + Assertions.assertTrue(LocalizationMessages.COMPONENT_CONTRACTS_EMPTY_OR_NULL("TYPE") .contains("Attempt to register component of type TYPE")); } } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ProviderBinderTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ProviderBinderTest.java index b17a6b2177..17d5e9ead6 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ProviderBinderTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/ProviderBinderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -52,9 +52,9 @@ import org.glassfish.jersey.message.internal.MessagingBinders; import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * ServiceProviders unit test. diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/inject/ReferencingFactoryTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/inject/ReferencingFactoryTest.java index 76429b0150..4d84e0993c 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/inject/ReferencingFactoryTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/internal/inject/ReferencingFactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -32,8 +32,8 @@ import org.glassfish.jersey.internal.inject.ReferencingFactory; import org.glassfish.jersey.internal.util.collection.Ref; -import org.junit.Test; -import static org.junit.Assert.assertSame; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertSame; /** * Referencing factory test. diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/AcceptableMediaTypeStringRepresentationTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/AcceptableMediaTypeStringRepresentationTest.java index 2faf424a89..740549ab6d 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/AcceptableMediaTypeStringRepresentationTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/AcceptableMediaTypeStringRepresentationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,19 +16,18 @@ package org.glassfish.jersey.tests.e2e.common.message.internal; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; +import java.util.stream.Stream; import org.glassfish.jersey.message.internal.AcceptableMediaType; import org.glassfish.jersey.message.internal.MediaTypeProvider; import org.glassfish.jersey.message.internal.Quality; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** @@ -36,38 +35,28 @@ * * @author Adam Lindenthal */ -@RunWith(Parameterized.class) public class AcceptableMediaTypeStringRepresentationTest { - @Parameterized.Parameters // expected result, acceptable media type - public static List getParameters() { + public static Stream getParameters() { final Map emptyParams = new HashMap(); final Map params = new HashMap(); params.put("myParam", "myValue"); - return Arrays.asList(new Object[][]{ - {"*/*", new AcceptableMediaType("*", "*")}, - {"*/*", new AcceptableMediaType("*", "*", Quality.DEFAULT, emptyParams)}, - {"*/*;q=0.75", new AcceptableMediaType("*", "*", 750, emptyParams)}, - {"text/html", new AcceptableMediaType("text", "html", Quality.DEFAULT, null)}, - {"text/html;q=0.5", new AcceptableMediaType("text", "html", 500, emptyParams)}, - {"image/*;myparam=myValue;q=0.8", new AcceptableMediaType("image", "*", 800, params)}, - }); + return Stream.of( + Arguments.of("*/*", new AcceptableMediaType("*", "*")), + Arguments.of("*/*", new AcceptableMediaType("*", "*", Quality.DEFAULT, emptyParams)), + Arguments.of("*/*;q=0.75", new AcceptableMediaType("*", "*", 750, emptyParams)), + Arguments.of("text/html", new AcceptableMediaType("text", "html", Quality.DEFAULT, null)), + Arguments.of("text/html;q=0.5", new AcceptableMediaType("text", "html", 500, emptyParams)), + Arguments.of("image/*;myparam=myValue;q=0.8", new AcceptableMediaType("image", "*", 800, params)) + ); } - private final String expectedValue; - private final AcceptableMediaType testedType; - - public AcceptableMediaTypeStringRepresentationTest(final String expectedValue, - final AcceptableMediaType testedType) { - this.expectedValue = expectedValue; - this.testedType = testedType; - } - - @Test - public void testStringRepresentation() { + @ParameterizedTest + @MethodSource("getParameters") + public void testStringRepresentation(String expectedValue, AcceptableMediaType testedType) { final MediaTypeProvider provider = new MediaTypeProvider(); - Assert.assertEquals(expectedValue, testedType.toString()); + Assertions.assertEquals(expectedValue, testedType.toString()); provider.fromString(testedType.toString()); } } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/AcceptableMediaTypeTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/AcceptableMediaTypeTest.java index 7821bfa617..013d410007 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/AcceptableMediaTypeTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/AcceptableMediaTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,57 +16,47 @@ package org.glassfish.jersey.tests.e2e.common.message.internal; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.core.MediaType; import org.glassfish.jersey.message.internal.AcceptableMediaType; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Acceptable media type unit tests. * * @author Marek Potociar */ -@RunWith(Parameterized.class) public class AcceptableMediaTypeTest { - @Parameterized.Parameters // expected result, media type, acceptable media type - public static List testBeds() { - return Arrays.asList(new Object[][]{ - {Boolean.TRUE, MediaType.APPLICATION_JSON_TYPE, new AcceptableMediaType("application", "json")}, - {Boolean.TRUE, MediaType.APPLICATION_JSON_TYPE, new AcceptableMediaType("application", "json", 1000, null)}, - {Boolean.FALSE, MediaType.APPLICATION_JSON_TYPE, new AcceptableMediaType("application", "json", 500, null)}, - {Boolean.FALSE, MediaType.APPLICATION_JSON_TYPE, new AcceptableMediaType("application", "xml")} - }); + public static Stream testBeds() { + return Stream.of( + Arguments.of(Boolean.TRUE, MediaType.APPLICATION_JSON_TYPE, new AcceptableMediaType("application", "json")), + Arguments.of(Boolean.TRUE, MediaType.APPLICATION_JSON_TYPE, + new AcceptableMediaType("application", "json", 1000, null)), + Arguments.of(Boolean.FALSE, MediaType.APPLICATION_JSON_TYPE, + new AcceptableMediaType("application", "json", 500, null)), + Arguments.of(Boolean.FALSE, MediaType.APPLICATION_JSON_TYPE, new AcceptableMediaType("application", "xml")) + ); } - private final boolean expectEquality; - private final MediaType mediaType; - private final AcceptableMediaType acceptableMediaType; - - public AcceptableMediaTypeTest(boolean expectEquality, MediaType mediaType, AcceptableMediaType acceptableMediaType) { - this.expectEquality = expectEquality; - this.mediaType = mediaType; - this.acceptableMediaType = acceptableMediaType; - } - - @Test - public void testEquals() throws Exception { + @ParameterizedTest + @MethodSource("testBeds") + public void testEquals(boolean expectEquality, MediaType mediaType, + AcceptableMediaType acceptableMediaType) throws Exception { if (expectEquality) { - Assert.assertEquals("Types not equal.", mediaType, acceptableMediaType); - Assert.assertEquals("Types not equal.", acceptableMediaType, mediaType); - Assert.assertEquals( - String.format("Hash codes not equal for %s and %s.", mediaType.toString(), acceptableMediaType.toString()), - mediaType.hashCode(), acceptableMediaType.hashCode()); + Assertions.assertEquals(mediaType, acceptableMediaType, "Types not equal."); + Assertions.assertEquals(acceptableMediaType, mediaType, "Types not equal."); + Assertions.assertEquals(mediaType.hashCode(), acceptableMediaType.hashCode(), + String.format("Hash codes not equal for %s and %s.", mediaType.toString(), acceptableMediaType.toString())); } else { - Assert.assertFalse(String.format("False equality of %s and %s", mediaType.toString(), acceptableMediaType.toString()), - acceptableMediaType.equals(mediaType)); + Assertions.assertFalse(acceptableMediaType.equals(mediaType), + String.format("False equality of %s and %s", mediaType.toString(), acceptableMediaType.toString())); } } } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/CommittingOutputStreamTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/CommittingOutputStreamTest.java index 23f88b7516..fc49c618a6 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/CommittingOutputStreamTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/CommittingOutputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,11 +32,11 @@ import org.glassfish.jersey.model.internal.CommonConfig; import org.glassfish.jersey.model.internal.ComponentBag; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test the {@link CommittingOutputStream}. @@ -295,7 +295,7 @@ public OutputStream getOutputStream(int contentLength) throws IOException { if (i >= expectedSize + 1) { break; } else { - assertFalse("committed already with byte #" + i, passed.b); + assertFalse(passed.b, "committed already with byte #" + i); } } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/CookiesParserTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/CookiesParserTest.java index 77ce25b128..540d44b748 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/CookiesParserTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/CookiesParserTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -23,7 +23,7 @@ import org.glassfish.jersey.message.internal.CookiesParser; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/HeaderUtilsTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/HeaderUtilsTest.java index bc370e4c8f..3ac47823cd 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/HeaderUtilsTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/HeaderUtilsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,14 +32,14 @@ import org.glassfish.jersey.message.internal.HeaderUtils; import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * {@link HeaderUtils} unit tests. diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/InboundMessageContextTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/InboundMessageContextTest.java index bd29bb4852..9a3fdd71ce 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/InboundMessageContextTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/InboundMessageContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,11 +35,11 @@ import org.glassfish.jersey.message.internal.InboundMessageContext; import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * {@link org.glassfish.jersey.message.internal.InboundMessageContext} test. diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/JerseyLinkTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/JerseyLinkTest.java index 7e25df847a..7110355796 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/JerseyLinkTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/JerseyLinkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -26,11 +26,11 @@ import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests for LinkTest class. @@ -55,12 +55,12 @@ public String notSelf() { } } - @Before + @BeforeEach public void setUp() throws Exception { RuntimeDelegate.setInstance(new TestRuntimeDelegate()); } - @After + @AfterEach public void tearDown() throws Exception { RuntimeDelegate.setInstance(null); } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/LinkProviderTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/LinkProviderTest.java index 0f8f3c7edc..7691af79e5 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/LinkProviderTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/LinkProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -21,10 +21,10 @@ import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for LinkProvider class. @@ -33,12 +33,12 @@ */ public class LinkProviderTest { - @Before + @BeforeEach public void setUp() throws Exception { RuntimeDelegate.setInstance(new TestRuntimeDelegate()); } - @After + @AfterEach public void tearDown() throws Exception { RuntimeDelegate.setInstance(null); } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/MatchingEntityTagTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/MatchingEntityTagTest.java index 19ad5e1ed4..36dcc2326c 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/MatchingEntityTagTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/MatchingEntityTagTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -24,14 +24,14 @@ import org.glassfish.jersey.message.internal.HttpHeaderReader; import org.glassfish.jersey.message.internal.MatchingEntityTag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * {@link MatchingEntityTag} unit tests ported from Jersey 1.x. diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/MediaTypesTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/MediaTypesTest.java index 12dcd81210..c9531a148d 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/MediaTypesTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/MediaTypesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,10 +27,10 @@ import org.glassfish.jersey.message.internal.HttpHeaderReader; import org.glassfish.jersey.message.internal.MediaTypes; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * MediaTypes utility method tests. @@ -43,16 +43,16 @@ public class MediaTypesTest { @Test public void testConvertToString() { final List emptyList = Collections.emptyList(); - Assert.assertEquals("", MediaTypes.convertToString(emptyList)); + Assertions.assertEquals("", MediaTypes.convertToString(emptyList)); - Assert.assertEquals("\"text/plain\"", MediaTypes.convertToString(Collections.singleton(MediaType.TEXT_PLAIN_TYPE))); + Assertions.assertEquals("\"text/plain\"", MediaTypes.convertToString(Collections.singleton(MediaType.TEXT_PLAIN_TYPE))); - Assert.assertEquals("\"text/plain\", \"application/json\"", + Assertions.assertEquals("\"text/plain\", \"application/json\"", MediaTypes.convertToString(Arrays.asList(MediaType.TEXT_PLAIN_TYPE, MediaType.APPLICATION_JSON_TYPE))); - Assert.assertEquals("\"text/plain\", \"application/json\", \"text/html\"", + Assertions.assertEquals("\"text/plain\", \"application/json\", \"text/html\"", MediaTypes.convertToString(Arrays.asList(MediaType.TEXT_PLAIN_TYPE, MediaType.APPLICATION_JSON_TYPE, MediaType.TEXT_HTML_TYPE))); diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundJaxrsResponseBuilderTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundJaxrsResponseBuilderTest.java index f0257cdc32..2a026dfae1 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundJaxrsResponseBuilderTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundJaxrsResponseBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.message.internal.OutboundMessageContext; import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * JaxrsResponseViewTest class. diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundJaxrsResponseTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundJaxrsResponseTest.java index 3267ad2dc3..d3c8621b41 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundJaxrsResponseTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundJaxrsResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,11 +29,11 @@ import org.glassfish.jersey.message.internal.OutboundMessageContext; import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * OutboundJaxrsResponse unit tests. @@ -96,7 +96,7 @@ public OutboundJaxrsResponseTest() { RuntimeDelegate.setInstance(new TestRuntimeDelegate()); } - @Before + @BeforeEach public void setUp() { rb = new OutboundJaxrsResponse.Builder(new OutboundMessageContext((Configuration) null)).status(Response.Status.OK); } @@ -110,7 +110,7 @@ public void testBufferEmptyEntity() { final OutboundJaxrsResponse r = OutboundJaxrsResponse.from(rb.build(), null); r.getContext().setStreamProvider(TEST_PROVIDER); - assertFalse("Buffer entity should return 'false' if no entity.", r.bufferEntity()); + assertFalse(r.bufferEntity(), "Buffer entity should return 'false' if no entity."); } /** @@ -121,7 +121,7 @@ public void testBufferNonStreamEntity() { final OutboundJaxrsResponse r = OutboundJaxrsResponse.from(rb.entity(new Object()).build(), null); r.getContext().setStreamProvider(TEST_PROVIDER); - assertFalse("Buffer entity should return 'false' for non-stream entity.", r.bufferEntity()); + assertFalse(r.bufferEntity(), "Buffer entity should return 'false' for non-stream entity."); } /** @@ -133,10 +133,10 @@ public void testBufferStreamEntity() { final OutboundJaxrsResponse r = OutboundJaxrsResponse.from(rb.entity(tis).build(), null); r.getContext().setStreamProvider(TEST_PROVIDER); - assertTrue("Buffer entity should return 'true' for stream entity.", r.bufferEntity()); - assertTrue("Second call to buffer entity should return 'true' for stream entity.", r.bufferEntity()); // second call - assertTrue("Buffered stream has not been fully read.", tis.isRead); - assertTrue("Buffered stream has not been closed after buffering.", tis.isClosed); + assertTrue(r.bufferEntity(), "Buffer entity should return 'true' for stream entity."); + assertTrue(r.bufferEntity(), "Second call to buffer entity should return 'true' for stream entity."); // second call + assertTrue(tis.isRead, "Buffered stream has not been fully read."); + assertTrue(tis.isClosed, "Buffered stream has not been closed after buffering."); } /** @@ -193,8 +193,8 @@ public void testCloseStreamEntity() { } r.close(); // second call should pass - assertFalse("Unbuffered closed response stream entity should not be read.", tis.isRead); - assertTrue("Closed response stream entity should have been closed.", tis.isClosed); + assertFalse(tis.isRead, "Unbuffered closed response stream entity should not be read."); + assertTrue(tis.isClosed, "Closed response stream entity should have been closed."); } /** @@ -245,8 +245,8 @@ public void testCloseStreamEntityNoStreamProvider() { } r.close(); // second call should pass - assertFalse("Unbuffered closed response stream entity should not be read.", tis.isRead); - assertTrue("Closed response stream entity should have been closed.", tis.isClosed); + assertFalse(tis.isRead, "Unbuffered closed response stream entity should not be read."); + assertTrue(tis.isClosed, "Closed response stream entity should have been closed."); } } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundMessageContextTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundMessageContextTest.java index 28775941b2..537078079e 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundMessageContextTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/OutboundMessageContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -36,15 +36,15 @@ import org.glassfish.jersey.message.internal.OutboundMessageContext; import org.glassfish.jersey.tests.e2e.common.TestRuntimeDelegate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * {@link OutboundMessageContext} test. diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/QualitySourceMediaTypeTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/QualitySourceMediaTypeTest.java index 1841774431..8e20a44d6f 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/QualitySourceMediaTypeTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/message/internal/QualitySourceMediaTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,57 +16,46 @@ package org.glassfish.jersey.tests.e2e.common.message.internal; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.core.MediaType; import org.glassfish.jersey.message.internal.QualitySourceMediaType; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; /** * Quality source media type unit tests. * * @author Marek Potociar */ -@RunWith(Parameterized.class) public class QualitySourceMediaTypeTest { - @Parameterized.Parameters // expected result, media type, quality source media type - public static List testBeds() { - return Arrays.asList(new Object[][]{ - {Boolean.TRUE, MediaType.APPLICATION_JSON_TYPE, new QualitySourceMediaType("application", "json")}, - {Boolean.TRUE, MediaType.APPLICATION_JSON_TYPE, new QualitySourceMediaType("application", "json", 1000, null)}, - {Boolean.FALSE, MediaType.APPLICATION_JSON_TYPE, new QualitySourceMediaType("application", "json", 500, null)}, - {Boolean.FALSE, MediaType.APPLICATION_JSON_TYPE, new QualitySourceMediaType("application", "xml")} - }); + public static Stream testBeds() { + return Stream.of( + Arguments.of(Boolean.TRUE, MediaType.APPLICATION_JSON_TYPE, new QualitySourceMediaType("application", "json")), + Arguments.of(Boolean.TRUE, MediaType.APPLICATION_JSON_TYPE, + new QualitySourceMediaType("application", "json", 1000, null)), + Arguments.of(Boolean.FALSE, MediaType.APPLICATION_JSON_TYPE, + new QualitySourceMediaType("application", "json", 500, null)), + Arguments.of(Boolean.FALSE, MediaType.APPLICATION_JSON_TYPE, new QualitySourceMediaType("application", "xml")) + ); } - private final boolean expectEquality; - private final MediaType mediaType; - private final QualitySourceMediaType qsMediaType; - - public QualitySourceMediaTypeTest(boolean expectEquality, MediaType mediaType, QualitySourceMediaType qsMediaType) { - this.expectEquality = expectEquality; - this.mediaType = mediaType; - this.qsMediaType = qsMediaType; - } - - @Test - public void testEquals() throws Exception { + @ParameterizedTest + @MethodSource("testBeds") + public void testEquals(boolean expectEquality, MediaType mediaType, QualitySourceMediaType qsMediaType) throws Exception { if (expectEquality) { - Assert.assertEquals("Types not equal.", mediaType, qsMediaType); - Assert.assertEquals("Types not equal.", qsMediaType, mediaType); - Assert.assertEquals( - String.format("Hash codes not equal for %s and %s.", mediaType.toString(), qsMediaType.toString()), - mediaType.hashCode(), qsMediaType.hashCode()); + Assertions.assertEquals(mediaType, qsMediaType, "Types not equal."); + Assertions.assertEquals(qsMediaType, mediaType, "Types not equal."); + Assertions.assertEquals(mediaType.hashCode(), qsMediaType.hashCode(), + String.format("Hash codes not equal for %s and %s.", mediaType.toString(), qsMediaType.toString())); } else { - Assert.assertFalse(String.format("False equality of %s and %s", mediaType.toString(), qsMediaType.toString()), - qsMediaType.equals(mediaType)); + Assertions.assertFalse(qsMediaType.equals(mediaType), + String.format("False equality of %s and %s", mediaType.toString(), qsMediaType.toString())); } } } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/model/internal/CommonConfigTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/model/internal/CommonConfigTest.java index e9319121f0..fb1a982aba 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/model/internal/CommonConfigTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/model/internal/CommonConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -52,21 +52,21 @@ import org.glassfish.jersey.model.internal.ManagedObjectsFinalizer; import org.glassfish.jersey.model.internal.RankedComparator; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test cases for {@link javax.ws.rs.core.Configuration}. @@ -77,7 +77,7 @@ public class CommonConfigTest { private CommonConfig config; - @Before + @BeforeEach public void setUp() throws Exception { config = new CommonConfig(null, ComponentBag.INCLUDE_ALL); } @@ -442,9 +442,9 @@ public void testRegisterClassContracts() throws Exception { final ContractProvider contractProvider = config.getComponentBag().getModel(ComplexEmptyProvider.class); final Set> contracts = contractProvider.getContracts(); assertEquals(2, contracts.size()); - assertTrue(ReaderInterceptor.class + " is not registered.", contracts.contains(ReaderInterceptor.class)); - assertTrue(ContainerRequestFilter.class + " is not registered.", contracts.contains(ContainerRequestFilter.class)); - assertFalse(WriterInterceptor.class + " should not be registered.", contracts.contains(WriterInterceptor.class)); + assertTrue(contracts.contains(ReaderInterceptor.class), ReaderInterceptor.class + " is not registered."); + assertTrue(contracts.contains(ContainerRequestFilter.class), ContainerRequestFilter.class + " is not registered."); + assertFalse(contracts.contains(WriterInterceptor.class), WriterInterceptor.class + " should not be registered."); assertTrue(config.getInstances().isEmpty()); assertTrue(config.getClasses().contains(ComplexEmptyProvider.class)); @@ -466,9 +466,9 @@ public void testRegisterInstancesContracts() throws Exception { final ContractProvider contractProvider = config.getComponentBag().getModel(ComplexEmptyProvider.class); final Set> contracts = contractProvider.getContracts(); assertEquals(2, contracts.size()); - assertTrue(ReaderInterceptor.class + " is not registered.", contracts.contains(ReaderInterceptor.class)); - assertTrue(ContainerRequestFilter.class + " is not registered.", contracts.contains(ContainerRequestFilter.class)); - assertFalse(WriterInterceptor.class + " should not be registered.", contracts.contains(WriterInterceptor.class)); + assertTrue(contracts.contains(ReaderInterceptor.class), ReaderInterceptor.class + " is not registered."); + assertTrue(contracts.contains(ContainerRequestFilter.class), ContainerRequestFilter.class + " is not registered."); + assertFalse(contracts.contains(WriterInterceptor.class), WriterInterceptor.class + " should not be registered."); assertTrue(config.getInstances().contains(complexEmptyProvider)); assertTrue(config.getClasses().isEmpty()); @@ -689,7 +689,7 @@ private void _testCollectionsCommon(final String testName, final Collection< throws Exception { // Not null. - assertNotNull(testName + " - returned collection is null.", collection); + assertNotNull(collection, testName + " - returned collection is null."); // Immutability. try { @@ -965,7 +965,7 @@ protected void configure() { @Test public void testFeatureInjections() throws Exception { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); config.register(InjectIntoFeatureClass.class) .register(new InjectIntoFeatureInstance()) @@ -985,7 +985,7 @@ protected void configure() { } @Test - @Ignore + @Disabled public void testFeatureInjectionsBindInFeature() throws Exception { config.register(new BindInjectMeInFeature()); config.register(InjectIntoFeatureClass.class); @@ -1078,9 +1078,9 @@ public void testBinderOrderingInGetClasses() { config.configureMetaProviders(injectionManager, finalizer); Object[] classes = config.getComponentBag().getClasses(contractProvider -> true).toArray(); - Assert.assertEquals(classes[0], ContractBinderOne.class); - Assert.assertEquals(classes[1], ContractBinderTwo.class); - Assert.assertEquals(classes[2], ContractBinder.class); + Assertions.assertEquals(classes[0], ContractBinderOne.class); + Assertions.assertEquals(classes[1], ContractBinderTwo.class); + Assertions.assertEquals(classes[2], ContractBinder.class); } @Test @@ -1093,9 +1093,9 @@ public void testBinderOrderingInGetInstances() { config.configureMetaProviders(injectionManager, finalizer); Object[] instances = config.getComponentBag().getInstances(contractProvider -> true).toArray(); - Assert.assertEquals(instances[0], binders[2]); - Assert.assertEquals(instances[1], binders[1]); - Assert.assertEquals(instances[2], binders[0]); + Assertions.assertEquals(instances[0], binders[2]); + Assertions.assertEquals(instances[1], binders[1]); + Assertions.assertEquals(instances[2], binders[0]); } public static class ContractBinderOne extends ContractBinder { diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/process/internal/ExecutorProvidersTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/process/internal/ExecutorProvidersTest.java index ccbc53d8e3..f5b0b0a077 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/process/internal/ExecutorProvidersTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/process/internal/ExecutorProvidersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -40,10 +40,10 @@ import org.glassfish.jersey.spi.ThreadPoolExecutorProvider; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * ExecutorProviders unit tests. @@ -205,7 +205,7 @@ protected void configure() { /** * Set-up the tests. */ - @Before + @BeforeEach public void setup() { injectionManager = Injections.createInjectionManager(this); ExecutorProviders.registerExecutorBindings(injectionManager); @@ -262,8 +262,8 @@ public void testExecutorInjectionAndReleasing() throws Exception { } private void testShutDown(String name, ExecutorService executorService) throws InterruptedException { - assertTrue(name + " not shutdown", executorService.isShutdown()); - assertTrue(name + " not terminated", executorService.isTerminated()); + assertTrue(executorService.isShutdown(), name + " not shutdown"); + assertTrue(executorService.isTerminated(), name + " not terminated"); } } diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/process/internal/RequestScopeTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/process/internal/RequestScopeTest.java index 36a23e9124..758289401b 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/process/internal/RequestScopeTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/process/internal/RequestScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,10 +25,10 @@ import org.glassfish.hk2.api.ServiceHandle; import org.glassfish.hk2.utilities.AbstractActiveDescriptor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test of the {@link RequestScope request scope}. diff --git a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/uri/internal/JerseyUriBuilderTest.java b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/uri/internal/JerseyUriBuilderTest.java index 06799b8d4b..d9a391b6b9 100644 --- a/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/uri/internal/JerseyUriBuilderTest.java +++ b/tests/e2e-core-common/src/test/java/org/glassfish/jersey/tests/e2e/common/uri/internal/JerseyUriBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -37,11 +37,11 @@ import org.glassfish.jersey.uri.UriComponent; import org.glassfish.jersey.uri.internal.JerseyUriBuilder; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * Uri builder implementation test. @@ -314,7 +314,7 @@ public void testUriBuilderTemplatesSimple() { } @Test - @Ignore + @Disabled public void failingTests() { testUri("a://#fragment"); // fails in JerseyUriBuilder testUri("a://?query"); @@ -413,107 +413,107 @@ private void testUri(final String input) { assertEquals(input, uri.toString()); } - @org.junit.Test + @Test public void testOpaqueUri() { final URI uri = UriBuilder.fromUri("mailto:a@b").build(); - Assert.assertEquals("mailto:a@b", uri.toString()); + Assertions.assertEquals("mailto:a@b", uri.toString()); } @Test public void testOpaqueUriReplaceSchemeSpecificPart() { final URI uri = UriBuilder.fromUri("mailto:a@b").schemeSpecificPart("c@d").build(); - Assert.assertEquals("mailto:c@d", uri.toString()); + Assertions.assertEquals("mailto:c@d", uri.toString()); } @Test public void testOpaqueReplaceUri() { final URI uri = UriBuilder.fromUri("mailto:a@b").uri(URI.create("c@d")).build(); - Assert.assertEquals("mailto:c@d", uri.toString()); + Assertions.assertEquals("mailto:c@d", uri.toString()); } @Test public void testReplaceScheme() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").scheme("https").build(); - Assert.assertEquals("https://localhost:8080/a/b/c", uri.toString()); + Assertions.assertEquals("https://localhost:8080/a/b/c", uri.toString()); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").scheme(null).build(); - Assert.assertEquals("//localhost:8080/a/b/c", uri.toString()); + Assertions.assertEquals("//localhost:8080/a/b/c", uri.toString()); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").scheme(null).host(null).build(); - Assert.assertEquals("//:8080/a/b/c", uri.toString()); + Assertions.assertEquals("//:8080/a/b/c", uri.toString()); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").scheme(null).host(null).port(-1).build(); - Assert.assertEquals("/a/b/c", uri.toString()); + Assertions.assertEquals("/a/b/c", uri.toString()); } @Test public void testReplaceSchemeSpecificPart() { final URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").schemeSpecificPart("//localhost:8080/a/b/c/d").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/d"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/d"), uri); } @Test public void testNameAuthorityUri() { final URI uri = UriBuilder.fromUri("http://x_y/a/b/c").build(); - Assert.assertEquals(URI.create("http://x_y/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://x_y/a/b/c"), uri); } @Test public void testReplaceNameAuthorityUriWithHost() { final URI uri = UriBuilder.fromUri("http://x_y.com/a/b/c").host("xy.com").build(); - Assert.assertEquals(URI.create("http://xy.com/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://xy.com/a/b/c"), uri); } @Test public void testReplaceNameAuthorityUriWithSSP() { URI uri = UriBuilder.fromUri("http://x_y.com/a/b/c").schemeSpecificPart("//xy.com/a/b/c").build(); - Assert.assertEquals(URI.create("http://xy.com/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://xy.com/a/b/c"), uri); uri = UriBuilder.fromUri("http://x_y.com/a/b/c").schemeSpecificPart("//v_w.com/a/b/c").build(); - Assert.assertEquals(URI.create("http://v_w.com/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://v_w.com/a/b/c"), uri); } @Test public void testReplaceUserInfo() { final URI uri = UriBuilder.fromUri("http://bob@localhost:8080/a/b/c").userInfo("sue").build(); - Assert.assertEquals(URI.create("http://sue@localhost:8080/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://sue@localhost:8080/a/b/c"), uri); } @Test public void testReplaceHost() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").host("a.com").build(); - Assert.assertEquals(URI.create("http://a.com:8080/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://a.com:8080/a/b/c"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").host("[::FFFF:129.144.52.38]").build(); - Assert.assertEquals(URI.create("http://[::FFFF:129.144.52.38]:8080/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://[::FFFF:129.144.52.38]:8080/a/b/c"), uri); } @Test public void testReplacePort() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").port(9090).build(); - Assert.assertEquals(URI.create("http://localhost:9090/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://localhost:9090/a/b/c"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").port(-1).build(); - Assert.assertEquals(URI.create("http://localhost/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://localhost/a/b/c"), uri); } @Test public void testReplacePath() { final URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").replacePath("/x/y/z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/x/y/z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/x/y/z"), uri); } @Test public void testReplacePathNull() { final URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").replacePath(null).build(); - Assert.assertEquals(URI.create("http://localhost:8080"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080"), uri); } @Test public void testReplaceMatrix() { final URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c;a=x;b=y").replaceMatrix("x=a;y=b").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c;x=a;y=b"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c;x=a;y=b"), uri); } @Test @@ -525,12 +525,12 @@ public void testReplaceMatrixParams() { final List ps = UriComponent.decodePath(uri, true); final MultivaluedMap mps = ps.get(2).getMatrixParameters(); final List a = mps.get("a"); - Assert.assertEquals(2, a.size()); - Assert.assertEquals("z", a.get(0)); - Assert.assertEquals("zz", a.get(1)); + Assertions.assertEquals(2, a.size()); + Assertions.assertEquals("z", a.get(0)); + Assertions.assertEquals("zz", a.get(1)); final List b = mps.get("b"); - Assert.assertEquals(1, b.size()); - Assert.assertEquals("y", b.get(0)); + Assertions.assertEquals(1, b.size()); + Assertions.assertEquals("y", b.get(0)); } { @@ -538,12 +538,12 @@ public void testReplaceMatrixParams() { final List ps = UriComponent.decodePath(uri, true); final MultivaluedMap mps = ps.get(2).getMatrixParameters(); final List a = mps.get("a"); - Assert.assertEquals(2, a.size()); - Assert.assertEquals("_z_", a.get(0)); - Assert.assertEquals("_zz_", a.get(1)); + Assertions.assertEquals(2, a.size()); + Assertions.assertEquals("_z_", a.get(0)); + Assertions.assertEquals("_zz_", a.get(1)); final List b = mps.get("b"); - Assert.assertEquals(1, b.size()); - Assert.assertEquals("y", b.get(0)); + Assertions.assertEquals(1, b.size()); + Assertions.assertEquals("y", b.get(0)); } { @@ -554,15 +554,15 @@ public void testReplaceMatrixParams() { final List ps = UriComponent.decodePath(uri, true); final MultivaluedMap mps = ps.get(2).getMatrixParameters(); final List a = mps.get("a"); - Assert.assertEquals(2, a.size()); - Assert.assertEquals("z", a.get(0)); - Assert.assertEquals("zz", a.get(1)); + Assertions.assertEquals(2, a.size()); + Assertions.assertEquals("z", a.get(0)); + Assertions.assertEquals("zz", a.get(1)); final List b = mps.get("b"); - Assert.assertEquals(1, b.size()); - Assert.assertEquals("y", b.get(0)); + Assertions.assertEquals(1, b.size()); + Assertions.assertEquals("y", b.get(0)); final List c = mps.get("c"); - Assert.assertEquals(1, c.size()); - Assert.assertEquals("c", c.get(0)); + Assertions.assertEquals(1, c.size()); + Assertions.assertEquals("c", c.get(0)); } { @@ -573,24 +573,24 @@ public void testReplaceMatrixParams() { MultivaluedMap mps = ps.get(0).getMatrixParameters(); List w = mps.get("w"); - Assert.assertEquals(1, w.size()); - Assert.assertEquals("123", w.get(0)); + Assertions.assertEquals(1, w.size()); + Assertions.assertEquals("123", w.get(0)); w = mps.get("q"); - Assert.assertEquals(1, w.size()); - Assert.assertEquals("15", w.get(0)); + Assertions.assertEquals(1, w.size()); + Assertions.assertEquals("15", w.get(0)); mps = ps.get(2).getMatrixParameters(); final List a = mps.get("a"); - Assert.assertEquals(2, a.size()); - Assert.assertEquals("z", a.get(0)); - Assert.assertEquals("zz", a.get(1)); + Assertions.assertEquals(2, a.size()); + Assertions.assertEquals("z", a.get(0)); + Assertions.assertEquals("zz", a.get(1)); final List b = mps.get("b"); - Assert.assertEquals(1, b.size()); - Assert.assertEquals("y", b.get(0)); + Assertions.assertEquals(1, b.size()); + Assertions.assertEquals("y", b.get(0)); final List c = mps.get("c"); - Assert.assertEquals(1, c.size()); - Assert.assertEquals("c", c.get(0)); + Assertions.assertEquals(1, c.size()); + Assertions.assertEquals("c", c.get(0)); } } @@ -602,9 +602,9 @@ public void testReplaceMatrixParamsEmpty() { final List ps = UriComponent.decodePath(uri, true); final MultivaluedMap mps = ps.get(2).getMatrixParameters(); final List a = mps.get("a"); - Assert.assertEquals(2, a.size()); - Assert.assertEquals("z", a.get(0)); - Assert.assertEquals("zz", a.get(1)); + Assertions.assertEquals(2, a.size()); + Assertions.assertEquals("z", a.get(0)); + Assertions.assertEquals("zz", a.get(1)); } } @@ -614,7 +614,7 @@ public void testReplaceMatrixParamsEncoded() throws URISyntaxException { ubu.replaceMatrixParam("limit", 100); final URI uri = ubu.build(); - Assert.assertEquals(URI.create("http://localhost/;limit=100;sql=select+*+from+users"), uri); + Assertions.assertEquals(URI.create("http://localhost/;limit=100;sql=select+*+from+users"), uri); } @Test @@ -623,7 +623,7 @@ public void testMatrixParamsWithTheSameName() { first = first.path("/child"); first = first.replaceMatrixParam("example", "another"); - Assert.assertEquals("http://www.com/;example=one;example=two/child;example=another", first.build().toString()); + Assertions.assertEquals("http://www.com/;example=one;example=two/child;example=another", first.build().toString()); } @Test @@ -632,23 +632,23 @@ public void testMatrixParamsWithTheDifferentName() { first = first.path("/child"); first = first.replaceMatrixParam("other", "another"); - Assert.assertEquals("http://www.com/;example=one;example=two/child;other=another", first.build().toString()); + Assertions.assertEquals("http://www.com/;example=one;example=two/child;other=another", first.build().toString()); } @Test public void testReplaceQuery() { final URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c?a=x&b=y").replaceQuery("x=a&y=b").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?x=a&y=b"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?x=a&y=b"), uri); } @Test public void testBuildEncodedQuery() { URI u = UriBuilder.fromPath("").queryParam("y", "1 %2B 2").build(); - Assert.assertEquals(URI.create("?y=1+%2B+2"), u); + Assertions.assertEquals(URI.create("?y=1+%2B+2"), u); // Issue 216 u = UriBuilder.fromPath("http://localhost:8080").path("/{x}/{y}/{z}/{x}").buildFromEncoded("%xy", " ", "="); - Assert.assertEquals(URI.create("http://localhost:8080/%25xy/%20/=/%25xy"), u); + Assertions.assertEquals(URI.create("http://localhost:8080/%25xy/%20/=/%25xy"), u); } @Test @@ -661,15 +661,15 @@ public void testReplaceQueryParams() { final MultivaluedMap qps = UriComponent.decodeQuery(uri, true); final List a = qps.get("a"); - Assert.assertEquals(2, a.size()); - Assert.assertEquals("z", a.get(0)); - Assert.assertEquals("zz", a.get(1)); + Assertions.assertEquals(2, a.size()); + Assertions.assertEquals("z", a.get(0)); + Assertions.assertEquals("zz", a.get(1)); final List b = qps.get("b"); - Assert.assertEquals(1, b.size()); - Assert.assertEquals("y", b.get(0)); + Assertions.assertEquals(1, b.size()); + Assertions.assertEquals("y", b.get(0)); final List c = qps.get("c"); - Assert.assertEquals(1, c.size()); - Assert.assertEquals("c", c.get(0)); + Assertions.assertEquals(1, c.size()); + Assertions.assertEquals("c", c.get(0)); } { @@ -677,15 +677,15 @@ public void testReplaceQueryParams() { final MultivaluedMap qps = UriComponent.decodeQuery(uri, true); final List a = qps.get("a"); - Assert.assertEquals(2, a.size()); - Assert.assertEquals("_z_", a.get(0)); - Assert.assertEquals("_zz_", a.get(1)); + Assertions.assertEquals(2, a.size()); + Assertions.assertEquals("_z_", a.get(0)); + Assertions.assertEquals("_zz_", a.get(1)); final List b = qps.get("b"); - Assert.assertEquals(1, b.size()); - Assert.assertEquals("y", b.get(0)); + Assertions.assertEquals(1, b.size()); + Assertions.assertEquals("y", b.get(0)); final List c = qps.get("c"); - Assert.assertEquals(1, c.size()); - Assert.assertEquals("c", c.get(0)); + Assertions.assertEquals(1, c.size()); + Assertions.assertEquals("c", c.get(0)); } // issue 257 - param is removed after setting it to null @@ -693,10 +693,10 @@ public void testReplaceQueryParams() { final URI u1 = UriBuilder.fromPath("http://localhost:8080").queryParam("x", "10") .replaceQueryParam("x", (Object[]) null) .build(); - Assert.assertTrue(u1.toString().equals("http://localhost:8080")); + Assertions.assertTrue(u1.toString().equals("http://localhost:8080")); final URI u2 = UriBuilder.fromPath("http://localhost:8080").queryParam("x", "10").replaceQueryParam("x").build(); - Assert.assertTrue(u2.toString().equals("http://localhost:8080")); + Assertions.assertTrue(u2.toString().equals("http://localhost:8080")); } // issue 257 - IllegalArgumentException @@ -709,7 +709,7 @@ public void testReplaceQueryParams() { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); } } @@ -724,12 +724,12 @@ public void testReplaceQueryParamsEmpty() { final MultivaluedMap qps = UriComponent.decodeQuery(uri, true); final List a = qps.get("a"); - Assert.assertEquals(2, a.size()); - Assert.assertEquals("z", a.get(0)); - Assert.assertEquals("zz", a.get(1)); + Assertions.assertEquals(2, a.size()); + Assertions.assertEquals("z", a.get(0)); + Assertions.assertEquals("zz", a.get(1)); final List c = qps.get("c"); - Assert.assertEquals(1, c.size()); - Assert.assertEquals("c", c.get(0)); + Assertions.assertEquals(1, c.size()); + Assertions.assertEquals("c", c.get(0)); } } @@ -739,7 +739,7 @@ public void testReplaceQueryParamsEncoded1() throws URISyntaxException { ubu.replaceQueryParam("limit", 100); final URI uri = ubu.build(); - Assert.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri); + Assertions.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri); } @Test @@ -748,7 +748,7 @@ public void testReplaceQueryParamsEncoded2() throws URISyntaxException { ubu.replaceQueryParam("limit", 100); final URI uri = ubu.build(); - Assert.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri); + Assertions.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri); } @Test @@ -757,7 +757,7 @@ public void testReplaceQueryParamsEncoded3() throws URISyntaxException { ubu.replaceQueryParam("limit", 100); final URI uri = ubu.build(); - Assert.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri); + Assertions.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri); } @Test @@ -766,13 +766,13 @@ public void testReplaceQueryParamsEncoded4() throws URISyntaxException { ubu.replaceQueryParam("limit", 100); final URI uri = ubu.build(); - Assert.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri); + Assertions.assertEquals(URI.create("http://localhost/?limit=100&sql=select+%2A+from+users"), uri); } @Test public void testReplaceFragment() { final URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c?a=x&b=y#frag").fragment("ment").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=x&b=y#ment"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=x&b=y#ment"), uri); } @Test @@ -780,22 +780,22 @@ public void testReplaceUri() { final URI u = URI.create("http://bob@localhost:8080/a/b/c?a=x&b=y#frag"); URI uri = UriBuilder.fromUri(u).uri(URI.create("https://bob@localhost:8080")).build(); - Assert.assertEquals(URI.create("https://bob@localhost:8080/a/b/c?a=x&b=y#frag"), uri); + Assertions.assertEquals(URI.create("https://bob@localhost:8080/a/b/c?a=x&b=y#frag"), uri); uri = UriBuilder.fromUri(u).uri(URI.create("https://sue@localhost:8080")).build(); - Assert.assertEquals(URI.create("https://sue@localhost:8080/a/b/c?a=x&b=y#frag"), uri); + Assertions.assertEquals(URI.create("https://sue@localhost:8080/a/b/c?a=x&b=y#frag"), uri); uri = UriBuilder.fromUri(u).uri(URI.create("https://sue@localhost:9090")).build(); - Assert.assertEquals(URI.create("https://sue@localhost:9090/a/b/c?a=x&b=y#frag"), uri); + Assertions.assertEquals(URI.create("https://sue@localhost:9090/a/b/c?a=x&b=y#frag"), uri); uri = UriBuilder.fromUri(u).uri(URI.create("/x/y/z")).build(); - Assert.assertEquals(URI.create("http://bob@localhost:8080/x/y/z?a=x&b=y#frag"), uri); + Assertions.assertEquals(URI.create("http://bob@localhost:8080/x/y/z?a=x&b=y#frag"), uri); uri = UriBuilder.fromUri(u).uri(URI.create("?x=a&b=y")).build(); - Assert.assertEquals(URI.create("http://bob@localhost:8080/a/b/c?x=a&b=y#frag"), uri); + Assertions.assertEquals(URI.create("http://bob@localhost:8080/a/b/c?x=a&b=y#frag"), uri); uri = UriBuilder.fromUri(u).uri(URI.create("#ment")).build(); - Assert.assertEquals(URI.create("http://bob@localhost:8080/a/b/c?a=x&b=y#ment"), uri); + Assertions.assertEquals(URI.create("http://bob@localhost:8080/a/b/c?a=x&b=y#ment"), uri); } @Test @@ -803,46 +803,46 @@ public void testSchemeSpecificPart() { final URI u = URI.create("http://bob@localhost:8080/a/b/c?a=x&b=y#frag"); final URI uri = UriBuilder.fromUri(u).schemeSpecificPart("//sue@remotehost:9090/x/y/z?x=a&y=b").build(); - Assert.assertEquals(URI.create("http://sue@remotehost:9090/x/y/z?x=a&y=b#frag"), uri); + Assertions.assertEquals(URI.create("http://sue@remotehost:9090/x/y/z?x=a&y=b#frag"), uri); } @Test public void testAppendPath() { URI uri = UriBuilder.fromUri("http://localhost:8080").path("a/b/c").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c"), uri); uri = UriBuilder.fromUri("http://localhost:8080/").path("a/b/c").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c"), uri); uri = UriBuilder.fromUri("http://localhost:8080").path("/a/b/c").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c/").path("/").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c/").path("/x/y/z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("/x/y/z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("x/y/z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("/").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a%20/b%20/c%20").path("/x /y /z ").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a%20/b%20/c%20/x%20/y%20/z%20"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a%20/b%20/c%20/x%20/y%20/z%20"), uri); } @Test public void testAppendSegment() { final URI uri = UriBuilder.fromUri("http://localhost:8080").segment("a/b/c;x").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a%2Fb%2Fc%3Bx"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a%2Fb%2Fc%3Bx"), uri); } @Test @@ -889,65 +889,65 @@ public void testWhitespacesInQueryParamsByResolve() { @Test public void testRelativeFromUri() { URI uri = UriBuilder.fromUri("a/b/c").build(); - Assert.assertEquals(URI.create("a/b/c"), uri); + Assertions.assertEquals(URI.create("a/b/c"), uri); uri = UriBuilder.fromUri("a/b/c").path("d").build(); - Assert.assertEquals(URI.create("a/b/c/d"), uri); + Assertions.assertEquals(URI.create("a/b/c/d"), uri); uri = UriBuilder.fromUri("a/b/c/").path("d").build(); - Assert.assertEquals(URI.create("a/b/c/d"), uri); + Assertions.assertEquals(URI.create("a/b/c/d"), uri); uri = UriBuilder.fromUri("a/b/c").path("/d").build(); - Assert.assertEquals(URI.create("a/b/c/d"), uri); + Assertions.assertEquals(URI.create("a/b/c/d"), uri); uri = UriBuilder.fromUri("a/b/c/").path("/d").build(); - Assert.assertEquals(URI.create("a/b/c/d"), uri); + Assertions.assertEquals(URI.create("a/b/c/d"), uri); uri = UriBuilder.fromUri("").queryParam("x", "y").build(); - Assert.assertEquals(URI.create("?x=y"), uri); + Assertions.assertEquals(URI.create("?x=y"), uri); } @Test public void testRelativefromPath() { URI uri = UriBuilder.fromPath("a/b/c").build(); - Assert.assertEquals(URI.create("a/b/c"), uri); + Assertions.assertEquals(URI.create("a/b/c"), uri); uri = UriBuilder.fromPath("a/b/c").path("d").build(); - Assert.assertEquals(URI.create("a/b/c/d"), uri); + Assertions.assertEquals(URI.create("a/b/c/d"), uri); uri = UriBuilder.fromPath("a/b/c/").path("d").build(); - Assert.assertEquals(URI.create("a/b/c/d"), uri); + Assertions.assertEquals(URI.create("a/b/c/d"), uri); uri = UriBuilder.fromPath("a/b/c").path("/d").build(); - Assert.assertEquals(URI.create("a/b/c/d"), uri); + Assertions.assertEquals(URI.create("a/b/c/d"), uri); uri = UriBuilder.fromPath("a/b/c/").path("/d").build(); - Assert.assertEquals(URI.create("a/b/c/d"), uri); + Assertions.assertEquals(URI.create("a/b/c/d"), uri); uri = UriBuilder.fromPath("").queryParam("x", "y").build(); - Assert.assertEquals(URI.create("?x=y"), uri); + Assertions.assertEquals(URI.create("?x=y"), uri); } @Test public void testAppendQueryParams() throws URISyntaxException { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c?a=x&b=y").queryParam("c", "z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=x&b=y&c=z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=x&b=y&c=z"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c?a=x&b=y").queryParam("c= ", "z= ").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=x&b=y&c%3D+=z%3D+"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=x&b=y&c%3D+=z%3D+"), uri); uri = UriBuilder.fromUri(new URI("http://localhost:8080/")).queryParam("c", "z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/?c=z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/?c=z"), uri); uri = UriBuilder.fromUri(new URI("http://localhost:8080")).queryParam("c", "z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/?c=z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/?c=z"), uri); uri = UriBuilder.fromUri("http://localhost:8080/").queryParam("c", "z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/?c=z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/?c=z"), uri); uri = UriBuilder.fromUri("http://localhost:8080").queryParam("c", "z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/?c=z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/?c=z"), uri); try { UriBuilder.fromPath("http://localhost:8080").queryParam("name", "x", null).build(); @@ -960,10 +960,10 @@ public void testAppendQueryParams() throws URISyntaxException { @Test public void testAppendMatrixParams() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c;a=x;b=y").matrixParam("c", "z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c;a=x;b=y;c=z"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c;a=x;b=y;c=z"), uri); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c;a=x;b=y").matrixParam("c=/ ;", "z=/ ;").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c;a=x;b=y;c%3D%2F%20%3B=z%3D%2F%20%3B"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c;a=x;b=y;c%3D%2F%20%3B=z%3D%2F%20%3B"), uri); } @Test @@ -971,7 +971,7 @@ public void testAppendPathAndMatrixParams() { final URI uri = UriBuilder.fromUri("http://localhost:8080/").path( "a").matrixParam("x", "foo").matrixParam("y", "bar").path("b").matrixParam("x", "foo").matrixParam("y", "bar") .build(); - Assert.assertEquals(URI.create("http://localhost:8080/a;x=foo;y=bar/b;x=foo;y=bar"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a;x=foo;y=bar/b;x=foo;y=bar"), uri); } @Path("resource") @@ -992,15 +992,15 @@ public Object locator() { @Test public void testResourceAppendPath() throws NoSuchMethodException { URI ub = UriBuilder.fromUri("http://localhost:8080/base").path(Resource.class).build(); - Assert.assertEquals(URI.create("http://localhost:8080/base/resource"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/resource"), ub); ub = UriBuilder.fromUri("http://localhost:8080/base").path(Resource.class, "get").build(); - Assert.assertEquals(URI.create("http://localhost:8080/base/method"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/method"), ub); final Method get = Resource.class.getMethod("get"); final Method locator = Resource.class.getMethod("locator"); ub = UriBuilder.fromUri("http://localhost:8080/base").path(get).path(locator).build(); - Assert.assertEquals(URI.create("http://localhost:8080/base/method/locator"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/method/locator"), ub); } @Path("resource/{id}") @@ -1021,15 +1021,15 @@ public Object locator() { @Test public void testResourceWithTemplateAppendPath() throws NoSuchMethodException { URI ub = UriBuilder.fromUri("http://localhost:8080/base").path(ResourceWithTemplate.class).build("foo"); - Assert.assertEquals(URI.create("http://localhost:8080/base/resource/foo"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/resource/foo"), ub); ub = UriBuilder.fromUri("http://localhost:8080/base").path(ResourceWithTemplate.class, "get").build("foo"); - Assert.assertEquals(URI.create("http://localhost:8080/base/method/foo"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/method/foo"), ub); final Method get = ResourceWithTemplate.class.getMethod("get"); final Method locator = ResourceWithTemplate.class.getMethod("locator"); ub = UriBuilder.fromUri("http://localhost:8080/base").path(get).path(locator).build("foo", "bar"); - Assert.assertEquals(URI.create("http://localhost:8080/base/method/foo/locator/bar"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/method/foo/locator/bar"), ub); } @Path("resource/{id: .+}") @@ -1050,15 +1050,15 @@ public Object locator() { @Test public void testResourceWithTemplateRegexAppendPath() throws NoSuchMethodException { URI ub = UriBuilder.fromUri("http://localhost:8080/base").path(ResourceWithTemplateRegex.class).build("foo"); - Assert.assertEquals(URI.create("http://localhost:8080/base/resource/foo"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/resource/foo"), ub); ub = UriBuilder.fromUri("http://localhost:8080/base").path(ResourceWithTemplateRegex.class, "get").build("foo"); - Assert.assertEquals(URI.create("http://localhost:8080/base/method/foo"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/method/foo"), ub); final Method get = ResourceWithTemplateRegex.class.getMethod("get"); final Method locator = ResourceWithTemplateRegex.class.getMethod("locator"); ub = UriBuilder.fromUri("http://localhost:8080/base").path(get).path(locator).build("foo", "bar"); - Assert.assertEquals(URI.create("http://localhost:8080/base/method/foo/locator/bar"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/method/foo/locator/bar"), ub); } interface GenericInterface { @@ -1081,20 +1081,20 @@ public Object find(@PathParam("id") final String s) { public void testResourceWithGenericInterfaceAppendPath() { final URI ub = UriBuilder.fromUri("http://localhost:8080/base").path(ResourceWithGenericInterface.class, "find") .build("foo"); - Assert.assertEquals(URI.create("http://localhost:8080/base/foo"), ub); + Assertions.assertEquals(URI.create("http://localhost:8080/base/foo"), ub); } @Test public void testBuildTemplates() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").build("x", "y", "z"); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x"), uri); final Map m = new HashMap(); m.put("foo", "x"); m.put("bar", "y"); m.put("baz", "z"); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").buildFromMap(m); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x"), uri); } @Test @@ -1107,20 +1107,20 @@ public void testBuildTemplatesByResolve() { final URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").resolveTemplates(m) .build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x"), uri); } @Test public void testBuildTemplatesWithNameAuthority() { URI uri = UriBuilder.fromUri("http://x_y.com:8080/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").build("x", "y", "z"); - Assert.assertEquals(URI.create("http://x_y.com:8080/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://x_y.com:8080/a/b/c/x/y/z/x"), uri); final Map m = new HashMap(); m.put("foo", "x"); m.put("bar", "y"); m.put("baz", "z"); uri = UriBuilder.fromUri("http://x_y.com:8080/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").buildFromMap(m); - Assert.assertEquals(URI.create("http://x_y.com:8080/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://x_y.com:8080/a/b/c/x/y/z/x"), uri); } @Test @@ -1131,7 +1131,7 @@ public void testBuildTemplatesWithNameAuthorityByResolve() { m.put("baz", "z"); final URI uri = UriBuilder.fromUri("http://x_y.com:8080/a/b/c") .path("/{foo}/{bar}/{baz}/{foo}").buildFromMap(m); - Assert.assertEquals(URI.create("http://x_y.com:8080/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://x_y.com:8080/a/b/c/x/y/z/x"), uri); } @Test @@ -1152,7 +1152,7 @@ public void testBuildFromMap() { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); } @Test @@ -1173,29 +1173,29 @@ public void testBuildFromMapByResolve() { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); } @Test public void testBuildQueryTemplates() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").queryParam("a", "{b}").build("=+&%xx%20"); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%2520"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%2520"), uri); final Map m = new HashMap(); m.put("b", "=+&%xx%20"); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").queryParam("a", "{b}").buildFromMap(m); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%2520"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%2520"), uri); } @Test public void testBuildFromEncodedQueryTemplates() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").queryParam("a", "{b}").buildFromEncoded("=+&%xx%20"); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%20"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%20"), uri); final Map m = new HashMap(); m.put("b", "=+&%xx%20"); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").queryParam("a", "{b}").buildFromEncodedMap(m); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%20"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%20"), uri); } @Test @@ -1207,19 +1207,19 @@ public void testBuildFromEncodedSlashInParamValue() { public void testResolveTemplateFromEncodedQueryTemplates() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").queryParam("a", "{b}") .resolveTemplateFromEncoded("b", "=+&%xx%20").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%20"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%20"), uri); final Map m = new HashMap(); m.put("b", "=+&%xx%20"); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").queryParam("a", "{b}").resolveTemplatesFromEncoded(m).build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%20"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c?a=%3D%2B%26%25xx%20"), uri); } @Test public void testBuildFragmentTemplates() { URI uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").fragment("{foo}") .build("x", "y", "z"); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x#x"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x#x"), uri); final Map m = new HashMap(); m.put("foo", "x"); @@ -1227,7 +1227,7 @@ public void testBuildFragmentTemplates() { m.put("baz", "z"); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").fragment("{foo}") .buildFromMap(m); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x#x"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x#x"), uri); } @Test @@ -1236,7 +1236,7 @@ public void testResolveTemplateFromFragmentTemplates() { .resolveTemplate("foo", "x").resolveTemplate("bar", "y") .resolveTemplate("baz", "z").build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x#x"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x#x"), uri); final Map m = new HashMap(); m.put("foo", "x"); @@ -1244,34 +1244,34 @@ public void testResolveTemplateFromFragmentTemplates() { m.put("baz", "z"); uri = UriBuilder.fromUri("http://localhost:8080/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").fragment("{foo}") .resolveTemplates(m).build(); - Assert.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x#x"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/a/b/c/x/y/z/x#x"), uri); } @Test public void testTemplatesDefaultPort() { URI uri = UriBuilder.fromUri("http://localhost/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").build("x", "y", "z"); - Assert.assertEquals(URI.create("http://localhost/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://localhost/a/b/c/x/y/z/x"), uri); final Map m = new HashMap(); m.put("foo", "x"); m.put("bar", "y"); m.put("baz", "z"); uri = UriBuilder.fromUri("http://localhost/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").buildFromMap(m); - Assert.assertEquals(URI.create("http://localhost/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://localhost/a/b/c/x/y/z/x"), uri); } @Test public void testResolveTemplatesDefaultPort() { URI uri = UriBuilder.fromUri("http://localhost/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").resolveTemplate("foo", "x") .resolveTemplate("bar", "y").resolveTemplate("baz" + "", "z").build(); - Assert.assertEquals(URI.create("http://localhost/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://localhost/a/b/c/x/y/z/x"), uri); final Map m = new HashMap(); m.put("foo", "x"); m.put("bar", "y"); m.put("baz", "z"); uri = UriBuilder.fromUri("http://localhost/a/b/c").path("/{foo}/{bar}/{baz}/{foo}").resolveTemplates(m).build(); - Assert.assertEquals(URI.create("http://localhost/a/b/c/x/y/z/x"), uri); + Assertions.assertEquals(URI.create("http://localhost/a/b/c/x/y/z/x"), uri); } @Test @@ -1280,8 +1280,8 @@ public void testClone() { final URI full = ub.clone().path("b").build(); final URI base = ub.build(); - Assert.assertEquals(URI.create("http://user@localhost:8080/a?query#fragment"), base); - Assert.assertEquals(URI.create("http://user@localhost:8080/a/b?query#fragment"), full); + Assertions.assertEquals(URI.create("http://user@localhost:8080/a?query#fragment"), base); + Assertions.assertEquals(URI.create("http://user@localhost:8080/a/b?query#fragment"), full); } @Test @@ -1292,7 +1292,7 @@ public void testIllegalArgumentException() { } catch (final IllegalArgumentException e) { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); caught = false; try { @@ -1300,7 +1300,7 @@ public void testIllegalArgumentException() { } catch (final IllegalArgumentException e) { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); caught = false; try { @@ -1308,7 +1308,7 @@ public void testIllegalArgumentException() { } catch (final IllegalArgumentException e) { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); } @Test @@ -1334,7 +1334,7 @@ public void testVariableWithoutValue() { } catch (final IllegalArgumentException e) { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); } @Test @@ -1345,7 +1345,7 @@ public void testPortValue() { } catch (final IllegalArgumentException e) { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); } @Test @@ -1353,16 +1353,16 @@ public void testPortSetting() throws URISyntaxException { URI uri; uri = new JerseyUriBuilder().uri("http://localhost").port(8080).build(); - Assert.assertEquals(URI.create("http://localhost:8080"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080"), uri); uri = new JerseyUriBuilder().uri(new URI("http://localhost")).port(8080).build(); - Assert.assertEquals(URI.create("http://localhost:8080"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080"), uri); uri = new JerseyUriBuilder().uri("http://localhost/").port(8080).build(); - Assert.assertEquals(URI.create("http://localhost:8080/"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/"), uri); uri = new JerseyUriBuilder().uri(new URI("http://localhost/")).port(8080).build(); - Assert.assertEquals(URI.create("http://localhost:8080/"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/"), uri); } @Test @@ -1373,13 +1373,13 @@ public void testHostValue() { } catch (final IllegalArgumentException e) { caught = true; } - Assert.assertTrue(caught); + Assertions.assertTrue(caught); URI uri = UriBuilder.fromPath("").host("abc").build(); - Assert.assertEquals(URI.create("//abc"), uri); + Assertions.assertEquals(URI.create("//abc"), uri); uri = UriBuilder.fromPath("").host("abc").host(null).build(); - Assert.assertEquals(URI.create(""), uri); + Assertions.assertEquals(URI.create(""), uri); } /** @@ -1392,7 +1392,7 @@ public void testHostValue() { public void testEncodeTemplateNames() { final URI uri = URI.create(UriComponent.encodeTemplateNames(UriBuilder.fromPath("http://localhost:8080").path( "/{a}/{b}").replaceQuery("q={c}").toTemplate())); - Assert.assertEquals(URI.create("http://localhost:8080/%7Ba%7D/%7Bb%7D?q=%7Bc%7D"), uri); + Assertions.assertEquals(URI.create("http://localhost:8080/%7Ba%7D/%7Bb%7D?q=%7Bc%7D"), uri); } @Test @@ -1405,7 +1405,7 @@ public void resolveTemplateTest() { m.put("a", "ignored-a"); m.put("b", "param-b"); m.put("q", "ignored-q"); - Assert.assertEquals(URI.create("http://localhost:8080/param-a/param-b?query=param-q"), uriBuilder.buildFromMap(m)); + Assertions.assertEquals(URI.create("http://localhost:8080/param-a/param-b?query=param-q"), uriBuilder.buildFromMap(m)); } @Test @@ -1419,7 +1419,7 @@ public void resolveTemplateFromEncodedTest() { m.put("a", "ignored-a"); m.put("b", "param-b/aaa"); m.put("q", "ignored-q"); - Assert.assertEquals("http://localhost:8080/x/y/z%3F%20/param-b/aaa/paramc1%2Fparamc2?query=q%3F%20%26", + Assertions.assertEquals("http://localhost:8080/x/y/z%3F%20/param-b/aaa/paramc1%2Fparamc2?query=q%3F%20%26", uriBuilder.buildFromEncodedMap(m).toString()); } @@ -1434,7 +1434,7 @@ public void resolveTemplateWithoutEncodedTest() { m.put("a", "ignored-a"); m.put("b", "param-b/aaa"); m.put("q", "ignored-q"); - Assert.assertEquals("http://localhost:8080/x%2Fy%2Fz%253F%2520/param-b%2Faaa/paramc1%2Fparamc2?query=q%3F%2520%2526", + Assertions.assertEquals("http://localhost:8080/x%2Fy%2Fz%253F%2520/param-b%2Faaa/paramc1%2Fparamc2?query=q%3F%2520%2526", uriBuilder.buildFromMap(m).toString()); } @@ -1445,7 +1445,7 @@ public void resolveTemplateWithEncodedSlashTest() { uriBuilder.resolveTemplate("a", "param-a/withSlash", false); uriBuilder.resolveTemplate("b", "param-b/withEncodedSlash", true); uriBuilder.resolveTemplate("q", "param-q", true); - Assert.assertEquals(URI.create("http://localhost:8080/param-a/withSlash/param-b%2FwithEncodedSlash?query=param-q"), + Assertions.assertEquals(URI.create("http://localhost:8080/param-a/withSlash/param-b%2FwithEncodedSlash?query=param-q"), uriBuilder.build()); uriBuilder.build(); } @@ -1461,7 +1461,7 @@ public void resolveTemplatesTest() { buildMap.put("a", "ignored-a"); buildMap.put("b", "param-b"); buildMap.put("q", "ignored-q"); - Assert.assertEquals(URI.create("http://localhost:8080/param-a/param-b?query=param-q"), uriBuilder.buildFromMap(buildMap)); + Assertions.assertEquals(URI.create("http://localhost:8080/param-a/param-b?query=param-q"), uriBuilder.buildFromMap(buildMap)); } @Test @@ -1476,7 +1476,7 @@ public void resolveTemplatesFromEncodedTest() { uriBuilder.resolveTemplatesFromEncoded(resolveMap); final Map buildMap = new HashMap(); buildMap.put("b", "param-b/aaa"); - Assert.assertEquals("http://localhost:8080/x/y/z%3F%20/param-b/aaa/paramc1/paramc2?query=q%3F%20%26", + Assertions.assertEquals("http://localhost:8080/x/y/z%3F%20/param-b/aaa/paramc1/paramc2?query=q%3F%20%26", uriBuilder.buildFromEncodedMap(buildMap).toString()); } @@ -1492,7 +1492,7 @@ public void resolveTemplatesFromNotEncodedTest() { uriBuilder.resolveTemplates(resolveMap); final Map buildMap = new HashMap(); buildMap.put("b", "param-b/aaa"); - Assert.assertEquals("http://localhost:8080/x%2Fy%2Fz%253F%2520/param-b%2Faaa/paramc1%2Fparamc2?query=q%3F%2520%2526", + Assertions.assertEquals("http://localhost:8080/x%2Fy%2Fz%253F%2520/param-b%2Faaa/paramc1%2Fparamc2?query=q%3F%2520%2526", uriBuilder.buildFromMap(buildMap).toString()); } @@ -1508,7 +1508,7 @@ public void resolveTemplatesEncodeSlash() { uriBuilder.resolveTemplates(resolveMap, false); final Map buildMap = new HashMap(); buildMap.put("b", "param-b/aaa"); - Assert.assertEquals("http://localhost:8080/x/y/z%253F%2520/param-b/aaa/paramc1/paramc2?query=q%3F%2520%2526", + Assertions.assertEquals("http://localhost:8080/x/y/z%253F%2520/param-b/aaa/paramc1/paramc2?query=q%3F%2520%2526", uriBuilder.buildFromMap(buildMap, false).toString()); } @@ -1521,7 +1521,7 @@ public void resolveTemplatesWithEncodedSlashTest() { resolveMap.put("q", "param-q"); uriBuilder.resolveTemplates(resolveMap, false); uriBuilder.resolveTemplate("b", "param-b/withEncodedSlash", true); - Assert.assertEquals(URI.create("http://localhost:8080/param-a/withSlash/param-b%2FwithEncodedSlash?query=param-q"), + Assertions.assertEquals(URI.create("http://localhost:8080/param-a/withSlash/param-b%2FwithEncodedSlash?query=param-q"), uriBuilder.build()); uriBuilder.build(); } @@ -1532,7 +1532,7 @@ public void resolveTemplateMultipleCall() { .resolveTemplate("a", "first-a").path("{a}").resolveTemplate("a", "second-a") .path("{a}/{a}").resolveTemplate("a", "twice-a"); - Assert.assertEquals(URI.create("http://localhost:8080/start-path/first-a/second-a/twice-a/twice-a"), + Assertions.assertEquals(URI.create("http://localhost:8080/start-path/first-a/second-a/twice-a/twice-a"), uriBuilder.build("start-path")); } @@ -1541,7 +1541,7 @@ public void replaceWithEmtpySchemeFromUriTest() throws URISyntaxException { final String uriOrig = "ftp://ftp.is.co.za/rfc/rfc1808.txt"; final URI uriReplace = new URI(null, "ftp.is.co.za", "/test/rfc1808.txt", null, null); final URI uri = UriBuilder.fromUri(new URI(uriOrig)).uri(uriReplace).build(); - Assert.assertEquals("ftp://ftp.is.co.za/test/rfc1808.txt", uri.toString()); + Assertions.assertEquals("ftp://ftp.is.co.za/test/rfc1808.txt", uri.toString()); } @Test @@ -1550,7 +1550,7 @@ public void replaceWithEmptySchemeFromStringTest() throws URISyntaxException { final URI uriReplace = new URI(null, "ftp.is.co.za", "/test/rfc1808.txt", null, null); final URI uri = UriBuilder.fromUri(new URI(uriOrig)).uri(uriReplace.toASCIIString()).build(); - Assert.assertEquals("ftp://ftp.is.co.za/test/rfc1808.txt", uri.toString()); + Assertions.assertEquals("ftp://ftp.is.co.za/test/rfc1808.txt", uri.toString()); } @Test @@ -1559,7 +1559,7 @@ public void replaceWithEmptyQueryFromStringTest() throws URISyntaxException { final URI uriReplace = new URI(null, "ftp.is.co.za", "/test/rfc1808.txt", null, null); final URI uri = UriBuilder.fromUri(new URI(uriOrig)).uri(uriReplace.toASCIIString()).build(); - Assert.assertEquals("ftp://ftp.is.co.za/test/rfc1808.txt?a=1", uri.toString()); + Assertions.assertEquals("ftp://ftp.is.co.za/test/rfc1808.txt?a=1", uri.toString()); } @Test @@ -1568,7 +1568,7 @@ public void replaceWithEmptyFragmentFromStringTest() throws URISyntaxException { final URI uriReplace = new URI(null, "ftp.is.co.za", "/test/rfc1808.txt", null, null); final URI uri = UriBuilder.fromUri(new URI(uriOrig)).uri(uriReplace.toASCIIString()).build(); - Assert.assertEquals("ftp://ftp.is.co.za/test/rfc1808.txt#myFragment", uri.toString()); + Assertions.assertEquals("ftp://ftp.is.co.za/test/rfc1808.txt#myFragment", uri.toString()); } @Test @@ -1596,35 +1596,35 @@ public void replaceOpaqueUriWithNonOpaqueFromUriTest() throws URISyntaxException public void testQueryParamEncoded() { final UriBuilder uriBuilder = UriBuilder.fromUri("http://localhost:8080/path"); uriBuilder.queryParam("query", "%dummy23"); - Assert.assertEquals("http://localhost:8080/path?query=%25dummy23", uriBuilder.build().toString()); + Assertions.assertEquals("http://localhost:8080/path?query=%25dummy23", uriBuilder.build().toString()); } @Test public void testQueryParamEncoded2() { final UriBuilder uriBuilder = UriBuilder.fromUri("http://localhost:8080/path"); uriBuilder.queryParam("query", "{param}"); - Assert.assertEquals("http://localhost:8080/path?query=%25dummy23", uriBuilder.build("%dummy23").toString()); + Assertions.assertEquals("http://localhost:8080/path?query=%25dummy23", uriBuilder.build("%dummy23").toString()); } @Test public void testQueryParamEncoded3() { final UriBuilder uriBuilder = UriBuilder.fromUri("http://localhost:8080/path"); uriBuilder.queryParam("query", "{param}"); - Assert.assertEquals("http://localhost:8080/path?query=%2525test", uriBuilder.build("%25test").toString()); + Assertions.assertEquals("http://localhost:8080/path?query=%2525test", uriBuilder.build("%25test").toString()); } @Test public void testQueryParamEncoded4() { final UriBuilder uriBuilder = UriBuilder.fromUri("http://localhost:8080/path"); uriBuilder.queryParam("query", "{param}"); - Assert.assertEquals("http://localhost:8080/path?query=%25test", uriBuilder.buildFromEncoded("%25test").toString()); + Assertions.assertEquals("http://localhost:8080/path?query=%25test", uriBuilder.buildFromEncoded("%25test").toString()); } @Test public void testQueryParamEncoded5() { final UriBuilder uriBuilder = UriBuilder.fromUri("http://localhost:8080/path"); uriBuilder.queryParam("query", "! # $ & ' ( ) * + , / : ; = ? @ [ ]"); - Assert.assertEquals( + Assertions.assertEquals( "http://localhost:8080/path?query=%21+%23+%24+%26+%27+%28+%29+%2A+%2B+%2C+%2F+%3A+%3B+%3D+%3F+%40+%5B+%5D", uriBuilder.build().toString()); } @@ -1664,7 +1664,7 @@ private void checkQueryFormat(String fromUri, JerseyQueryParamStyle queryParamSt .queryParam("key2", "val1") .queryParam("key1", "val3") .build(); - Assert.assertEquals(expected, uri.getQuery()); + Assertions.assertEquals(expected, uri.getQuery()); } } diff --git a/tests/e2e-entity/pom.xml b/tests/e2e-entity/pom.xml index f4560b62f3..be1e63642c 100644 --- a/tests/e2e-entity/pom.xml +++ b/tests/e2e-entity/pom.xml @@ -175,16 +175,16 @@ jersey-test-framework-util test - - org.hamcrest - hamcrest + org.junit.platform + junit-platform-suite + ${junit-platform-suite.version} test - xmlunit - xmlunit + org.hamcrest + hamcrest test diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/AbstractTypeTester.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/AbstractTypeTester.java index 2ca9ddd64e..5cf22c3091 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/AbstractTypeTester.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/AbstractTypeTester.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -44,7 +44,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Abstract entity type tester base class. @@ -166,7 +166,7 @@ protected static void _verify(byte[] in, byte[] out) { assertEquals(in.length, out.length); for (int i = 0; i < in.length; i++) { if (in[i] != out[i]) { - assertEquals("Index: " + i, in[i], out[i]); + assertEquals(in[i], out[i], "Index: " + i); } } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/BeanStreamingTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/BeanStreamingTest.java index 8882e6e249..bf4ac93784 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/BeanStreamingTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/BeanStreamingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -42,10 +42,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Paul Sandoz diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/CharsetTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/CharsetTest.java index f81aa04c09..ed9e64f1fc 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/CharsetTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/CharsetTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -46,8 +46,7 @@ import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONObject; -import org.glassfish.jersey.client.ClientResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Paul Sandoz diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ContextResolverMediaTypeTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ContextResolverMediaTypeTest.java index e9250e3246..0a7de6630a 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ContextResolverMediaTypeTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ContextResolverMediaTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -33,22 +33,20 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz * @author Martin Matula */ -@RunWith(Enclosed.class) public class ContextResolverMediaTypeTest { @Produces("text/plain") @Provider - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class TextPlainContextResolver implements ContextResolver { public String getContext(Class objectType) { @@ -58,7 +56,7 @@ public String getContext(Class objectType) { @Produces("text/*") @Provider - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class TextContextResolver implements ContextResolver { public String getContext(Class objectType) { @@ -68,7 +66,7 @@ public String getContext(Class objectType) { @Produces("*/*") @Provider - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class WildcardContextResolver implements ContextResolver { public String getContext(Class objectType) { @@ -78,7 +76,7 @@ public String getContext(Class objectType) { @Produces({"text/plain", "text/html"}) @Provider - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class TextPlainHtmlContextResolver implements ContextResolver { public String getContext(Class objectType) { @@ -89,7 +87,7 @@ public String getContext(Class objectType) { @Produces("text/html") @Provider - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class TextHtmlContextResolver implements ContextResolver { public String getContext(Class objectType) { @@ -99,7 +97,7 @@ public String getContext(Class objectType) { } @Path("/") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class ContextResource { @Context @@ -125,6 +123,7 @@ public String get(@PathParam("id") MediaType m) { } } + @Nested public static class ProduceTest extends JerseyTest { @Override @@ -151,6 +150,7 @@ public void testProduce() throws IOException { } } + @Nested public static class ProducesTest extends JerseyTest { @Override @@ -177,6 +177,7 @@ public void testProduces() throws IOException { } } + @Nested public static class ProducesSeparateTest extends JerseyTest { @Override @@ -204,6 +205,7 @@ public void testProducesSeparate() throws IOException { } } + @Nested public static class ProducesXXXTest extends JerseyTest { @Override diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyEntityTest.java index dac06e6e63..9b64a7409c 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyEntityTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -48,11 +48,11 @@ import org.glassfish.jersey.message.internal.ReaderWriter; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * JERSEY-1540. diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyRequestToEntityParamTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyRequestToEntityParamTest.java index 4b7865d14f..50b7fa963b 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyRequestToEntityParamTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyRequestToEntityParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test for JERSEY-1579. @@ -46,13 +46,13 @@ public static class EntityResource { @DELETE public void delete(Map entity) { - Assert.assertNull(entity); + Assertions.assertNull(entity); } } @Test public void testEmptyRequest() { Response response = target().request().delete(Response.class); - Assert.assertEquals(204, response.getStatus()); + Assertions.assertEquals(204, response.getStatus()); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyRequestWithJaxbTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyRequestWithJaxbTest.java index a7c4f0d811..5588da69ad 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyRequestWithJaxbTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EmptyRequestWithJaxbTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -39,22 +39,20 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz * @author Martin Matula */ -@RunWith(Enclosed.class) public class EmptyRequestWithJaxbTest { @SuppressWarnings("UnusedParameters") @Path("/") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class Resource { @POST @@ -88,6 +86,7 @@ public void arrayType(JaxbBeanType[] b) { } + @Nested public static class EmptyRequestTest extends JerseyTest { @Override @@ -129,7 +128,7 @@ public void testEmptyXmlRequest() { } } - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public abstract static class CR implements ContextResolver { private final JAXBContext context; @@ -153,6 +152,7 @@ public JAXBContext getContext(Class objectType) { } } + @Nested public static class MappedJettisonCRTest extends JerseyTest { @Override @@ -178,6 +178,7 @@ public void testMappedJettisonCR() { } } + @Nested public static class BadgerFishCRTest extends JerseyTest { @Override diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EntityTypesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EntityTypesTest.java index 39ed8f202e..2a28919909 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EntityTypesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EntityTypesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -73,24 +73,25 @@ import org.glassfish.jersey.jettison.JettisonFeature; import org.glassfish.jersey.message.internal.FileProvider; import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONObject; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; import org.w3c.dom.Document; import org.xml.sax.InputSource; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Paul Sandoz * @author Martin Matula */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class EntityTypesTest extends AbstractTypeTester { @Path("InputStreamResource") @@ -110,6 +111,7 @@ public InputStream post(final InputStream in) throws IOException { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testInputStream() { final ByteArrayInputStream in = new ByteArrayInputStream("CONTENT".getBytes()); _test(in, InputStreamResource.class); @@ -120,6 +122,7 @@ public static class StringResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testString() { _test("CONTENT", StringResource.class); } @@ -133,6 +136,7 @@ public static class ByteArrayResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testByteArrayRepresentation() { _test("CONTENT".getBytes(), ByteArrayResource.class); } @@ -144,6 +148,7 @@ public static class JaxbBeanResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentation() { _test(new JaxbBean("CONTENT"), JaxbBeanResource.class, MediaType.APPLICATION_XML_TYPE); } @@ -155,11 +160,13 @@ public static class JaxbBeanResourceMediaType extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationMediaType() { _test(new JaxbBean("CONTENT"), JaxbBeanResourceMediaType.class, MediaType.valueOf("application/foo+xml")); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationError() { final WebTarget target = target("JaxbBeanResource"); @@ -175,6 +182,7 @@ public static class JaxbBeanTextResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanTextRepresentation() { _test(new JaxbBean("CONTENT"), JaxbBeanTextResource.class, MediaType.TEXT_XML_TYPE); } @@ -186,6 +194,7 @@ public static class JAXBElementBeanResource extends AResource> getJAXBElementList() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBElementListXMLRepresentation() { _testListOrArray(true, MediaType.APPLICATION_XML_TYPE); } @@ -218,14 +228,15 @@ public void _testListOrArray(final boolean isList, final MediaType mt) { .asList((JAXBElement[]) in); final List> outList = isList ? ((List>) out) : Arrays .asList((JAXBElement[]) out); - assertEquals("Lengths differ", inList.size(), outList.size()); + assertEquals(inList.size(), outList.size(), "Lengths differ"); for (int i = 0; i < inList.size(); i++) { - assertEquals("Names of elements at index " + i + " differ", inList.get(i).getName(), outList.get(i).getName()); - assertEquals("Values of elements at index " + i + " differ", inList.get(i).getValue(), outList.get(i).getValue()); + assertEquals(inList.get(i).getName(), outList.get(i).getName(), "Names of elements at index " + i + " differ"); + assertEquals(inList.get(i).getValue(), outList.get(i).getValue(), "Values of elements at index " + i + " differ"); } } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBElementListJSONRepresentation() { _testListOrArray(true, MediaType.APPLICATION_JSON_TYPE); } @@ -244,11 +255,13 @@ private JAXBElement[] getJAXBElementArray() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBElementArrayXMLRepresentation() { _testListOrArray(false, MediaType.APPLICATION_XML_TYPE); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBElementArrayJSONRepresentation() { _testListOrArray(false, MediaType.APPLICATION_JSON_TYPE); } @@ -260,11 +273,13 @@ public static class JAXBElementBeanResourceMediaType extends AResource } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationMediaTypeAtom() { _test(new JaxbBean("CONTENT"), JaxbBeanResourceAtom.class, MediaType.valueOf("application/atom+xml")); } @@ -318,6 +335,7 @@ protected void configureClient(final ClientConfig config) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBTypeRepresentation() { final WebTarget target = target("JAXBTypeResource"); final JaxbBean in = new JaxbBean("CONTENT"); @@ -332,6 +350,7 @@ public static class JAXBTypeResourceMediaType extends JAXBTypeResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBTypeRepresentationMediaType() { final WebTarget target = target("JAXBTypeResourceMediaType"); final JaxbBean in = new JaxbBean("CONTENT"); @@ -365,6 +384,7 @@ public JAXBContext getContext(final Class c) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBObjectRepresentation() { final WebTarget target = target("JAXBObjectResource"); final Object in = new JaxbBean("CONTENT"); @@ -379,6 +399,7 @@ public static class JAXBObjectResourceMediaType extends JAXBObjectResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBObjectRepresentationMediaType() { final WebTarget target = target("JAXBObjectResourceMediaType"); final Object in = new JaxbBean("CONTENT"); @@ -387,6 +408,7 @@ public void testJAXBObjectRepresentationMediaType() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBObjectRepresentationError() { final WebTarget target = target("JAXBObjectResource"); @@ -400,6 +422,7 @@ public static class FileResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFileRepresentation() throws IOException { final FileProvider fp = new FileProvider(); final File in = fp.readFrom(File.class, File.class, null, null, null, @@ -415,6 +438,7 @@ public static class FormResource extends AResource
{ } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFormRepresentation() { final Form fp = new Form(); fp.param("Email", "johndoe@gmail.com"); @@ -442,6 +466,7 @@ public static class JSONObjectResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJSONObjectRepresentation() throws Exception { final JSONObject object = new JSONObject(); object.put("userid", 1234) @@ -459,6 +484,7 @@ public static class JSONObjectResourceGeneralMediaType extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJSONArrayRepresentation() throws Exception { final JSONArray array = new JSONArray(); array.put("One").put("Two").put("Three").put(1).put(2.0); @@ -490,6 +517,7 @@ public static class JSONOArrayResourceGeneralMediaType extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testReaderRepresentation() throws Exception { _test(new StringReader("CONTENT"), ReaderResource.class); } @@ -539,6 +568,7 @@ public static class StreamSourceResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testStreamSourceRepresentation() throws Exception { final StreamSource ss = new StreamSource( new ByteArrayInputStream(XML_DOCUMENT.getBytes())); @@ -550,6 +580,7 @@ public static class SAXSourceResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testSAXSourceRepresentation() throws Exception { final StreamSource ss = new StreamSource( new ByteArrayInputStream(XML_DOCUMENT.getBytes())); @@ -561,6 +592,7 @@ public static class DOMSourceResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDOMSourceRepresentation() throws Exception { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); final Document d = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(XML_DOCUMENT))); @@ -573,6 +605,7 @@ public static class DocumentResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDocumentRepresentation() throws Exception { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); final Document d = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(XML_DOCUMENT))); @@ -591,6 +624,7 @@ public MultivaluedMap post(final MultivaluedMap } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFormMultivaluedMapRepresentation() { final MultivaluedMap fp = new MultivaluedStringMap(); fp.add("Email", "johndoe@gmail.com"); @@ -620,6 +654,7 @@ public void write(final OutputStream entity) throws IOException { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testStreamingOutputRepresentation() throws Exception { final WebTarget target = target("StreamingOutputResource"); assertEquals("CONTENT", target.request().get(String.class)); @@ -632,6 +667,7 @@ public static class JAXBElementBeanJSONResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationJSON() { final WebTarget target = target("JaxbBeanResourceJSON"); final JaxbBean in = new JaxbBean("CONTENT"); @@ -672,6 +709,7 @@ public static class JaxbBeanResourceJSONMediaType extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationJSONMediaType() { final WebTarget target = target("JaxbBeanResourceJSONMediaType"); final JaxbBean in = new JaxbBean("CONTENT"); @@ -686,6 +724,7 @@ public static class JAXBElementBeanResourceJSON extends AResource { } @Test - @Ignore("TODO: unignore once fi support implemented (JERSEY-1190)") + @Execution(ExecutionMode.CONCURRENT) + @Disabled("TODO: unignore once fi support implemented (JERSEY-1190)") // TODO: unignore once fi support implemented (JERSEY-1190) public void testJaxbBeanRepresentationFastInfoset() { final WebTarget target = target("JaxbBeanResourceFastInfoset"); @@ -768,7 +811,8 @@ public static class JAXBElementBeanResourceFastInfoset extends AResource { private JAXBContext context; @@ -80,7 +78,7 @@ public int invoked() { } @Provider - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class MarshallerResolver implements ContextResolver { private JAXBContext context; @@ -113,7 +111,7 @@ public int invoked() { } @Provider - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class UnmarshallerResolver implements ContextResolver { private JAXBContext context; @@ -146,7 +144,7 @@ public int invoked() { } @Path("/") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class JaxbBeanResource { @POST @@ -176,6 +174,7 @@ public void testJAXBContext() throws Exception { } } + @Nested public static class UnmarshallerTest extends AbstractTypeTester { private JAXBContextResolver cr; @@ -205,29 +204,30 @@ public void testUnmarshaller() throws Exception { @Provider @Produces("application/xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class JAXBContextResolverApp extends JAXBContextResolver { } @Provider @Produces("application/xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class MarshallerResolverApp extends MarshallerResolver { } @Provider @Produces("application/xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class UnmarshallerResolverApp extends UnmarshallerResolver { } @Path("/") @Consumes("application/xml") @Produces("application/xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class JaxbBeanResourceApp extends JaxbBeanResource { } + @Nested public static class JAXBContextAppTest extends AbstractTypeTester { private JAXBContextResolver cr; @@ -249,6 +249,7 @@ public void testJAXBContextApp() throws Exception { } } + @Nested public static class UnmarshallerAppTest extends AbstractTypeTester { private JAXBContextResolver cr; @@ -289,29 +290,30 @@ public void testUnmarshallerApp() throws Exception { @Provider @Produces("text/xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class JAXBContextResolverText extends JAXBContextResolver { } @Provider @Produces("text/xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class MarshallerResolverText extends MarshallerResolver { } @Provider @Produces("text/xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class UnmarshallerResolverText extends UnmarshallerResolver { } @Path("/") @Consumes("text/xml") @Produces("text/xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class JaxbBeanResourceText extends JaxbBeanResource { } + @Nested public static class JAXBContextTextTest extends AbstractTypeTester { private JAXBContextResolver cr; @@ -332,6 +334,7 @@ public void testJAXBContextText() throws Exception { } } + @Nested public static class UnmarshallerTextTest extends AbstractTypeTester { private JAXBContextResolver cr; @@ -363,23 +366,24 @@ public void testUnmarshallerText() throws Exception { @Provider @Produces("text/foo+xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class MarshallerResolverFoo extends MarshallerResolver { } @Provider @Produces("text/foo+xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class UnmarshallerResolverFoo extends UnmarshallerResolver { } @Path("/") @Consumes("text/foo+xml") @Produces("text/foo+xml") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class JaxbBeanResourceFoo extends JaxbBeanResource { } + @Nested public static class UnmarshallerFooTest extends AbstractTypeTester { private JAXBContextResolver cr; @@ -419,7 +423,7 @@ public void testUnmarshallerFoo() throws Exception { } @Path("/") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class JaxbBeanResourceAll { @POST @@ -444,6 +448,7 @@ public JaxbBean getText(JaxbBean b) { } } + @Nested public static class JAXBContextAllTest extends AbstractTypeTester { private JAXBContextResolver cr; @@ -479,6 +484,7 @@ public void testJAXBContextAll() throws Exception { } } + @Nested public static class UnmarshallerAllTest extends AbstractTypeTester { private JAXBContextResolver cr; @@ -546,7 +552,7 @@ public void testUnmarshallerAll() throws Exception { } @XmlRootElement - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class OtherJaxbBean { public String value; @@ -568,7 +574,7 @@ public String toString() { } @Path("/") - @Ignore("This class is not a test class & must be ignored by the Enclosed test runner.") + @Disabled("This class is not a test class & must be ignored by the Enclosed test runner.") public static class JaxbBeanResourceAllOtherJaxbBean { @POST @@ -593,6 +599,7 @@ public OtherJaxbBean getText(OtherJaxbBean b) { } } + @Nested public static class JAXBContextAllWithOtherJaxbBeanTest extends AbstractTypeTester { private JAXBContextResolver cr; diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JsonMoxyTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JsonMoxyTest.java index 62a4dc24f3..0ba1190465 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JsonMoxyTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JsonMoxyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -50,17 +50,19 @@ import org.glassfish.jersey.moxy.json.MoxyJsonFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.TestProperties; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class JsonMoxyTest extends AbstractTypeTester { @Path("JAXBElementListResource") @@ -97,14 +99,15 @@ public void _testListOrArray(final boolean isList, final MediaType mt) { isList ? ((List>) in) : Arrays.asList((JAXBElement[]) in); final List> outList = isList ? ((List>) out) : Arrays .asList((JAXBElement[]) out); - assertEquals("Lengths differ", inList.size(), outList.size()); + assertEquals(inList.size(), outList.size(), "Lengths differ"); for (int i = 0; i < inList.size(); i++) { - assertEquals("Names of elements at index " + i + " differ", inList.get(i).getName(), outList.get(i).getName()); - assertEquals("Values of elements at index " + i + " differ", inList.get(i).getValue(), outList.get(i).getValue()); + assertEquals(inList.get(i).getName(), outList.get(i).getName(), "Names of elements at index " + i + " differ"); + assertEquals(inList.get(i).getValue(), outList.get(i).getValue(), "Values of elements at index " + i + " differ"); } } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBElementListJSONRepresentation() { _testListOrArray(true, MediaType.APPLICATION_JSON_TYPE); } @@ -124,6 +127,7 @@ private JAXBElement[] getJAXBElementArray() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBElementArrayJSONRepresentation() { _testListOrArray(false, MediaType.APPLICATION_JSON_TYPE); } @@ -152,6 +156,7 @@ public static class JAXBElementBeanJSONResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationJSON() { final WebTarget target = target("JaxbBeanResourceJSON"); final JaxbBean in = new JaxbBean("CONTENT"); @@ -196,6 +202,7 @@ public static class JaxbBeanResourceJSONMediaType extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationJSONMediaType() { final WebTarget target = target("JaxbBeanResourceJSONMediaType"); final JaxbBean in = new JaxbBean("CONTENT"); @@ -210,6 +217,7 @@ public static class JAXBElementBeanResourceJSON extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentation() { _test(new JaxbBean("CONTENT"), JaxbBeanResource.class, MediaType.APPLICATION_XML_TYPE); } @@ -86,11 +89,13 @@ public static class JaxbBeanResourceMediaType extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationMediaType() { _test(new JaxbBean("CONTENT"), JaxbBeanResourceMediaType.class, MediaType.valueOf("application/foo+xml")); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanRepresentationError() { final WebTarget target = target("JaxbBeanResource"); @@ -106,6 +111,7 @@ public static class JaxbBeanTextResource extends AResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJaxbBeanTextRepresentation() { _test(new JaxbBean("CONTENT"), JaxbBeanTextResource.class, MediaType.TEXT_XML_TYPE); } @@ -117,6 +123,7 @@ public static class JAXBElementBeanResource extends AResource> getJAXBElementList() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBElementListXMLRepresentation() { _testListOrArray(true, MediaType.APPLICATION_XML_TYPE); } @@ -150,10 +158,10 @@ public void _testListOrArray(final boolean isList, final MediaType mt) { isList ? ((List>) in) : Arrays.asList((JAXBElement[]) in); final List> outList = isList ? ((List>) out) : Arrays .asList((JAXBElement[]) out); - assertEquals("Lengths differ", inList.size(), outList.size()); + assertEquals(inList.size(), outList.size(), "Lengths differ"); for (int i = 0; i < inList.size(); i++) { - assertEquals("Names of elements at index " + i + " differ", inList.get(i).getName(), outList.get(i).getName()); - assertEquals("Values of elements at index " + i + " differ", inList.get(i).getValue(), outList.get(i).getValue()); + assertEquals(inList.get(i).getName(), outList.get(i).getName(), "Names of elements at index " + i + " differ"); + assertEquals(inList.get(i).getValue(), outList.get(i).getValue(), "Values of elements at index " + i + " differ"); } } @@ -172,6 +180,7 @@ private JAXBElement[] getJAXBElementArray() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBElementArrayXMLRepresentation() { _testListOrArray(false, MediaType.APPLICATION_XML_TYPE); } @@ -183,11 +192,13 @@ public static class JAXBElementBeanResourceMediaType extends AResource c) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBObjectRepresentation() { final WebTarget target = target("JAXBObjectResource"); final Object in = new JaxbBean("CONTENT"); @@ -292,6 +307,7 @@ public static class JAXBObjectResourceMediaType extends JAXBObjectResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBObjectRepresentationMediaType() { final WebTarget target = target("JAXBObjectResourceMediaType"); final Object in = new JaxbBean("CONTENT"); @@ -300,6 +316,7 @@ public void testJAXBObjectRepresentationMediaType() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBObjectRepresentationError() { final WebTarget target = target("JAXBObjectResource"); @@ -393,6 +410,7 @@ public JaxbBean[] postType(final JaxbBeanType[] l) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBArrayRepresentation() { final WebTarget target = target("JAXBArrayResource"); @@ -417,6 +435,7 @@ public static class JAXBListResourceMediaType extends JAXBListResource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBListRepresentationMediaType() { final WebTarget target = target("JAXBListResourceMediaType"); @@ -472,6 +491,7 @@ public int compare(final JaxbBean t, final JaxbBean t1) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testJAXBListRepresentationError() { final WebTarget target = target("JAXBListResource"); @@ -535,6 +555,7 @@ public ComplexJaxbBean get() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testAdditionalClasses() throws Exception { final ComplexJaxbBean nonJaxbBean = target("AdditionalClassesResource").request().get(ComplexJaxbBean.class); final Object simpleBean = nonJaxbBean.getSimpleBean(); diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EmptyEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EmptyEntityTest.java index 43c3562a32..0096c5aef9 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EmptyEntityTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EmptyEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -28,7 +28,7 @@ import org.glassfish.jersey.tests.e2e.entity.filtering.domain.EmptyEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.NonEmptyEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Use-cases to check whether empty class causes problems (JERSEY-2824 reproducer). diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringClientTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringClientTest.java index 973b01a02a..0fa7b140a1 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringClientTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,19 +32,21 @@ import org.glassfish.jersey.message.filtering.EntityFilteringFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.TestProperties; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsOnClassEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; + import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class EntityFilteringClientTest extends EntityFilteringTest { public static final MediaType ENTITY_FILTERING = new MediaType("entity", "filtering"); @@ -76,6 +78,7 @@ public String post(final String value) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testEntityAnnotationsPrimaryView() throws Exception { final ClientConfig config = new ClientConfig() .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, PrimaryDetailedView.Factory.get()); @@ -95,6 +98,7 @@ public void testEntityAnnotationsPrimaryView() throws Exception { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testEntityAnnotationsDefaultView() throws Exception { final String fields = target() .request() @@ -107,6 +111,7 @@ public void testEntityAnnotationsDefaultView() throws Exception { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testEntityAnnotationsInvalidView() throws Exception { final String fields = target() .request() @@ -120,17 +125,20 @@ public void testEntityAnnotationsInvalidView() throws Exception { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testConfigurationPrimaryView() throws Exception { testConfiguration("field,accessor,property,subEntities.field2,subEntities.property2,subEntities.property1," + "subEntities.field1,defaultEntities.field,defaultEntities.property", PrimaryDetailedView.Factory.get()); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testConfigurationDefaultView() throws Exception { testConfiguration("", new DefaultFilteringScope()); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testConfigurationMultipleViews() throws Exception { testConfiguration("field,accessor,property,subEntities.field2,subEntities.property2,subEntities.property1," + "subEntities.field1,defaultEntities.field,defaultEntities.property", PrimaryDetailedView.Factory.get(), @@ -151,6 +159,7 @@ private void testConfiguration(final String expected, final Annotation... annota } @Test + @Execution(ExecutionMode.CONCURRENT) public void testInvalidConfiguration() throws Exception { final ClientConfig config = new ClientConfig() .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, "invalid_value"); @@ -166,6 +175,7 @@ public void testInvalidConfiguration() throws Exception { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testEntityAnnotationsOverConfiguration() throws Exception { final ClientConfig config = new ClientConfig() .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, SecondaryDetailedView.Factory.get()); diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java index 912c24d9da..16235d3ddd 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,7 +32,7 @@ import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsOnClassEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Use-cases with entity-filtering annotations on class. diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnPropertiesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnPropertiesTest.java index 22603ab56b..bb41fdbe77 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnPropertiesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringOnPropertiesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,7 +32,7 @@ import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsOnPropertiesEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnPropertiesEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Use-cases with entity-filtering annotations on properties. diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringScopesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringScopesTest.java index 5f910fbee5..64a536628c 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringScopesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringScopesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,7 +28,7 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ComplexEntity; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringServerTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringServerTest.java index 4d8303b136..7e2a9ba9e8 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringServerTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/EntityFilteringServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,15 +29,15 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsOnClassEntity; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * @author Michal Gajdos */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ EntityFilteringServerTest.ConfigurationServerTest.class, EntityFilteringServerTest.ConfigurationDefaultViewServerTest.class, EntityFilteringServerTest.AnnotationsServerTest.class, diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEmptyEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEmptyEntityTest.java index b2ee42c96d..7dc9b5aa1c 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEmptyEntityTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEmptyEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,8 +16,6 @@ package org.glassfish.jersey.tests.e2e.entity.filtering.json; -import java.util.Arrays; - import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -33,14 +31,11 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.EmptyEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.NonEmptyEntity; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; @@ -51,12 +46,18 @@ * * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class JsonEmptyEntityTest extends JerseyTest { +public class JsonEmptyEntityTest { + + public static class MoxyJsonFeatureJsonEmptyEntityTest extends JsonEmptyEntityTemplateTest { + public MoxyJsonFeatureJsonEmptyEntityTest() { + super(MoxyJsonFeature.class); + } + } - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}}); + public static class JacksonFeatureJsonEmptyEntityTest extends JsonEmptyEntityTemplateTest { + public JacksonFeatureJsonEmptyEntityTest() { + super(JacksonFeature.class); + } } @Path("/") @@ -77,32 +78,35 @@ public EmptyEntity emptyEntity() { } } - public JsonEmptyEntityTest(final Class filteringProvider) { - super(new ResourceConfig(Resource.class, EntityFilteringFeature.class) - .register(filteringProvider) - .register(new ContextResolver() { - @Override - public ObjectMapper getContext(final Class type) { - return new ObjectMapper() - .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) - .setSerializationInclusion(JsonInclude.Include.NON_NULL); - } - })); - - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); - } + public abstract static class JsonEmptyEntityTemplateTest extends JerseyTest { + + public JsonEmptyEntityTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(Resource.class, EntityFilteringFeature.class) + .register(filteringProvider) + .register(new ContextResolver() { + @Override + public ObjectMapper getContext(final Class type) { + return new ObjectMapper() + .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false) + .setSerializationInclusion(JsonInclude.Include.NON_NULL); + } + })); + + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } - @Test - public void testNonEmptyEntity() throws Exception { - final NonEmptyEntity entity = target("nonEmptyEntity").request().get(NonEmptyEntity.class); + @Test + public void testNonEmptyEntity() throws Exception { + final NonEmptyEntity entity = target("nonEmptyEntity").request().get(NonEmptyEntity.class); - assertThat(entity.getValue(), is("foo")); - assertThat(entity.getEmptyEntity(), nullValue()); - } + assertThat(entity.getValue(), is("foo")); + assertThat(entity.getEmptyEntity(), nullValue()); + } - @Test - public void testEmptyEntity() throws Exception { - assertThat(target("emptyEntity").request().get(String.class), is("{}")); + @Test + public void testEmptyEntity() throws Exception { + assertThat(target("emptyEntity").request().get(String.class), is("{}")); + } } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringClientTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringClientTest.java index 9180c2eb85..2251b60b7e 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringClientTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -17,7 +17,6 @@ package org.glassfish.jersey.tests.e2e.entity.filtering.json; import java.lang.annotation.Annotation; -import java.util.Arrays; import javax.ws.rs.Consumes; import javax.ws.rs.POST; @@ -46,232 +45,241 @@ import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsSubEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringSubEntity; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class JsonEntityFilteringClientTest extends JerseyTest { +public class JsonEntityFilteringClientTest { - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}}); + public static class MoxyJsonFeatureJsonEntityFilteringClientTest extends JsonEntityFilteringClientTemplateTest { + public MoxyJsonFeatureJsonEntityFilteringClientTest() { + super(MoxyJsonFeature.class); + } } - @Parameterized.Parameter - public Class filteringProvider; + public static class JacksonFeatureJsonEntityFilteringClientTest extends JsonEntityFilteringClientTemplateTest { + public JacksonFeatureJsonEntityFilteringClientTest() { + super(JacksonFeature.class); + } + } - @Override - protected Application configure() { - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); + public abstract static class JsonEntityFilteringClientTemplateTest extends JerseyTest { + private Class filteringProvider; - return new ResourceConfig() - // Resources. - .register(Resource.class); - } + public JsonEntityFilteringClientTemplateTest(Class filteringProvider) { + this.filteringProvider = filteringProvider; + } - @Override - protected void configureClient(final ClientConfig config) { - config.register(EntityFilteringFeature.class).register(filteringProvider); - } + @Override + protected Application configure() { + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); - @Path("/") - @Consumes("application/json") - @Produces("application/json") - public static class Resource { + return new ResourceConfig() + // Resources. + .register(Resource.class); + } - @POST - public String post(final String value) { - return value; + @Override + protected void configureClient(final ClientConfig config) { + config.register(EntityFilteringFeature.class).register(filteringProvider); } - } - @Test - public void testEntityAnnotationsPrimaryView() throws Exception { - final OneFilteringOnClassEntity entity = target() - .request() - .post(Entity.entity( - OneFilteringOnClassEntity.INSTANCE, - MediaType.APPLICATION_JSON_TYPE, - new Annotation[] {PrimaryDetailedView.Factory.get()}), - OneFilteringOnClassEntity.class); - - _testPrimaryViewEntity(entity); - } + @Test + public void testEntityAnnotationsPrimaryView() throws Exception { + final OneFilteringOnClassEntity entity = target() + .request() + .post(Entity.entity( + OneFilteringOnClassEntity.INSTANCE, + MediaType.APPLICATION_JSON_TYPE, + new Annotation[] {PrimaryDetailedView.Factory.get()}), + OneFilteringOnClassEntity.class); + + _testPrimaryViewEntity(entity); + } - @Test - public void testEntityAnnotationsDefaultView() throws Exception { - final OneFilteringOnClassEntity entity = target() - .request() - .post(Entity.entity( - OneFilteringOnClassEntity.INSTANCE, - MediaType.APPLICATION_JSON_TYPE, - new Annotation[] {new DefaultFilteringScope()}), - OneFilteringOnClassEntity.class); - - _testEmptyEntity(entity); - } + @Test + public void testEntityAnnotationsDefaultView() throws Exception { + final OneFilteringOnClassEntity entity = target() + .request() + .post(Entity.entity( + OneFilteringOnClassEntity.INSTANCE, + MediaType.APPLICATION_JSON_TYPE, + new Annotation[] {new DefaultFilteringScope()}), + OneFilteringOnClassEntity.class); + + _testEmptyEntity(entity); + } - @Test - public void testEntityAnnotationsInvalidView() throws Exception { - final OneFilteringOnClassEntity entity = target() - .request() - .post(Entity.entity( - OneFilteringOnClassEntity.INSTANCE, - MediaType.APPLICATION_JSON_TYPE, - new Annotation[] {CustomAnnotationLiteral.INSTANCE}), - OneFilteringOnClassEntity.class); - - _testEmptyEntity(entity); - } + @Test + public void testEntityAnnotationsInvalidView() throws Exception { + final OneFilteringOnClassEntity entity = target() + .request() + .post(Entity.entity( + OneFilteringOnClassEntity.INSTANCE, + MediaType.APPLICATION_JSON_TYPE, + new Annotation[] {CustomAnnotationLiteral.INSTANCE}), + OneFilteringOnClassEntity.class); + + _testEmptyEntity(entity); + } - @Test - public void testConfigurationPrimaryView() throws Exception { - _testPrimaryViewEntity(retrieveEntity(PrimaryDetailedView.Factory.get())); - } + @Test + public void testConfigurationPrimaryView() throws Exception { + _testPrimaryViewEntity(retrieveEntity(PrimaryDetailedView.Factory.get())); + } - @Test - public void testConfigurationDefaultView() throws Exception { - _testEmptyEntity(retrieveEntity(new DefaultFilteringScope())); - } + @Test + public void testConfigurationDefaultView() throws Exception { + _testEmptyEntity(retrieveEntity(new DefaultFilteringScope())); + } - @Test - public void testConfigurationMultipleViews() throws Exception { - _testPrimaryViewEntity(retrieveEntity(PrimaryDetailedView.Factory.get(), CustomAnnotationLiteral.INSTANCE)); - } + @Test + public void testConfigurationMultipleViews() throws Exception { + _testPrimaryViewEntity(retrieveEntity(PrimaryDetailedView.Factory.get(), CustomAnnotationLiteral.INSTANCE)); + } - private OneFilteringOnClassEntity retrieveEntity(final Annotation... annotations) { - final ClientConfig config = new ClientConfig() - .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, annotations.length == 1 ? annotations[0] : annotations); - configureClient(config); + private OneFilteringOnClassEntity retrieveEntity(final Annotation... annotations) { + final ClientConfig config = new ClientConfig() + .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, + annotations.length == 1 ? annotations[0] : annotations); + configureClient(config); + + return ClientBuilder.newClient(config) + .target(getBaseUri()) + .request() + .post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE), + OneFilteringOnClassEntity.class); + } - return ClientBuilder.newClient(config) - .target(getBaseUri()) - .request() - .post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE), - OneFilteringOnClassEntity.class); - } + @Test + public void testInvalidConfiguration() throws Exception { + final ClientConfig config = new ClientConfig() + .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, "invalid_value"); + configureClient(config); - @Test - public void testInvalidConfiguration() throws Exception { - final ClientConfig config = new ClientConfig() - .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, "invalid_value"); - configureClient(config); + final OneFilteringOnClassEntity entity = + ClientBuilder.newClient(config) + .target(getBaseUri()) + .request() + .post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE), + OneFilteringOnClassEntity.class); - final OneFilteringOnClassEntity entity = - ClientBuilder.newClient(config) - .target(getBaseUri()) - .request() - .post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE), - OneFilteringOnClassEntity.class); + _testEmptyEntity(entity); + } - _testEmptyEntity(entity); - } + @Test + public void testEntityAnnotationsOverConfiguration() throws Exception { + final ClientConfig config = new ClientConfig() + .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, SecondaryDetailedView.Factory.get()); + configureClient(config); + + final ManyFilteringsOnClassEntity entity = ClientBuilder.newClient(config) + .target(getBaseUri()) + .request() + .post(Entity.entity( + ManyFilteringsOnClassEntity.INSTANCE, + MediaType.APPLICATION_JSON_TYPE, + new Annotation[] {PrimaryDetailedView.Factory.get()}), + ManyFilteringsOnClassEntity.class); + + // ManyFilteringsOnClassEntity + assertThat(entity.field, is(50)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, notNullValue()); + assertThat(entity.defaultEntities.size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, notNullValue()); + assertThat(entity.oneEntities.size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(30)); + assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, notNullValue()); + assertThat(entity.manyEntities.size(), is(1)); + final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); + assertThat(manyFilteringsSubEntity.field1, is(60)); + assertThat(manyFilteringsSubEntity.field2, is(0)); + assertThat(manyFilteringsSubEntity.getProperty1(), is("property1")); + assertThat(manyFilteringsSubEntity.getProperty2(), nullValue()); + } - @Test - public void testEntityAnnotationsOverConfiguration() throws Exception { - final ClientConfig config = new ClientConfig() - .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, SecondaryDetailedView.Factory.get()); - configureClient(config); - - final ManyFilteringsOnClassEntity entity = ClientBuilder.newClient(config) - .target(getBaseUri()) - .request() - .post(Entity.entity( - ManyFilteringsOnClassEntity.INSTANCE, - MediaType.APPLICATION_JSON_TYPE, - new Annotation[] {PrimaryDetailedView.Factory.get()}), - ManyFilteringsOnClassEntity.class); - - // ManyFilteringsOnClassEntity - assertThat(entity.field, is(50)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, notNullValue()); - assertThat(entity.defaultEntities.size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, notNullValue()); - assertThat(entity.oneEntities.size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(30)); - assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, notNullValue()); - assertThat(entity.manyEntities.size(), is(1)); - final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); - assertThat(manyFilteringsSubEntity.field1, is(60)); - assertThat(manyFilteringsSubEntity.field2, is(0)); - assertThat(manyFilteringsSubEntity.getProperty1(), is("property1")); - assertThat(manyFilteringsSubEntity.getProperty2(), nullValue()); - } + private void _testEmptyEntity(final OneFilteringOnClassEntity entity) { + // OneFilteringOnClassEntity + assertThat(entity.field, is(0)); + assertThat(entity.accessorTransient, nullValue()); + assertThat(entity.getProperty(), nullValue()); - private void _testEmptyEntity(final OneFilteringOnClassEntity entity) { - // OneFilteringOnClassEntity - assertThat(entity.field, is(0)); - assertThat(entity.accessorTransient, nullValue()); - assertThat(entity.getProperty(), nullValue()); + // FilteredClassEntity + final FilteredClassEntity filtered = entity.getFiltered(); + assertThat(filtered, nullValue()); - // FilteredClassEntity - final FilteredClassEntity filtered = entity.getFiltered(); - assertThat(filtered, nullValue()); + // DefaultFilteringSubEntity + assertThat(entity.getDefaultEntities(), nullValue()); - // DefaultFilteringSubEntity - assertThat(entity.getDefaultEntities(), nullValue()); + // OneFilteringSubEntity + assertThat(entity.getSubEntities(), nullValue()); + } - // OneFilteringSubEntity - assertThat(entity.getSubEntities(), nullValue()); + private void _testPrimaryViewEntity(final OneFilteringOnClassEntity entity) { + // OneFilteringOnClassEntity + assertThat(entity.field, is(10)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.getFiltered(); + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.getDefaultEntities(), notNullValue()); + assertThat(entity.getDefaultEntities().size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.getDefaultEntities().get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.getSubEntities(), notNullValue()); + assertThat(entity.getSubEntities().size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.getSubEntities().get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(30)); + assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + } } - private void _testPrimaryViewEntity(final OneFilteringOnClassEntity entity) { - // OneFilteringOnClassEntity - assertThat(entity.field, is(10)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.getFiltered(); - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.getDefaultEntities(), notNullValue()); - assertThat(entity.getDefaultEntities().size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.getDefaultEntities().get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.getSubEntities(), notNullValue()); - assertThat(entity.getSubEntities().size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.getSubEntities().get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(30)); - assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + @Path("/") + @Consumes("application/json") + @Produces("application/json") + public static class Resource { + + @POST + public String post(final String value) { + return value; + } } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnClassTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnClassTest.java index e18eeee4b3..7420415d9e 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnClassTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -17,7 +17,6 @@ package org.glassfish.jersey.tests.e2e.entity.filtering.json; import java.lang.annotation.Annotation; -import java.util.Arrays; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -42,33 +41,268 @@ import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsSubEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnClassEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringSubEntity; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Use-cases with entity-filtering annotations on class, JSON output. * * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class JsonEntityFilteringOnClassTest extends JerseyTest { +public class JsonEntityFilteringOnClassTest { + + public static class MoxyJsonFeatureJsonEntityFilteringOnClassTest extends JsonEntityFilteringOnClassTemplateTest { + public MoxyJsonFeatureJsonEntityFilteringOnClassTest() { + super(MoxyJsonFeature.class); + } + } - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}}); + public static class JacksonFeatureJsonEntityFilteringOnClassTest extends JsonEntityFilteringOnClassTemplateTest { + public JacksonFeatureJsonEntityFilteringOnClassTest() { + super(JacksonFeature.class); + } } - public JsonEntityFilteringOnClassTest(final Class filteringProvider) { - super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider)); + public abstract static class JsonEntityFilteringOnClassTemplateTest extends JerseyTest { + public JsonEntityFilteringOnClassTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider)); + + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } + + @Test + public void testOneEntityFilteringOnClass() throws Exception { + final OneFilteringOnClassEntity entity = target("OneFilteringEntity").request().get(OneFilteringOnClassEntity.class); + + // OneFilteringOnClassEntity + assertThat(entity.field, is(10)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.getFiltered(); + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.getDefaultEntities(), notNullValue()); + assertThat(entity.getDefaultEntities().size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.getDefaultEntities().get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.getSubEntities(), notNullValue()); + assertThat(entity.getSubEntities().size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.getSubEntities().get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(30)); + assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + } + + @Test + public void testOneEntityFilteringOnClassDefaultViewResponse() throws Exception { + final OneFilteringOnClassEntity entity = target("OneFilteringEntityDefaultViewResponse").request() + .get(OneFilteringOnClassEntity.class); + + // OneFilteringOnClassEntity + assertThat(entity.field, is(0)); + assertThat(entity.accessorTransient, nullValue()); + assertThat(entity.getProperty(), nullValue()); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.getFiltered(); + assertThat(filtered, nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.getDefaultEntities(), nullValue()); + + // OneFilteringSubEntity + assertThat(entity.getSubEntities(), nullValue()); + } + + @Test + public void testOneEntityFilteringOnClassDefaultView() throws Exception { + final OneFilteringOnClassEntity entity = target("OneFilteringEntityDefaultView").request() + .get(OneFilteringOnClassEntity.class); + + // OneFilteringOnClassEntity + assertThat(entity.field, is(0)); + assertThat(entity.accessorTransient, nullValue()); + assertThat(entity.getProperty(), nullValue()); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.getFiltered(); + assertThat(filtered, nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.getDefaultEntities(), nullValue()); + + // OneFilteringSubEntity + assertThat(entity.getSubEntities(), nullValue()); + } + + @Test + public void testMultipleViewsOnClass() throws Exception { + testOneEntityFilteringOnClass(); + testOneEntityFilteringOnClassDefaultView(); + } + + @Test + public void testManyFilteringsEntityPrimaryView() throws Exception { + final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityPrimaryView").request() + .get(ManyFilteringsOnClassEntity.class); + + // ManyFilteringsOnClassEntity + assertThat(entity.field, is(50)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, notNullValue()); + assertThat(entity.defaultEntities.size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, notNullValue()); + assertThat(entity.oneEntities.size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(30)); + assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, notNullValue()); + assertThat(entity.manyEntities.size(), is(1)); + final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); + assertThat(manyFilteringsSubEntity.field1, is(60)); + assertThat(manyFilteringsSubEntity.field2, is(0)); + assertThat(manyFilteringsSubEntity.getProperty1(), is("property1")); + assertThat(manyFilteringsSubEntity.getProperty2(), nullValue()); + } + + @Test + public void testManyFilteringsEntitySecondaryView() throws Exception { + final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntitySecondaryView").request() + .get(ManyFilteringsOnClassEntity.class); + + // ManyFilteringsOnClassEntity + assertThat(entity.field, is(50)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, notNullValue()); + assertThat(entity.defaultEntities.size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, notNullValue()); + assertThat(entity.oneEntities.size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(0)); + assertThat(oneFilteringSubEntity.getProperty1(), nullValue()); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, notNullValue()); + assertThat(entity.manyEntities.size(), is(1)); + final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); + assertThat(manyFilteringsSubEntity.field1, is(60)); + assertThat(manyFilteringsSubEntity.field2, is(70)); + assertThat(manyFilteringsSubEntity.getProperty1(), nullValue()); + assertThat(manyFilteringsSubEntity.getProperty2(), is("property2")); + } + + @Test + public void testManyFilteringsEntityDefaultView() throws Exception { + final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityDefaultView").request() + .get(ManyFilteringsOnClassEntity.class); + + // ManyFilteringsOnClassEntity + assertThat(entity.field, is(0)); + assertThat(entity.accessorTransient, nullValue()); + assertThat(entity.getProperty(), nullValue()); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, nullValue()); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, nullValue()); - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, nullValue()); + } + + @Test + public void testManyFilteringsEntityManyViews() throws Exception { + final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityManyViews").request() + .get(ManyFilteringsOnClassEntity.class); + + // ManyFilteringsOnClassEntity + assertThat(entity.field, is(50)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, notNullValue()); + assertThat(entity.defaultEntities.size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, notNullValue()); + assertThat(entity.oneEntities.size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(30)); + assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, notNullValue()); + assertThat(entity.manyEntities.size(), is(1)); + final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); + assertThat(manyFilteringsSubEntity.field1, is(60)); + assertThat(manyFilteringsSubEntity.field2, is(70)); + assertThat(manyFilteringsSubEntity.getProperty1(), is("property1")); + assertThat(manyFilteringsSubEntity.getProperty2(), is("property2")); + } } @Path("/") @@ -130,234 +364,4 @@ public ManyFilteringsOnClassEntity getManyFilteringsEntityManyViews() { return ManyFilteringsOnClassEntity.INSTANCE; } } - - @Test - public void testOneEntityFilteringOnClass() throws Exception { - final OneFilteringOnClassEntity entity = target("OneFilteringEntity").request().get(OneFilteringOnClassEntity.class); - - // OneFilteringOnClassEntity - assertThat(entity.field, is(10)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.getFiltered(); - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.getDefaultEntities(), notNullValue()); - assertThat(entity.getDefaultEntities().size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.getDefaultEntities().get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.getSubEntities(), notNullValue()); - assertThat(entity.getSubEntities().size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.getSubEntities().get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(30)); - assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - } - - @Test - public void testOneEntityFilteringOnClassDefaultViewResponse() throws Exception { - final OneFilteringOnClassEntity entity = target("OneFilteringEntityDefaultViewResponse").request() - .get(OneFilteringOnClassEntity.class); - - // OneFilteringOnClassEntity - assertThat(entity.field, is(0)); - assertThat(entity.accessorTransient, nullValue()); - assertThat(entity.getProperty(), nullValue()); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.getFiltered(); - assertThat(filtered, nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.getDefaultEntities(), nullValue()); - - // OneFilteringSubEntity - assertThat(entity.getSubEntities(), nullValue()); - } - - @Test - public void testOneEntityFilteringOnClassDefaultView() throws Exception { - final OneFilteringOnClassEntity entity = target("OneFilteringEntityDefaultView").request() - .get(OneFilteringOnClassEntity.class); - - // OneFilteringOnClassEntity - assertThat(entity.field, is(0)); - assertThat(entity.accessorTransient, nullValue()); - assertThat(entity.getProperty(), nullValue()); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.getFiltered(); - assertThat(filtered, nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.getDefaultEntities(), nullValue()); - - // OneFilteringSubEntity - assertThat(entity.getSubEntities(), nullValue()); - } - - @Test - public void testMultipleViewsOnClass() throws Exception { - testOneEntityFilteringOnClass(); - testOneEntityFilteringOnClassDefaultView(); - } - - @Test - public void testManyFilteringsEntityPrimaryView() throws Exception { - final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityPrimaryView").request() - .get(ManyFilteringsOnClassEntity.class); - - // ManyFilteringsOnClassEntity - assertThat(entity.field, is(50)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, notNullValue()); - assertThat(entity.defaultEntities.size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, notNullValue()); - assertThat(entity.oneEntities.size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(30)); - assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, notNullValue()); - assertThat(entity.manyEntities.size(), is(1)); - final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); - assertThat(manyFilteringsSubEntity.field1, is(60)); - assertThat(manyFilteringsSubEntity.field2, is(0)); - assertThat(manyFilteringsSubEntity.getProperty1(), is("property1")); - assertThat(manyFilteringsSubEntity.getProperty2(), nullValue()); - } - - @Test - public void testManyFilteringsEntitySecondaryView() throws Exception { - final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntitySecondaryView").request() - .get(ManyFilteringsOnClassEntity.class); - - // ManyFilteringsOnClassEntity - assertThat(entity.field, is(50)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, notNullValue()); - assertThat(entity.defaultEntities.size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, notNullValue()); - assertThat(entity.oneEntities.size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(0)); - assertThat(oneFilteringSubEntity.getProperty1(), nullValue()); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, notNullValue()); - assertThat(entity.manyEntities.size(), is(1)); - final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); - assertThat(manyFilteringsSubEntity.field1, is(60)); - assertThat(manyFilteringsSubEntity.field2, is(70)); - assertThat(manyFilteringsSubEntity.getProperty1(), nullValue()); - assertThat(manyFilteringsSubEntity.getProperty2(), is("property2")); - } - - @Test - public void testManyFilteringsEntityDefaultView() throws Exception { - final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityDefaultView").request() - .get(ManyFilteringsOnClassEntity.class); - - // ManyFilteringsOnClassEntity - assertThat(entity.field, is(0)); - assertThat(entity.accessorTransient, nullValue()); - assertThat(entity.getProperty(), nullValue()); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, nullValue()); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, nullValue()); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, nullValue()); - } - - @Test - public void testManyFilteringsEntityManyViews() throws Exception { - final ManyFilteringsOnClassEntity entity = target("ManyFilteringsEntityManyViews").request() - .get(ManyFilteringsOnClassEntity.class); - - // ManyFilteringsOnClassEntity - assertThat(entity.field, is(50)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, notNullValue()); - assertThat(entity.defaultEntities.size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, notNullValue()); - assertThat(entity.oneEntities.size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(30)); - assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, notNullValue()); - assertThat(entity.manyEntities.size(), is(1)); - final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); - assertThat(manyFilteringsSubEntity.field1, is(60)); - assertThat(manyFilteringsSubEntity.field2, is(70)); - assertThat(manyFilteringsSubEntity.getProperty1(), is("property1")); - assertThat(manyFilteringsSubEntity.getProperty2(), is("property2")); - } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnPropertiesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnPropertiesTest.java index 2d107b3243..e729381ed8 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnPropertiesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringOnPropertiesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -17,7 +17,6 @@ package org.glassfish.jersey.tests.e2e.entity.filtering.json; import java.lang.annotation.Annotation; -import java.util.Arrays; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -42,33 +41,259 @@ import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsSubEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringOnPropertiesEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringSubEntity; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Use-cases with entity-filtering annotations on properties, JSON output. * * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class JsonEntityFilteringOnPropertiesTest extends JerseyTest { +public class JsonEntityFilteringOnPropertiesTest { + + public static class MoxyJsonFeatureJsonEntityFilteringOnPropertiesTest extends JsonEntityFilteringOnPropertiesTemplateTest { + public MoxyJsonFeatureJsonEntityFilteringOnPropertiesTest() { + super(MoxyJsonFeature.class); + } + } - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}}); + public static class JacksonFeatureJsonEntityFilteringOnPropertiesTest extends JsonEntityFilteringOnPropertiesTemplateTest { + public JacksonFeatureJsonEntityFilteringOnPropertiesTest() { + super(JacksonFeature.class); + } } - public JsonEntityFilteringOnPropertiesTest(final Class filteringProvider) { - super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider)); + public abstract static class JsonEntityFilteringOnPropertiesTemplateTest extends JerseyTest { + public JsonEntityFilteringOnPropertiesTemplateTest(final Class filteringProvider) { + super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider)); + + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } + + @Test + public void testOneEntityFilteringOnProperties() throws Exception { + final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntity").request() + .get(OneFilteringOnPropertiesEntity.class); + + // OneFilteringOnPropertiesEntity + assertThat(entity.field, is(80)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.getFiltered(); + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.getDefaultEntities(), notNullValue()); + assertThat(entity.getDefaultEntities().size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.getDefaultEntities().get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.getSubEntities(), notNullValue()); + assertThat(entity.getSubEntities().size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.getSubEntities().get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(30)); + assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + } + + @Test + public void testOneEntityFilteringOnPropertiesDefaultViewResponse() throws Exception { + final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntityDefaultViewResponse").request() + .get(OneFilteringOnPropertiesEntity.class); + + // OneFilteringOnPropertiesEntity + assertThat(entity.field, is(80)); + assertThat(entity.accessorTransient, nullValue()); + assertThat(entity.getProperty(), nullValue()); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.getFiltered(); + assertThat(filtered, nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.getDefaultEntities(), nullValue()); + + // OneFilteringSubEntity + assertThat(entity.getSubEntities(), nullValue()); + } + + @Test + public void testOneEntityFilteringOnPropertiesDefaultView() throws Exception { + final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntityDefaultView").request() + .get(OneFilteringOnPropertiesEntity.class); + + // OneFilteringOnPropertiesEntity + assertThat(entity.field, is(80)); + assertThat(entity.accessorTransient, nullValue()); + assertThat(entity.getProperty(), nullValue()); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.getFiltered(); + assertThat(filtered, nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.getDefaultEntities(), nullValue()); + + // OneFilteringSubEntity + assertThat(entity.getSubEntities(), nullValue()); + } + + @Test + public void testMultipleViewsOnProperties() throws Exception { + testOneEntityFilteringOnProperties(); + testOneEntityFilteringOnPropertiesDefaultView(); + } + + @Test + public void testManyFilteringsEntityPrimaryView() throws Exception { + final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityPrimaryView").request() + .get(ManyFilteringsOnPropertiesEntity.class); + + // ManyFilteringsOnPropertiesEntity + assertThat(entity.field, is(90)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, notNullValue()); + assertThat(entity.defaultEntities.size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, notNullValue()); + assertThat(entity.oneEntities.size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(30)); + assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, nullValue()); + } + + @Test + public void testManyFilteringsEntitySecondaryView() throws Exception { + final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntitySecondaryView").request() + .get(ManyFilteringsOnPropertiesEntity.class); + + // ManyFilteringsOnPropertiesEntity + assertThat(entity.field, is(90)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, nullValue()); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, notNullValue()); + assertThat(entity.oneEntities.size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(0)); + assertThat(oneFilteringSubEntity.getProperty1(), nullValue()); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, notNullValue()); + assertThat(entity.manyEntities.size(), is(1)); + final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); + assertThat(manyFilteringsSubEntity.field1, is(60)); + assertThat(manyFilteringsSubEntity.field2, is(70)); + assertThat(manyFilteringsSubEntity.getProperty1(), nullValue()); + assertThat(manyFilteringsSubEntity.getProperty2(), is("property2")); + } + + @Test + public void testManyFilteringsEntityDefaultView() throws Exception { + final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityDefaultView").request() + .get(ManyFilteringsOnPropertiesEntity.class); + + // ManyFilteringsOnPropertiesEntity + assertThat(entity.field, is(90)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), nullValue()); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, nullValue()); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, nullValue()); - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, nullValue()); + } + + @Test + public void testManyFilteringsEntityManyViews() throws Exception { + final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityManyViews").request() + .get(ManyFilteringsOnPropertiesEntity.class); + + // ManyFilteringsOnPropertiesEntity + assertThat(entity.field, is(90)); + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // FilteredClassEntity + final FilteredClassEntity filtered = entity.filtered; + assertThat(filtered, notNullValue()); + assertThat(filtered.field, is(0)); + assertThat(filtered.getProperty(), nullValue()); + + // DefaultFilteringSubEntity + assertThat(entity.defaultEntities, notNullValue()); + assertThat(entity.defaultEntities.size(), is(1)); + final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); + assertThat(defaultFilteringSubEntity.field, is(true)); + assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); + + // OneFilteringSubEntity + assertThat(entity.oneEntities, notNullValue()); + assertThat(entity.oneEntities.size(), is(1)); + final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); + assertThat(oneFilteringSubEntity.field1, is(20)); + assertThat(oneFilteringSubEntity.field2, is(30)); + assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); + assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); + + // ManyFilteringsSubEntity + assertThat(entity.manyEntities, notNullValue()); + assertThat(entity.manyEntities.size(), is(1)); + final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); + assertThat(manyFilteringsSubEntity.field1, is(60)); + assertThat(manyFilteringsSubEntity.field2, is(70)); + assertThat(manyFilteringsSubEntity.getProperty1(), is("property1")); + assertThat(manyFilteringsSubEntity.getProperty2(), is("property2")); + } } @Path("/") @@ -130,225 +355,4 @@ public ManyFilteringsOnPropertiesEntity getManyFilteringsEntityManyViews() { return ManyFilteringsOnPropertiesEntity.INSTANCE; } } - - @Test - public void testOneEntityFilteringOnProperties() throws Exception { - final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntity").request() - .get(OneFilteringOnPropertiesEntity.class); - - // OneFilteringOnPropertiesEntity - assertThat(entity.field, is(80)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.getFiltered(); - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.getDefaultEntities(), notNullValue()); - assertThat(entity.getDefaultEntities().size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.getDefaultEntities().get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.getSubEntities(), notNullValue()); - assertThat(entity.getSubEntities().size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.getSubEntities().get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(30)); - assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - } - - @Test - public void testOneEntityFilteringOnPropertiesDefaultViewResponse() throws Exception { - final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntityDefaultViewResponse").request() - .get(OneFilteringOnPropertiesEntity.class); - - // OneFilteringOnPropertiesEntity - assertThat(entity.field, is(80)); - assertThat(entity.accessorTransient, nullValue()); - assertThat(entity.getProperty(), nullValue()); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.getFiltered(); - assertThat(filtered, nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.getDefaultEntities(), nullValue()); - - // OneFilteringSubEntity - assertThat(entity.getSubEntities(), nullValue()); - } - - @Test - public void testOneEntityFilteringOnPropertiesDefaultView() throws Exception { - final OneFilteringOnPropertiesEntity entity = target("OneFilteringEntityDefaultView").request() - .get(OneFilteringOnPropertiesEntity.class); - - // OneFilteringOnPropertiesEntity - assertThat(entity.field, is(80)); - assertThat(entity.accessorTransient, nullValue()); - assertThat(entity.getProperty(), nullValue()); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.getFiltered(); - assertThat(filtered, nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.getDefaultEntities(), nullValue()); - - // OneFilteringSubEntity - assertThat(entity.getSubEntities(), nullValue()); - } - - @Test - public void testMultipleViewsOnProperties() throws Exception { - testOneEntityFilteringOnProperties(); - testOneEntityFilteringOnPropertiesDefaultView(); - } - - @Test - public void testManyFilteringsEntityPrimaryView() throws Exception { - final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityPrimaryView").request() - .get(ManyFilteringsOnPropertiesEntity.class); - - // ManyFilteringsOnPropertiesEntity - assertThat(entity.field, is(90)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, notNullValue()); - assertThat(entity.defaultEntities.size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, notNullValue()); - assertThat(entity.oneEntities.size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(30)); - assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, nullValue()); - } - - @Test - public void testManyFilteringsEntitySecondaryView() throws Exception { - final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntitySecondaryView").request() - .get(ManyFilteringsOnPropertiesEntity.class); - - // ManyFilteringsOnPropertiesEntity - assertThat(entity.field, is(90)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, nullValue()); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, notNullValue()); - assertThat(entity.oneEntities.size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(0)); - assertThat(oneFilteringSubEntity.getProperty1(), nullValue()); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, notNullValue()); - assertThat(entity.manyEntities.size(), is(1)); - final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); - assertThat(manyFilteringsSubEntity.field1, is(60)); - assertThat(manyFilteringsSubEntity.field2, is(70)); - assertThat(manyFilteringsSubEntity.getProperty1(), nullValue()); - assertThat(manyFilteringsSubEntity.getProperty2(), is("property2")); - } - - @Test - public void testManyFilteringsEntityDefaultView() throws Exception { - final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityDefaultView").request() - .get(ManyFilteringsOnPropertiesEntity.class); - - // ManyFilteringsOnPropertiesEntity - assertThat(entity.field, is(90)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), nullValue()); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, nullValue()); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, nullValue()); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, nullValue()); - } - - @Test - public void testManyFilteringsEntityManyViews() throws Exception { - final ManyFilteringsOnPropertiesEntity entity = target("ManyFilteringsEntityManyViews").request() - .get(ManyFilteringsOnPropertiesEntity.class); - - // ManyFilteringsOnPropertiesEntity - assertThat(entity.field, is(90)); - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // FilteredClassEntity - final FilteredClassEntity filtered = entity.filtered; - assertThat(filtered, notNullValue()); - assertThat(filtered.field, is(0)); - assertThat(filtered.getProperty(), nullValue()); - - // DefaultFilteringSubEntity - assertThat(entity.defaultEntities, notNullValue()); - assertThat(entity.defaultEntities.size(), is(1)); - final DefaultFilteringSubEntity defaultFilteringSubEntity = entity.defaultEntities.get(0); - assertThat(defaultFilteringSubEntity.field, is(true)); - assertThat(defaultFilteringSubEntity.getProperty(), is(20L)); - - // OneFilteringSubEntity - assertThat(entity.oneEntities, notNullValue()); - assertThat(entity.oneEntities.size(), is(1)); - final OneFilteringSubEntity oneFilteringSubEntity = entity.oneEntities.get(0); - assertThat(oneFilteringSubEntity.field1, is(20)); - assertThat(oneFilteringSubEntity.field2, is(30)); - assertThat(oneFilteringSubEntity.getProperty1(), is("property1")); - assertThat(oneFilteringSubEntity.getProperty2(), is("property2")); - - // ManyFilteringsSubEntity - assertThat(entity.manyEntities, notNullValue()); - assertThat(entity.manyEntities.size(), is(1)); - final ManyFilteringsSubEntity manyFilteringsSubEntity = entity.manyEntities.get(0); - assertThat(manyFilteringsSubEntity.field1, is(60)); - assertThat(manyFilteringsSubEntity.field2, is(70)); - assertThat(manyFilteringsSubEntity.getProperty1(), is("property1")); - assertThat(manyFilteringsSubEntity.getProperty2(), is("property2")); - } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringScopesTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringScopesTest.java index 4dba516cd3..813db39354 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringScopesTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringScopesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,8 +16,6 @@ package org.glassfish.jersey.tests.e2e.entity.filtering.json; -import java.util.Arrays; - import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -34,31 +32,60 @@ import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ComplexEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ComplexSubEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ComplexSubSubEntity; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class JsonEntityFilteringScopesTest extends JerseyTest { +public class JsonEntityFilteringScopesTest { - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}}); + public static class MoxyJsonFeatureJsonEntityFilteringScopesTest extends JsonEntityFilteringScopesTemplateTest { + public MoxyJsonFeatureJsonEntityFilteringScopesTest() { + super(MoxyJsonFeature.class); + } } - public JsonEntityFilteringScopesTest(final Class filteringProvider) { - super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider)); + public static class JacksonFeatureJsonEntityFilteringScopesTest extends JsonEntityFilteringScopesTemplateTest { + public JacksonFeatureJsonEntityFilteringScopesTest() { + super(JacksonFeature.class); + } + } + + public abstract static class JsonEntityFilteringScopesTemplateTest extends JerseyTest { + public JsonEntityFilteringScopesTemplateTest(Class filteringProvider) { + super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider)); + + enable(TestProperties.DUMP_ENTITY); + enable(TestProperties.LOG_TRAFFIC); + } + + /** + * Primary -> Default -> Primary. + */ + @Test + public void testEntityFilteringScopes() throws Exception { + final ComplexEntity entity = target().request().get(ComplexEntity.class); - enable(TestProperties.DUMP_ENTITY); - enable(TestProperties.LOG_TRAFFIC); + // ComplexEntity + assertThat(entity.accessorTransient, is("propertyproperty")); + assertThat(entity.getProperty(), is("property")); + + // ComplexSubEntity + final ComplexSubEntity subEntity = entity.field; + assertThat(subEntity, notNullValue()); + assertThat(subEntity.accessorTransient, is("fieldfield")); + assertThat(subEntity.field, is("field")); + + // ComplexSubSubEntity + final ComplexSubSubEntity subSubEntity = entity.field.getProperty(); + assertThat(subSubEntity.accessorTransient, is("fieldfield")); + assertThat(subSubEntity.getProperty(), is("property")); + assertThat(subSubEntity.field, nullValue()); + } } @Path("/") @@ -72,28 +99,4 @@ public ComplexEntity get() { return ComplexEntity.INSTANCE; } } - - /** - * Primary -> Default -> Primary. - */ - @Test - public void testEntityFilteringScopes() throws Exception { - final ComplexEntity entity = target().request().get(ComplexEntity.class); - - // ComplexEntity - assertThat(entity.accessorTransient, is("propertyproperty")); - assertThat(entity.getProperty(), is("property")); - - // ComplexSubEntity - final ComplexSubEntity subEntity = entity.field; - assertThat(subEntity, notNullValue()); - assertThat(subEntity.accessorTransient, is("fieldfield")); - assertThat(subEntity.field, is("field")); - - // ComplexSubSubEntity - final ComplexSubSubEntity subSubEntity = entity.field.getProperty(); - assertThat(subSubEntity.accessorTransient, is("fieldfield")); - assertThat(subSubEntity.getProperty(), is("property")); - assertThat(subSubEntity.field, nullValue()); - } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringServerTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringServerTest.java index 5ae7b7f75f..d8078f5924 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringServerTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/JsonEntityFilteringServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -17,7 +17,9 @@ package org.glassfish.jersey.tests.e2e.entity.filtering.json; import java.lang.annotation.Annotation; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -31,6 +33,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; +import org.glassfish.jersey.test.spi.TestHelper; import org.glassfish.jersey.tests.e2e.entity.filtering.DefaultFilteringScope; import org.glassfish.jersey.tests.e2e.entity.filtering.PrimaryDetailedView; import org.glassfish.jersey.tests.e2e.entity.filtering.SecondaryDetailedView; @@ -39,26 +42,18 @@ import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsOnClassEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.ManyFilteringsSubEntity; import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringSubEntity; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Suite; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ - JsonEntityFilteringServerTest.ConfigurationServerTest.class, - JsonEntityFilteringServerTest.ConfigurationDefaultViewServerTest.class, - JsonEntityFilteringServerTest.AnnotationsServerTest.class, - JsonEntityFilteringServerTest.AnnotationsOverConfigurationServerTest.class -}) public class JsonEntityFilteringServerTest { @Path("/") @@ -117,15 +112,37 @@ public Response getAnnotationsOverConfigurationOverResource() { } } - @RunWith(Parameterized.class) - public static class ConfigurationServerTest extends JerseyTest { + public static Iterable> providers() { + return Arrays.asList(MoxyJsonFeature.class, JacksonFeature.class); + } - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + providers().forEach(filteringProvider -> { + ConfigurationServerTest test1 = new ConfigurationServerTest(filteringProvider) {}; + tests.add(TestHelper.toTestContainer(test1, + ConfigurationServerTest.class.getSimpleName() + " (" + filteringProvider.getSimpleName() + ")")); + + ConfigurationDefaultViewServerTest test2 = new ConfigurationDefaultViewServerTest(filteringProvider) {}; + tests.add(TestHelper.toTestContainer(test2, + ConfigurationDefaultViewServerTest.class.getSimpleName() + " (" + filteringProvider.getSimpleName() + ")")); + + AnnotationsServerTest test3 = new AnnotationsServerTest(filteringProvider) {}; + tests.add(TestHelper.toTestContainer(test3, + AnnotationsServerTest.class.getSimpleName() + " (" + filteringProvider.getSimpleName() + ")")); + + AnnotationsOverConfigurationServerTest test4 = new AnnotationsOverConfigurationServerTest(filteringProvider) {}; + tests.add(TestHelper.toTestContainer(test4, + AnnotationsOverConfigurationServerTest.class.getSimpleName() + + " (" + filteringProvider.getSimpleName() + ")")); + }); + return tests; + } - public ConfigurationServerTest(final Class filteringProvider) { + public abstract static class ConfigurationServerTest extends JerseyTest { + + public ConfigurationServerTest(Class filteringProvider) { super(new ResourceConfig(Resource.class, EntityFilteringFeature.class) .register(filteringProvider) .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, PrimaryDetailedView.Factory.get())); @@ -145,15 +162,9 @@ public void testConfigurationOverResource() throws Exception { } } - @RunWith(Parameterized.class) - public static class ConfigurationDefaultViewServerTest extends JerseyTest { - - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } + public abstract static class ConfigurationDefaultViewServerTest extends JerseyTest { - public ConfigurationDefaultViewServerTest(final Class filteringProvider) { + public ConfigurationDefaultViewServerTest(final Class filteringProvider) { super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider)); enable(TestProperties.DUMP_ENTITY); @@ -184,15 +195,9 @@ public void testConfiguration() throws Exception { } } - @RunWith(Parameterized.class) - public static class AnnotationsServerTest extends JerseyTest { - - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } + public abstract static class AnnotationsServerTest extends JerseyTest { - public AnnotationsServerTest(final Class filteringProvider) { + public AnnotationsServerTest(final Class filteringProvider) { super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider)); enable(TestProperties.DUMP_ENTITY); @@ -210,15 +215,9 @@ public void testAnnotationsOverResource() throws Exception { } } - @RunWith(Parameterized.class) - public static class AnnotationsOverConfigurationServerTest extends JerseyTest { - - @Parameterized.Parameters(name = "Provider: {0}") - public static Iterable providers() { - return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}}); - } + public abstract static class AnnotationsOverConfigurationServerTest extends JerseyTest { - public AnnotationsOverConfigurationServerTest(final Class filteringProvider) { + public AnnotationsOverConfigurationServerTest(final Class filteringProvider) { super(new ResourceConfig(Resource.class, EntityFilteringFeature.class) .register(filteringProvider) .property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, new DefaultFilteringScope())); diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/MoxyEntityFilteringTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/MoxyEntityFilteringTest.java index aefabf4284..f2ded4f39e 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/MoxyEntityFilteringTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/filtering/json/MoxyEntityFilteringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -30,7 +30,7 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/HeaderDelegateProviderTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/HeaderDelegateProviderTest.java index 8bc9fb0699..9d118a5a58 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/HeaderDelegateProviderTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/HeaderDelegateProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.message.internal.InboundMessageContext; import org.glassfish.jersey.message.internal.OutboundMessageContext; import org.glassfish.jersey.spi.HeaderDelegateProvider; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -48,7 +48,7 @@ import java.util.List; import java.util.Map; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; public class HeaderDelegateProviderTest { static final String HEADER_NAME = "BEAN_HEADER"; @@ -148,7 +148,7 @@ public void testTheProviderIsFound() { found++; } } - Assert.assertEquals(2, found); + Assertions.assertEquals(2, found); } @Test @@ -203,7 +203,7 @@ protected Iterable getReaderInterceptors() { }; inboundMessageContext.header(HttpHeaders.CONTENT_TYPE, ""); MediaType mediaType = inboundMessageContext.getMediaType(); - Assert.assertEquals(MediaType.APPLICATION_OCTET_STREAM_TYPE, mediaType); + Assertions.assertEquals(MediaType.APPLICATION_OCTET_STREAM_TYPE, mediaType); } @Test @@ -222,13 +222,13 @@ public void testGetMediaTypeInOutboundMessageContext() { outboundMessageContext = new OutboundMessageContext(config.getConfiguration()); outboundMessageContext.getHeaders().add(HttpHeaders.CONTENT_TYPE, ""); MediaType mediaType = outboundMessageContext.getMediaType(); - Assert.assertEquals(MediaType.APPLICATION_OCTET_STREAM_TYPE, mediaType); + Assertions.assertEquals(MediaType.APPLICATION_OCTET_STREAM_TYPE, mediaType); } private void testMap(MultivaluedMap map, String expectedValue) { for (Map.Entry> entry : map.entrySet()) { - Assert.assertEquals(HEADER_NAME, entry.getKey()); - Assert.assertEquals(expectedValue, entry.getValue().iterator().next()); + Assertions.assertEquals(HEADER_NAME, entry.getKey()); + Assertions.assertEquals(expectedValue, entry.getValue().iterator().next()); } } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/RuntimeDelegateProviderDisabledTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/RuntimeDelegateProviderDisabledTest.java index d2a03d7a89..29994b2d1d 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/RuntimeDelegateProviderDisabledTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/RuntimeDelegateProviderDisabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -19,8 +19,8 @@ import org.glassfish.jersey.CommonProperties; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -39,11 +39,11 @@ protected Application configure() { @Test public void testClientResponseHeaders() { try (Response response = target("/simple").request().get()) { - Assert.assertEquals( + Assertions.assertEquals( DISABLED_VALUE, response.getHeaderString(HeaderDelegateProviderTest.HeaderContainerResponseFilter.class.getSimpleName()) ); - Assert.assertEquals( + Assertions.assertEquals( DISABLED_VALUE, response.getStringHeaders().getFirst(HEADER_NAME) ); @@ -53,7 +53,7 @@ public void testClientResponseHeaders() { @Test public void testContainerResponseFilter() { try (Response response = target("/simple").request().get()) { - Assert.assertEquals(DISABLED_VALUE, response.getHeaderString(HEADER_NAME)); + Assertions.assertEquals(DISABLED_VALUE, response.getHeaderString(HEADER_NAME)); } } @@ -63,7 +63,7 @@ public void testProviderOnClientDisabled() { .property(CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE_CLIENT, true).request() .header(HEADER_NAME, new HeaderDelegateProviderTest.BeanForHeaderDelegateProviderTest()) .get()) { - Assert.assertEquals( + Assertions.assertEquals( DISABLED_VALUE, response.getHeaderString(HeaderDelegateProviderTest.HeaderSettingResource.class.getSimpleName()) ); @@ -76,7 +76,7 @@ public void testProviderOnClientFilter() { .property(CommonProperties.METAINF_SERVICES_LOOKUP_DISABLE_CLIENT, true) .register(HeaderDelegateProviderTest.HeaderClientRequestFilter.class) .request().get()) { - Assert.assertEquals( + Assertions.assertEquals( DISABLED_VALUE, response.readEntity(String.class) ); diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/RuntimeDelegateProviderEnabledTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/RuntimeDelegateProviderEnabledTest.java index 2f3c73d13f..109c22993e 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/RuntimeDelegateProviderEnabledTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/header/RuntimeDelegateProviderEnabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -19,8 +19,8 @@ import org.glassfish.jersey.CommonProperties; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -37,11 +37,11 @@ protected Application configure() { @Test public void testClientResponseHeaders() { try (Response response = target("/simple").request().get()) { - Assert.assertEquals( + Assertions.assertEquals( HeaderDelegateProviderTest.BeanForHeaderDelegateProviderTest.getValue(), response.getHeaderString(HeaderDelegateProviderTest.HeaderContainerResponseFilter.class.getSimpleName()) ); - Assert.assertEquals( + Assertions.assertEquals( HeaderDelegateProviderTest.BeanForHeaderDelegateProviderTest.getValue(), response.getStringHeaders().getFirst(HEADER_NAME) ); @@ -51,7 +51,7 @@ public void testClientResponseHeaders() { @Test public void testContainerResponseFilter() { try (Response response = target("/simple").request().get()) { - Assert.assertEquals( + Assertions.assertEquals( HeaderDelegateProviderTest.BeanForHeaderDelegateProviderTest.getValue(), response.getHeaderString(HEADER_NAME) ); @@ -62,7 +62,7 @@ public void testContainerResponseFilter() { public void testProviderOnClient() { try (Response response = target("/headers").request() .header(HEADER_NAME, new HeaderDelegateProviderTest.BeanForHeaderDelegateProviderTest()).get()) { - Assert.assertEquals( + Assertions.assertEquals( HeaderDelegateProviderTest.BeanForHeaderDelegateProviderTest.getValue(), response.getHeaderString(HeaderDelegateProviderTest.HeaderSettingResource.class.getSimpleName()) ); @@ -74,7 +74,7 @@ public void testProviderOnClientFilter() { try (Response response = target("/clientfilter") .register(HeaderDelegateProviderTest.HeaderClientRequestFilter.class) .request().get()) { - Assert.assertEquals( + Assertions.assertEquals( HeaderDelegateProviderTest.BeanForHeaderDelegateProviderTest.getValue(), response.readEntity(String.class) ); diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/GenericTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/GenericTest.java index 5f7f5b9222..2deec5f662 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/GenericTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/GenericTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,40 +16,30 @@ package org.glassfish.jersey.tests.e2e.json; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - +import org.glassfish.jersey.test.spi.TestHelper; +import org.glassfish.jersey.tests.e2e.json.JsonTest.JsonTestSetup; import org.glassfish.jersey.tests.e2e.json.entity.ColorHolder; import org.glassfish.jersey.tests.e2e.json.entity.Jersey1199List; -import org.junit.Ignore; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.TestFactory; /** * Unignore when you need to run a specific test. * * @author Michal Gajdos */ -@Ignore("Unignore only when you need to run a specific test.") -@RunWith(Parameterized.class) -public class GenericTest extends AbstractJsonTest { +@Disabled("Unignore only when you need to run a specific test.") +public class GenericTest { - @Parameterized.Parameters() - public static Collection generateTestCases() throws Exception { - final List jsonTestSetups = new LinkedList(); + @TestFactory + public DynamicContainer generateTests() throws Exception { final Class[] classes = {Jersey1199List.class, ColorHolder.class}; - for (JsonTestProvider jsonProvider : new JsonTestProvider[]{new JsonTestProvider.MoxyJsonTestProvider()}) { - jsonTestSetups.add(new JsonTestSetup[]{new JsonTestSetup(classes, jsonProvider)}); - } - - return jsonTestSetups; + JsonTestProvider jsonProvider = new JsonTestProvider.MoxyJsonTestProvider(); + JsonTestSetup setupTest = new JsonTestSetup(classes, jsonProvider); + JsonTest jsonTest = new JsonTest(setupTest) {}; + return TestHelper.toTestContainer(jsonTest, String.format("genTest (%s)", jsonProvider.getClass().getSimpleName())); } - - public GenericTest(final JsonTestSetup jsonTestSetup) throws Exception { - super(jsonTestSetup); - } - } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/InheritanceTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/InheritanceTest.java index 881d15d764..27a1edea00 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/InheritanceTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/InheritanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,41 +16,38 @@ package org.glassfish.jersey.tests.e2e.json; +import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedList; import java.util.List; +import org.glassfish.jersey.test.spi.TestHelper; +import org.glassfish.jersey.tests.e2e.json.JsonTest.JsonTestSetup; import org.glassfish.jersey.tests.e2e.json.entity.Animal; import org.glassfish.jersey.tests.e2e.json.entity.AnimalList; import org.glassfish.jersey.tests.e2e.json.entity.Cat; import org.glassfish.jersey.tests.e2e.json.entity.Dog; - -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.TestFactory; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class InheritanceTest extends AbstractJsonTest { +public class InheritanceTest { - @Parameterized.Parameters() - public static Collection generateTestCases() throws Exception { - final List jsonTestSetups = new LinkedList(); + @TestFactory + public Collection generateTests() throws Exception { + List tests = new ArrayList<>(); final Class[] classes = {AnimalList.class, Animal.class, Dog.class, Cat.class}; for (final JsonTestProvider jsonProvider : JsonTestProvider.JAXB_PROVIDERS) { // TODO - remove the condition after jsonb polymorphic adapter is implemented if (!(jsonProvider instanceof JsonTestProvider.JsonbTestProvider)) { - jsonTestSetups.add(new JsonTestSetup[]{new JsonTestSetup(classes, jsonProvider)}); + JsonTestSetup setupTest = new JsonTestSetup(classes, jsonProvider); + JsonTest jsonTest = new JsonTest(setupTest) {}; + tests.add(TestHelper.toTestContainer(jsonTest, + String.format("inheritanceTest (%s)", jsonProvider.getClass().getSimpleName()))); } } - - return jsonTestSetups; + return tests; } - - public InheritanceTest(final JsonTestSetup jsonTestSetup) throws Exception { - super(jsonTestSetup); - } - } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jackson1JsonViewTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jackson1JsonViewTest.java index d71dd569d6..5219c2ef44 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jackson1JsonViewTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jackson1JsonViewTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -33,7 +33,7 @@ import org.glassfish.jersey.test.JerseyTest; import org.codehaus.jackson.map.annotate.JsonView; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JacksonJsonViewTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JacksonJsonViewTest.java index c4c8dd96af..7e3253681d 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JacksonJsonViewTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JacksonJsonViewTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,7 +32,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JaxbTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JaxbTest.java index 7733e232b5..49e4703010 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JaxbTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JaxbTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,12 +16,14 @@ package org.glassfish.jersey.tests.e2e.json; +import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedList; import java.util.List; import org.glassfish.grizzly.utils.ArrayUtils; import org.glassfish.jersey.internal.util.PropertiesHelper; +import org.glassfish.jersey.test.spi.TestHelper; +import org.glassfish.jersey.tests.e2e.json.JsonTest.JsonTestSetup; import org.glassfish.jersey.tests.e2e.json.entity.AnotherArrayTestBean; import org.glassfish.jersey.tests.e2e.json.entity.AttrAndCharDataBean; import org.glassfish.jersey.tests.e2e.json.entity.ComplexBeanWithAttributes; @@ -51,15 +53,13 @@ import org.glassfish.jersey.tests.e2e.json.entity.TwoListsWrapperBean; import org.glassfish.jersey.tests.e2e.json.entity.User; import org.glassfish.jersey.tests.e2e.json.entity.UserTable; - -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.TestFactory; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class JaxbTest extends AbstractJsonTest { +public class JaxbTest { private static final Class[] CLASSES = { AnotherArrayTestBean.class, @@ -93,10 +93,6 @@ public class JaxbTest extends AbstractJsonTest { UserTable.class }; - public JaxbTest(final JsonTestSetup jsonTestSetup) throws Exception { - super(jsonTestSetup); - } - /** * checks provided string to be a number * @@ -130,18 +126,21 @@ private static boolean isJavaVersionSupported() { return true; } - @Parameterized.Parameters() - public static Collection getJsonProviders() throws Exception { + @TestFactory + public Collection generateTests() throws Exception { + List tests = new ArrayList<>(); final Class[] filteredClasses = (isJavaVersionSupported()) ? CLASSES : ArrayUtils.remove(CLASSES, EncodedContentBean.class); - final List jsonTestSetups = new LinkedList<>(); for (final JsonTestProvider jsonProvider : JsonTestProvider.JAXB_PROVIDERS) { for (final Class entityClass : filteredClasses) { - jsonTestSetups.add(new JsonTestSetup[]{new JsonTestSetup(entityClass, jsonProvider)}); + JsonTestSetup setupTest = new JsonTestSetup(entityClass, jsonProvider); + JsonTest jsonTest = new JsonTest(setupTest) {}; + tests.add(TestHelper.toTestContainer(jsonTest, + String.format("jaxbTest (%s, %s)", entityClass.getSimpleName(), jsonProvider.getClass().getSimpleName()))); } } - return jsonTestSetups; + return tests; } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jersey1199Test.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jersey1199Test.java index b3dec8da76..0aaad3e048 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jersey1199Test.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jersey1199Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,39 +16,38 @@ package org.glassfish.jersey.tests.e2e.json; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.LinkedList; import java.util.List; import javax.json.bind.adapter.JsonbAdapter; +import org.glassfish.jersey.test.spi.TestHelper; +import org.glassfish.jersey.tests.e2e.json.JsonTest.JsonTestSetup; import org.glassfish.jersey.tests.e2e.json.entity.ColorHolder; import org.glassfish.jersey.tests.e2e.json.entity.Jersey1199List; - -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.TestFactory; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class Jersey1199Test extends AbstractJsonTest { +public class Jersey1199Test { - @Parameterized.Parameters() - public static Collection generateTestCases() throws Exception { - final List jsonTestSetups = new LinkedList<>(); + @TestFactory + public Collection generateTests() throws Exception { + List tests = new ArrayList<>(); final Class[] classes = {Jersey1199List.class, ColorHolder.class}; for (final JsonTestProvider jsonProvider : JsonTestProvider.JAXB_PROVIDERS) { - jsonTestSetups.add(new JsonTestSetup[]{new JsonTestSetup(classes, jsonProvider)}); + JsonTestSetup setupTest = new JsonTestSetup(classes, jsonProvider); + JsonTest jsonTest = new JsonTest(setupTest) {}; + tests.add(TestHelper.toTestContainer(jsonTest, + String.format("jersey1199Test (%s)", jsonProvider.getClass().getSimpleName()))); } - return jsonTestSetups; - } - - public Jersey1199Test(final JsonTestSetup jsonTestSetup) throws Exception { - super(jsonTestSetup); + return tests; } /** diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jersey1835Test.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jersey1835Test.java index fa291d5126..881a362349 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jersey1835Test.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/Jersey1835Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,32 +16,24 @@ package org.glassfish.jersey.tests.e2e.json; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - +import org.glassfish.jersey.test.spi.TestHelper; +import org.glassfish.jersey.tests.e2e.json.JsonTest.JsonTestSetup; import org.glassfish.jersey.tests.e2e.json.entity.SingleItemListWrapperBean; - -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.TestFactory; /** * Reproducible test case for JERSEY-1835. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) -public class Jersey1835Test extends AbstractJsonTest { - - @Parameterized.Parameters() - public static Collection generateTestCases() throws Exception { - final List result = new LinkedList(); - result.add(new JsonTestSetup[] {new JsonTestSetup(new Class[] {SingleItemListWrapperBean.class}, - new JsonTestProvider.JettisonMappedJsonTestProvider())}); - return result; - } +public class Jersey1835Test { - public Jersey1835Test(final JsonTestSetup jsonTestSetup) throws Exception { - super(jsonTestSetup); + @TestFactory + public DynamicContainer generateTests() throws Exception { + JsonTestSetup setupTest = new JsonTestSetup(new Class[] + {SingleItemListWrapperBean.class}, new JsonTestProvider.JettisonMappedJsonTestProvider()); + JsonTest jsonTest = new JsonTest(setupTest) {}; + return TestHelper.toTestContainer(jsonTest, "jersey1835Test"); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonProcessingDisabledTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonProcessingDisabledTest.java index 57a4e665e7..1d6b0941d4 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonProcessingDisabledTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonProcessingDisabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,8 +36,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonProcessingTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonProcessingTest.java index ab9f5231b8..90c5604f6e 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonProcessingTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonProcessingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -42,15 +42,15 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; + import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -// @RunWith(ConcurrentRunner.class) public class JsonProcessingTest extends JerseyTest { private static final String JSON_OBJECT_STR1 = "{\"foo\":\"bar\"}"; diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/AbstractJsonTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonTest.java similarity index 96% rename from tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/AbstractJsonTest.java rename to tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonTest.java index f3bdcec118..ed04c64781 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/AbstractJsonTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -49,18 +49,18 @@ import org.glassfish.jersey.test.TestProperties; import org.eclipse.persistence.jaxb.JAXBContextFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Common functionality for JSON tests that are using multiple JSON providers (e.g. MOXy, Jackson, Jettison). * * @author Michal Gajdos */ -public abstract class AbstractJsonTest extends JerseyTest { +public abstract class JsonTest extends JerseyTest { private static final String PKG_NAME = "org/glassfish/jersey/tests/e2e/json/entity/"; - private static final Logger LOGGER = Logger.getLogger(AbstractJsonTest.class.getName()); + private static final Logger LOGGER = Logger.getLogger(JsonTest.class.getName()); /** * Helper class representing configuration for one test case. @@ -259,7 +259,7 @@ protected static JAXBContextResolver createJaxbContextResolver(final JsonTestPro jsonProvider instanceof JsonTestProvider.MoxyJsonTestProvider); } - protected AbstractJsonTest(final JsonTestSetup jsonTestSetup) throws Exception { + JsonTest(final JsonTestSetup jsonTestSetup) throws Exception { super(configureJaxrsApplication(jsonTestSetup)); enable(TestProperties.LOG_TRAFFIC); enable(TestProperties.DUMP_ENTITY); @@ -326,8 +326,9 @@ public void test() throws Exception { // TODO remove once JUnit supports parameterized tests with custom names // TODO (see http://stackoverflow.com/questions/650894/change-test-name-of-parameterized-tests // TODO or https://github.com/KentBeck/junit/pull/393) - assertEquals(String.format("%s - %s: Received JSON entity content does not match expected JSON entity content.", + assertEquals(entity, receivedEntity, + String.format("%s - %s: Received JSON entity content does not match expected JSON entity content.", getJsonTestSetup().getJsonProvider().getClass().getSimpleName(), - getJsonTestSetup().getEntityClass().getSimpleName()), entity, receivedEntity); + getJsonTestSetup().getEntityClass().getSimpleName())); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingEncodingFilterTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingEncodingFilterTest.java index 4d681da77a..0c2759d9df 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingEncodingFilterTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingEncodingFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -33,9 +33,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests, that JSONP callback wrapping takes places before the eventual entity compression. diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingTest.java index 17f35dff53..02016040ae 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithPaddingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,9 +16,8 @@ package org.glassfish.jersey.tests.e2e.json; +import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedList; -import java.util.List; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -35,25 +34,23 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; - +import org.glassfish.jersey.test.spi.TestHelper; import org.hamcrest.Matcher; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class JsonWithPaddingTest extends JerseyTest { +public class JsonWithPaddingTest { - @SuppressWarnings("UnusedDeclaration") @XmlRootElement public static class JsonBean { @@ -118,164 +115,165 @@ public JsonBean getJsonWithPaddingCallback() { } } - @Parameterized.Parameters(name = "{0}") - public static Collection getJsonProviders() throws Exception { - final List testProviders = new LinkedList<>(); - - for (final JsonTestProvider jsonProvider : JsonTestProvider.JAXB_PROVIDERS) { - testProviders.add(new JsonTestProvider[] {jsonProvider}); - } - - return testProviders; + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JsonTestProvider.JAXB_PROVIDERS.forEach(jsonProvider -> { + JsonWithPaddingTemplateTest test = new JsonWithPaddingTemplateTest(jsonProvider) {}; + tests.add(TestHelper.toTestContainer(test, jsonProvider.getClass().getSimpleName())); + }); + return tests; } - private final JsonTestProvider jsonTestProvider; - private final String errorMessage; + public abstract static class JsonWithPaddingTemplateTest extends JerseyTest { + private final JsonTestProvider jsonTestProvider; + private final String errorMessage; - public JsonWithPaddingTest(final JsonTestProvider jsonTestProvider) throws Exception { - super(configureJaxrsApplication(jsonTestProvider)); - enable(TestProperties.LOG_TRAFFIC); - enable(TestProperties.DUMP_ENTITY); + public JsonWithPaddingTemplateTest(final JsonTestProvider jsonTestProvider) { + super(configureJaxrsApplication(jsonTestProvider)); + enable(TestProperties.LOG_TRAFFIC); + enable(TestProperties.DUMP_ENTITY); - this.jsonTestProvider = jsonTestProvider; - this.errorMessage = String.format("%s: Received JSON entity content does not match expected JSON entity content.", - jsonTestProvider.getClass().getSimpleName()); - } + this.jsonTestProvider = jsonTestProvider; + this.errorMessage = String.format("%s: Received JSON entity content does not match expected JSON entity content.", + jsonTestProvider.getClass().getSimpleName()); + } - @Override - protected void configureClient(final ClientConfig config) { - config.register(jsonTestProvider.getFeature()); - } + @Override + protected void configureClient(final ClientConfig config) { + config.register(jsonTestProvider.getFeature()); + } - private static Application configureJaxrsApplication(final JsonTestProvider jsonTestProvider) { - final ResourceConfig resourceConfig = new ResourceConfig() - .registerClasses(JsonResource.class) - .register(jsonTestProvider.getFeature()); + @Test + public void testJson() throws Exception { + final Response response = target("jsonp").path("PureJson").request("application/json").get(); - if (jsonTestProvider.getProviders() != null) { - resourceConfig.registerInstances(jsonTestProvider.getProviders()); - } + assertThat(response.getStatus(), equalTo(200)); + assertThat(response.getMediaType().toString(), equalTo("application/json")); - return resourceConfig; - } + final String entity = response.readEntity(String.class); - @Test - public void testJson() throws Exception { - final Response response = target("jsonp").path("PureJson").request("application/json").get(); + assertThat(errorMessage, entity, allOf(not(startsWith("callback(")), not(endsWith(")")))); + } - assertThat(response.getStatus(), equalTo(200)); - assertThat(response.getMediaType().toString(), equalTo("application/json")); + @Test + public void testJsonWithJavaScriptMediaType() throws Exception { + final Response response = target("jsonp").path("PureJson").request("application/x-javascript").get(); - final String entity = response.readEntity(String.class); + // Method is invoked but we do not have a MBW for application/x-javascript. + if (jsonTestProvider.getFeature().getClass() == JacksonFeature.class) { + assertThat(response.getStatus(), equalTo(200)); + } else { + assertThat(response.getStatus(), equalTo(500)); + } + } - assertThat(errorMessage, entity, allOf(not(startsWith("callback(")), not(endsWith(")")))); - } + @Test + public void testJsonWithPaddingDefault() throws Exception { + test("JsonWithPaddingDefault", "callback"); + } - @Test - public void testJsonWithJavaScriptMediaType() throws Exception { - final Response response = target("jsonp").path("PureJson").request("application/x-javascript").get(); + @Test + public void testJsonWithPaddingQueryCallbackParam() throws Exception { + test("JsonWithPaddingQueryCallbackParam", "eval", "parse"); + } - // Method is invoked but we do not have a MBW for application/x-javascript. - if (jsonTestProvider.getFeature().getClass() == JacksonFeature.class) { - assertThat(response.getStatus(), equalTo(200)); - } else { - assertThat(response.getStatus(), equalTo(500)); + @Test + public void testJsonWithPaddingQueryCallbackParamDefaultQueryParam() throws Exception { + test("JsonWithPaddingQueryCallbackParam", "callback", "parse", "callback"); } - } - @Test - public void testJsonWithPaddingDefault() throws Exception { - test("JsonWithPaddingDefault", "callback"); - } + @Test + public void testJsonWithPaddingQueryCallbackParamDefaultCallback() throws Exception { + test("JsonWithPaddingQueryCallbackParam", null, "callback"); + } - @Test - public void testJsonWithPaddingQueryCallbackParam() throws Exception { - test("JsonWithPaddingQueryCallbackParam", "eval", "parse"); - } + @Test + public void testJsonWithPaddingQueryCallbackParamNegative() throws Exception { + test("JsonWithPaddingQueryCallbackParam", "call", "parse", true); + } - @Test - public void testJsonWithPaddingQueryCallbackParamDefaultQueryParam() throws Exception { - test("JsonWithPaddingQueryCallbackParam", "callback", "parse", "callback"); - } + @Test + public void testJsonWithPaddingCallbackAndQueryCallbackParam() throws Exception { + test("JsonWithPaddingCallbackAndQueryCallbackParam", "eval", "run"); + } - @Test - public void testJsonWithPaddingQueryCallbackParamDefaultCallback() throws Exception { - test("JsonWithPaddingQueryCallbackParam", null, "callback"); - } + @Test + public void testJsonWithPaddingCallbackAndQueryCallbackParamNegative() throws Exception { + test("JsonWithPaddingCallbackAndQueryCallbackParam", "eval", "run", "parse", true); + } - @Test - public void testJsonWithPaddingQueryCallbackParamNegative() throws Exception { - test("JsonWithPaddingQueryCallbackParam", "call", "parse", true); - } + @Test + public void testJsonWithPaddingCallbackAndQueryCallbackParamDefault() throws Exception { + test("JsonWithPaddingCallbackAndQueryCallbackParam", "evalx", "parse"); + } - @Test - public void testJsonWithPaddingCallbackAndQueryCallbackParam() throws Exception { - test("JsonWithPaddingCallbackAndQueryCallbackParam", "eval", "run"); - } + @Test + public void testJsonWithPaddingCallbackAndQueryCallbackParamDefaultNegative() throws Exception { + test("JsonWithPaddingCallbackAndQueryCallbackParam", "evalx", "xlave", "eval", true); + } - @Test - public void testJsonWithPaddingCallbackAndQueryCallbackParamNegative() throws Exception { - test("JsonWithPaddingCallbackAndQueryCallbackParam", "eval", "run", "parse", true); - } + @Test + public void testJsonWithPaddingCallback() throws Exception { + test("JsonWithPaddingCallback", "eval", "eval"); + } - @Test - public void testJsonWithPaddingCallbackAndQueryCallbackParamDefault() throws Exception { - test("JsonWithPaddingCallbackAndQueryCallbackParam", "evalx", "parse"); - } + @Test + public void testJsonWithPaddingCallbackNegative() throws Exception { + test("JsonWithPaddingCallback", "eval", "lave", true); + } - @Test - public void testJsonWithPaddingCallbackAndQueryCallbackParamDefaultNegative() throws Exception { - test("JsonWithPaddingCallbackAndQueryCallbackParam", "evalx", "xlave", "eval", true); - } + private void test(final String path, final String callback) { + test(path, null, null, callback); + } - @Test - public void testJsonWithPaddingCallback() throws Exception { - test("JsonWithPaddingCallback", "eval", "eval"); - } + private void test(final String path, final String queryParamName, final String callback) { + test(path, queryParamName, callback, callback, false); + } - @Test - public void testJsonWithPaddingCallbackNegative() throws Exception { - test("JsonWithPaddingCallback", "eval", "lave", true); - } + private void test(final String path, final String queryParamName, final String callback, final boolean isNegative) { + test(path, queryParamName, callback, callback, isNegative); + } - private void test(final String path, final String callback) { - test(path, null, null, callback); - } + private void test(final String path, final String queryParamName, final String queryParamValue, final String callback) { + test(path, queryParamName, queryParamValue, callback, false); + } - private void test(final String path, final String queryParamName, final String callback) { - test(path, queryParamName, callback, callback, false); - } + private void test(final String path, final String queryParamName, final String queryParamValue, final String callback, + final boolean isNegative) { - private void test(final String path, final String queryParamName, final String callback, final boolean isNegative) { - test(path, queryParamName, callback, callback, isNegative); - } + WebTarget tempTarget = target("jsonp").path(path); + if (queryParamName != null) { + tempTarget = tempTarget.queryParam(queryParamName, queryParamValue); + } - private void test(final String path, final String queryParamName, final String queryParamValue, final String callback) { - test(path, queryParamName, queryParamValue, callback, false); - } + final Response response = tempTarget.request("application/x-javascript").get(); - private void test(final String path, final String queryParamName, final String queryParamValue, final String callback, - final boolean isNegative) { + assertThat(response.getStatus(), equalTo(200)); + assertThat(response.getMediaType().toString(), equalTo("application/x-javascript")); - WebTarget tempTarget = target("jsonp").path(path); - if (queryParamName != null) { - tempTarget = tempTarget.queryParam(queryParamName, queryParamValue); - } + final String entity = response.readEntity(String.class); - final Response response = tempTarget.request("application/x-javascript").get(); + // Check the entity. + final Matcher startsWith = startsWith(callback + "("); + final Matcher endsWith = endsWith(")"); - assertThat(response.getStatus(), equalTo(200)); - assertThat(response.getMediaType().toString(), equalTo("application/x-javascript")); + final Matcher callbackMatcher = isNegative ? not(startsWith) : startsWith; - final String entity = response.readEntity(String.class); + assertThat(errorMessage, entity, allOf(callbackMatcher, endsWith)); + } + } - // Check the entity. - final Matcher startsWith = startsWith(callback + "("); - final Matcher endsWith = endsWith(")"); + private static Application configureJaxrsApplication(final JsonTestProvider jsonTestProvider) { + final ResourceConfig resourceConfig = new ResourceConfig() + .registerClasses(JsonResource.class) + .register(jsonTestProvider.getFeature()); - final Matcher callbackMatcher = isNegative ? not(startsWith) : startsWith; + if (jsonTestProvider.getProviders() != null) { + resourceConfig.registerInstances(jsonTestProvider.getProviders()); + } - assertThat(errorMessage, entity, allOf(callbackMatcher, endsWith)); + return resourceConfig; } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithoutExceptionMapperTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithoutExceptionMapperTest.java index dfb07f7713..1db9c6fee6 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithoutExceptionMapperTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JsonWithoutExceptionMapperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -19,8 +19,8 @@ import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.annotation.Priority; import javax.ws.rs.client.Entity; @@ -64,7 +64,7 @@ protected Application configure() { public void testZullBooleanValue() { String response = target().request(MediaType.APPLICATION_JSON) .buildPost(Entity.entity("zull", MediaType.APPLICATION_JSON_TYPE)).invoke().readEntity(String.class); - Assert.assertFalse(response.contains("zull")); - Assert.assertTrue(response.equals(LowPriorityExceptionMapper.class.getSimpleName())); + Assertions.assertFalse(response.contains("zull")); + Assertions.assertTrue(response.equals(LowPriorityExceptionMapper.class.getSimpleName())); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/PojoTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/PojoTest.java index 26475b4c6c..84fb2ce39e 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/PojoTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/PojoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -16,40 +16,36 @@ package org.glassfish.jersey.tests.e2e.json; +import java.util.ArrayList; import java.util.Collection; -import java.util.LinkedList; import java.util.List; +import org.glassfish.jersey.test.spi.TestHelper; +import org.glassfish.jersey.tests.e2e.json.JsonTest.JsonTestSetup; import org.glassfish.jersey.tests.e2e.json.entity.pojo.PojoAnimal; import org.glassfish.jersey.tests.e2e.json.entity.pojo.PojoAnimalList; import org.glassfish.jersey.tests.e2e.json.entity.pojo.PojoCat; import org.glassfish.jersey.tests.e2e.json.entity.pojo.PojoDog; - -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.TestFactory; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class PojoTest extends AbstractJsonTest { +public class PojoTest { - @Parameterized.Parameters(name = "{0}") - public static Collection generateTestCases() throws Exception { - final List jsonTestSetups = new LinkedList<>(); + @TestFactory + public Collection generateTests() throws Exception { + List tests = new ArrayList<>(); final Class[] classes = {PojoAnimalList.class, PojoAnimal.class, PojoDog.class, PojoCat.class}; for (final JsonTestProvider jsonProvider : JsonTestProvider.POJO_PROVIDERS) { - jsonTestSetups.add(new JsonTestSetup[]{ - new JsonTestSetup(classes, jsonProvider) - }); + JsonTestSetup setupTest = new JsonTestSetup(classes, jsonProvider); + JsonTest jsonTest = new JsonTest(setupTest) {}; + tests.add(TestHelper.toTestContainer(jsonTest, + String.format("pojoTest (%s)", jsonProvider.getClass().getSimpleName()))); } - return jsonTestSetups; - } - - public PojoTest(final JsonTestSetup jsonTestSetup) throws Exception { - super(jsonTestSetup); + return tests; } - } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterCloseTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterCloseTest.java index 3edcf338e1..866f8f7836 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterCloseTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterCloseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -43,8 +43,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test broadcaster behaviour when closing. @@ -140,12 +140,12 @@ public void testBroadcasterKeepsSendingAfterCLose() throws InterruptedException .resolveTemplate("msg", "msg" + i) .request() .get(); - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); }); // instruct broadcaster to close final Response response = target().path("events/close").request().get(); - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); // send one more message (should be rejected -> request will fail) final Response badResponse = target() @@ -153,19 +153,19 @@ public void testBroadcasterKeepsSendingAfterCLose() throws InterruptedException .resolveTemplate("msg", "too-late") .request() .get(); - Assert.assertNotEquals(Response.Status.OK.getStatusCode(), badResponse.getStatus()); + Assertions.assertNotEquals(Response.Status.OK.getStatusCode(), badResponse.getStatus()); // wait up to latency * msgcount (+1 as reserve) before the server shuts down - Assert.assertTrue(onCompleteLatch.await(SLOW_SUBSCRIBER_LATENCY * (MSG_COUNT + 1), TimeUnit.MILLISECONDS)); + Assertions.assertTrue(onCompleteLatch.await(SLOW_SUBSCRIBER_LATENCY * (MSG_COUNT + 1), TimeUnit.MILLISECONDS)); // get data gathered by the slow subsciber String result = target().path("events/result").request().get(String.class); final String[] resultArray = result.split(","); // check, that broadcaster sent all the buffered events to the subscriber before completely closing - Assert.assertEquals(MSG_COUNT, resultArray.length); + Assertions.assertEquals(MSG_COUNT, resultArray.length); for (int i = 0; i < MSG_COUNT; i++) { - Assert.assertEquals("msg" + i, resultArray[i]); + Assertions.assertEquals("msg" + i, resultArray[i]); } } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterExecutorTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterExecutorTest.java index 9d1249c5ed..2a6caf4623 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterExecutorTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterExecutorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -44,8 +44,8 @@ import org.glassfish.jersey.spi.ThreadPoolExecutorProvider; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Managed executor service injection and propagation into broadcaster test. @@ -166,15 +166,15 @@ public void test() throws InterruptedException { target().path("sse/push/firstBroadcast").request().get(String.class); target().path("sse/push/secondBroadcast").request().get(String.class); - Assert.assertTrue("txLatch time-outed.", txLatch.await(2000, TimeUnit.MILLISECONDS)); + Assertions.assertTrue(txLatch.await(2000, TimeUnit.MILLISECONDS), "txLatch time-outed."); target().path("sse/close").request().get(); - Assert.assertTrue("closeLatch time-outed.", closeLatch.await(2000, TimeUnit.MILLISECONDS)); + Assertions.assertTrue(closeLatch.await(2000, TimeUnit.MILLISECONDS), "closeLatch time-outed."); - Assert.assertTrue("send either not invoked at all or from wrong thread", sendThreadOk); - Assert.assertTrue("onComplete either not invoked at all or from wrong thread", onCompleteThreadOk); + Assertions.assertTrue(sendThreadOk, "send either not invoked at all or from wrong thread"); + Assertions.assertTrue(onCompleteThreadOk, "onComplete either not invoked at all or from wrong thread"); - Assert.assertTrue("Client event called from wrong thread ( " + onEventThreadName[0] + ")", - onEventThreadName[0].startsWith("custom-client-executor")); + Assertions.assertTrue(onEventThreadName[0].startsWith("custom-client-executor"), + "Client event called from wrong thread ( " + onEventThreadName[0] + ")"); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterTest.java index 0fc1d28956..9cf94cc9fb 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/BroadcasterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -19,8 +19,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.inject.Singleton; import javax.ws.rs.GET; @@ -166,8 +166,8 @@ public void test() throws InterruptedException { eventSourceA.register(event -> resultsA2.add(event.readData())); eventSourceA.open(); - Assert.assertTrue(resultsA1.waitBroadcast()); //some delay is required to process consumer and producer - Assert.assertTrue(resultsA2.waitBroadcast()); //some delay is required to process consumer and producer + Assertions.assertTrue(resultsA1.waitBroadcast()); //some delay is required to process consumer and producer + Assertions.assertTrue(resultsA2.waitBroadcast()); //some delay is required to process consumer and producer target().path("sse/push/firstBroadcast").request().get(String.class); @@ -180,56 +180,56 @@ public void test() throws InterruptedException { eventSourceB.register(event -> resultsB2.add(event.readData())); eventSourceB.open(); - Assert.assertTrue(resultsB1.waitBroadcast()); //some delay is required to process consumer and producer - Assert.assertTrue(resultsB2.waitBroadcast()); //some delay is required to process consumer and producer + Assertions.assertTrue(resultsB1.waitBroadcast()); //some delay is required to process consumer and producer + Assertions.assertTrue(resultsB2.waitBroadcast()); //some delay is required to process consumer and producer target().path("sse/push/secondBroadcast").request().get(String.class); - Assert.assertTrue("Waiting for resultsA1 to be complete failed.", - resultsA1.getEventCountDown().await(ASYNC_WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - Assert.assertTrue("Waiting for resultsA2 to be complete failed.", - resultsA2.getEventCountDown().await(ASYNC_WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + Assertions.assertTrue(resultsA1.getEventCountDown().await(ASYNC_WAIT_TIMEOUT, TimeUnit.MILLISECONDS), + "Waiting for resultsA1 to be complete failed."); + Assertions.assertTrue(resultsA2.getEventCountDown().await(ASYNC_WAIT_TIMEOUT, TimeUnit.MILLISECONDS), + "Waiting for resultsA2 to be complete failed."); - Assert.assertTrue("Waiting for resultsB1 to be complete failed.", - resultsB1.getEventCountDown().await(ASYNC_WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - Assert.assertTrue("Waiting for resultsB2 to be complete failed.", - resultsB2.getEventCountDown().await(ASYNC_WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + Assertions.assertTrue(resultsB1.getEventCountDown().await(ASYNC_WAIT_TIMEOUT, TimeUnit.MILLISECONDS), + "Waiting for resultsB1 to be complete failed."); + Assertions.assertTrue(resultsB2.getEventCountDown().await(ASYNC_WAIT_TIMEOUT, TimeUnit.MILLISECONDS), + "Waiting for resultsB2 to be complete failed."); - Assert.assertTrue(txLatch.await(5000, TimeUnit.MILLISECONDS)); + Assertions.assertTrue(txLatch.await(5000, TimeUnit.MILLISECONDS)); // Event1, Event2, Event3, firstBroadcast, secondBroadcast - Assert.assertEquals("resultsA1 does not contain 5 elements.", 5, resultsA1.size()); - Assert.assertEquals("resultsA2 does not contain 5 elements.", 5, resultsA2.size()); - Assert.assertTrue("resultsA1 does not contain expected data", - resultsA1.get(0).equals("Event1") + Assertions.assertEquals(5, resultsA1.size(), "resultsA1 does not contain 5 elements."); + Assertions.assertEquals(5, resultsA2.size(), "resultsA2 does not contain 5 elements."); + Assertions.assertTrue(resultsA1.get(0).equals("Event1") && resultsA1.get(1).equals("Event2") && resultsA1.get(2).equals("Event3") && resultsA1.get(3).equals("firstBroadcast") - && resultsA1.get(4).equals("secondBroadcast")); + && resultsA1.get(4).equals("secondBroadcast"), + "resultsA1 does not contain expected data"); - Assert.assertTrue("resultsA2 does not contain expected data", - resultsA2.get(0).equals("Event1") + Assertions.assertTrue(resultsA2.get(0).equals("Event1") && resultsA2.get(1).equals("Event2") && resultsA2.get(2).equals("Event3") && resultsA2.get(3).equals("firstBroadcast") - && resultsA2.get(4).equals("secondBroadcast")); + && resultsA2.get(4).equals("secondBroadcast"), + "resultsA2 does not contain expected data"); - Assert.assertEquals("resultsB1 does not contain 4 elements.", 4, resultsB1.size()); - Assert.assertEquals("resultsB2 does not contain 4 elements.", 4, resultsB2.size()); - Assert.assertTrue("resultsB1 does not contain expected data", - resultsB1.get(0).equals("Event1") + Assertions.assertEquals(4, resultsB1.size(), "resultsB1 does not contain 4 elements."); + Assertions.assertEquals(4, resultsB2.size(), "resultsB2 does not contain 4 elements."); + Assertions.assertTrue(resultsB1.get(0).equals("Event1") && resultsB1.get(1).equals("Event2") && resultsB1.get(2).equals("Event3") - && resultsB1.get(3).equals("secondBroadcast")); + && resultsB1.get(3).equals("secondBroadcast"), + "resultsB1 does not contain expected data"); - Assert.assertTrue("resultsB2 does not contain expected data", - resultsB2.get(0).equals("Event1") + Assertions.assertTrue(resultsB2.get(0).equals("Event1") && resultsB2.get(1).equals("Event2") && resultsB2.get(2).equals("Event3") - && resultsB2.get(3).equals("secondBroadcast")); + && resultsB2.get(3).equals("secondBroadcast"), + "resultsB2 does not contain expected data"); target().path("sse/close").request().get(); closeLatch.await(); - Assert.assertTrue("Sse instances injected into resource and constructor differ. Sse should have been injected" - + "as a singleton", isSingleton); + Assertions.assertTrue(isSingleton, "Sse instances injected into resource and constructor differ. " + + "Sse should have been injected as a singleton"); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/EventOutputTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/EventOutputTest.java index 6f43bda1a7..5eb2071dba 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/EventOutputTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/EventOutputTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -46,12 +46,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Event output tests. @@ -178,12 +178,12 @@ public void onEvent(InboundEvent inboundEvent) { closeTimedOut = es.close(5, TimeUnit.SECONDS); } - assertEquals("Unexpected event count", 2, eventComments.size()); + assertEquals(2, eventComments.size(), "Unexpected event count"); for (int i = 1; i <= 2; i++) { - assertEquals("Unexpected comment data on event #" + i, "No comment #" + i, eventComments.poll()); + assertEquals("No comment #" + i, eventComments.poll(), "Unexpected comment data on event #" + i); } - assertTrue("Event latch has timed out", latchTimedOut); - assertTrue("EventSource.close() has timed out", closeTimedOut); + assertTrue(latchTimedOut, "Event latch has timed out"); + assertTrue(closeTimedOut, "EventSource.close() has timed out"); } @Test @@ -263,9 +263,9 @@ public void onEvent(InboundEvent inboundEvent) { closeTimedOut = es.close(5, TimeUnit.SECONDS); } - assertEquals("Unexpected event count", 1, counter.get()); - assertEquals("Unexpected event data", "single", eventData.get()); - assertTrue("Event latch has timed out", latchTimedOut); - assertTrue("EventSource.close() has timed out", closeTimedOut); + assertEquals(1, counter.get(), "Unexpected event count"); + assertEquals("single", eventData.get(), "Unexpected event data"); + assertTrue(latchTimedOut, "Event latch has timed out"); + assertTrue(closeTimedOut, "EventSource.close() has timed out"); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/EventSourceWithNamedEventsTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/EventSourceWithNamedEventsTest.java index 28f9edf026..64b3c285a4 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/EventSourceWithNamedEventsTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/EventSourceWithNamedEventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -40,8 +40,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests handling of SSEs with name defined in {@link EventSource}. @@ -128,8 +128,8 @@ public void onEvent(InboundEvent inboundEvent) { try { final Integer data = inboundEvent.readData(Integer.class); System.out.println(inboundEvent.getName() + "; " + data); - Assert.assertEquals(SSE_NAME, inboundEvent.getName()); - Assert.assertEquals(MSG_COUNT - count.getCount(), data.intValue()); + Assertions.assertEquals(SSE_NAME, inboundEvent.getName()); + Assertions.assertEquals(MSG_COUNT - count.getCount(), data.intValue()); count.countDown(); } catch (ProcessingException ex) { throw new RuntimeException("Error when deserializing of data.", ex); @@ -139,8 +139,8 @@ public void onEvent(InboundEvent inboundEvent) { eventSource.register(listener, "message-to-client"); eventSource.open(); final boolean sent = latch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS); - Assert.assertTrue("Awaiting for SSE message has timeout. Not all message were sent.", sent); + Assertions.assertTrue(sent, "Awaiting for SSE message has timeout. Not all message were sent."); final boolean handled = count.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS); - Assert.assertTrue("Awaiting for SSE message has timeout. Not all message were handled by the listener.", handled); + Assertions.assertTrue(handled, "Awaiting for SSE message has timeout. Not all message were handled by the listener."); } } diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/GenericEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/GenericEntityTest.java index a19e16cefc..f481d071ca 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/GenericEntityTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/GenericEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022 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 @@ -19,7 +19,7 @@ import java.util.Objects; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.inject.Singleton; import javax.ws.rs.GET; @@ -49,8 +49,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import static junit.framework.TestCase.assertEquals; -import static junit.framework.TestCase.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; public class GenericEntityTest extends JerseyTest { private static final int BUFFER_SIZE = 20; @@ -107,10 +108,12 @@ public void testGenericList() throws InterruptedException { } - @Test(expected = IllegalArgumentException.class) + @Test public void testRegisterNull() { - final SseEventSource source = SseEventSource.target(target("genericentityresource/string")).build(); - source.register(null); + assertThrows(IllegalArgumentException.class, () -> { + final SseEventSource source = SseEventSource.target(target("genericentityresource/string")).build(); + source.register(null); + }); } @Singleton diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/SseCustomEventImplTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/SseCustomEventImplTest.java index 61abaa5e04..d15ab70128 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/SseCustomEventImplTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/SseCustomEventImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -44,8 +44,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test that {@link org.glassfish.jersey.media.sse.OutboundEventWriter} works with custom @@ -91,11 +91,11 @@ public void testWithJaxRsAPI() { eventSource.open(); final boolean allReceived = receivedLatch.await(5000, TimeUnit.MILLISECONDS); - Assert.assertTrue(allReceived); - Assert.assertEquals(3, results.size()); - Assert.assertEquals("foo", results.get(0).readData()); - Assert.assertEquals("bar", results.get(1).readData()); - Assert.assertEquals("baz", results.get(2).readData()); + Assertions.assertTrue(allReceived); + Assertions.assertEquals(3, results.size()); + Assertions.assertEquals("foo", results.get(0).readData()); + Assertions.assertEquals("bar", results.get(1).readData()); + Assertions.assertEquals("baz", results.get(2).readData()); } catch (final InterruptedException e) { e.printStackTrace(); } @@ -112,18 +112,18 @@ public void testWithJerseyAPI() throws InterruptedException { try { results.add(inboundEvent.readData()); receiveLatch.countDown(); - Assert.assertEquals(SSE_EVENT_NAME, inboundEvent.getName()); + Assertions.assertEquals(SSE_EVENT_NAME, inboundEvent.getName()); } catch (ProcessingException ex) { throw new RuntimeException("Error when deserializing of data.", ex); } }; eventSource.register(listener, SSE_EVENT_NAME); eventSource.open(); - Assert.assertTrue(receiveLatch.await(5000, TimeUnit.MILLISECONDS)); - Assert.assertEquals(3, results.size()); - Assert.assertEquals("foo", results.get(0)); - Assert.assertEquals("bar", results.get(1)); - Assert.assertEquals("baz", results.get(2)); + Assertions.assertTrue(receiveLatch.await(5000, TimeUnit.MILLISECONDS)); + Assertions.assertEquals(3, results.size()); + Assertions.assertEquals("foo", results.get(0)); + Assertions.assertEquals("bar", results.get(1)); + Assertions.assertEquals("baz", results.get(2)); } static class MyOutboundEvent implements OutboundSseEvent { diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/SseEventSinkToEventSourceTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/SseEventSinkToEventSourceTest.java index 53a9f45ae3..4e86ec1ec6 100644 --- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/SseEventSinkToEventSourceTest.java +++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/sse/SseEventSinkToEventSourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -45,8 +45,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * JAX-RS {@link SseEventSource} and {@link SseEventSink} test. @@ -117,9 +117,9 @@ public void testWithSimpleSubscriber() { eventSource.open(); final boolean allTransmitted = transmitLatch.await(5000, TimeUnit.MILLISECONDS); final boolean allReceived = receivedLatch.await(5000, TimeUnit.MILLISECONDS); - Assert.assertTrue(allTransmitted); - Assert.assertTrue(allReceived); - Assert.assertEquals(30, results.size()); + Assertions.assertTrue(allTransmitted); + Assertions.assertTrue(allReceived); + Assertions.assertEquals(30, results.size()); } catch (final InterruptedException e) { e.printStackTrace(); } @@ -137,16 +137,16 @@ public void testWithJerseyApi() throws InterruptedException { try { results.add(inboundEvent.readData(Integer.class)); receiveLatch.countDown(); - Assert.assertEquals(INTEGER_SSE_NAME, inboundEvent.getName()); + Assertions.assertEquals(INTEGER_SSE_NAME, inboundEvent.getName()); } catch (ProcessingException ex) { throw new RuntimeException("Error when deserializing of data.", ex); } }; eventSource.register(listener, INTEGER_SSE_NAME); eventSource.open(); - Assert.assertTrue(transmitLatch.await(5000, TimeUnit.MILLISECONDS)); - Assert.assertTrue(receiveLatch.await(5000, TimeUnit.MILLISECONDS)); - Assert.assertEquals(10, results.size()); + Assertions.assertTrue(transmitLatch.await(5000, TimeUnit.MILLISECONDS)); + Assertions.assertTrue(receiveLatch.await(5000, TimeUnit.MILLISECONDS)); + Assertions.assertEquals(10, results.size()); } @@ -164,15 +164,13 @@ public void testWithEventSource() throws InterruptedException { eventSource.open(); final boolean sent = transmitLatch.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS); - Assert.assertTrue("Awaiting for SSE message has timeout. Not all message were sent.", sent); + Assertions.assertTrue(sent, "Awaiting for SSE message has timeout. Not all message were sent."); final boolean handled2 = count2.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS); - Assert.assertTrue( - "Awaiting for SSE message has timeout. Not all message were handled by eventSource2.", handled2); + Assertions.assertTrue(handled2, "Awaiting for SSE message has timeout. Not all message were handled by eventSource2."); final boolean handled1 = count1.await(5 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS); - Assert.assertTrue( - "Awaiting for SSE message has timeout. Not all message were handled by eventSource1.", handled1); + Assertions.assertTrue(handled1, "Awaiting for SSE message has timeout. Not all message were handled by eventSource1."); } diff --git a/tests/e2e-inject/cdi-inject-weld/pom.xml b/tests/e2e-inject/cdi-inject-weld/pom.xml index 46c3cd6a90..73363d900c 100644 --- a/tests/e2e-inject/cdi-inject-weld/pom.xml +++ b/tests/e2e-inject/cdi-inject-weld/pom.xml @@ -79,8 +79,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/EventsTest.java b/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/EventsTest.java index 4c0cb297b8..987a1e66cc 100644 --- a/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/EventsTest.java +++ b/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/EventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -25,10 +25,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests that the resource can fire an event. @@ -39,11 +40,12 @@ public class EventsTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -53,6 +55,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { diff --git a/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/InterceptorDecoratorTest.java b/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/InterceptorDecoratorTest.java index a7752bdcab..acb29a9407 100644 --- a/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/InterceptorDecoratorTest.java +++ b/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/InterceptorDecoratorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -24,10 +24,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests that the resource can be intercepted and decorated. @@ -38,11 +39,12 @@ public class InterceptorDecoratorTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -52,6 +54,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { diff --git a/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/scopes/ScopesTest.java b/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/scopes/ScopesTest.java index 9f7522b111..f88b1e2501 100644 --- a/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/scopes/ScopesTest.java +++ b/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/scopes/ScopesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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,9 +20,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; /** * Tests CDI resources. @@ -31,6 +33,7 @@ public class ScopesTest extends JerseyTest { private Weld weld; + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -38,6 +41,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); diff --git a/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/subresources/ModelProcessorScopeTest.java b/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/subresources/ModelProcessorScopeTest.java index a26cb29654..58d2e5bbd6 100644 --- a/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/subresources/ModelProcessorScopeTest.java +++ b/tests/e2e-inject/cdi-inject-weld/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/weld/subresources/ModelProcessorScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -21,14 +21,13 @@ import org.glassfish.jersey.server.ApplicationHandler; import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.tests.e2e.inject.cdi.weld.RequestContextBuilder; import org.jboss.weld.environment.se.Weld; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test scope of resources enhanced by model processors. @@ -40,13 +39,13 @@ public class ModelProcessorScopeTest { private Weld weld; - @Before + @BeforeEach public void setUp() throws Exception { weld = new Weld(); weld.initialize(); } - @After + @AfterEach public void tearDown() throws Exception { weld.shutdown(); } diff --git a/tests/e2e-inject/cdi2-se/pom.xml b/tests/e2e-inject/cdi2-se/pom.xml index 4af136d12d..31a1f13261 100644 --- a/tests/e2e-inject/cdi2-se/pom.xml +++ b/tests/e2e-inject/cdi2-se/pom.xml @@ -64,8 +64,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/EventsTest.java b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/EventsTest.java index e47ba14494..58349985ab 100644 --- a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/EventsTest.java +++ b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/EventsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests that the resource can fire an event. diff --git a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/InterceptorDecoratorTest.java b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/InterceptorDecoratorTest.java index b3f70a3c91..fa9a281f2b 100644 --- a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/InterceptorDecoratorTest.java +++ b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/InterceptorDecoratorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests that the resource can be intercepted and decorated. diff --git a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/scopes/ScopesTest.java b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/scopes/ScopesTest.java index 96be176343..baeb657a48 100644 --- a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/scopes/ScopesTest.java +++ b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/scopes/ScopesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -19,9 +19,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; /** * Tests CDI resources. diff --git a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/subresources/ModelProcessorScopeTest.java b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/subresources/ModelProcessorScopeTest.java index c431a650ad..3545f4c237 100644 --- a/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/subresources/ModelProcessorScopeTest.java +++ b/tests/e2e-inject/cdi2-se/src/test/java/org/glassfish/jersey/tests/e2e/inject/cdi/se/subresources/ModelProcessorScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.tests.e2e.inject.cdi.se.RequestContextBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test scope of resources enhanced by model processors. diff --git a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderClassTest.java b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderClassTest.java index d4587014ec..6634e8300c 100644 --- a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderClassTest.java +++ b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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,7 +18,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.inject.Singleton; import javax.ws.rs.core.Application; diff --git a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderInFeaturesTest.java b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderInFeaturesTest.java index 7a348e2046..04ddf1159c 100644 --- a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderInFeaturesTest.java +++ b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderInFeaturesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -19,7 +19,7 @@ import org.glassfish.jersey.internal.inject.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderInstanceTest.java b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderInstanceTest.java index 97113ab7ed..e825e473eb 100644 --- a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderInstanceTest.java +++ b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderInstanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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,7 +18,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.inject.Singleton; import javax.ws.rs.core.Application; diff --git a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderTest.java b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderTest.java index d7a6547907..f544adbc3c 100644 --- a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderTest.java +++ b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/HK2AbstractBinderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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,7 +18,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.inject.Singleton; import javax.ws.rs.core.Application; diff --git a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/JerseyAbstractBinderTest.java b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/JerseyAbstractBinderTest.java index 36a969e771..b342ad64d6 100644 --- a/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/JerseyAbstractBinderTest.java +++ b/tests/e2e-inject/hk2/src/test/java/org/glassfish/jersey/tests/e2e/inject/hk2/JerseyAbstractBinderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -19,7 +19,7 @@ import org.glassfish.jersey.internal.inject.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.inject.Singleton; import javax.ws.rs.core.Application; diff --git a/tests/e2e-server/pom.xml b/tests/e2e-server/pom.xml index 2579e9ee5d..8238980ed9 100644 --- a/tests/e2e-server/pom.xml +++ b/tests/e2e-server/pom.xml @@ -180,6 +180,12 @@ jersey-test-framework-util test + + org.junit.platform + junit-platform-suite + ${junit-platform-suite.version} + test + org.hamcrest @@ -188,8 +194,8 @@ - xmlunit - xmlunit + org.xmlunit + xmlunit-core test diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AbstractDisableMetainfServicesLookupTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AbstractDisableMetainfServicesLookupTest.java index 60b1902836..ddd0b8303a 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AbstractDisableMetainfServicesLookupTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AbstractDisableMetainfServicesLookupTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -49,7 +49,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; +import org.junit.jupiter.api.Assertions; /** * This is base for tests testing enabling/disabling configuration property @@ -63,24 +63,24 @@ protected void testGet(int expectedGetResponseCode, int expectedPostResponseCode final String name = "Jersey"; { Response response = target("/").path(name).request().get(); - Assert.assertEquals(expectedGetResponseCode, response.getStatus()); + Assertions.assertEquals(expectedGetResponseCode, response.getStatus()); if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { UselessMessage entity = response.readEntity(UselessMessage.class); if (entity != null) { - Assert.assertEquals("Hello " + name, entity.getMessage()); + Assertions.assertEquals("Hello " + name, entity.getMessage()); } } } { Entity uselessMessageEntity = Entity.entity(new UselessMessage(name), MediaType.TEXT_PLAIN_TYPE); Response response = target("/").request().post(uselessMessageEntity); - Assert.assertEquals(expectedPostResponseCode, response.getStatus()); + Assertions.assertEquals(expectedPostResponseCode, response.getStatus()); if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) { String entity = response.readEntity(String.class); if (entity.length() > 0) { - Assert.assertEquals(name, entity); + Assertions.assertEquals(name, entity); } } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AllInjectablesTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AllInjectablesTest.java index 069b031c34..5e8d2d81fd 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AllInjectablesTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AllInjectablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -37,10 +37,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Paul Sandoz diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AmbigousResourceMethodTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AmbigousResourceMethodTest.java index 9eb249e4bd..6b0526e052 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AmbigousResourceMethodTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AmbigousResourceMethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test of validation of resources as an end-to-end test. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AppNameBindingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AppNameBindingTest.java index 6f1df29cee..5a3d65a9c0 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AppNameBindingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AppNameBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AppNameBindingTest2.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AppNameBindingTest2.java index a9e90020c5..c3d8087ad5 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AppNameBindingTest2.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AppNameBindingTest2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -43,8 +43,8 @@ import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test {@link NameBinding name binding} annotations on the {@link Application} class. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ArrayParamConverterTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ArrayParamConverterTest.java index e6f2cc510c..625dbb9a5e 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ArrayParamConverterTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ArrayParamConverterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ArrayParamConverterTest extends JerseyTest { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AsyncCallbackTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AsyncCallbackTest.java index 30df0369db..d471fba4e5 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AsyncCallbackTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AsyncCallbackTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,9 +35,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests {@link ConnectionCallback connection callback}. @@ -103,13 +103,12 @@ public void countDown() { @Override public void await() throws InterruptedException { final boolean success = super.await(10 * multiplier, TimeUnit.SECONDS); - Assert.assertTrue( - Thread.currentThread().getName() + ": Latch [" + name + "] awaiting -> timeout!!!", - success); + Assertions.assertTrue(success, + Thread.currentThread().getName() + ": Latch [" + name + "] awaiting -> timeout!!!"); } } - @Before + @BeforeEach public void setup() { onDisconnectCalled.set(false); streamClosedSignal = new TestLatch(1, "streamClosedSignal", getAsyncTimeoutMultiplier()); @@ -141,7 +140,7 @@ private void _testConnectionCallback(String path) throws IOException, Interrupte response.close(); streamClosedSignal.countDown(); callbackCalledSignal.await(); - Assert.assertTrue(onDisconnectCalled.get()); + Assertions.assertTrue(onDisconnectCalled.get()); } public static class MyConnectionCallback implements ConnectionCallback { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AsyncResponseTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AsyncResponseTest.java index 03d840ebd2..e47897d16e 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AsyncResponseTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/AsyncResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -46,12 +46,12 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Pavel Bucek diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BeanParamExceptionTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BeanParamExceptionTest.java index fa7f37162f..bb5db01650 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BeanParamExceptionTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BeanParamExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -37,8 +37,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BeanParamTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BeanParamTest.java index cb72b3fdef..bf534f5062 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BeanParamTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BeanParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -39,8 +39,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests {@link BeanParam bean param injections}. @@ -59,32 +59,32 @@ protected Application configure() { public void compareBeanWithStandardParams() { FullBean bean = getFullBean(); Response response = doRequest(bean, "resource/compareBean"); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("true", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("true", response.readEntity(String.class)); } @Test public void testSingleFullBean() { FullBean bean = getFullBean(); Response response = doRequest(bean, "resource/singleBean"); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(bean.toString(), response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(bean.toString(), response.readEntity(String.class)); } @Test public void testSingleConstructorInitializedBean() { FullBean bean = getFullBean(); Response response = doRequest(bean, "resource/constructorBean"); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(bean.toString(), response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(bean.toString(), response.readEntity(String.class)); } @Test public void testTwoFullBeans() { FullBean bean = getFullBean(); Response response = doRequest(bean, "resource/twoBeans"); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(bean.toString() + " / " + bean.toString(), response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(bean.toString() + " / " + bean.toString(), response.readEntity(String.class)); } @Test @@ -92,8 +92,8 @@ public void testTwoDifferentBeans() { FullBean fullBean = getFullBean(); SmallBean smallBean = new SmallBean(fullBean); Response response = doRequest(fullBean, "resource/differentBeans"); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(fullBean.toString() + " / " + smallBean.toString(), response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(fullBean.toString() + " / " + smallBean.toString(), response.readEntity(String.class)); } @Test @@ -103,10 +103,10 @@ public void testEncodedBean() { fullBean.setMatrixParam("not-encoded/a?&&+./?"); Response response = doRequest(fullBean, "resource/encodedBean"); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); EncodedBean bean = new EncodedBean("not-encoded/a?&&+./?", "encoded%2Fa%3F%26%26%2B.%2F%3F"); - Assert.assertEquals(bean.toString(), response.readEntity(String.class)); + Assertions.assertEquals(bean.toString(), response.readEntity(String.class)); } private Response doRequest(FullBean bean, String path) { @@ -489,8 +489,8 @@ public String post() { public void testResourceInitializedBySetter() { FullBean bean = getFullBean(); final Response response = doRequest(bean, "resource-setter"); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(bean.toString(), response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(bean.toString(), response.readEntity(String.class)); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BroadcasterTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BroadcasterTest.java index 9a967cc70d..cfb2c6e79e 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BroadcasterTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/BroadcasterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula @@ -145,6 +145,6 @@ private void checkStream(String golden, InputStream... inputStreams) throws IOEx } private void checkClosed(int count) { - assertEquals("Closed count does not match", count, closedOutputs.size()); + assertEquals(count, closedOutputs.size(), "Closed count does not match"); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ChunkedInputOutputTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ChunkedInputOutputTest.java index 5a35dd4050..69e75a6e81 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ChunkedInputOutputTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ChunkedInputOutputTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -40,11 +40,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Chunked input/output tests. @@ -178,8 +178,8 @@ protected Application configure() { public void testChunkedOutputToSingleString() throws Exception { final String response = target().path("test").request().get(String.class); - assertEquals("Unexpected value of chunked response unmarshalled as a single string.", - "test\r\ntest\r\ntest\r\n", response); + assertEquals("test\r\ntest\r\ntest\r\n", response, + "Unexpected value of chunked response unmarshalled as a single string."); } /** @@ -195,11 +195,11 @@ public void testChunkedOutputToChunkInput() throws Exception { int counter = 0; String chunk; while ((chunk = input.read()) != null) { - assertEquals("Unexpected value of chunk " + counter, "test", chunk); + assertEquals("test", chunk, "Unexpected value of chunk " + counter); counter++; } - assertEquals("Unexpected numbed of received chunks.", 3, counter); + assertEquals(3, counter, "Unexpected numbed of received chunks."); } /** @@ -216,7 +216,7 @@ public void testInterceptedChunkedOutputToChunkInput() throws Exception { int counter = 0; String chunk; while ((chunk = input.read()) != null) { - assertEquals("Unexpected value of chunk " + counter, "test", chunk); + assertEquals("test", chunk, "Unexpected value of chunk " + counter); counter++; } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ClientResponseOnServerTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ClientResponseOnServerTest.java index e3b2f2bcfb..09be4771d4 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ClientResponseOnServerTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ClientResponseOnServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.Uri; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test for support of client-side response in the server-side resource implementation. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CloseableTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CloseableTest.java index 89bf38d65c..d222327fad 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CloseableTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CloseableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Marc Hadley diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CompletionStageTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CompletionStageTest.java index fb4eafcb68..262bd0eb2f 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CompletionStageTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CompletionStageTest.java @@ -20,7 +20,7 @@ import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.server.ServerRuntime; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -50,9 +50,9 @@ import java.util.function.Function; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ContainerListenerRegistrationAsProvidersTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ContainerListenerRegistrationAsProvidersTest.java index 6543ed4b17..e456efa634 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ContainerListenerRegistrationAsProvidersTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ContainerListenerRegistrationAsProvidersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,9 +24,9 @@ import org.glassfish.jersey.server.spi.Container; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ContentNegotiationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ContentNegotiationTest.java index 77732c7950..a145a9d0ab 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ContentNegotiationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ContentNegotiationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,8 +32,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests determining media type of the response (especially that qs quality parameter is respected when @@ -161,8 +161,8 @@ protected Application configure() { public void testWithoutDefinedRequestedMediaType() { WebTarget target = target().path("/persons"); Response response = target.request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); } @Test @@ -171,54 +171,54 @@ public void testWithoutDefinedRequestedMediaTypeAndTwoMethods() { //From Class javadoc: "The elements in the returned array are not sorted and are not in any particular order." //If there are same endpoints it is necessary to use quality parameter to ensure ordering. Response response = target().path("/persons/twoMethodsOneEndpoint").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_XML_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_XML_TYPE, response.getMediaType()); } @Test public void testWithoutDefinedRequestedMediaTypeOrQualityModifiersJson() { Response response = target().path("/persons/shouldPickFirstJson").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); } @Test public void testWithoutDefinedRequestedMediaTypeOrQualityModifiersXml() { Response response = target().path("/persons/shouldPickFirstXml").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_XML_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_XML_TYPE, response.getMediaType()); } @Test public void test() { WebTarget target = target().path("/persons"); Response response = target.request(MediaType.WILDCARD).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); } @Test public void testInverted() { WebTarget target = target().path("/persons/inverted"); Response response = target.request(MediaType.WILDCARD).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_XML_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_XML_TYPE, response.getMediaType()); } @Test public void testInvertedWithJSONPreferredByClient() { WebTarget target = target().path("/persons/inverted"); Response response = target.request("application/json;q=1.0", "application/xml;q=0.8").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); } @Test public void testReordered() { WebTarget target = target().path("/persons/reordered"); Response response = target.request(MediaType.WILDCARD).get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType()); } /** @@ -230,7 +230,7 @@ public void testWithUnknownTypePreferredByClient() { WebTarget target = target().path("/persons/reordered"); Response response = target.request("application/json;q=0.8", "application/xml;q=0.9", "unknown/hello;qs=1.0").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_XML_TYPE, response.getMediaType()); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(MediaType.APPLICATION_XML_TYPE, response.getMediaType()); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesApplicationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesApplicationTest.java index a9f1a9e2b1..8c30b30815 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesApplicationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesApplicationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -49,11 +49,11 @@ import org.glassfish.jersey.test.DeploymentContext; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; /** * @author Pavel Bucek @@ -147,14 +147,14 @@ public String getAndIncSingleton() { } } - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } @Override protected DeploymentContext configureDeployment() { - // If strategy is not IMMEDIATE then test will fail even before @Before setup method invocation. + // If strategy is not IMMEDIATE then test will fail even before @BeforeEach setup method invocation. // It has no other reason then just run the tests in IMMEDIATE strategy. if (Hk2InjectionManagerFactory.isImmediateStrategy()) { return DeploymentContext.newInstance(MyApplication.class); diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesResourceConfigTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesResourceConfigTest.java index 01acb853a1..04429a7c3d 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesResourceConfigTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomInjectablesResourceConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,8 +35,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomMultivaluedMapProviderTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomMultivaluedMapProviderTest.java index e9088dfc05..f5686877c2 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomMultivaluedMapProviderTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/CustomMultivaluedMapProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -37,9 +37,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests that the Custom MultivaluedMap provider overrides the default diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EncodedFormParamTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EncodedFormParamTest.java index 34d0379c65..62b8a6f151 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EncodedFormParamTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EncodedFormParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Proper encoding of Form params diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EncodedSlashInPathSegmentTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EncodedSlashInPathSegmentTest.java index 79d7ad73a8..a15b95613f 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EncodedSlashInPathSegmentTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EncodedSlashInPathSegmentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test for JERSEY-1167. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EntityExpansionTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EntityExpansionTest.java index fee7de4a02..99f9e43e45 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EntityExpansionTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/EntityExpansionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -38,10 +38,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXParseException; /** @@ -137,14 +137,14 @@ public void setInput(String input) { } } - @BeforeClass + @BeforeAll public static void setXdkFlag() { // XDK SAXParser does not support this feature, so the test has to be skipped if XDK detected. if (SaxHelper.isXdkParserFactory(SAXParserFactory.newInstance())) { LOG.warning("XDK SAXParser detected, FEATURE_SECURE_PROCESSING is not supported. Tests will be skipped."); isXdk = true; } - Assume.assumeTrue(!isXdk); + Assumptions.assumeTrue(!isXdk); } @Test @@ -158,9 +158,9 @@ public void testEntityExpansion() { + "&lol3;"; final Response response = target().path("resource").request().post(Entity.entity(str, MediaType.APPLICATION_XML)); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final String entity = response.readEntity(String.class); - Assert.assertTrue(entity.startsWith("PASSED")); + Assertions.assertTrue(entity.startsWith("PASSED")); } @Test @@ -168,9 +168,9 @@ public void testMaxAttributes() { String str = "" + "test"; final Response response = target().path("resource").request().post(Entity.entity(str, MediaType.APPLICATION_XML)); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); final String entity = response.readEntity(String.class); - Assert.assertTrue(entity.startsWith("PASSED")); + Assertions.assertTrue(entity.startsWith("PASSED")); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionLoggingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionLoggingTest.java index 8f1c138831..eca6d05e31 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionLoggingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionLoggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -37,8 +37,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Make sure exceptions, that are not mapped to responses get logged. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperPriorityTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperPriorityTest.java index 1142e12a15..be846672ad 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperPriorityTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperPriorityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -28,9 +28,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Pavel Bucek diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperPropagationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperPropagationTest.java index ef9daf7d5f..4516eaed7f 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperPropagationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperPropagationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -49,12 +49,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test exception mappers handling exceptions thrown from different part of code. @@ -65,7 +65,7 @@ * @author Miroslav Fuksa * */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ExceptionMapperPropagationTest extends JerseyTest { public static final String EXCEPTION_TYPE = "exception-type"; @@ -298,186 +298,222 @@ private static void throwRuntimeExceptionAndIO(String exceptionType, Class pr // Resource @Test + @Execution(ExecutionMode.CONCURRENT) public void testCheckedExceptionInResource() { _test(TestCheckedException.class, ExceptionResource.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInResource() { _test(TestRuntimeException.class, ExceptionResource.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWebApplicationExceptionInResource() { _testWae(ExceptionResource.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInResource() { _test(ProcessingException.class, ExceptionResource.class); } // Sub resource @Test + @Execution(ExecutionMode.CONCURRENT) public void testCheckedExceptionInSubResourceLocatorMethod() { _test(TestCheckedException.class, ExceptionResource.class, "exception/sub"); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInSubResourceLocatorMethod() { _test(TestRuntimeException.class, ExceptionResource.class, "exception/sub"); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWaeInSubResourceLocatorMethod() { _testWae(ExceptionResource.class, "exception/sub"); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInSubResourceLocatorMethod() { _test(ProcessingException.class, ExceptionResource.class, "exception/sub"); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testCheckedExceptionInSubResource() { _test(TestCheckedException.class, SubResourceLocator.class, "exception/sub"); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInSubResource() { _test(TestRuntimeException.class, SubResourceLocator.class, "exception/sub"); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWaeInSubResource() { _testWae(SubResourceLocator.class, "exception/sub"); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInSubResource() { _test(ProcessingException.class, SubResourceLocator.class, "exception/sub"); } // response filters @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInResponseFilter() { _test(TestRuntimeException.class, TestResponseFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testIOExceptionInResponseFilter() { _test(IOException.class, TestResponseFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWaeInResponseFilter() { _testWae(TestResponseFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInResponseFilter() { _test(ProcessingException.class, TestResponseFilter.class); } // response filters @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInRequestFilter() { _test(TestRuntimeException.class, TestRequestFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testIOExceptionInRequestFilter() { _test(IOException.class, TestRequestFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWaeInRequestFilter() { _testWae(TestRequestFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInRequestFilter() { _test(ProcessingException.class, TestRequestFilter.class); } // MBR/W @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInMBW() { _test(TestRuntimeException.class, TestMBW.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testIOExceptionInMBW() { _test(IOException.class, TestMBW.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWaeInMBW() { _testWae(TestMBW.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInMBW() { _test(ProcessingException.class, TestMBW.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInMBR() { _test(TestRuntimeException.class, TestMBR.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testIOExceptionInMBR() { _test(IOException.class, TestMBR.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWaeInMBR() { _testWae(TestMBR.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInMBR() { _test(ProcessingException.class, TestMBR.class); } // interceptors @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInReaderInterceptor() { _test(TestRuntimeException.class, TestReaderInterceptor.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testIOExceptionInReaderInterceptor() { _test(IOException.class, TestReaderInterceptor.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWaeInReaderInterceptor() { _testWae(TestReaderInterceptor.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInReaderInterceptor() { _test(ProcessingException.class, TestReaderInterceptor.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testRuntimeExceptionInWriterInterceptor() { _test(TestRuntimeException.class, TestWriterInterceptor.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testIOExceptionInWriterInterceptor() { _test(IOException.class, TestWriterInterceptor.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testWaeInWriterInterceptor() { _testWae(TestWriterInterceptor.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testProcessingExceptionInWriterInterceptor() { _test(ProcessingException.class, TestWriterInterceptor.class); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperTest.java index 6ebbac531c..f84d80dead 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExceptionMapperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -57,10 +57,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests throwing exceptions in {@link MessageBodyReader} and {@link MessageBodyWriter}. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExtendedExceptionMapperTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExtendedExceptionMapperTest.java index 350b8c4868..91347b7009 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExtendedExceptionMapperTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExtendedExceptionMapperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,9 +33,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Miroslav Fuksa @@ -288,10 +288,10 @@ public void test() { private void _test(String input, String expectedMapper) { final Response response = target("resource").request().post(Entity.entity(input, MediaType.TEXT_PLAIN_TYPE)); if (expectedMapper == null) { - Assert.assertEquals(500, response.getStatus()); + Assertions.assertEquals(500, response.getStatus()); } else { - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(expectedMapper, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(expectedMapper, response.readEntity(String.class)); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExtendedUriInfoTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExtendedUriInfoTest.java index b88f94e42a..8992059c9d 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExtendedUriInfoTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ExtendedUriInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -40,10 +40,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * {@link ExtendedUriInfo} e2e tests - testing e.g. getting matched resources, mapped throwable, etc. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/FormParamMultivaluedInjectionTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/FormParamMultivaluedInjectionTest.java index 8270802683..b75ca4919b 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/FormParamMultivaluedInjectionTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/FormParamMultivaluedInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests that the MultivaluedMap injection does not close the request buffer and allows diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GlobalNameBoundInterceptorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GlobalNameBoundInterceptorTest.java index 5aaec35e7a..a27caae504 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GlobalNameBoundInterceptorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GlobalNameBoundInterceptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -45,8 +45,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests name bound and global bound interceptors. @@ -196,58 +196,59 @@ public Object aroundReadFrom(ReaderInterceptorContext context) throws IOExceptio @Test public void testPrematchingException() { final Response response = target("resource").request().header("pre-filter", "exception").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("mapped-(pre-matching-exception)-[global-bound]", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("mapped-(pre-matching-exception)-[global-bound]", response.readEntity(String.class)); } @Test public void testPrematchingAbort() { final Response response = target("resource").request().header("pre-filter", "abort").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("(pre-matching-abort)-[global-bound]", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("(pre-matching-abort)-[global-bound]", response.readEntity(String.class)); } @Test public void testRequestFilterException() { final Response response = target("resource").request().header("request-filter", "exception").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("mapped-(request-filter-exception)-[global-bound]-[test-bound]", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("mapped-(request-filter-exception)-[global-bound]-[test-bound]", + response.readEntity(String.class)); } @Test public void testRequestFilterAbort() { final Response response = target("resource").request().header("request-filter", "abort").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("(request-filter-abort)-[global-bound]-[test-bound]", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("(request-filter-abort)-[global-bound]-[test-bound]", response.readEntity(String.class)); } @Test public void testStandardResource() { final Response response = target("resource/standard").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("ok-[global-bound]", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("ok-[global-bound]", response.readEntity(String.class)); } @Test public void testTestResource() { final Response response = target("resource").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("get-[global-bound]-[test-bound]", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("get-[global-bound]-[test-bound]", response.readEntity(String.class)); } @Test public void testPost() { final Response response = target("resource/postGlobal").request().post(Entity.entity("post", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("post-[global-reader-interceptor]-[global-bound]", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("post-[global-reader-interceptor]-[global-bound]", response.readEntity(String.class)); } @Test public void testPostBound() { final Response response = target("resource/postBound").request().post(Entity.entity("post", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("post-[global-reader-interceptor]-[post-reader-interceptor]-[global-bound]", + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("post-[global-reader-interceptor]-[post-reader-interceptor]-[global-bound]", response.readEntity(String.class)); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GloballyNameBoundResourceFilterTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GloballyNameBoundResourceFilterTest.java index 3c9076bb31..8cb8403375 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GloballyNameBoundResourceFilterTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GloballyNameBoundResourceFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,11 +35,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * JAX-RS global name-bound filter tests. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GrizzlyInjectionTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GrizzlyInjectionTest.java index 240fe6eaee..1d0ac8074f 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GrizzlyInjectionTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GrizzlyInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -30,9 +30,9 @@ import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test for JERSEY-1170 diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GsonCustomTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GsonCustomTest.java index 3d9f0850f6..a3bdb03077 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GsonCustomTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GsonCustomTest.java @@ -16,7 +16,7 @@ package org.glassfish.jersey.tests.e2e.server; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Date; @@ -31,7 +31,7 @@ import org.glassfish.jersey.gson.JsonGsonFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GsonDefaultTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GsonDefaultTest.java index 724a32864b..1414990c33 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GsonDefaultTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/GsonDefaultTest.java @@ -16,7 +16,7 @@ package org.glassfish.jersey.tests.e2e.server; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -31,7 +31,7 @@ import org.glassfish.jersey.gson.JsonGsonFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GsonDefaultTest extends JerseyTest { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/IllegalArgumentExceptionTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/IllegalArgumentExceptionTest.java index 3e27023f0c..555b1711e5 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/IllegalArgumentExceptionTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/IllegalArgumentExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -32,9 +32,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class IllegalArgumentExceptionTest extends JerseyTest { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InitializationLoggingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InitializationLoggingTest.java index aba53738b5..7d6894dcf2 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InitializationLoggingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InitializationLoggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InjectionManagerServerProviderTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InjectionManagerServerProviderTest.java index d44521a1a4..8ce2adb29d 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InjectionManagerServerProviderTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InjectionManagerServerProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -45,8 +45,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests {@link InjectionManagerProvider}. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InjectionTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InjectionTest.java index 5c38427d0b..3180f17b7b 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InjectionTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -37,10 +37,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Injection E2E tests. @@ -105,23 +105,23 @@ protected Application configure() { * We would need to by-pass these issues in underlying layer to un-ignore the test. */ @Test - @Ignore + @Disabled public void testInjectionIntoDeleteMethod() { Response response; response = target("injection").path("delete-path-param/test").request() .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true) .method("DELETE", Entity.text("body")); - assertNotNull("Response is null.", response); - assertEquals("Unexpected response status.", 200, response.getStatus()); - assertEquals("Unexpected response entity.", "deleted: test-body", response.readEntity(String.class)); + assertNotNull(response, "Response is null."); + assertEquals(200, response.getStatus(), "Unexpected response status."); + assertEquals("deleted: test-body", response.readEntity(String.class), "Unexpected response entity."); response = target("injection").path("delete-path-param-async/test").request() .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true) .method("DELETE", Entity.text("body")); - assertNotNull("Response is null.", response); - assertEquals("Unexpected response status.", 200, response.getStatus()); - assertEquals("Unexpected response entity.", "deleted: test-body", response.readEntity(String.class)); + assertNotNull(response, "Response is null."); + assertEquals(200, response.getStatus(), "Unexpected response status."); + assertEquals("deleted: test-body", response.readEntity(String.class), "Unexpected response entity."); } /** @@ -133,7 +133,7 @@ public void testInjectionIntoDeleteMethod() { public void testAsyncMethodParamInjection() { Response response = target("injection").path("async").request().get(); - assertEquals("Unexpected response status.", 200, response.getStatus()); - assertNotNull("Response is null.", response); + assertEquals(200, response.getStatus(), "Unexpected response status."); + assertNotNull(response, "Response is null."); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InputStreamResponseTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InputStreamResponseTest.java index 593eba14e1..6a8476ad4a 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InputStreamResponseTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InputStreamResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * This is to make sure you can just pass an input stream to Jersey, diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InterceptorHttpHeadersInjectionTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InterceptorHttpHeadersInjectionTest.java index 248c44ca6d..fd6588197d 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InterceptorHttpHeadersInjectionTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InterceptorHttpHeadersInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,9 +35,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for JERSEY-1545. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InterceptorNameAndDynamicBindingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InterceptorNameAndDynamicBindingTest.java index 88aee31ee9..e4bc6f91c3 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InterceptorNameAndDynamicBindingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/InterceptorNameAndDynamicBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -46,8 +46,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/Issue4097Test.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/Issue4097Test.java index c7f08a215c..2395d18a88 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/Issue4097Test.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/Issue4097Test.java @@ -16,7 +16,7 @@ package org.glassfish.jersey.tests.e2e.server; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -26,7 +26,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Issue4097Test extends JerseyTest { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ManagedClientExecutorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ManagedClientExecutorTest.java index 822cb0822a..d588cf5b04 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ManagedClientExecutorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ManagedClientExecutorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -53,8 +53,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Test, that managed client uses the custom executor service. @@ -257,13 +257,13 @@ public SchedulerThreadName readFrom(Class type, Type generi @Test public void testManagedClientExecutor() { final String response = target().path("test/executor").request().get(String.class); - Assert.assertEquals("foo-executor-service-0", response); + Assertions.assertEquals("foo-executor-service-0", response); } @Test public void testManagedClientScheduledExecutor() { final String response = target().path("test/scheduledExecutor").request().get(String.class); - Assert.assertEquals("bar-executor-service bar-executor-service", response); + Assertions.assertEquals("bar-executor-service bar-executor-service", response); System.out.println(response); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MessageBodyProvidersExceptionsTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MessageBodyProvidersExceptionsTest.java index 799337d8cd..ac93f34dd5 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MessageBodyProvidersExceptionsTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MessageBodyProvidersExceptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * JERSEY-2500 reproducer test. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MetainfServicesLookupDisabledTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MetainfServicesLookupDisabledTest.java index 989d872096..90a36d8824 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MetainfServicesLookupDisabledTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MetainfServicesLookupDisabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,7 +21,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Property {@link ServerProperties#METAINF_SERVICES_LOOKUP_DISABLE} IS set. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MetainfServicesLookupEnabledTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MetainfServicesLookupEnabledTest.java index 2e30267db0..a517ff46d3 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MetainfServicesLookupEnabledTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/MetainfServicesLookupEnabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,7 +16,7 @@ package org.glassfish.jersey.tests.e2e.server; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Property {@link org.glassfish.jersey.server.ServerProperties#METAINF_SERVICES_LOOKUP_DISABLE} is NOT set. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ModelProcessorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ModelProcessorTest.java index e0c1c8b710..6964f53839 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ModelProcessorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ModelProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -44,11 +44,12 @@ import org.glassfish.jersey.server.model.ResourceMethod; import org.glassfish.jersey.server.model.ResourceModel; import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.Test; -import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test model processor. @@ -56,7 +57,7 @@ * @author Miroslav Fuksa * */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ModelProcessorTest extends JerseyTest { public static class ModelProcessorFeature implements Feature { @@ -229,6 +230,7 @@ protected Application configure() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceAGet() { Response response = target("/a").request().get(); assertEquals(200, response.getStatus()); @@ -237,6 +239,7 @@ public void testResourceAGet() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceAPost() { Response response = target("/a").request().post(Entity.entity("post", MediaType.TEXT_PLAIN_TYPE)); assertEquals(200, response.getStatus()); @@ -245,6 +248,7 @@ public void testResourceAPost() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceAOptions() { Response response = target("/a").request(MediaType.TEXT_PLAIN_TYPE).options(); assertEquals(200, response.getStatus()); @@ -253,6 +257,7 @@ public void testResourceAOptions() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceAChildGet() { Response response = target("/a/child").request().get(); assertEquals(200, response.getStatus()); @@ -261,6 +266,7 @@ public void testResourceAChildGet() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceALocatorGet() { Response response = target("/a/locator").request().get(); assertEquals(200, response.getStatus()); @@ -269,6 +275,7 @@ public void testResourceALocatorGet() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceALocatorOptions() { Response response = target("/a/locator").request(MediaType.TEXT_PLAIN_TYPE).options(); assertEquals(204, response.getStatus()); @@ -277,6 +284,7 @@ public void testResourceALocatorOptions() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceBGet() { Response response = target("/b").request().get(); assertEquals(200, response.getStatus()); @@ -285,6 +293,7 @@ public void testResourceBGet() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceBOptions() { Response response = target("/b").request(MediaType.TEXT_PLAIN_TYPE).options(); assertEquals(200, response.getStatus()); @@ -293,6 +302,7 @@ public void testResourceBOptions() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceBLocatorGet() { Response response = target("/b/locator").request().get(); assertEquals(200, response.getStatus()); @@ -301,6 +311,7 @@ public void testResourceBLocatorGet() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceBLocatorOptions() { Response response = target("/b/locator").request(MediaType.TEXT_PLAIN_TYPE).options(); assertEquals(204, response.getStatus()); @@ -309,6 +320,7 @@ public void testResourceBLocatorOptions() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceAMyResource() { Response response = target("/a/my-resource").request().get(); assertEquals(200, response.getStatus()); @@ -317,6 +329,7 @@ public void testResourceAMyResource() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceALocatorMyResource() { Response response = target("/a/locator/my-resource").request(MediaType.TEXT_PLAIN_TYPE).get(); assertEquals(200, response.getStatus()); @@ -325,6 +338,7 @@ public void testResourceALocatorMyResource() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceBMyResource() { Response response = target("/b/my-resource").request().get(); assertEquals(200, response.getStatus()); @@ -333,6 +347,7 @@ public void testResourceBMyResource() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testInfo() { Response response = target("/model").request().get(); assertEquals(200, response.getStatus()); diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/NameBindingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/NameBindingTest.java index 02a740c776..8900a3c79e 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/NameBindingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/NameBindingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -41,14 +41,15 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.Test; -import org.junit.runner.RunWith; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test-suite ensuring the correct functionality of name binding. @@ -56,7 +57,7 @@ * @author Miroslav Fuksa * @author Michal Gajdos */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class NameBindingTest extends JerseyTest { @Override @@ -171,11 +172,11 @@ private void checkCalled(final Response response, final Class... filtersThatS final Set> positiveFilters = Arrays.stream(filtersThatShouldBeCalled).collect(Collectors.toSet()); for (final Class filter : FILTERS) { if (positiveFilters.contains(filter)) { - assertEquals("Filter '" + filter.getSimpleName() + "' should be called.", "called", response.getHeaders() - .getFirst(filter.getSimpleName())); + assertEquals("called", response.getHeaders().getFirst(filter.getSimpleName()), + "Filter '" + filter.getSimpleName() + "' should be called."); } else { - assertNull("Filter '" + filter.getSimpleName() + "' should not be called.", response.getHeaders().get(filter - .getSimpleName())); + assertNull(response.getHeaders().get(filter.getSimpleName()), + "Filter '" + filter.getSimpleName() + "' should not be called."); } } } @@ -187,11 +188,13 @@ private Response _getResponse(final String path) { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceNoBinding() { checkCalled(_getResponse("resource")); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceFooBinding() { checkCalled(_getResponse("resource/foo"), FooFilter.class); } @@ -201,6 +204,7 @@ public void testResourceFooBinding() { * invoked for each resource method (globally). */ @Test + @Execution(ExecutionMode.CONCURRENT) public void preMatchingNameBinding() { final Response response = _getResponse("resource/preMatchingNameBinding"); @@ -209,11 +213,13 @@ public void preMatchingNameBinding() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceBarBinding() { checkCalled(_getResponse("resource/bar"), BarFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testResourceFooBarBinding() { checkCalled(_getResponse("resource/foobar"), FooFilter.class, BarFilter.class, FooBarFilter.class); } @@ -225,21 +231,25 @@ public static class FooResource extends Resource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFooResourceNoBinding() { checkCalled(_getResponse("foo-resource"), FooFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFooResourceFooBinding() { checkCalled(_getResponse("foo-resource/foo"), FooFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFooResourceBarBinding() { checkCalled(_getResponse("foo-resource/bar"), FooFilter.class, BarFilter.class, FooBarFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFooResourceFooBarBinding() { checkCalled(_getResponse("foo-resource/foobar"), FooFilter.class, BarFilter.class, FooBarFilter.class); } @@ -251,21 +261,25 @@ public static class BarResource extends Resource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBarResourceNoBinding() { checkCalled(_getResponse("bar-resource"), BarFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBarResourceFooBinding() { checkCalled(_getResponse("bar-resource/foo"), BarFilter.class, FooFilter.class, FooBarFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBarResourceBarBinding() { checkCalled(_getResponse("bar-resource/bar"), BarFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBarResourceFooBarBinding() { checkCalled(_getResponse("bar-resource/foobar"), BarFilter.class, FooFilter.class, FooBarFilter.class); } @@ -278,21 +292,25 @@ public static class FooBarResource extends Resource { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFooBarResourceNoBinding() { checkCalled(_getResponse("foobar-resource"), BarFilter.class, FooFilter.class, FooBarFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFooBarResourceFooBinding() { checkCalled(_getResponse("foobar-resource/foo"), BarFilter.class, FooFilter.class, FooBarFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFooBarResourceBarBinding() { checkCalled(_getResponse("foobar-resource/bar"), BarFilter.class, FooFilter.class, FooBarFilter.class); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFooBarResourceFooBarBinding() { checkCalled(_getResponse("foobar-resource/foobar"), BarFilter.class, FooFilter.class, FooBarFilter.class); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/OptionalParamConverterNoProviderTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/OptionalParamConverterNoProviderTest.java index 162692920a..2092af5b22 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/OptionalParamConverterNoProviderTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/OptionalParamConverterNoProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -16,7 +16,7 @@ package org.glassfish.jersey.tests.e2e.server; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; import java.util.Optional; @@ -32,7 +32,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class OptionalParamConverterNoProviderTest extends JerseyTest { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/OptionalParamConverterTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/OptionalParamConverterTest.java index 5306b217a5..0734c550fc 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/OptionalParamConverterTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/OptionalParamConverterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -37,10 +37,10 @@ import org.glassfish.jersey.internal.inject.ExtractorException; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; public class OptionalParamConverterTest extends JerseyTest { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ParamConverterPriorityTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ParamConverterPriorityTest.java index 6a4991711a..b335bf3749 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ParamConverterPriorityTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ParamConverterPriorityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -34,7 +34,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.typeCompatibleWith; diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ParamConverterTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ParamConverterTest.java index 6ef6bc63b2..ed473a9ad1 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ParamConverterTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ParamConverterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -43,11 +43,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests {@link ParamConverter param converters} as e2e test. @@ -131,7 +131,7 @@ public void testStringParam() { } @Test - @Ignore("TODO: ParamConversion not yet implemented in the ResponseBuilder (JERSEY-1385).") + @Disabled("TODO: ParamConversion not yet implemented in the ResponseBuilder (JERSEY-1385).") // TODO: JERSEY-1385: after clarifying with spec the ResponseBuilder paramconversion should be finished (or removed) public void testStringParamInResponse() { final Response response = target().path("resource/response").request().get(); diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PathEncodingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PathEncodingTest.java index 19abcc3ea3..1ce41716d5 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PathEncodingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PathEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,8 +27,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Testing encoding of {@Path path annotations}. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PerRequestLifecycleTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PerRequestLifecycleTest.java index be234045ee..a7f99f22a1 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PerRequestLifecycleTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PerRequestLifecycleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -33,10 +33,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Marc Hadley diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PostConstructTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PostConstructTest.java index d3812baae8..fe47a28185 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PostConstructTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PostConstructTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,10 +35,10 @@ import org.glassfish.jersey.test.DeploymentContext; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Testing that {@link Context injection} is done before invoking method annotated with {@link PostConstruct}. @@ -94,14 +94,14 @@ public Map getProperties() { } } - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } @Override protected DeploymentContext configureDeployment() { - // If strategy is not IMMEDIATE then test will fail even before @Before setup method invocation. + // If strategy is not IMMEDIATE then test will fail even before @BeforeEach setup method invocation. // It has no other reason then just run the tests in IMMEDIATE strategy. if (Hk2InjectionManagerFactory.isImmediateStrategy()) { return DeploymentContext.newInstance(MyApplication.class); diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PrimitiveTypesTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PrimitiveTypesTest.java index 7dabf96e88..dbf0e19e39 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PrimitiveTypesTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/PrimitiveTypesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,19 +34,20 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.Test; -import org.junit.runner.RunWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * Tests primitive types as entity. * * @author Miroslav Fuksa */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class PrimitiveTypesTest extends JerseyTest { @Override protected ResourceConfig configure() { @@ -54,6 +55,7 @@ protected ResourceConfig configure() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testInteger() { WebTarget web = target().path("test"); Response response = web.path("Integer").request().post(Entity.entity(5, MediaType.TEXT_PLAIN_TYPE)); @@ -62,6 +64,7 @@ public void testInteger() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveInt() { WebTarget web = target().path("test"); Response response = web.path("int").request().post(Entity.entity(5, MediaType.TEXT_PLAIN_TYPE)); @@ -70,6 +73,7 @@ public void testPrimitiveInt() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveIntNull() { WebTarget web = target().path("test"); Response response = web.path("int").request().post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE)); @@ -78,6 +82,7 @@ public void testPrimitiveIntNull() { @Test + @Execution(ExecutionMode.CONCURRENT) public void testLong() { WebTarget web = target().path("test"); Response response = web.path("Long").request().post(Entity.entity(5L, MediaType.TEXT_PLAIN_TYPE)); @@ -86,6 +91,7 @@ public void testLong() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveLong() { WebTarget web = target().path("test"); Response response = web.path("long").request().post(Entity.entity(5L, MediaType.TEXT_PLAIN_TYPE)); @@ -94,6 +100,7 @@ public void testPrimitiveLong() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveLongNull() { WebTarget web = target().path("test"); Response response = web.path("long").request().post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE)); @@ -102,6 +109,7 @@ public void testPrimitiveLongNull() { @Test + @Execution(ExecutionMode.CONCURRENT) public void testShort() { WebTarget web = target().path("test"); Response response = web.path("Short").request().post(Entity.entity((short) 5, MediaType.TEXT_PLAIN_TYPE)); @@ -110,6 +118,7 @@ public void testShort() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveShort() { WebTarget web = target().path("test"); Response response = web.path("short").request().post(Entity.entity((short) 5, MediaType.TEXT_PLAIN_TYPE)); @@ -118,6 +127,7 @@ public void testPrimitiveShort() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveShortNull() { WebTarget web = target().path("test"); Response response = web.path("short").request().post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE)); @@ -125,6 +135,7 @@ public void testPrimitiveShortNull() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testByte() { WebTarget web = target().path("test"); Response response = web.path("Byte").request().post(Entity.entity((byte) 5, MediaType.TEXT_PLAIN_TYPE)); @@ -133,6 +144,7 @@ public void testByte() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveByte() { WebTarget web = target().path("test"); Response response = web.path("byte").request().post(Entity.entity((byte) 5, MediaType.TEXT_PLAIN_TYPE)); @@ -141,6 +153,7 @@ public void testPrimitiveByte() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveByteNull() { WebTarget web = target().path("test"); Response response = web.path("byte").request().post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE)); @@ -148,6 +161,7 @@ public void testPrimitiveByteNull() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testFloat() { WebTarget web = target().path("test"); Response response = web.path("Float").request().post(Entity.entity((float) 5, MediaType.TEXT_PLAIN_TYPE)); @@ -156,6 +170,7 @@ public void testFloat() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveFloat() { WebTarget web = target().path("test"); Response response = web.path("float").request().post(Entity.entity(5f, MediaType.TEXT_PLAIN_TYPE)); @@ -164,6 +179,7 @@ public void testPrimitiveFloat() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveFloatNull() { WebTarget web = target().path("test"); Response response = web.path("float").request().post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE)); @@ -171,6 +187,7 @@ public void testPrimitiveFloatNull() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testDouble() { WebTarget web = target().path("test"); Response response = web.path("Double").request().post(Entity.entity((double) 5, MediaType.TEXT_PLAIN_TYPE)); @@ -179,6 +196,7 @@ public void testDouble() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveDouble() { WebTarget web = target().path("test"); Response response = web.path("double").request().post(Entity.entity(5d, MediaType.TEXT_PLAIN_TYPE)); @@ -187,6 +205,7 @@ public void testPrimitiveDouble() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveDoubleNull() { WebTarget web = target().path("test"); Response response = web.path("double").request().post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE)); @@ -194,6 +213,7 @@ public void testPrimitiveDoubleNull() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testCharacter() { WebTarget web = target().path("test"); Response response = web.path("Character").request().post(Entity.entity('a', MediaType.TEXT_PLAIN_TYPE)); @@ -202,6 +222,7 @@ public void testCharacter() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveCharacter() { WebTarget web = target().path("test"); Response response = web.path("char").request().post(Entity.entity('a', MediaType.TEXT_PLAIN_TYPE)); @@ -210,6 +231,7 @@ public void testPrimitiveCharacter() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveCharacterNull() { WebTarget web = target().path("test"); Response response = web.path("char").request().post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE)); @@ -217,6 +239,7 @@ public void testPrimitiveCharacterNull() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testString() { WebTarget web = target().path("test"); Response response = web.path("String").request().post(Entity.entity("String", MediaType.TEXT_PLAIN_TYPE)); @@ -225,6 +248,7 @@ public void testString() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBoolean() { WebTarget web = target().path("test"); Response response = web.path("Boolean").request().post(Entity.entity(Boolean.TRUE, MediaType.TEXT_PLAIN_TYPE)); @@ -234,6 +258,7 @@ public void testBoolean() { @Test + @Execution(ExecutionMode.CONCURRENT) public void testPrimitiveBoolean() { WebTarget web = target().path("test"); Response response = web.path("boolean").request().post(Entity.entity(true, MediaType.TEXT_PLAIN_TYPE)); @@ -242,6 +267,7 @@ public void testPrimitiveBoolean() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBigDecimal() { WebTarget web = target().path("test"); Response response = web.path("bigDecimal").request().post(Entity.entity(new BigDecimal("15"), MediaType.TEXT_PLAIN_TYPE)); @@ -250,6 +276,7 @@ public void testBigDecimal() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testBigInteger() { WebTarget web = target().path("test"); Response response = web.path("bigInteger").request().post(Entity.entity(new BigInteger("15"), MediaType.TEXT_PLAIN_TYPE)); @@ -258,6 +285,7 @@ public void testBigInteger() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testAtomicInteger() { WebTarget web = target().path("test"); Response response = web.path("atomicInteger").request().post(Entity.entity(new AtomicInteger(15), @@ -267,6 +295,7 @@ public void testAtomicInteger() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testAtomicLong() { WebTarget web = target().path("test"); Response response = web.path("atomicLong").request().post(Entity.entity(new AtomicLong(15), diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ReloadTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ReloadTest.java index 98bf87248e..add5544ea8 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ReloadTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ReloadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.server.spi.Container; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Reload capability test. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/RequestScopedAndAsyncTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/RequestScopedAndAsyncTest.java index 09a312bcec..6c17209022 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/RequestScopedAndAsyncTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/RequestScopedAndAsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -39,9 +39,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * JERSEY-2677 reproducer - test, that {@code Factory.dispose()} is correctly called for both sync and async cases. @@ -118,7 +118,7 @@ public void async(@Suspended AsyncResponse ar) { } } - @Before + @BeforeEach public void resetCounters() { InjectableFactory.reset(); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceConfigTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceConfigTest.java index f6f4f049da..e2010e4161 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceConfigTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * End to end test class for testing {@code ResourceConfig} features. @@ -159,7 +159,7 @@ public void testJersey1094() throws Exception { } @Test - @Ignore("TODO: Add test for reloading resource config in the container (once it is supported)") + @Disabled("TODO: Add test for reloading resource config in the container (once it is supported)") public void testJersey1094ReloadResourceConfig() throws Exception { // TODO test reloading resource config in the container (once it is supported) } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceFilterTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceFilterTest.java index 26156cb133..abda5e7631 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceFilterTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -44,13 +44,13 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JAX-RS name-bound filter tests. @@ -116,9 +116,9 @@ public void testGlobalPostMatchingNotInvokedOn404() { private void test(String name) { Response r = target("basic").path(name).request().get(); - assertEquals("Unexpected HTTP response status code.", 200, r.getStatus()); - assertTrue("Response does not have entity.", r.hasEntity()); - assertEquals("Unexpected response entity value.", name, r.readEntity(String.class)); + assertEquals(200, r.getStatus(), "Unexpected HTTP response status code."); + assertTrue(r.hasEntity(), "Response does not have entity."); + assertEquals(name, r.readEntity(String.class), "Unexpected response entity value."); } @Path("/basic") diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceRoutingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceRoutingTest.java index 6274c4a785..2642ed6dfc 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceRoutingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResourceRoutingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** @@ -69,21 +69,21 @@ protected Application configure() { @Test public void subWrongPath() throws Exception { Response response = target("a/b/d").request().get(); - Assert.assertEquals(404, response.getStatus()); + Assertions.assertEquals(404, response.getStatus()); } @Test public void correctPath() throws Exception { Response response = target("a/b/c").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("a/b/c", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("a/b/c", response.readEntity(String.class)); } @Test public void correctPath2() throws Exception { Response response = target("a/q").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("a/q", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("a/q", response.readEntity(String.class)); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResponseStatusTypeTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResponseStatusTypeTest.java index 7c59ae86b5..71c22ec71b 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResponseStatusTypeTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ResponseStatusTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -34,19 +34,19 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * Tests custom response status reason phrase with jersey containers and connectors. * * @author Miroslav Fuksa */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ResponseStatusTypeTest.InMemoryTest.class, +@Suite +@SelectClasses({ResponseStatusTypeTest.InMemoryTest.class, ResponseStatusTypeTest.GrizzlyContainerGrizzlyConnectorTest.class, ResponseStatusTypeTest.GrizzlyContainerApacheConnectorTest.class, ResponseStatusTypeTest.SimpleContainerHttpUrlConnectorTest.class}) @@ -80,8 +80,8 @@ public void testBadRequest() { public void testCustomBadRequest() { // with InMemory container and connector status info should be transferred as it is produced. final Response response = target().path("resource/custom-bad-request").request().get(); - Assert.assertEquals(400, response.getStatus()); - Assert.assertNull(response.getStatusInfo().getReasonPhrase()); + Assertions.assertEquals(400, response.getStatus()); + Assertions.assertNull(response.getStatusInfo().getReasonPhrase()); } @@ -191,7 +191,7 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc } @Test - @Ignore("Jdk http container does not support custom response reason phrases.") + @Disabled("Jdk http container does not support custom response reason phrases.") public void testCustom() { _testCustom(target()); } @@ -266,19 +266,19 @@ public Response.Status.Family getFamily() { public static void _testCustom(WebTarget target) { final Response response = target.path("resource/custom").request().get(); - Assert.assertEquals(428, response.getStatus()); - Assert.assertEquals(REASON_PHRASE, response.getStatusInfo().getReasonPhrase()); + Assertions.assertEquals(428, response.getStatus()); + Assertions.assertEquals(REASON_PHRASE, response.getStatusInfo().getReasonPhrase()); } public static void _testBadRequest(WebTarget target) { final Response response = target.path("resource/bad-request").request().get(); - Assert.assertEquals(400, response.getStatus()); - Assert.assertEquals(Response.Status.BAD_REQUEST.getReasonPhrase(), response.getStatusInfo().getReasonPhrase()); + Assertions.assertEquals(400, response.getStatus()); + Assertions.assertEquals(Response.Status.BAD_REQUEST.getReasonPhrase(), response.getStatusInfo().getReasonPhrase()); } public static void _testCustomBadRequest(WebTarget target) { final Response response = target.path("resource/custom-bad-request").request().get(); - Assert.assertEquals(400, response.getStatus()); - Assert.assertEquals(Response.Status.BAD_REQUEST.getReasonPhrase(), response.getStatusInfo().getReasonPhrase()); + Assertions.assertEquals(400, response.getStatus()); + Assertions.assertEquals(Response.Status.BAD_REQUEST.getReasonPhrase(), response.getStatusInfo().getReasonPhrase()); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/RuntimeConfigTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/RuntimeConfigTest.java index 91e0d1b5a8..cba7c9b762 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/RuntimeConfigTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/RuntimeConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -37,13 +37,13 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ScheduledThreadPoolExecutorProviderTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ScheduledThreadPoolExecutorProviderTest.java index 4a1a1306b0..098f9713cb 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ScheduledThreadPoolExecutorProviderTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ScheduledThreadPoolExecutorProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -27,10 +27,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.spi.ScheduledThreadPoolExecutorProvider; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ScheduledThreadPoolExecutorProviderTest { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SecurityContextFilterTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SecurityContextFilterTest.java index afc7d2d399..e5a253f20c 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SecurityContextFilterTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SecurityContextFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -30,9 +30,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * End to end test class for testing security context in the Filter and @@ -63,11 +63,11 @@ public static class SecurityContextFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext context) { - Assert.assertNotNull(context.getSecurityContext()); + Assertions.assertNotNull(context.getSecurityContext()); // test injections // TODO: won't work until SecurityContext is proxiable -// Assert.assertEquals(context.getSecurityContext(), securityContext); +// Assertions.assertEquals(context.getSecurityContext(), securityContext); String header = context.getHeaders().getFirst(SKIP_FILTER); if ("true".equals(header)) { @@ -129,7 +129,7 @@ public void testContainerSecurityContext() throws Exception { Response response = target().path("test").request().header(SKIP_FILTER, "true").get(); assertEquals(200, response.getStatus()); String entity = response.readEntity(String.class); - Assert.assertTrue(!entity.equals(PRINCIPAL_NAME)); + Assertions.assertTrue(!entity.equals(PRINCIPAL_NAME)); } /** @@ -148,7 +148,7 @@ public static class Resource { // TODO: inject SecurityContext directly once JERSEY-1282 is fixed @GET public String getPrincipal(@Context ContainerRequestContext crc) { - Assert.assertNotNull(crc.getSecurityContext()); + Assertions.assertNotNull(crc.getSecurityContext()); Principal userPrincipal = crc.getSecurityContext().getUserPrincipal(); return userPrincipal == null ? PRINCIPAL_IS_NULL : userPrincipal.getName(); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ServerDestroyTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ServerDestroyTest.java index 511ac31d68..5df8cee5f6 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ServerDestroyTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/ServerDestroyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -49,11 +49,11 @@ import org.glassfish.jersey.test.DeploymentContext; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Assert that pre destroy method on application, resources and providers is invoked. @@ -68,7 +68,7 @@ public class ServerDestroyTest extends JerseyTest { private Reloader reloader; @Override - @Before + @BeforeEach public void setUp() throws Exception { destroyed.clear(); destroyed.put("application", false); diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonProviderTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonProviderTest.java index 16ee4a15d3..d75491eb3c 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonProviderTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -44,10 +44,10 @@ import org.glassfish.jersey.spi.ContextResolvers; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Class testing that providers are managed correctly in the singleton scope. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonProvidersResourcesTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonProvidersResourcesTest.java index 19a6f8dca6..97a1710d97 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonProvidersResourcesTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonProvidersResourcesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -33,10 +33,10 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test resources which also acts as providers. @@ -60,9 +60,9 @@ protected Application configure() { @Test public void testResourceAsFilter() { String str = target().path("singleton").request().header("singleton", "singleton").get(String.class); - assertTrue(str, str.startsWith("true/")); + assertTrue(str.startsWith("true/"), str); String str2 = target().path("singleton").request().header("singleton", "singleton").get(String.class); - assertTrue(str2, str2.startsWith("true/")); + assertTrue(str2.startsWith("true/"), str2); assertEquals(str, str2); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonResourceTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonResourceTest.java index 1073e09593..e090462e6c 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonResourceTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SingletonResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,8 +35,8 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Class testing Resources managed as singletons. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/StreamMethodCallTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/StreamMethodCallTest.java index 74434899be..da0fff63e8 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/StreamMethodCallTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/StreamMethodCallTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests that appropriate methods are called in the intercepted output stream. @@ -99,9 +99,9 @@ public String get() { @Test public void testCalledMethods() { final Response response = target().path("resource").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertTrue("close() has not been called.", TestOutputStream.closeCalled); - Assert.assertTrue("flush() has not been called before close().", TestOutputStream.flushCalledBeforeClose); - Assert.assertTrue("write() has not been called.", TestOutputStream.writeCalled); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertTrue(TestOutputStream.closeCalled, "close() has not been called."); + Assertions.assertTrue(TestOutputStream.flushCalledBeforeClose, "flush() has not been called before close()."); + Assertions.assertTrue(TestOutputStream.writeCalled, "write() has not been called."); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SubResourceTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SubResourceTest.java index f9ece42e02..c1f0ff36ac 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SubResourceTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SubResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -32,9 +32,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Sub-resource access/processing E2E tests. @@ -114,33 +114,33 @@ public void testConcurrentSubResourceAccess() throws Exception { @Test public void subResourceTest() throws Exception { Response response = target("root/sub/sub2").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(SubResource.MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(SubResource.MESSAGE, response.readEntity(String.class)); response = target("root/sub/sub2").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(SubResource.MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(SubResource.MESSAGE, response.readEntity(String.class)); } @Test public void subResourceWithoutPathTest() throws Exception { Response response = target("root/sub").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(SubResource.MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(SubResource.MESSAGE, response.readEntity(String.class)); } @Test public void testGet() throws Exception { Response response = target("root/sub/some/path").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(Resource.GET, response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals(Resource.GET, response.readEntity(String.class)); } @Test public void testPost() throws Exception { Response response = target("root/sub/sub2").request().post(Entity.entity("post", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("post", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("post", response.readEntity(String.class)); } // this resource class will report warning during validation, but should be loaded @@ -189,41 +189,41 @@ public String getInner() { @Test public void testGetIsCalled() throws Exception { Response response = target("locator-and-method").request().get(); - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); } @Test public void testGetIsCalledInSub() throws Exception { Response response = target("locator-and-method/sub").request().get(); - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); - Assert.assertEquals("get", response.readEntity(String.class)); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals("get", response.readEntity(String.class)); } @Test public void testGetIsCalledInInner() throws Exception { Response response = target("locator-and-method/inner").request().get(); - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); - Assert.assertEquals("inner", response.readEntity(String.class)); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals("inner", response.readEntity(String.class)); } @Test public void testGetIsCalledInSubInner() throws Exception { Response response = target("locator-and-method/sub/inner").request().get(); - Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); - Assert.assertEquals("inner", response.readEntity(String.class)); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + Assertions.assertEquals("inner", response.readEntity(String.class)); } @Test public void testPostShouldNeverBeCalled() throws Exception { Response response = target("locator-and-method").request().post(Entity.entity("post", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(Response.Status.METHOD_NOT_ALLOWED.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.METHOD_NOT_ALLOWED.getStatusCode(), response.getStatus()); } @Test public void testPostShouldNeverBeCalledInSub() throws Exception { Response response = target("locator-and-method/sub").request().post(Entity.entity("post", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(Response.Status.METHOD_NOT_ALLOWED.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.METHOD_NOT_ALLOWED.getStatusCode(), response.getStatus()); } @Path("empty-root") @@ -234,7 +234,7 @@ public static class EmptyRootResource { @Test public void testCallEmptyResource() throws Exception { Response response = target("empty-root").request().get(); - Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); } public static class EmptySubResourceClass { @@ -244,6 +244,6 @@ public static class EmptySubResourceClass { @Test public void testCallEmptySubResource() throws Exception { Response response = target("empty-locator").request().get(); - Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); + Assertions.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus()); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SubjectSecurityContextTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SubjectSecurityContextTest.java index b96f53a303..3cc11f4688 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SubjectSecurityContextTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/SubjectSecurityContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2022 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 @@ -35,7 +35,7 @@ import org.glassfish.jersey.server.SubjectSecurityContext; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/UriBuilderTemplateTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/UriBuilderTemplateTest.java index f30c82c692..ba31c33f94 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/UriBuilderTemplateTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/UriBuilderTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -30,8 +30,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Testing URI template as an e2e test. @@ -80,12 +81,14 @@ public String getAnyResource(@PathParam("resourceName") String resourceName) { } } - @Test(expected = IllegalArgumentException.class) + @Test public void testResolveTemplate() { - Map map = new HashMap(); - map.put("a", "xyz"); - map.put(null, "path"); - UriBuilder builder = UriBuilder.fromPath("").path("{a}/{b}"); - builder.resolveTemplates(map); + assertThrows(IllegalArgumentException.class, () -> { + Map map = new HashMap(); + map.put("a", "xyz"); + map.put(null, "path"); + UriBuilder builder = UriBuilder.fromPath("").path("{a}/{b}"); + builder.resolveTemplates(map); + }); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/WebApplicationExceptionLoggingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/WebApplicationExceptionLoggingTest.java index 7f07197468..9f8b5ca140 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/WebApplicationExceptionLoggingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/WebApplicationExceptionLoggingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,11 +36,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests that {@link WebApplicationException} is logged on the correct level. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/PostToPutDeleteTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/PostToPutDeleteTest.java index 414159aee0..4fd86fa9ae 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/PostToPutDeleteTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/PostToPutDeleteTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -32,8 +32,8 @@ import org.glassfish.jersey.server.filter.HttpMethodOverrideFilter; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/RolesAllowedTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/RolesAllowedTest.java index 4dda6f38eb..f55457f56e 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/RolesAllowedTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/RolesAllowedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -39,10 +39,10 @@ import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageMediaTypeNegativeTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageMediaTypeNegativeTest.java index 4c191dd8b8..dfcf48a0ea 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageMediaTypeNegativeTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageMediaTypeNegativeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * No activation property ({@value org.glassfish.jersey.server.ServerProperties#LANGUAGE_MAPPINGS}, diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageMediaTypeTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageMediaTypeTest.java index 635b499234..8e4f034734 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageMediaTypeTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageMediaTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageTest.java index 25b537b2ff..e56bc7ae02 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegLanguageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegMediaTypeTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegMediaTypeTest.java index f842a3212c..18771f97a5 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegMediaTypeTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/filter/UriConnegMediaTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/ApplicationInfoTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/ApplicationInfoTest.java index da6f40910a..96d31a5744 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/ApplicationInfoTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/ApplicationInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,9 +16,6 @@ package org.glassfish.jersey.tests.e2e.server.monitoring; -import java.util.Arrays; -import java.util.List; - import javax.ws.rs.ConstrainedTo; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -28,6 +25,11 @@ import javax.ws.rs.core.FeatureContext; import javax.ws.rs.core.Response; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + import javax.annotation.Priority; import javax.inject.Provider; @@ -38,11 +40,11 @@ import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.server.monitoring.ApplicationInfo; import org.glassfish.jersey.test.JerseyTest; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; /** * The test uses server properties {@link ServerProperties#MONITORING_STATISTICS_MBEANS_ENABLED}, @@ -53,52 +55,101 @@ * * @author Libor Kramolis */ -@RunWith(Parameterized.class) -public class ApplicationInfoTest extends JerseyTest { +public class ApplicationInfoTest { private static final String FORCE_ENABLE = "FORCE_ENABLE"; private static final String ENABLE_MONITORING = "ENABLE_MONITORING"; private static final String ENABLE_MONITORING_STATISTICS = "ENABLE_MONITORING_STATISTICS"; private static final String ENABLE_MONITORING_STATISTICS_MBEANS = "ENABLE_MONITORING_STATISTICS_MBEANS"; - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { + static class TestData { + boolean forceEnable; + boolean enableMonitoring; + boolean enableMonitoringStatistics; + boolean enableMonitoringStatisticsMBeans; + Boolean monitoringEnabled; + Boolean monitoringStatisticsEnabled; + Boolean monitoringStatisticsMBeansEnabled; + int responseStatus; + + public TestData(boolean forceEnable, boolean enableMonitoring, + boolean enableMonitoringStatistics, boolean enableMonitoringStatisticsMBeans, + Boolean monitoringEnabled, Boolean monitoringStatisticsEnabled, + Boolean monitoringStatisticsMBeansEnabled, int responseStatus) { + this.forceEnable = forceEnable; + this.enableMonitoring = enableMonitoring; + this.enableMonitoringStatistics = enableMonitoringStatistics; + this.enableMonitoringStatisticsMBeans = enableMonitoringStatisticsMBeans; + this.monitoringEnabled = monitoringEnabled; + this.monitoringStatisticsEnabled = monitoringStatisticsEnabled; + this.monitoringStatisticsMBeansEnabled = monitoringStatisticsMBeansEnabled; + this.responseStatus = responseStatus; + } + + @Override + public String toString() { + return "TestData [forceEnable=" + forceEnable + ", enableMonitoring=" + enableMonitoring + + ", enableMonitoringStatistics=" + enableMonitoringStatistics + + ", enableMonitoringStatisticsMBeans=" + enableMonitoringStatisticsMBeans + ", monitoringEnabled=" + + monitoringEnabled + ", monitoringStatisticsEnabled=" + monitoringStatisticsEnabled + + ", monitoringStatisticsMBeansEnabled=" + monitoringStatisticsMBeansEnabled + ", responseStatus=" + + responseStatus + "]"; + } + } + + public static List testData() { + return Arrays.asList(new TestData[] { //force, 3x AutoDiscoverable, 3x ResourceConfig, response // no property set => 500 - {false, false, false, false, null, null, null, 500}, + new TestData(false, false, false, false, null, null, null, 500), // property set by ForcedAutoDiscoverable => 200 - {false, true, false, false, null, null, null, 200}, - {false, false, true, false, null, null, null, 200}, - {false, false, false, true, null, null, null, 200}, + new TestData(false, true, false, false, null, null, null, 200), + new TestData(false, false, true, false, null, null, null, 200), + new TestData(false, false, false, true, null, null, null, 200), // property disable by ResourceConfig => 500 - {false, true, false, false, false, false, false, 500}, - {false, false, true, false, false, false, false, 500}, - {false, false, false, true, false, false, false, 500}, + new TestData(false, true, false, false, false, false, false, 500), + new TestData(false, false, true, false, false, false, false, 500), + new TestData(false, false, false, true, false, false, false, 500), // property disable by ResourceConfig but forced by ForcedAutoDiscoverable => 200 - {true, true, false, false, false, false, false, 200}, - {true, false, true, false, false, false, false, 200}, - {true, false, false, true, false, false, false, 200} + new TestData(true, true, false, false, false, false, false, 200), + new TestData(true, false, true, false, false, false, false, 200), + new TestData(true, false, false, true, false, false, false, 200) }); } - private int responseStatus; - - public ApplicationInfoTest(boolean forceEnable, boolean enableMonitoring, - boolean enableMonitoringStatistics, boolean enableMonitoringStatisticsMBeans, - Boolean monitoringEnabled, Boolean monitoringStatisticsEnabled, - Boolean monitoringStatisticsMBeansEnabled, int responseStatus) { - super(createApplication(forceEnable, enableMonitoring, - enableMonitoringStatistics, enableMonitoringStatisticsMBeans, - monitoringEnabled, monitoringStatisticsEnabled, - monitoringStatisticsMBeansEnabled)); - this.responseStatus = responseStatus; + @TestFactory + public Collection generatedTests() { + Collection tests = new ArrayList<>(); + for (TestData testCase : testData()) { + ApplicationInfoTemplateTest test = new ApplicationInfoTemplateTest(testCase) {}; + tests.add(TestHelper.toTestContainer(test, "applicationInfoTest for case " + testCase.toString())); + } + return tests; + } + public abstract static class ApplicationInfoTemplateTest extends JerseyTest { + private int responseStatus; + + public ApplicationInfoTemplateTest(TestData testCase) { + super(createApplication(testCase.forceEnable, testCase.enableMonitoring, + testCase.enableMonitoringStatistics, testCase.enableMonitoringStatisticsMBeans, + testCase.monitoringEnabled, testCase.monitoringStatisticsEnabled, + testCase.monitoringStatisticsMBeansEnabled)); + this.responseStatus = testCase.responseStatus; + } + + @Test + public void test() { + final Response response = target().path("resource").request().get(); + Assertions.assertEquals(responseStatus, response.getStatus()); + if (responseStatus == 200) { + Assertions.assertEquals("testApp", response.readEntity(String.class)); + } + } } private static Application createApplication(boolean forceEnable, boolean enableMonitoring, - boolean enableMonitoringStatistics, boolean enableMonitoringStatisticsMBeans, - Boolean monitoringEnabled, Boolean monitoringStatisticsEnabled, - Boolean monitoringStatisticsMBeansEnabled) { + boolean enableMonitoringStatistics, boolean enableMonitoringStatisticsMBeans, Boolean monitoringEnabled, + Boolean monitoringStatisticsEnabled, Boolean monitoringStatisticsMBeansEnabled) { final ResourceConfig resourceConfig = new ResourceConfig(Resource.class); resourceConfig.property(ServerProperties.APPLICATION_NAME, "testApp"); resourceConfig.property(FORCE_ENABLE, forceEnable); @@ -118,21 +169,13 @@ private static Application createApplication(boolean forceEnable, boolean enable resourceConfig.property(ServerProperties.MONITORING_STATISTICS_ENABLED, monitoringStatisticsEnabled); } if (monitoringStatisticsMBeansEnabled != null) { - resourceConfig.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, monitoringStatisticsMBeansEnabled); + resourceConfig.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, + monitoringStatisticsMBeansEnabled); } return resourceConfig; } - @Test - public void test() { - final Response response = target().path("resource").request().get(); - Assert.assertEquals(responseStatus, response.getStatus()); - if (responseStatus == 200) { - Assert.assertEquals("testApp", response.readEntity(String.class)); - } - } - @Path("resource") public static class Resource { diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/EventListenerTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/EventListenerTest.java index 3bda9a92ce..d2065e3f23 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/EventListenerTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/EventListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -49,11 +49,11 @@ import org.glassfish.jersey.server.monitoring.RequestEventListener; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * @author Miroslav Fuksa @@ -161,7 +161,7 @@ public void onEvent(RequestEvent event) { } break; case FINISHED: - Assert.assertNotNull(event.getContainerResponse()); + Assertions.assertNotNull(event.getContainerResponse()); this.appEventListener.finishedCalled.countDown(); break; } @@ -383,7 +383,7 @@ public void testAsyncProcessing() throws InterruptedException { assertEquals("[" + i + "]", response.getHeaderString("R.RESP_FILTERS_FINISHED.order")); final boolean success = applicationEventListener.finishedCalled.await(3 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS); - Assert.assertTrue(success); + Assertions.assertTrue(success); } @Test @@ -402,6 +402,6 @@ public void testAsyncProcessingWithOneThread() throws InterruptedException { final boolean success = applicationEventListener.finishedCalled.await(3 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS); - Assert.assertTrue(success); + Assertions.assertTrue(success); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/MBeansTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/MBeansTest.java index 85d0b97255..00f930c5e9 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/MBeansTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/MBeansTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -43,11 +43,11 @@ import org.glassfish.jersey.server.spi.Container; import org.glassfish.jersey.test.JerseyTest; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * @author Miroslav Fuksa @@ -159,10 +159,10 @@ public void onShutdown(Container container) { } @Override - @After + @AfterEach public void tearDown() throws Exception { super.tearDown(); - Assert.assertTrue(StatisticsListener.ON_SHUTDOWN_CALLED); + Assertions.assertTrue(StatisticsListener.ON_SHUTDOWN_CALLED); } @@ -211,7 +211,7 @@ public void test() throws Exception { final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); final ObjectName name = new ObjectName("org.glassfish.jersey:type=myApplication,subType=Global,global=Configuration"); final String str = (String) mBeanServer.getAttribute(name, "ApplicationName"); - Assert.assertEquals("myApplication", str); + Assertions.assertEquals("myApplication", str); checkResourceMBean("/resource"); checkResourceMBean("/resource/sub"); @@ -231,7 +231,7 @@ private void checkResourceMBean(String name) throws MalformedObjectNameException try { mbean = mBeanServer.getObjectInstance(objectName); } catch (InstanceNotFoundException e) { - Assert.fail("Resource MBean name '" + name + "' not found."); + Assertions.fail("Resource MBean name '" + name + "' not found."); } assertNotNull(mbean); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/MonitoringStatisticsLocatorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/MonitoringStatisticsLocatorTest.java index 877dc57c9a..d22e0569f9 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/MonitoringStatisticsLocatorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/MonitoringStatisticsLocatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -38,10 +38,10 @@ import org.glassfish.jersey.server.wadl.processor.WadlModelProcessor; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * This test verifies that {@link ResourceMethodStatistics} are not duplicated in diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/ReloadApplicationEventTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/ReloadApplicationEventTest.java index a7a3697ede..49b952c51c 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/ReloadApplicationEventTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/ReloadApplicationEventTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -48,13 +48,15 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * This test tests the lifecycle of the application in accordance to the monitoring @@ -64,8 +66,8 @@ * * @author Miroslav Fuksa */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ReloadApplicationEventTest.GrizzlyTestCase.class, ReloadApplicationEventTest.JdkServerTestCase.class, +@Suite +@SelectClasses({ReloadApplicationEventTest.GrizzlyTestCase.class, ReloadApplicationEventTest.JdkServerTestCase.class, ReloadApplicationEventTest.SimpleHttpServerTestCase.class}) public class ReloadApplicationEventTest extends JerseyTest { @@ -109,6 +111,7 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc public static class ParentTest extends JerseyTest { + @BeforeEach @Override public void setUp() throws Exception { super.setUp(); @@ -343,7 +346,7 @@ public void testApplicationEvents() throws MalformedObjectNameException, Attribu while ((!ReloadedResult.initEventCalled) && (cnt++ < 30)) { Thread.sleep(200); } - assertTrue("Timeout: application was not reloaded in time.", ReloadedResult.initEventCalled); + assertTrue(ReloadedResult.initEventCalled, "Timeout: application was not reloaded in time."); // wait again some time until events are processed and mbeans are invoked Thread.sleep(700); @@ -378,10 +381,10 @@ private void checkMBeanRegistration(String appName, boolean shouldBeRegistered) Thread.sleep(waitTime); registered = mBeanServer.isRegistered(name); } - Assert.assertEquals(shouldBeRegistered, registered); + Assertions.assertEquals(shouldBeRegistered, registered); if (registered) { final String str = (String) mBeanServer.getAttribute(name, "ApplicationName"); - Assert.assertEquals(appName, str); + Assertions.assertEquals(appName, str); } } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/StatisticsDestroyTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/StatisticsDestroyTest.java index 1fa5d766a9..0979ebe64e 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/StatisticsDestroyTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/monitoring/StatisticsDestroyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,15 +16,17 @@ package org.glassfish.jersey.tests.e2e.server.monitoring; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.lang.management.ManagementFactory; +import javax.management.MBeanServer; +import javax.management.ObjectName; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.Application; -import javax.management.MBeanServer; -import javax.management.ObjectName; - import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.server.monitoring.DestroyListener; @@ -39,21 +41,18 @@ import org.glassfish.jersey.test.simple.SimpleTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * * @author Miroslav Fuksa */ -@RunWith(Suite.class) -@Suite.SuiteClasses({StatisticsDestroyTest.GrizzlyTestCase.class, StatisticsDestroyTest.JdkServerTestCase.class, +@Suite +@SelectClasses({StatisticsDestroyTest.GrizzlyTestCase.class, StatisticsDestroyTest.JdkServerTestCase.class, StatisticsDestroyTest.SimpleHttpServerTestCase.class}) public class StatisticsDestroyTest { @@ -71,7 +70,7 @@ public Application configure() { } @Override - @After + @AfterEach public void tearDown() throws Exception { super.tearDown(); assertTrue(StatisticsListener.ON_SHUTDOWN_CALLED); @@ -90,7 +89,7 @@ public void tearDown() throws Exception { registered = mBeanServer.isRegistered(name); } - Assert.assertFalse("MBean should be already unregistered!", mBeanServer.isRegistered(name)); + Assertions.assertFalse(mBeanServer.isRegistered(name), "MBean should be already unregistered!"); } @Path("resource") @@ -119,9 +118,9 @@ public void test() throws Exception { registered = mBeanServer.isRegistered(name); } - assertTrue("MBean should be already registered!", mBeanServer.isRegistered(name)); + assertTrue(mBeanServer.isRegistered(name), "MBean should be already registered!"); final String str = (String) mBeanServer.getAttribute(name, "ApplicationName"); - Assert.assertEquals("myApplication", str); + Assertions.assertEquals("myApplication", str); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/BeanValidationErrorTemplateTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/BeanValidationErrorTemplateTest.java index 9558bb610e..781c57d85c 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/BeanValidationErrorTemplateTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/BeanValidationErrorTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -34,11 +34,11 @@ import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; import org.hibernate.validator.constraints.Length; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Michal Gajdos @@ -47,7 +47,7 @@ public class BeanValidationErrorTemplateTest extends JerseyTest { private Properties props; - @Before + @BeforeEach public void setUp() throws Exception { props = new Properties(); diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/CustomViewableContextTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/CustomViewableContextTest.java index afcb4d847c..cc4c0b3acc 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/CustomViewableContextTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/CustomViewableContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,8 +32,8 @@ import org.glassfish.jersey.tests.e2e.server.mvc.provider.CustomViewableContext; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ErrorTemplateTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ErrorTemplateTest.java index ef8475a73b..9dc41de347 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ErrorTemplateTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ErrorTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,8 +32,9 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * @author Michal Gajdos @@ -93,9 +94,10 @@ public String get() { } } - @Test(expected = InternalServerErrorException.class) + @Test public void testErrorMethodTemplateSubResource() throws Exception { - target("subResourceTemplate").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target("subResourceTemplate").request().get(String.class)); } @Test diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExceptionViewProcessorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExceptionViewProcessorTest.java index 287b614a84..c3c1fb210e 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExceptionViewProcessorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExceptionViewProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -38,9 +38,9 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz @@ -123,7 +123,7 @@ public void testResolvingClassExplicitTemplate() throws IOException { p.getProperty("path")); assertEquals("406", p.getProperty("model")); - Assert.assertEquals(MediaType.TEXT_PLAIN_TYPE, cr.getMediaType()); + Assertions.assertEquals(MediaType.TEXT_PLAIN_TYPE, cr.getMediaType()); cr.close(); } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExplicitProduceTemplateTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExplicitProduceTemplateTest.java index 95d970be74..67e6b3cb11 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExplicitProduceTemplateTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExplicitProduceTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,9 +33,9 @@ import org.glassfish.jersey.tests.e2e.server.mvc.provider.AbcViewProcessor; import org.glassfish.jersey.tests.e2e.server.mvc.provider.DefViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExplicitTemplateTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExplicitTemplateTest.java index 0bbd8b5a79..46c79d4524 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExplicitTemplateTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ExplicitTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/FlatInheritedViewProcessorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/FlatInheritedViewProcessorTest.java index b3c0dce7e5..05e4e100c6 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/FlatInheritedViewProcessorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/FlatInheritedViewProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/FlatViewProcessorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/FlatViewProcessorTest.java index 72a1f39a2c..5ba48ca020 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/FlatViewProcessorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/FlatViewProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -38,8 +38,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitProducesViewProcessorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitProducesViewProcessorTest.java index bd705f01ff..a90e8ee013 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitProducesViewProcessorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitProducesViewProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,8 +35,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitTemplateProgrammaticTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitTemplateProgrammaticTest.java index 0de34861bd..91052f2b16 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitTemplateProgrammaticTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitTemplateProgrammaticTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitTemplateTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitTemplateTest.java index 7fb0ba80b8..fb6b7f97df 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitTemplateTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitTemplateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitViewWithResourceFilterTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitViewWithResourceFilterTest.java index 4d815766e4..0a496112ca 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitViewWithResourceFilterTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitViewWithResourceFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -39,9 +39,9 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * @author Paul Sandoz diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/InheritedViewProcessorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/InheritedViewProcessorTest.java index 88d847a8df..9f01f423a2 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/InheritedViewProcessorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/InheritedViewProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest.java index 68ad121f09..b6b1b82a16 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,6 +16,7 @@ package org.glassfish.jersey.tests.e2e.server.mvc; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -37,23 +38,21 @@ import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; /** * MVC encoding charset tests. * * @author Miroslav Fuksa */ -@RunWith(Parameterized.class) -public class MvcEncodingTest extends JerseyTest { +public class MvcEncodingTest { public static final String MESSAGE = "\\u0161\\u010d\\u0159\\u017e\\u00fd\\u00e1\\u00ed\\u00e9"; - @Parameterized.Parameters public static Collection data() { return Arrays.asList(new Object[][]{ {new FreemarkerMvcFeature(), "freemarker", "FreemarkerResource.ftl", "UTF-8"}, @@ -67,85 +66,105 @@ public static Collection data() { }); } - private static String templateName; - private final String defaultEncoding; - - public MvcEncodingTest(Feature feature, String propertySuffix, String templateName, String defaultEncoding) { - super(new ResourceConfig() - .register(feature) - .register(FreemarkerResource.class) - .property(MvcFeature.ENCODING + "." + propertySuffix, defaultEncoding)); - MvcEncodingTest.templateName = templateName; - this.defaultEncoding = defaultEncoding; + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + data().forEach(arr -> { + MvcEncodingTemplateTest test = new MvcEncodingTemplateTest((Feature) arr[0], (String) arr[1], + (String) arr[2], (String) arr[3]) {}; + tests.add(TestHelper.toTestContainer(test, String.format("%s (%s, %s, %s, %s)", + MvcEncodingTemplateTest.class.getSimpleName(), + arr[0].getClass().getSimpleName(), arr[1], arr[2], arr[3]))); + }); + return tests; } + public abstract static class MvcEncodingTemplateTest extends JerseyTest { + private final String defaultEncoding; - @Path("resource") - public static class FreemarkerResource { - @GET - public Viewable get() { - final Map map = new HashMap(); - map.put("user", MESSAGE); + public MvcEncodingTemplateTest(Feature feature, String propertySuffix, String templateName, String defaultEncoding) { + super(new ResourceConfig() + .register(feature) + .register(new FreemarkerResource(templateName)) + .property(MvcFeature.ENCODING + "." + propertySuffix, defaultEncoding)); - return new Viewable("/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest/" + templateName, map); + this.defaultEncoding = defaultEncoding; } - @GET - @Path("textplain") - @Produces("text/plain") - public Viewable getTextPlain() { - final Map map = new HashMap(); - map.put("user", MESSAGE); + @Path("resource") + public static class FreemarkerResource { - return new Viewable("/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest/" + templateName, map); - } + private String templateName; + + public FreemarkerResource(String templateName) { + this.templateName = templateName; + } - @GET - @Path("textplainUTF16") - @Produces("text/plain;charset=UTF-16") - public Viewable getTextPlainUTF16() { - final Map map = new HashMap(); - map.put("user", MESSAGE); + @GET + public Viewable get() { + final Map map = new HashMap(); + map.put("user", MESSAGE); - return new Viewable("/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest/" + templateName, map); + return new Viewable("/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest/" + templateName, map); + } + + @GET + @Path("textplain") + @Produces("text/plain") + public Viewable getTextPlain() { + final Map map = new HashMap(); + map.put("user", MESSAGE); + + return new Viewable("/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest/" + templateName, map); + } + + @GET + @Path("textplainUTF16") + @Produces("text/plain;charset=UTF-16") + public Viewable getTextPlainUTF16() { + final Map map = new HashMap(); + map.put("user", MESSAGE); + + return new Viewable("/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest/" + templateName, map); + } } - } - @Override - protected TestContainerFactory getTestContainerFactory() throws TestContainerException { - return new GrizzlyTestContainerFactory(); - } + @Override + protected TestContainerFactory getTestContainerFactory() throws TestContainerException { + return new GrizzlyTestContainerFactory(); + } - @Test - public void testDefaultEncoding() { - final Response response = target().path("resource").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("Model:" + MESSAGE, response.readEntity(String.class)); - Assert.assertEquals("*/*;charset=" + defaultEncoding, response.getMediaType().toString()); - Assert.assertEquals(defaultEncoding, response.getMediaType().getParameters().get(MediaType.CHARSET_PARAMETER)); - } + @Test + public void testDefaultEncoding() { + final Response response = target().path("resource").request().get(); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("Model:" + MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals("*/*;charset=" + defaultEncoding, response.getMediaType().toString()); + Assertions.assertEquals(defaultEncoding, response.getMediaType().getParameters().get(MediaType.CHARSET_PARAMETER)); + } - @Test - public void testTextPlainDefaultEncoding() { - final Response response = target().path("resource/textplain").request("*/*,text/plain,text/html").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("Model:" + MESSAGE, response.readEntity(String.class)); - Assert.assertEquals("text/plain;charset=" + defaultEncoding, response.getMediaType().toString()); - Assert.assertEquals(defaultEncoding, response.getMediaType().getParameters().get(MediaType.CHARSET_PARAMETER)); - } + @Test + public void testTextPlainDefaultEncoding() { + final Response response = target().path("resource/textplain").request("*/*,text/plain,text/html").get(); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("Model:" + MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals("text/plain;charset=" + defaultEncoding, response.getMediaType().toString()); + Assertions.assertEquals(defaultEncoding, response.getMediaType().getParameters().get(MediaType.CHARSET_PARAMETER)); + } - @Test - public void testTextPlain406() { - final Response response = target().path("resource/textplain").request("text/html").get(); - Assert.assertEquals(406, response.getStatus()); - } + @Test + public void testTextPlain406() { + final Response response = target().path("resource/textplain").request("text/html").get(); + Assertions.assertEquals(406, response.getStatus()); + } - @Test - public void testTextPlainUTF16() { - final Response response = target().path("resource/textplainUTF16").request("*/*,text/plain,text/html").get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("Model:" + MESSAGE, response.readEntity(String.class)); - Assert.assertEquals("text/plain;charset=UTF-16", response.getMediaType().toString()); - Assert.assertEquals("UTF-16", response.getMediaType().getParameters().get(MediaType.CHARSET_PARAMETER)); + @Test + public void testTextPlainUTF16() { + final Response response = target().path("resource/textplainUTF16").request("*/*,text/plain,text/html").get(); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("Model:" + MESSAGE, response.readEntity(String.class)); + Assertions.assertEquals("text/plain;charset=UTF-16", response.getMediaType().toString()); + Assertions.assertEquals("UTF-16", response.getMediaType().getParameters().get(MediaType.CHARSET_PARAMETER)); + } } } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/TemplateMethodSelectionTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/TemplateMethodSelectionTest.java index 39d3f77de8..da8dae41eb 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/TemplateMethodSelectionTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/TemplateMethodSelectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -38,12 +38,12 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests that {@link Template} annotated methods are selected by the routing algorithms as if they diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ViewProcessorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ViewProcessorTest.java index 15be3f6f4f..d82c18b738 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ViewProcessorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/ViewProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -40,8 +40,8 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/spi/AbstractTemplateProcessorTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/spi/AbstractTemplateProcessorTest.java index 719e1a5ab1..589eac0c72 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/spi/AbstractTemplateProcessorTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/mvc/spi/AbstractTemplateProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,10 +16,15 @@ package org.glassfish.jersey.tests.e2e.server.mvc.spi; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + import java.io.IOException; import java.io.OutputStream; import java.io.Reader; +import javax.inject.Inject; +import javax.servlet.ServletContext; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.Configuration; @@ -27,9 +32,6 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; -import javax.inject.Inject; -import javax.servlet.ServletContext; - import org.glassfish.jersey.internal.inject.InjectionManager; import org.glassfish.jersey.internal.util.collection.Value; import org.glassfish.jersey.internal.util.collection.Values; @@ -40,18 +42,15 @@ import org.glassfish.jersey.server.mvc.spi.AbstractTemplateProcessor; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.spi.TestContainerException; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; /** * @author Michal Gajdos */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ AbstractTemplateProcessorTest.FactoryInstanceTest.class, AbstractTemplateProcessorTest.FactoryInstanceNegativeTest.class, AbstractTemplateProcessorTest.FactoryClassTest.class, diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/InheritanceTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/InheritanceTest.java index 547297554c..43fb6fd5e5 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/InheritanceTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/InheritanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,9 +33,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/RegularExpressionsTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/RegularExpressionsTest.java index e5f31dc55b..4df1dd3fbb 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/RegularExpressionsTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/RegularExpressionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,7 +18,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.POST; diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/ResponseMediaTypeFromProvidersTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/ResponseMediaTypeFromProvidersTest.java index 09ed78d834..c47a0b5931 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/ResponseMediaTypeFromProvidersTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/routing/ResponseMediaTypeFromProvidersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -43,9 +43,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/scanning/RankedProviderScanningTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/scanning/RankedProviderScanningTest.java index 9b5defa7ae..c80bbf49c7 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/scanning/RankedProviderScanningTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/scanning/RankedProviderScanningTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/scanning/Resource.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/scanning/Resource.java index 916ec20d81..2ecbed2b92 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/scanning/Resource.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/scanning/Resource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.tests.e2e.server.scanning.ext.Ext3WriterInterceptor; import org.glassfish.jersey.tests.e2e.server.scanning.ext.Ext4WriterInterceptor; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/BasicValidationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/BasicValidationTest.java index 954d472851..a948319f98 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/BasicValidationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/BasicValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -53,10 +53,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/ContactBean.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/ContactBean.java index bad13aec09..d302a5e7ea 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/ContactBean.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/ContactBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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,12 +18,11 @@ import java.io.Serializable; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; -import org.hibernate.validator.constraints.Email; -import org.hibernate.validator.constraints.NotBlank; - /** * @author Michal Gajdos */ diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/CustomConfigValidationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/CustomConfigValidationTest.java index de5aefbc32..80b5a3d593 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/CustomConfigValidationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/CustomConfigValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -54,10 +54,10 @@ import org.eclipse.persistence.jaxb.BeanValidationMode; import org.eclipse.persistence.jaxb.MarshallerProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/EntityInheritanceValidationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/EntityInheritanceValidationTest.java index e50537420b..f535dc682f 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/EntityInheritanceValidationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/EntityInheritanceValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -25,6 +25,7 @@ import javax.validation.Valid; import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import org.glassfish.jersey.client.ClientConfig; @@ -32,8 +33,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.hibernate.validator.constraints.NotBlank; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/FieldPropertyValidationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/FieldPropertyValidationTest.java index 67507696af..5acd401735 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/FieldPropertyValidationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/FieldPropertyValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -22,9 +22,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/InheritanceValidationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/InheritanceValidationTest.java index a8fa2c8512..1dd8c4a573 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/InheritanceValidationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/InheritanceValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/ProgrammaticValidationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/ProgrammaticValidationTest.java index 3b3081250d..36dcd53d77 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/ProgrammaticValidationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/ProgrammaticValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,8 +31,8 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Bean Validation tests for programmatically created resources. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/PropertyValidationTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/PropertyValidationTest.java index 92ce1a69f2..ef035ec471 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/PropertyValidationTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/PropertyValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.server.validation.ValidationFeature; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test various combinations of enabling/disabling: auto-discovery, bean validation, validation feature. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/AnotherContactBean.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/AnotherContactBean.java index 451b7911bd..d76ee5faa0 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/AnotherContactBean.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/AnotherContactBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,6 +18,8 @@ import java.io.Serializable; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.executable.ExecutableType; @@ -26,9 +28,6 @@ import org.glassfish.jersey.tests.e2e.server.validation.Extended; -import org.hibernate.validator.constraints.Email; -import org.hibernate.validator.constraints.NotBlank; - /** * @author Michal Gajdos */ diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionAbstractTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionAbstractTest.java index 8ffb658f33..c01ded8a96 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionAbstractTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionAbstractTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,10 +20,12 @@ import javax.ws.rs.core.Response; import org.glassfish.jersey.test.JerseyTest; -import org.glassfish.jersey.test.util.runner.RunSeparately; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos @@ -156,7 +158,6 @@ public void testOnTypeValidateResultPassValidateExecutableMatch() throws Excepti } @Test - @RunSeparately public void testOnTypeValidateResultFailValidateExecutableMatch() throws Exception { _testOnType("match", -15, 500); } @@ -167,7 +168,6 @@ public void testOnTypeValidateResultPassValidateExecutableMiss() throws Exceptio } @Test - @RunSeparately public void testOnTypeValidateResultPassBiggerValidateExecutableMiss() throws Exception { _testOnType("miss", -15, 200); } @@ -178,7 +178,6 @@ public void testOnTypeValidateResultPassValidateExecutableNone() throws Exceptio } @Test - @RunSeparately public void testOnTypeValidateResultPassBiggerValidateExecutableNone() throws Exception { _testOnType("none", -15, 200); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionBasicTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionBasicTest.java index da00461fda..cded242406 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionBasicTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionBasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,16 +35,17 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.test.TestProperties; -import org.glassfish.jersey.test.util.runner.RunSeparately; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; + import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -// @RunWith(ConcurrentRunner.class) public class ValidateOnExecutionBasicTest extends ValidateOnExecutionAbstractTest { /** @@ -319,7 +320,6 @@ public void testOnTypeValidateInputFailValidateExecutableDefault() throws Except } @Test - @RunSeparately public void testOnTypeValidateResultFailValidateExecutableDefault() throws Exception { _testOnType("default", -15, 500); } diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceGenericsTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceGenericsTest.java index 662bfd4121..093a0a8b2d 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceGenericsTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceGenericsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,15 +27,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; /** * @author Michal Gajdos */ -// @RunWith(ConcurrentRunner.class) public class ValidateOnExecutionInheritanceGenericsTest extends ValidateOnExecutionAbstractTest { /** diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceTest.java index b606a6640a..af6e1e8e48 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,12 +28,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Michal Gajdos */ -// @RunWith(ConcurrentRunner.class) public class ValidateOnExecutionInheritanceTest extends ValidateOnExecutionAbstractTest { /** diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionOverrideTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionOverrideTest.java index 6c54c4298b..4a50e47eb3 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionOverrideTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionOverrideTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -33,10 +33,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Testing whether an {@link javax.validation.ValidationException} is raised when {@link ValidateOnExecution} is present on diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/OverrideWadlResourceTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/OverrideWadlResourceTest.java index 4b38262585..392fcfba77 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/OverrideWadlResourceTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/OverrideWadlResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/ResourceExtendedFlagTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/ResourceExtendedFlagTest.java index 3da5917808..37cc260f8e 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/ResourceExtendedFlagTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/ResourceExtendedFlagTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -54,10 +54,10 @@ import org.glassfish.jersey.server.model.ResourceModel; import org.glassfish.jersey.server.wadl.internal.WadlUtils; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.xml.sax.SAXException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test verifies functionality of {@link org.glassfish.jersey.server.model.Resource#isExtended()} and its diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlBeanParamTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlBeanParamTest.java index 8486a72712..e06cbdb19b 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlBeanParamTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlBeanParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -50,15 +50,15 @@ import org.glassfish.jersey.internal.util.SimpleNamespaceResolver; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; - -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.ElementNameAndTextQualifier; -import org.custommonkey.xmlunit.SimpleNamespaceContext; -import org.custommonkey.xmlunit.XMLAssert; -import org.custommonkey.xmlunit.XMLUnit; -import org.junit.Test; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.diff.ComparisonResult; +import org.xmlunit.diff.ComparisonType; +import org.xmlunit.diff.DefaultNodeMatcher; +import org.xmlunit.diff.Diff; +import org.xmlunit.diff.ElementSelectors; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; -import org.w3c.dom.Element; import org.w3c.dom.Node; import com.google.common.collect.ImmutableMap; @@ -77,35 +77,6 @@ */ public class WadlBeanParamTest extends JerseyTest { - private final ElementNameAndTextQualifier elementQualifier = new ElementNameAndTextQualifier() { - - /** - * For {@code } nodes, the comparison is based on matching {@code name} attributes while ignoring - * their order. For any other nodes, strict comparison (including ordering) is made. - * - * @param control The reference element to compare the {@code test} with. - * @param test The test element to compare against {@code control}. - * @return Whether given nodes qualify for comparison. - */ - @Override - public boolean qualifyForComparison(final Element control, final Element test) { - if (test != null && !"param".equals(test.getNodeName())) { - return super.qualifyForComparison(control, test); - } - if (!(control != null && test != null - && equalsNamespace(control, test) - && getNonNamespacedNodeName(control).equals(getNonNamespacedNodeName(test)))) { - return false; - } - if (control.hasAttribute("name") && test.hasAttribute("name")) { - if (control.getAttribute("name").equals(test.getAttribute("name"))) { - return true; - } - } - return false; - } - }; - @Override protected Application configure() { return new ResourceConfig(ReferenceResourceBeanParam.class, TestResourceBeanParam.class, @@ -159,18 +130,28 @@ private void testBeanParamConstructorInitializedBean(String resource) throws Exc final SimpleNamespaceResolver nsContext = new SimpleNamespaceResolver("wadl", "http://wadl.dev.java.net/2009/02"); xp.setNamespaceContext(nsContext); - final Diff diff = XMLUnit.compareXML( + final Diff diff = DiffBuilder.compare( nodeAsString( xp.evaluate("//wadl:resource[@path='wadlBeanParamReference']/wadl:resource", d, - XPathConstants.NODE)), + XPathConstants.NODE))) + .withTest( nodeAsString( xp.evaluate("//wadl:resource[@path='" + resource + "']/wadl:resource", d, XPathConstants.NODE)) - ); - XMLUnit.setXpathNamespaceContext( - new SimpleNamespaceContext(ImmutableMap.of("wadl", "http://wadl.dev.java.net/2009/02"))); - diff.overrideElementQualifier(elementQualifier); - XMLAssert.assertXMLEqual(diff, true); + ).withNamespaceContext(ImmutableMap.of("wadl", "http://wadl.dev.java.net/2009/02")) + /** + * For nodes, the comparison is based on matching {@code name} attributes while ignoring + * their order. For any other nodes, strict comparison (including ordering) is made. + * **/ + .withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndAttributes("name"))) + .withDifferenceEvaluator(((comparison, outcome) -> { + if (outcome == ComparisonResult.DIFFERENT && comparison.getType() == ComparisonType.CHILD_NODELIST_SEQUENCE) { + return ComparisonResult.EQUAL; + } + return outcome; + })) + .build(); + Assertions.assertFalse(diff.hasDifferences()); } @Path("wadlBeanParamReference") diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlEmptyMediaTypeTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlEmptyMediaTypeTest.java index 0aa59caec4..5ce3934267 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlEmptyMediaTypeTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlEmptyMediaTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -34,11 +34,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests, that Jersey returns wildcard mediaType in case no response representation was specified. diff --git a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlResourceTest.java b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlResourceTest.java index 042947b5cd..b89476899a 100644 --- a/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlResourceTest.java +++ b/tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/WadlResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -90,27 +90,25 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.ElementQualifier; -import org.custommonkey.xmlunit.SimpleNamespaceContext; -import org.custommonkey.xmlunit.XMLAssert; -import org.custommonkey.xmlunit.XMLUnit; -import org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import org.xmlunit.builder.DiffBuilder; +import org.xmlunit.diff.Diff; + import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.common.collect.ImmutableMap; @@ -129,8 +127,8 @@ * @author Libor Kramolis * @author Marek Potociar */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ WadlResourceTest.Wadl1Test.class, WadlResourceTest.Wadl2Test.class, WadlResourceTest.Wadl3Test.class, @@ -1057,7 +1055,7 @@ public String postTemplateB(final String str) { } @Test - @Ignore("JERSEY-1670: WADL Options invoked on resources with same template returns only methods from one of them.") + @Disabled("JERSEY-1670: WADL Options invoked on resources with same template returns only methods from one of them.") // TODO: fix public void testWadlForAmbiguousResourceTemplates() throws IOException, SAXException, ParserConfigurationException, XPathExpressionException { @@ -1074,7 +1072,7 @@ public void testWadlForAmbiguousResourceTemplates() } @Test - @Ignore("JERSEY-1670: WADL Options invoked on resources with same template returns only methods from one of them.") + @Disabled("JERSEY-1670: WADL Options invoked on resources with same template returns only methods from one of them.") // TODO: fix public void testWadlForAmbiguousChildResourceTemplates() throws IOException, SAXException, ParserConfigurationException, XPathExpressionException { @@ -1270,19 +1268,16 @@ public void testWadlIsSameForAnnotatedAndNot() throws Exception { final SimpleNamespaceResolver nsContext = new SimpleNamespaceResolver("wadl", "http://wadl.dev.java.net/2009/02"); xp.setNamespaceContext(nsContext); - final Diff diff = XMLUnit.compareXML( + final Diff diff = DiffBuilder.compare( nodeAsString( xp.evaluate("//wadl:resource[@path='annotated']/wadl:resource", document, - XPathConstants.NODE)), + XPathConstants.NODE))) + .withTest( nodeAsString( xp.evaluate("//wadl:resource[@path='not-annotated']/wadl:resource", document, XPathConstants.NODE)) - ); - XMLUnit.setXpathNamespaceContext( - new SimpleNamespaceContext(ImmutableMap.of("wadl", "http://wadl.dev.java.net/2009/02"))); - final ElementQualifier elementQualifier = new RecursiveElementNameAndTextQualifier(); - diff.overrideElementQualifier(elementQualifier); - XMLAssert.assertXMLEqual(diff, true); + ).withNamespaceContext(ImmutableMap.of("wadl", "http://wadl.dev.java.net/2009/02")).build(); + Assertions.assertFalse(diff.hasDifferences()); } diff --git a/tests/e2e-testng/src/test/java/org/glassfish/jersey/tests/e2e/BeforeClassParallelTest.java b/tests/e2e-testng/src/test/java/org/glassfish/jersey/tests/e2e/BeforeClassParallelTest.java index 8ba02b6205..c220a8e1d0 100644 --- a/tests/e2e-testng/src/test/java/org/glassfish/jersey/tests/e2e/BeforeClassParallelTest.java +++ b/tests/e2e-testng/src/test/java/org/glassfish/jersey/tests/e2e/BeforeClassParallelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.ContainerPerClassTestNgStrategy; import org.glassfish.jersey.test.spi.TestNgStrategy; -import org.testng.annotations.AfterClass; -import org.testng.annotations.BeforeClass; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; @@ -36,13 +36,13 @@ public class BeforeClassParallelTest extends AbstractParallelTest { private ConcurrentMap values = new ConcurrentHashMap<>(); - @BeforeClass + @BeforeAll @Override public void setUp() throws Exception { super.setUp(); } - @AfterClass + @AfterAll @Override public void tearDown() throws Exception { super.tearDown(); diff --git a/tests/e2e/pom.xml b/tests/e2e/pom.xml index 5d22471a60..f4f83445b4 100644 --- a/tests/e2e/pom.xml +++ b/tests/e2e/pom.xml @@ -169,6 +169,12 @@ ${project.version} test + + org.junit.platform + junit-platform-suite + ${junit-platform-suite.version} + test + org.glassfish.jersey.test-framework @@ -181,12 +187,6 @@ hamcrest test - - - xmlunit - xmlunit - test - diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AbortingFilterTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AbortingFilterTest.java index 0cffe140fe..511a0f7de8 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AbortingFilterTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AbortingFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -40,8 +40,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * JERSEY-2345 Reproducer. @@ -119,11 +120,13 @@ public void testAbortingResponseFilter() { * Try to abort response in a container request filter. With an invalid WWW-Authenticate header (according to HTTP specs) * and HttpUrlConnector, it throws an exception. This is an original scenario reported by jrh3k5 on java.net */ - @Test(expected = ProcessingException.class) + @Test public void testAbortingFilter() { - final Response response = target().path("simple").request().get(); - int status = response.getStatus(); - logger.info("Response status is: " + status); + assertThrows(ProcessingException.class, () -> { + final Response response = target().path("simple").request().get(); + int status = response.getStatus(); + logger.info("Response status is: " + status); + }); } /** @@ -144,11 +147,13 @@ public void testAbortingFilterWithApacheConnector() { /** * This test shows, that the behaviour is not caused by the use of the filters, but by the response content itself. */ - @Test(expected = ProcessingException.class) + @Test public void testDirectResponse() { - final Response response = target().path("simple/direct").request().get(); - int status = response.getStatus(); - logger.info("Response status is: " + status); + assertThrows(ProcessingException.class, () -> { + final Response response = target().path("simple/direct").request().get(); + int status = response.getStatus(); + logger.info("Response status is: " + status); + }); } /** diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AcceptMediaTypeProviderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AcceptMediaTypeProviderTest.java index 13ae165ac8..9bc42eb3f0 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AcceptMediaTypeProviderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AcceptMediaTypeProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -21,10 +21,10 @@ import javax.ws.rs.core.MediaType; import org.glassfish.jersey.message.internal.AcceptableMediaType; import org.glassfish.jersey.message.internal.HttpHeaderReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author unknown diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AnnotationInheritanceTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AnnotationInheritanceTest.java index 9f463481d8..1111d79725 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AnnotationInheritanceTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/AnnotationInheritanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -19,14 +19,14 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test that JAX-RS annotations are correctly inherited according to the specification. @@ -117,11 +117,11 @@ public String getBar() { @Test public void testSuperClassPrecedence() { final String superClassResponse = target().path("foo/superFooHello").request(MediaType.TEXT_PLAIN).get(String.class); - assertEquals("The path from the super-class annotation should be used instead of the path from interface", - "Hello!", superClassResponse); + assertEquals("Hello!", superClassResponse, + "The path from the super-class annotation should be used instead of the path from interface"); final Response ifaceResponse = target().path("foo/fooableHello").request(MediaType.TEXT_PLAIN).get(Response.class); - assertEquals("The path defined in the interface annotation should not exist.", 404, ifaceResponse.getStatus()); + assertEquals(404, ifaceResponse.getStatus(), "The path defined in the interface annotation should not exist."); } /** @@ -130,8 +130,7 @@ public void testSuperClassPrecedence() { @Test public void testInterfaceAnnotationInheritance() { final String response = target().path("foo/fooableHi").request(MediaType.TEXT_PLAIN).get(String.class); - assertEquals("The path from the super-class annotation should inherited.", - "Hi!", response); + assertEquals("Hi!", response, "The path from the super-class annotation should inherited."); } /** @@ -143,8 +142,7 @@ public void testInterfaceAnnotationInheritance() { @Test public void testInheritenceFromSuperclassInterface() { final String response = target().path("foo/superFooableWhatsUp").request(MediaType.TEXT_PLAIN).get(String.class); - assertEquals("The path from the interface of the superclass should inherited.", - "What's up?", response); + assertEquals("What's up?", response, "The path from the interface of the superclass should inherited."); } /** @@ -157,11 +155,11 @@ public void testInheritenceFromSuperclassInterface() { @Test public void testClassAnnotationInheritance() { final String superClassResponse = target().path("hyperBar/bar").request(MediaType.TEXT_PLAIN).get(String.class); - assertEquals("The path from the superclass annotation should be used instead of the path from interface", - "bar", superClassResponse); + assertEquals("bar", superClassResponse, + "The path from the superclass annotation should be used instead of the path from interface"); final Response ifaceResponse = target().path("barable/bar").request(MediaType.TEXT_PLAIN).get(Response.class); - assertEquals("The path defined in the interface annotation should not exist.", 404, ifaceResponse.getStatus()); + assertEquals(404, ifaceResponse.getStatus(), "The path defined in the interface annotation should not exist."); } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ApplicationCachingTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ApplicationCachingTest.java index 6286924997..b71b182bb8 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ApplicationCachingTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ApplicationCachingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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,8 +18,8 @@ import org.glassfish.jersey.server.ServerProperties; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -81,8 +81,8 @@ protected Application configure() { @Test public void testOneTimeCalled() { try (Response r = target().request().get()) { - Assert.assertEquals(200, r.getStatus()); + Assertions.assertEquals(200, r.getStatus()); } - Assert.assertEquals(1, singletonCounter.get()); + Assertions.assertEquals(1, singletonCounter.get()); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/CacheControlImplTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/CacheControlImplTest.java index 678c965d06..801147ba54 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/CacheControlImplTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/CacheControlImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,8 +20,8 @@ import org.glassfish.jersey.message.internal.CacheControlProvider; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Marc Hadley diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ClientInvocationTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ClientInvocationTest.java index 200f0ec45d..aa0941d586 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ClientInvocationTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ClientInvocationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -32,9 +32,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * {@link Invocation} E2E API tests. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ConstructorSelectionTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ConstructorSelectionTest.java index 51bfaa2da6..851fb64867 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ConstructorSelectionTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ConstructorSelectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -42,9 +42,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test to verify the proper constructor is selected. @@ -211,8 +211,8 @@ protected Application configure() { public void testResourceConstructorSelection() { final Response response = target("resource-test").request().get(); - assertNotNull("Returned response must not be null.", response); - assertEquals("Resource constructor with most arguments has not been selected.", 200, response.getStatus()); + assertNotNull(response, "Returned response must not be null."); + assertEquals(200, response.getStatus(), "Resource constructor with most arguments has not been selected."); } /** @@ -222,7 +222,7 @@ public void testResourceConstructorSelection() { public void testProviderConstructorSelection() { final Response response = target("provider-test").request().post(Entity.text("echo")); - assertNotNull("Returned response must not be null.", response); + assertNotNull(response, "Returned response must not be null."); assertEquals(200, response.getStatus()); assertEquals("pass", response.readEntity(String.class)); } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ConsumeProduceTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ConsumeProduceTest.java index cc946677bc..590a6a1eb0 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ConsumeProduceTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ConsumeProduceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -22,9 +22,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.glassfish.jersey.message.internal.MediaTypes; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ContentDispositionTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ContentDispositionTest.java index 8cbdcc1a50..f54685fe63 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ContentDispositionTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ContentDispositionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,11 +23,11 @@ import org.glassfish.jersey.message.internal.HttpDateFormat; import org.glassfish.jersey.message.internal.HttpHeaderReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/CookieImplTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/CookieImplTest.java index db4d91c69c..234d855f5f 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/CookieImplTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/CookieImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.message.internal.HttpHeaderReader; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Marc Hadley diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/EntityTagProviderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/EntityTagProviderTest.java index dc6f80b526..bd76e67e9b 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/EntityTagProviderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/EntityTagProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,9 +20,9 @@ import org.glassfish.jersey.message.internal.EntityTagProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Marc Hadley diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ExceptionTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ExceptionTest.java index fd53e8577d..11c493cf49 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ExceptionTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -56,10 +56,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; /** * Exception throwing and handling related tests; such as @@ -703,9 +703,8 @@ public void testWaeExceptionThrownFromParamConverter() { private void testSingle(String caseName, int expectedStatus, Invocation.Builder request) { final Response response = request.get(); - assertEquals("Test of an exception thrown during field/parameter injection [" + caseName + "] failed.", - expectedStatus, - response.getStatus()); + assertEquals(expectedStatus, response.getStatus(), + "Test of an exception thrown during field/parameter injection [" + caseName + "] failed."); } /** * END: JERSEY-1532 reproducer code. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/FormDataContentDispositionTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/FormDataContentDispositionTest.java index 9d74547f6c..c9318094b2 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/FormDataContentDispositionTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/FormDataContentDispositionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.message.internal.HttpDateFormat; import org.glassfish.jersey.message.internal.HttpHeaderReader; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Imran@SmartITEngineering.Com diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/HttpHeaderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/HttpHeaderTest.java index b0ecbdcba9..4b6227a058 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/HttpHeaderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/HttpHeaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -28,9 +28,9 @@ import org.glassfish.jersey.message.internal.LanguageTag; import org.glassfish.jersey.message.internal.ParameterizedHeader; import org.glassfish.jersey.message.internal.Token; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Paul Sandoz diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocaleProviderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocaleProviderTest.java index 9bce717224..6539e35ca1 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocaleProviderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocaleProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,9 +19,9 @@ import java.util.Locale; import org.glassfish.jersey.message.internal.LocaleProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Mark Hadley diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderAsyncTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderAsyncTest.java index e8f71e9426..ac1d98b405 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderAsyncTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderAsyncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -41,22 +41,23 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test if the location relativer URI is correctly resolved within asynchronous processing cases. * * @author Adam Lindenthal */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class LocationHeaderAsyncTest extends JerseyTest { private static final Logger LOGGER = Logger.getLogger(LocationHeaderAsyncTest.class.getName()); @@ -77,6 +78,7 @@ protected ResourceConfig configure() { * In this case it prepares executor thread pool of size one and initializes the thread. * @throws Exception */ + @BeforeEach @Override public void setUp() throws Exception { super.setUp(); @@ -212,6 +214,7 @@ private UriBuilder getUriBuilder() { * Basic asynchronous testcase; checks if the URI is correctly absolutized also within a separate thread during * async processing */ + @Execution(ExecutionMode.CONCURRENT) @Test public void testAsync() { final String expectedUri = getBaseUri() + "ResponseTest/locationAsync"; @@ -219,7 +222,7 @@ public void testAsync() { final String msg = String.format("Comparison failed in the resource method. \nExpected: %1$s\nActual: %2$s", expectedUri, response.readEntity(String.class)); - assertNotEquals(msg, response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + assertNotEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), msg); final String location = response.getHeaderString(HttpHeaders.LOCATION); LOGGER.info("Location resolved from response > " + location); @@ -229,23 +232,25 @@ public void testAsync() { /** * Test with a thread from thread-pool (created out of request scope) */ + @Execution(ExecutionMode.CONCURRENT) @Test public void testExecutorAsync() { final Response response = target().path("ResponseTest/executorAsync").request().get(Response.class); final String location = response.getHeaderString(HttpHeaders.LOCATION); LOGGER.info("Location resolved from response > " + location); - assertFalse("The comparison failed in the resource method.", executorComparisonFailed.get()); + assertFalse(executorComparisonFailed.get(), "The comparison failed in the resource method."); assertEquals(getBaseUri() + "ResponseTest/executorAsync", location); } /** * Asynchronous testcase split over two distinct requests */ + @Execution(ExecutionMode.CONCURRENT) @Test public void testSeparatedAsync() throws ExecutionException, InterruptedException { final Future futureResponse = target().path("ResponseTest/locationAsyncStart").request().async().get(); final Boolean result = target().path("ResponseTest/locationAsyncFinish").request().get(Boolean.class); - assertFalse("Thread was interrupted on inserting into blocking queue.", interrupted.get()); + assertFalse(interrupted.get(), "Thread was interrupted on inserting into blocking queue."); assertTrue(result); final Response response = futureResponse.get(); diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderBasicTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderBasicTest.java index 338baefce5..0e82a19f56 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderBasicTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderBasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -37,23 +37,24 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.glassfish.jersey.test.util.runner.ConcurrentRunner; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.parallel.Execution; +import org.junit.jupiter.api.parallel.ExecutionMode; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test if the location relative URI is correctly resolved within basic cases. * * @author Adam Lindenthal */ -@RunWith(ConcurrentRunner.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class LocationHeaderBasicTest extends JerseyTest { private static final Logger LOGGER = Logger.getLogger(LocationHeaderBasicTest.class.getName()); @@ -231,6 +232,7 @@ private UriBuilder getUriBuilder() { * Basic test; resource methods returns relative uri, test expects uri to be absolute */ @Test + @Execution(ExecutionMode.CONCURRENT) public void testConvertRelativeUriToAbsolute() { checkResource("ResponseTest/location", "location"); // checkResource("ResponseTest/location"); @@ -241,6 +243,7 @@ public void testConvertRelativeUriToAbsolute() { * This test ensures, that the uri conversion works even in case when entity is present. */ @Test + @Execution(ExecutionMode.CONCURRENT) public void testAbsoluteUriWithEntity() { final Response response = checkResource("ResponseTest/locationWithBody", "locationWithBody"); assertNotNull(response.getEntity()); @@ -252,23 +255,26 @@ public void testAbsoluteUriWithEntity() { * Ensures, that the null location is processed correctly. */ @Test + @Execution(ExecutionMode.CONCURRENT) public void testNullLocation() { final Response response = target().path("ResponseTest/locationNull").request(MediaType.TEXT_PLAIN).get(Response.class); final String location = response.getHeaderString(HttpHeaders.LOCATION); LOGGER.info("Location resolved from response > " + location); - assertNull("Location header should be absolute URI", location); + assertNull(location, "Location header should be absolute URI"); } /** * Tests if the URI is absolutized in the Response directly after Response.Builder.created() is called */ @Test + @Execution(ExecutionMode.CONCURRENT) public void testConversionDirectly() { final Boolean result = target().path("ResponseTest/locationDirect").request(MediaType.TEXT_PLAIN).get(Boolean.class); assertTrue(result); } @Test + @Execution(ExecutionMode.CONCURRENT) public void testSeeOther() { Response response = target().path("ResponseTest/seeOther").request() .post(Entity.entity("TEXT", MediaType.TEXT_PLAIN_TYPE)); @@ -285,6 +291,7 @@ public void testSeeOther() { } @Test + @Execution(ExecutionMode.CONCURRENT) public void testTemporaryRedirect() { Response response = target().path("ResponseTest/temporaryRedirect").request(MediaType.TEXT_PLAIN).get(Response.class); String location = response.getHeaderString(HttpHeaders.LOCATION); diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderFiltersTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderFiltersTest.java index 8ee7f1fede..dcd66c9d03 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderFiltersTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderFiltersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -19,7 +19,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -50,10 +51,10 @@ import java.util.concurrent.Executors; import java.util.logging.Logger; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Test if the location response header relative URI is correctly resolved within complex cases with interceptors, filters, @@ -85,6 +86,7 @@ protected ResourceConfig configure() { * In this case it prepares executor thread pool of size one and initializes the thread. * @throws Exception */ + @BeforeEach @Override public void setUp() throws Exception { super.setUp(); @@ -147,8 +149,8 @@ public Response locationTestWithInterceptor() { @GET @Path("locationAborted") public String locationTestAborted() { - assertTrue("The resource method locationTestAborted() should not have been called. The post-matching filter was " - + "not configured correctly. ", false); + assertTrue(false, "The resource method locationTestAborted() should not have been called. " + + "The post-matching filter was not configured correctly."); return "DUMMY_RESPONSE"; // this string should never reach the client (the resource method will not be called) } @@ -161,8 +163,8 @@ public String locationTestAborted() { @GET @Path("locationAbortedPreMatching") public String locationTestPreMatchingAborted() { - assertTrue("The resource method locationTestPreMatchingAborted() should not have been called. The pre-matching " - + "filter was not configured correctly. ", false); + assertTrue(false, "The resource method locationTestPreMatchingAborted() should not have been called. " + + "The pre-matching filter was not configured correctly."); return "DUMMY_RESPONSE"; // this string should never reach the client (the resource method will not be called) } @@ -587,8 +589,8 @@ private Response checkResource(final String resourcePath, final String expectedR private void checkResponseFilter(final String resourcePath, final String expectedRelativeUri) { final Response response = target().path(resourcePath).request().get(Response.class); - assertNotEquals("Message from response filter: " + response.readEntity(String.class), - response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + assertNotEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), + "Message from response filter: " + response.readEntity(String.class)); assertEquals(getBaseUri() + expectedRelativeUri, response.getLocation().toString()); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderWithAbsolutizationDisabledTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderWithAbsolutizationDisabledTest.java index 93ef150e2d..7b25771463 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderWithAbsolutizationDisabledTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderWithAbsolutizationDisabledTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -30,10 +30,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Test if the location response header is left intact in case the diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderWithIncompatibleFlagTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderWithIncompatibleFlagTest.java index 1e18d54469..d442b2b902 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderWithIncompatibleFlagTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/LocationHeaderWithIncompatibleFlagTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -30,10 +30,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Test if the location response header is resolved according to RFC7231 (in a JAX-RS 2.0 incompatible way) when diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MediaTypeProviderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MediaTypeProviderTest.java index 782fe8e1d2..17c8a9fb88 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MediaTypeProviderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MediaTypeProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -22,10 +22,10 @@ import org.glassfish.jersey.message.internal.MediaTypeProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Media type provider tests. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MessageBodyReaderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MessageBodyReaderTest.java index d0bd7f6e88..191896db6e 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MessageBodyReaderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MessageBodyReaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -44,8 +44,8 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Jan Supol (jan.supol at oracle.com) diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MessageBodyWriterTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MessageBodyWriterTest.java index a3f75e5657..ad14824743 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MessageBodyWriterTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/MessageBodyWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -44,10 +44,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Various MessageBodyWriter tests. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/OptionsTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/OptionsTest.java index 0cca39d0fd..4614c8f700 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/OptionsTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/OptionsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/QualitySourceMediaTypeProviderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/QualitySourceMediaTypeProviderTest.java index 83719090d8..38466df199 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/QualitySourceMediaTypeProviderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/QualitySourceMediaTypeProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.message.internal.HttpHeaderReader; import org.glassfish.jersey.message.internal.QualitySourceMediaType; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author unknown diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResourceContextTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResourceContextTest.java index 2ed454196d..de51c03f7d 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResourceContextTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResourceContextTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,10 +29,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test {@link ResourceContext}: resource context must provide access to @@ -45,9 +45,9 @@ */ public class ResourceContextTest extends JerseyTest { - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } @Override diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseE2ETest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseE2ETest.java index d993c23587..df79b4aee9 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseE2ETest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseE2ETest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -42,10 +42,10 @@ import org.glassfish.jersey.server.Uri; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Response E2E tests. @@ -273,9 +273,9 @@ protected Application configure() { public void testCustomResponse() { final Response response = target("response").path("custom").request().get(); - assertNotNull("Response is null.", response); - assertEquals("Unexpected response status.", 200, response.getStatus()); - assertEquals("Unexpected response entity.", "subresponse", response.readEntity(String.class)); + assertNotNull(response, "Response is null."); + assertEquals(200, response.getStatus(), "Unexpected response status."); + assertEquals("subresponse", response.readEntity(String.class), "Unexpected response entity."); } /** @@ -287,14 +287,14 @@ public void testNoStatusResponse() { Response response; response = target.resolveTemplate("param", "with").request().get(); - assertNotNull("Response is null.", response); - assertEquals("Unexpected response status.", 200, response.getStatus()); - assertEquals("Unexpected response entity.", "1234567890", response.readEntity(String.class)); + assertNotNull(response, "Response is null."); + assertEquals(200, response.getStatus(), "Unexpected response status."); + assertEquals("1234567890", response.readEntity(String.class), "Unexpected response entity."); response = target.resolveTemplate("param", "without").request().get(); - assertNotNull("Response is null.", response); - assertEquals("Unexpected response status.", 204, response.getStatus()); - assertFalse("Unexpected non-empty response entity.", response.hasEntity()); + assertNotNull(response, "Response is null."); + assertEquals(204, response.getStatus(), "Unexpected response status."); + assertFalse(response.hasEntity(), "Unexpected non-empty response entity."); } /** @@ -304,9 +304,9 @@ public void testNoStatusResponse() { public void testNullResponse() { final Response response = target("response").path("null").request().get(); - assertNotNull("Response is null.", response); - assertEquals("Unexpected response status.", 204, response.getStatus()); - assertFalse("Unexpected non-empty response entity.", response.hasEntity()); + assertNotNull(response, "Response is null."); + assertEquals(204, response.getStatus(), "Unexpected response status."); + assertFalse(response.hasEntity(), "Unexpected non-empty response entity."); } /** @@ -318,9 +318,9 @@ public void testInboundOutboundResponseMixing() { Response response; response = target.request().get(); - assertNotNull("Response is null.", response); - assertEquals("Unexpected response status.", 200, response.getStatus()); - assertEquals("Unexpected response entity.", "internal", response.readEntity(String.class)); + assertNotNull(response, "Response is null."); + assertEquals(200, response.getStatus(), "Unexpected response status."); + assertEquals("internal", response.readEntity(String.class), "Unexpected response entity."); } /** @@ -334,9 +334,9 @@ public void testEntityInNotModifiedPutResposne() { Response response; response = target.request().put(Entity.text("put-data")); - assertNotNull("Response is null.", response); - assertEquals("Unexpected response status.", Response.Status.NOT_MODIFIED.getStatusCode(), response.getStatus()); + assertNotNull(response, "Response is null."); + assertEquals(Response.Status.NOT_MODIFIED.getStatusCode(), response.getStatus(), "Unexpected response status."); // response entity is dropped by server container in compliance with HTTP 1.1 spec - assertFalse("Unexpected response entity.", response.hasEntity()); + assertFalse(response.hasEntity(), "Unexpected response entity."); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseIntegrationTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseIntegrationTest.java index 9703c96613..43e91c24f1 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseIntegrationTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseTest.java index acac1b7762..f1f42bcb59 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/ResponseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,11 +35,11 @@ import org.glassfish.jersey.internal.util.PropertiesHelper; import org.glassfish.jersey.message.internal.HeaderUtils; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Pavel Bucek diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/RestrictedHeaderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/RestrictedHeaderTest.java index 06568bd38f..99d8dce740 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/RestrictedHeaderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/RestrictedHeaderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,9 +35,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * Test setting headers that are restricted by {@link java.net.HttpURLConnection}. @@ -70,13 +70,13 @@ protected ResourceConfig configure() { return new ResourceConfig(MyResource.class, LoggingFeature.class); } - @Ignore("The setting of allowRestrictedHeaders system property is global and cached. Only " + @Disabled("The setting of allowRestrictedHeaders system property is global and cached. Only " + "one of both testForbiddenHeadersNotAllowed() and testForbiddenHeadersAllowed() can be run during one test.") @Test public void testForbiddenHeadersNotAllowed() { Client client = ClientBuilder.newClient(); Response response = testHeaders(client); - Assert.assertEquals(500, response.getStatus()); + Assertions.assertEquals(500, response.getStatus()); } /** @@ -92,7 +92,7 @@ public void testForbiddenHeadersAllowed() { Response response = testHeaders(client); System.out.println(response.readEntity(String.class)); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); } /** diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/SourceEntityProviderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/SourceEntityProviderTest.java index 47b6173456..896636adeb 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/SourceEntityProviderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/SourceEntityProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -48,12 +48,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test of {@link javax.xml.transform.Source Source} MessageBody Provider @@ -143,8 +143,8 @@ public void getSaxSourceTest() throws Exception { Response response = target().path("test").path("sax").request().get(); assertEquals(Status.OK.getStatusCode(), response.getStatus()); String content = extractContent(response.readEntity(SAXSource.class)); - assertTrue("Content '" + content + "' does not start with the expected prefix '" + prefix + "'", - content.startsWith(prefix) || content.startsWith(xdkPrefix)); + assertTrue(content.startsWith(prefix) || content.startsWith(xdkPrefix), + "Content '" + content + "' does not start with the expected prefix '" + prefix + "'"); } @Test @@ -152,8 +152,8 @@ public void getDomSourceTest() throws Exception { Response response = target().path("test").path("dom").request().get(); assertEquals(Status.OK.getStatusCode(), response.getStatus()); String content = extractContent(response.readEntity(DOMSource.class)); - assertTrue("Content '" + content + "' does not start with the expected prefix '" + prefix + "'", - content.startsWith(prefix) || content.startsWith(xdkPrefix)); + assertTrue(content.startsWith(prefix) || content.startsWith(xdkPrefix), + "Content '" + content + "' does not start with the expected prefix '" + prefix + "'"); } private static SAXSource createSAXSource(String content) throws SAXException, ParserConfigurationException { diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/UnsafeCharsInUriTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/UnsafeCharsInUriTest.java index 14bb29939f..468e3ecd23 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/UnsafeCharsInUriTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/UnsafeCharsInUriTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -34,9 +34,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertArrayEquals; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; /** * Test if URI can contain unsafe characters in the query parameter, e.g. for sending JSON @@ -82,7 +82,7 @@ public void testSpecCharsInUriWithSockets() throws IOException { } @Test - @Ignore("Incorrectly written test (doesn't deal with http encoding).") + @Disabled("Incorrectly written test (doesn't deal with http encoding).") public void testSecialCharsInQueryParam() throws IOException { // quotes are encoded by browsers, curly brackets are not, so the quotes will be sent pre-encoded // HTTP 1.0 is used for simplicity diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/VariantsTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/VariantsTest.java index e283a01ca3..a2f72316c6 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/VariantsTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/api/VariantsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -33,10 +33,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Server-side variant selection & handling test. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ClientTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ClientTest.java index 9b13afe3b3..0eb7b83d27 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ClientTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -38,11 +38,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Marek Potociar @@ -132,12 +132,12 @@ public void testContextHeaders() { reqHeaders = r.readEntity(String.class).toLowerCase(); for (final String expected : new String[] {"custom-header:[custom-value]", "custom-header:custom-value"}) { - assertTrue(String.format("Request headers do not contain expected '%s' entry:\n%s", expected, reqHeaders), - reqHeaders.contains(expected)); + assertTrue(reqHeaders.contains(expected), + String.format("Request headers do not contain expected '%s' entry:\n%s", expected, reqHeaders)); } final String unexpected = "content-encoding"; - assertFalse(String.format("Request headers contains unexpected '%s' entry:\n%s", unexpected, reqHeaders), - reqHeaders.contains(unexpected)); + assertFalse(reqHeaders.contains(unexpected), + String.format("Request headers contains unexpected '%s' entry:\n%s", unexpected, reqHeaders)); ib = target.request("*/*"); i = ib.build("POST", @@ -146,7 +146,7 @@ public void testContextHeaders() { final String expected = "content-encoding:[deflate]"; reqHeaders = r.readEntity(String.class).toLowerCase(); - assertTrue(String.format("Request headers do not contain expected '%s' entry:\n%s", expected, reqHeaders), - reqHeaders.contains(expected)); + assertTrue(reqHeaders.contains(expected), + String.format("Request headers do not contain expected '%s' entry:\n%s", expected, reqHeaders)); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ExecutorServiceProviderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ExecutorServiceProviderTest.java index 654bce4af2..246ccc5ae5 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ExecutorServiceProviderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/ExecutorServiceProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -55,9 +55,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.spi.ExecutorServiceProvider; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * {@link org.glassfish.jersey.spi.ExecutorServiceProvider} E2E tests. @@ -277,10 +277,10 @@ public void testCustomClientExecutorsInjectionAndReleasing() throws Exception { assertEquals("resource", response.readEntity(String.class)); // no executors should be created or released at this point yet - assertEquals("Unexpected number of created client executors", 0, provider.executorCreationCount); - assertEquals("Unexpected number of released client executors", 0, provider.executorReleaseCount); - assertEquals("Unexpected number of client executors stored in the set.", - 0, provider.executors.size()); + assertEquals(0, provider.executorCreationCount, "Unexpected number of created client executors"); + assertEquals(0, provider.executorReleaseCount, "Unexpected number of released client executors"); + assertEquals(0, provider.executors.size(), + "Unexpected number of client executors stored in the set."); Future fr = client.target(getBaseUri()).path("resource").request().async().get(); response = fr.get(); @@ -289,18 +289,16 @@ public void testCustomClientExecutorsInjectionAndReleasing() throws Exception { assertEquals("resource", response.readEntity(String.class)); // single executor should be created but not released at this point yet - assertEquals("Unexpected number of created client executors", 1, provider.executorCreationCount); - assertEquals("Unexpected number of released client executors", 0, provider.executorReleaseCount); - assertEquals("Unexpected number of client executors stored in the set.", - 1, provider.executors.size()); + assertEquals(1, provider.executorCreationCount, "Unexpected number of created client executors"); + assertEquals(0, provider.executorReleaseCount, "Unexpected number of released client executors"); + assertEquals(1, provider.executors.size(), "Unexpected number of client executors stored in the set."); client.close(); // the created executor needs to be released by now; no more executors should be created - assertEquals("Unexpected number of created client executors", 1, provider.executorCreationCount); - assertEquals("Unexpected number of released client executors", 1, provider.executorReleaseCount); - assertEquals("Unexpected number of client executors stored in the set.", - 0, provider.executors.size()); + assertEquals(1, provider.executorCreationCount, "Unexpected number of created client executors"); + assertEquals(1, provider.executorReleaseCount, "Unexpected number of released client executors"); + assertEquals(0, provider.executors.size(), "Unexpected number of client executors stored in the set."); } /** @@ -319,10 +317,9 @@ public void testCustomServerExecutorsInjectionAndReleasing() throws Exception { assertEquals("resource", response.readEntity(String.class)); // no executors should be created or released at this point yet - assertEquals("Unexpected number of created server executors", 0, serverExecutorProvider.executorCreationCount); - assertEquals("Unexpected number of released server executors", 0, serverExecutorProvider.executorReleaseCount); - assertEquals("Unexpected number of server executors stored in the set.", - 0, serverExecutorProvider.executors.size()); + assertEquals(0, serverExecutorProvider.executorCreationCount, "Unexpected number of created server executors"); + assertEquals(0, serverExecutorProvider.executorReleaseCount, "Unexpected number of released server executors"); + assertEquals(0, serverExecutorProvider.executors.size(), "Unexpected number of server executors stored in the set."); response = target("resource/async").request().get(); @@ -330,18 +327,16 @@ public void testCustomServerExecutorsInjectionAndReleasing() throws Exception { assertEquals("async-resource-passed", response.readEntity(String.class)); // single executor should be created but not released at this point yet - assertEquals("Unexpected number of created server executors", 1, serverExecutorProvider.executorCreationCount); - assertEquals("Unexpected number of released server executors", 0, serverExecutorProvider.executorReleaseCount); - assertEquals("Unexpected number of server executors stored in the set.", - 1, serverExecutorProvider.executors.size()); + assertEquals(1, serverExecutorProvider.executorCreationCount, "Unexpected number of created server executors"); + assertEquals(0, serverExecutorProvider.executorReleaseCount, "Unexpected number of released server executors"); + assertEquals(1, serverExecutorProvider.executors.size(), "Unexpected number of server executors stored in the set."); tearDown(); // stopping test container // the created executor needs to be released by now; no more executors should be created - assertEquals("Unexpected number of created server executors", 1, serverExecutorProvider.executorCreationCount); - assertEquals("Unexpected number of released server executors", 1, serverExecutorProvider.executorReleaseCount); - assertEquals("Unexpected number of server executors stored in the set.", - 0, serverExecutorProvider.executors.size()); + assertEquals(1, serverExecutorProvider.executorCreationCount, "Unexpected number of created server executors"); + assertEquals(1, serverExecutorProvider.executorReleaseCount, "Unexpected number of released server executors"); + assertEquals(0, serverExecutorProvider.executors.size(), "Unexpected number of server executors stored in the set."); setUp(); // re-starting test container to ensure proper post-test tearDown. } @@ -361,18 +356,16 @@ public void testCustomNamedServerExecutorsInjectionAndReleasing() throws Excepti assertEquals("custom-async-resource-passed", response.readEntity(String.class)); // single executor should be created but not released at this point yet - assertEquals("Unexpected number of created server executors", 1, serverExecutorProvider.executorCreationCount); - assertEquals("Unexpected number of released server executors", 0, serverExecutorProvider.executorReleaseCount); - assertEquals("Unexpected number of server executors stored in the set.", - 1, serverExecutorProvider.executors.size()); + assertEquals(1, serverExecutorProvider.executorCreationCount, "Unexpected number of created server executors"); + assertEquals(0, serverExecutorProvider.executorReleaseCount, "Unexpected number of released server executors"); + assertEquals(1, serverExecutorProvider.executors.size(), "Unexpected number of server executors stored in the set."); tearDown(); // stopping test container // the created executor needs to be released by now; no more executors should be created - assertEquals("Unexpected number of created server executors", 1, serverExecutorProvider.executorCreationCount); - assertEquals("Unexpected number of released server executors", 1, serverExecutorProvider.executorReleaseCount); - assertEquals("Unexpected number of server executors stored in the set.", - 0, serverExecutorProvider.executors.size()); + assertEquals(1, serverExecutorProvider.executorCreationCount, "Unexpected number of created server executors"); + assertEquals(1, serverExecutorProvider.executorReleaseCount, "Unexpected number of released server executors"); + assertEquals(0, serverExecutorProvider.executors.size(), "Unexpected number of server executors stored in the set."); setUp(); // re-starting test container to ensure proper post-test tearDown. } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/InterceptorCustomTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/InterceptorCustomTest.java index b2aac950d9..ab799d9861 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/InterceptorCustomTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/InterceptorCustomTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -46,10 +46,10 @@ import org.glassfish.jersey.tests.e2e.InterceptorGzipTest.GZIPReaderTestInterceptor; import org.glassfish.jersey.tests.e2e.InterceptorGzipTest.GZIPWriterTestInterceptor; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests interceptors. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/InterceptorGzipTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/InterceptorGzipTest.java index 96475ab696..6b2d764be7 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/InterceptorGzipTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/InterceptorGzipTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -47,8 +47,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests gzip interceptors. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/LinkTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/LinkTest.java index e7033ed795..2ba39fb62a 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/LinkTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/LinkTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,10 +35,10 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.uri.UriTemplate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Martin Matula diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/MessageBodyExceptionWrappingTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/MessageBodyExceptionWrappingTest.java index c2446f4b9f..431203b6af 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/MessageBodyExceptionWrappingTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/MessageBodyExceptionWrappingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -40,9 +40,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import static javax.ws.rs.client.Entity.entity; diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/HugeEntityTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/HugeEntityTest.java index e157590185..49a47735ea 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/HugeEntityTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/HugeEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -21,8 +21,6 @@ import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.List; import java.util.concurrent.Future; import javax.ws.rs.POST; @@ -43,10 +41,7 @@ import org.glassfish.jersey.jdk.connector.JdkConnectorProvider; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; @@ -55,8 +50,7 @@ * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) -public class HugeEntityTest extends JerseyTest { +public class HugeEntityTest { private static final int BUFFER_LENGTH = 1024 * 1024; // 1M private static final long HUGE_DATA_LENGTH = 20L * 1024L * 1024L * 1024L; // 20G seems sufficient @@ -98,27 +92,72 @@ public String echo(String s) { } } - private final ConnectorProvider connectorProvider; - - public HugeEntityTest(ConnectorProvider connectorProvider) { - this.connectorProvider = connectorProvider; + public static class GrizzlyConnectorProviderHugeEntityTest extends HugeEntityTemplateTest { + public GrizzlyConnectorProviderHugeEntityTest() { + super(new GrizzlyConnectorProvider()); + } } - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new GrizzlyConnectorProvider(), new JdkConnectorProvider()); + public static class JdkConnectorProviderHugeEntityTest extends HugeEntityTemplateTest { + public JdkConnectorProviderHugeEntityTest() { + super(new JdkConnectorProvider()); + } } - @Override - protected Application configure() { - return new ResourceConfig(ConsumerResource.class); - } + public abstract static class HugeEntityTemplateTest extends JerseyTest { + private final ConnectorProvider connectorProvider; + + public HugeEntityTemplateTest(ConnectorProvider connectorProvider) { + this.connectorProvider = connectorProvider; + } + + @Override + protected Application configure() { + return new ResourceConfig(ConsumerResource.class); + } + + @Override + protected void configureClient(ClientConfig config) { + config.register(TestEntityWriter.class); + config.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.CHUNKED); + config.connectorProvider(connectorProvider); + } + + /** + * JERSEY-2337 reproducer. We are going to send huge amount of data over the wire. + * Should not the data have been chunk-encoded, we would easily run out of memory. + * + * @throws Exception in case of a test error. + */ + @Test + public void testPost() throws Exception { + Response response = target("/size").request() + .post(Entity.entity(new TestEntity(HUGE_DATA_LENGTH), MediaType.APPLICATION_OCTET_STREAM_TYPE)); + String content = response.readEntity(String.class); + assertThat(Long.parseLong(content), equalTo(HUGE_DATA_LENGTH)); + + // just to check the right data have been transfered. + response = target("/echo").request().post(Entity.text("Hey Sync!")); + assertThat(response.readEntity(String.class), equalTo("Hey Sync!")); + } - @Override - protected void configureClient(ClientConfig config) { - config.register(TestEntityWriter.class); - config.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.CHUNKED); - config.connectorProvider(connectorProvider); + /** + * JERSEY-2337 reproducer. We are going to send huge amount of data over the wire. This time in an async fashion. + * Should not the data have been chunk-encoded, we would easily run out of memory. + * + * @throws Exception in case of a test error. + */ + @Test + public void testAsyncPost() throws Exception { + Future response = target("/size").request().async() + .post(Entity.entity(new TestEntity(HUGE_DATA_LENGTH), MediaType.APPLICATION_OCTET_STREAM_TYPE)); + final String content = response.get().readEntity(String.class); + assertThat(Long.parseLong(content), equalTo(HUGE_DATA_LENGTH)); + + // just to check the right data have been transfered. + response = target("/echo").request().async().post(Entity.text("Hey Async!")); + assertThat(response.get().readEntity(String.class), equalTo("Hey Async!")); + } } public static class TestEntity { @@ -167,40 +206,4 @@ public void writeTo(TestEntity t, } } } - - /** - * JERSEY-2337 reproducer. We are going to send huge amount of data over the wire. - * Should not the data have been chunk-encoded, we would easily run out of memory. - * - * @throws Exception in case of a test error. - */ - @Test - public void testPost() throws Exception { - Response response = target("/size").request() - .post(Entity.entity(new TestEntity(HUGE_DATA_LENGTH), MediaType.APPLICATION_OCTET_STREAM_TYPE)); - String content = response.readEntity(String.class); - assertThat(Long.parseLong(content), equalTo(HUGE_DATA_LENGTH)); - - // just to check the right data have been transfered. - response = target("/echo").request().post(Entity.text("Hey Sync!")); - assertThat(response.readEntity(String.class), equalTo("Hey Sync!")); - } - - /** - * JERSEY-2337 reproducer. We are going to send huge amount of data over the wire. This time in an async fashion. - * Should not the data have been chunk-encoded, we would easily run out of memory. - * - * @throws Exception in case of a test error. - */ - @Test - public void testAsyncPost() throws Exception { - Future response = target("/size").request().async() - .post(Entity.entity(new TestEntity(HUGE_DATA_LENGTH), MediaType.APPLICATION_OCTET_STREAM_TYPE)); - final String content = response.get().readEntity(String.class); - assertThat(Long.parseLong(content), equalTo(HUGE_DATA_LENGTH)); - - // just to check the right data have been transfered. - response = target("/echo").request().async().post(Entity.text("Hey Async!")); - assertThat(response.get().readEntity(String.class), equalTo("Hey Async!")); - } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/MethodTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/MethodTest.java index c3d2d0e9f4..f7a873e942 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/MethodTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/client/connector/MethodTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -16,9 +16,6 @@ package org.glassfish.jersey.tests.e2e.client.connector; -import java.util.Arrays; -import java.util.List; - import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -35,19 +32,16 @@ import org.glassfish.jersey.jdk.connector.JdkConnectorProvider; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; +import org.junit.jupiter.api.Test; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests the Http methods. * * @author Stepan Kopriva */ -@RunWith(Parameterized.class) -public class MethodTest extends JerseyTest { +public class MethodTest { private static final String PATH = "test"; @@ -75,48 +69,57 @@ public String delete() { } } - private final ConnectorProvider connectorProvider; - - public MethodTest(ConnectorProvider connectorProvider) { - this.connectorProvider = connectorProvider; + public static class GrizzlyConnectorProviderMethodTest extends MethodTemplateTest { + public GrizzlyConnectorProviderMethodTest() { + super(new GrizzlyConnectorProvider()); + } } - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new GrizzlyConnectorProvider(), new JdkConnectorProvider()); + public static class JdkConnectorProviderMethodTest extends MethodTemplateTest { + public JdkConnectorProviderMethodTest() { + super(new JdkConnectorProvider()); + } } - @Override - protected Application configure() { - return new ResourceConfig(HttpMethodResource.class); - } + public abstract static class MethodTemplateTest extends JerseyTest { + private final ConnectorProvider connectorProvider; - @Override - protected void configureClient(ClientConfig config) { - config.connectorProvider(connectorProvider); - } + public MethodTemplateTest(ConnectorProvider connectorProvider) { + this.connectorProvider = connectorProvider; + } - @Test - public void testGet() { - Response response = target(PATH).request().get(); - assertEquals("GET", response.readEntity(String.class)); - } + @Override + protected Application configure() { + return new ResourceConfig(HttpMethodResource.class); + } - @Test - public void testPost() { - Response response = target(PATH).request().post(Entity.entity("POST", MediaType.TEXT_PLAIN)); - assertEquals("POST", response.readEntity(String.class)); - } + @Override + protected void configureClient(ClientConfig config) { + config.connectorProvider(connectorProvider); + } - @Test - public void testPut() { - Response response = target(PATH).request().put(Entity.entity("PUT", MediaType.TEXT_PLAIN)); - assertEquals("PUT", response.readEntity(String.class)); - } + @Test + public void testGet() { + Response response = target(PATH).request().get(); + assertEquals("GET", response.readEntity(String.class)); + } - @Test - public void testDelete() { - Response response = target(PATH).request().delete(); - assertEquals("DELETE", response.readEntity(String.class)); + @Test + public void testPost() { + Response response = target(PATH).request().post(Entity.entity("POST", MediaType.TEXT_PLAIN)); + assertEquals("POST", response.readEntity(String.class)); + } + + @Test + public void testPut() { + Response response = target(PATH).request().put(Entity.entity("PUT", MediaType.TEXT_PLAIN)); + assertEquals("PUT", response.readEntity(String.class)); + } + + @Test + public void testDelete() { + Response response = target(PATH).request().delete(); + assertEquals("DELETE", response.readEntity(String.class)); + } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/AutoDiscoverableTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/AutoDiscoverableTest.java index 5c0b7c3dcc..87fc2f6886 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/AutoDiscoverableTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/AutoDiscoverableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -36,8 +36,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Note: Auto-discoverables from this test "affects" all other tests in suit. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ConstrainedToTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ConstrainedToTest.java index 79bbc5f72d..5bb0a9d761 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ConstrainedToTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ConstrainedToTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests whether providers are correctly validated in the client runtime (for example if provider constrained to @@ -69,11 +69,11 @@ public void testClientWithProviderInstances() { private void _testFilters(Client client) { final Response response = client.target(getBaseUri()).path("resource").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("called", response.getHeaderString("ClientFilterConstrainedToClient")); - Assert.assertEquals("called", response.getHeaderString("ClientFilter")); - Assert.assertNull("The ClientFilterConstrainedToServer should not be called as it is constrained to server.", - response.getHeaderString("ClientFilterConstrainedToServer")); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("called", response.getHeaderString("ClientFilterConstrainedToClient")); + Assertions.assertEquals("called", response.getHeaderString("ClientFilter")); + Assertions.assertNull(response.getHeaderString("ClientFilterConstrainedToServer"), + "The ClientFilterConstrainedToServer should not be called as it is constrained to server."); } @ConstrainedTo(RuntimeType.CLIENT) diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentLengthTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentLengthTest.java index a9ae6c44c5..75edbb6f2a 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentLengthTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentLengthTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -35,10 +35,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentTypeTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentTypeTest.java index ad65f33615..39991d1750 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentTypeTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ContentTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -59,9 +59,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * @author Michal Gajdos diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/DetermineContentLengthTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/DetermineContentLengthTest.java index 05cab0a673..32f149c3e4 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/DetermineContentLengthTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/DetermineContentLengthTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -48,8 +48,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test determining of the content length. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/EncodingTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/EncodingTest.java index 2e4ce8cca9..b9b899c333 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/EncodingTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/EncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -37,9 +37,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/FeatureConstraintTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/FeatureConstraintTest.java index 7ced3186f6..7d70e12adf 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/FeatureConstraintTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/FeatureConstraintTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -19,10 +19,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.Uri; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import javax.ws.rs.ConstrainedTo; import javax.ws.rs.GET; diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ForcedAutoDiscoverableTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ForcedAutoDiscoverableTest.java index 7defa2d781..967e78cf7e 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ForcedAutoDiscoverableTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ForcedAutoDiscoverableTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -37,9 +37,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Note: Auto-discoverables from this test "affects" all other tests in suit. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderParamTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderParamTest.java index 0a328f4317..f1772f3929 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderParamTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2022 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 @@ -32,7 +32,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderValueExceptionTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderValueExceptionTest.java index 97f5305e70..614397a68e 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderValueExceptionTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/HeaderValueExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests HeaderValueException. @@ -54,21 +54,21 @@ public void testInboundHeaderThrowsException() throws ExecutionException, Interr final Response response = target("resource/inbound").request() .header(HttpHeaders.DATE, "foo") .post(Entity.entity("inbound", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(400, response.getStatus()); + Assertions.assertEquals(400, response.getStatus()); } @Test public void testOutboundHeaderThrowsException() throws ExecutionException, InterruptedException { final Response response = target("resource/outbound").request() .post(Entity.entity("outbound", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(500, response.getStatus()); + Assertions.assertEquals(500, response.getStatus()); } @Test public void testOutboundResponseHeaderThrowsException() throws ExecutionException, InterruptedException { final Response response = target("resource/outbound-Response").request() .post(Entity.entity("outbound", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(500, response.getStatus()); + Assertions.assertEquals(500, response.getStatus()); } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/Hk2BinderSupportTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/Hk2BinderSupportTest.java index 7ecb616042..eb51ff0eb5 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/Hk2BinderSupportTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/Hk2BinderSupportTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -28,8 +28,8 @@ import org.glassfish.hk2.utilities.binding.AbstractBinder; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests that HK2Binder and Jersey Binder work together. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/LoggingFeatureTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/LoggingFeatureTest.java index 413f54b366..5f2020e154 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/LoggingFeatureTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/LoggingFeatureTest.java @@ -55,9 +55,9 @@ import org.hamcrest.Matcher; import org.hamcrest.core.SubstringMatcher; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.containsString; @@ -72,8 +72,8 @@ * * @author Michal Gajdos */ -@RunWith(Suite.class) -@Suite.SuiteClasses({ +@Suite +@SelectClasses({ LoggingFeatureTest.ClientTest.class, LoggingFeatureTest.ContainerTest.class, LoggingFeatureTest.ContainerAutodiscoveryTest.class, @@ -739,7 +739,7 @@ public void testFilterAsContainerFilter() throws Exception { private static final class ContainsHeaderMatcher extends SubstringMatcher { ContainsHeaderMatcher(String headerName, String... headerValues) { - super(makeRegex(headerName, Arrays.asList(headerValues))); + super("matching regex", true, makeRegex(headerName, Arrays.asList(headerValues))); } private static String makeRegex(String headerName, List headerValues) { @@ -762,10 +762,5 @@ private static String quote(String input) { protected boolean evalSubstringOf(String string) { return string.matches(substring); } - - @Override - protected String relationship() { - return "matching regex"; - } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyReaderUnsupportedTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyReaderUnsupportedTest.java index cdd496525b..a5103adffe 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyReaderUnsupportedTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyReaderUnsupportedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -39,10 +39,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test case for unsupported media type. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyWorkerInheritanceTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyWorkerInheritanceTest.java index 81d2fa97de..9430af5ad2 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyWorkerInheritanceTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyWorkerInheritanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -41,8 +41,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test-case for JERSEY-1481. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyWriterObjectDistanceTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyWriterObjectDistanceTest.java index 6ff32ac636..33ec4ae38e 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyWriterObjectDistanceTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/MessageBodyWriterObjectDistanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -34,8 +34,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Object.class needs special handling when computing type distance - it should be always further than any other diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/NoEntityTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/NoEntityTest.java index 201f846a28..5fc0ec6d6b 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/NoEntityTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/NoEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -37,10 +37,10 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Tests that no content type is sent when an entity is not present. @@ -143,7 +143,7 @@ public void testEntity() { * https://java.net/jira/browse/JERSEY-1994 */ @Test - @Ignore("see https://java.net/jira/browse/JERSEY-1994") + @Disabled("see https://java.net/jira/browse/JERSEY-1994") public void testNoEntityString() { Response response = target().path("resource/string").request().get(); MyEntity myEntity = response.readEntity(MyEntity.class); diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/NonPublicNonStaticTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/NonPublicNonStaticTest.java index f14804864f..898fbe843e 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/NonPublicNonStaticTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/NonPublicNonStaticTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -36,13 +36,13 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests deployment of non-standard or invalid resources and providers. @@ -53,8 +53,8 @@ * @author Paul Sandoz * @author Adam Lindenthal */ -@RunWith(Suite.class) -@Suite.SuiteClasses({NonPublicNonStaticTest.NonStaticResourceTest.class, +@Suite +@SelectClasses({NonPublicNonStaticTest.NonStaticResourceTest.class, NonPublicNonStaticTest.NonStaticResourceSubResourceTest.class, NonPublicNonStaticTest.NonPublicResourceTest.class, NonPublicNonStaticTest.NonPublicResourceSubResourceTest.class, @@ -304,8 +304,8 @@ public void testNonStaticResource() throws IOException { break; } } - assertTrue("Expected log message (1st) was not found.", firstFound); - assertTrue("Expected log message (2nd) was not found.", secondFound); + assertTrue(firstFound, "Expected log message (1st) was not found."); + assertTrue(secondFound, "Expected log message (2nd) was not found."); } } @@ -316,9 +316,10 @@ public ResourceConfig configure() { return new ResourceConfig(NonStaticResourceSubResource.class); } - @Test(expected = InternalServerErrorException.class) + @Test public void testNonStaticResource() throws IOException { - target().path("/non-static-sub/class").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target().path("/non-static-sub/class").request().get(String.class)); } } @@ -329,9 +330,10 @@ public ResourceConfig configure() { return new ResourceConfig(NonPublicResource.class); } - @Test(expected = InternalServerErrorException.class) + @Test public void testNonPublicResource() throws IOException { - target().path("/non-public").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target().path("/non-public").request().get(String.class)); } } @@ -342,9 +344,10 @@ public ResourceConfig configure() { return new ResourceConfig(NonPublicResourceSubResource.class); } - @Test(expected = InternalServerErrorException.class) + @Test public void testNonPublicResource() throws IOException { - target().path("/non-public-sub/class").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target().path("/non-public-sub/class").request().get(String.class)); } } @@ -366,7 +369,7 @@ public void testAbstractResource() throws IOException { break; } } - assertTrue("Expected log record was not found.", found); + assertTrue(found, "Expected log record was not found."); } } @@ -377,9 +380,10 @@ public ResourceConfig configure() { return new ResourceConfig(AbstractResourceSubResource.class); } - @Test(expected = InternalServerErrorException.class) + @Test public void testAbstractResourceSubResource() throws IOException { - target().path("abstract-sub/class").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target().path("abstract-sub/class").request().get(String.class)); } } @@ -406,8 +410,8 @@ public void testInterfaceResource() throws IOException { break; } } - assertTrue("Expected log message (1st) was not found.", firstFound); - assertTrue("Expected log message (2nd) was not found.", secondFound); + assertTrue(firstFound, "Expected log message (1st) was not found."); + assertTrue(secondFound, "Expected log message (2nd) was not found."); } } @@ -418,9 +422,10 @@ public ResourceConfig configure() { return new ResourceConfig(InterfaceResourceSubResource.class); } - @Test(expected = InternalServerErrorException.class) + @Test public void testInterfaceResourceSubResource() throws IOException { - target().path("interface-sub/class").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target().path("interface-sub/class").request().get(String.class)); } } @@ -431,9 +436,10 @@ public ResourceConfig configure() { return new ResourceConfig(NonPublicResourceWithConstructor.class); } - @Test(expected = InternalServerErrorException.class) + @Test public void testNonPublicResourceWithConstructor() throws IOException { - target().path("non-public-with-constructor").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target().path("non-public-with-constructor").request().get(String.class)); } } @@ -444,9 +450,10 @@ public ResourceConfig configure() { return new ResourceConfig(NonPublicResourceSubResourceWithConstructor.class); } - @Test(expected = InternalServerErrorException.class) + @Test public void testNonPublicResourceSubResourceWithConstructor() throws IOException { - target().path("non-public-sub-with-constructor/class").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target().path("non-public-sub-with-constructor/class").request().get(String.class)); } } @@ -458,9 +465,10 @@ public ResourceConfig configure() { return new ResourceConfig(PublicResourceWithPrivateConstructor.class); } - @Test(expected = InternalServerErrorException.class) + @Test public void testPublicResourceWithPrivateConstructor() throws IOException { - target().path("public-with-private-constructor").request().get(String.class); + assertThrows(InternalServerErrorException.class, + () -> target().path("public-with-private-constructor").request().get(String.class)); } } @@ -482,7 +490,7 @@ public void testNonStaticProvider() throws IOException { break; } } - assertTrue("Expected log record was not found.", found); + assertTrue(found, "Expected log record was not found."); } } @@ -525,7 +533,7 @@ public void testNonPublicProvider() throws IOException { break; } } - assertTrue("Expected log record was not found.", found); + assertTrue(found, "Expected log record was not found."); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ProvidersLegacyOrderingTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ProvidersLegacyOrderingTest.java index 7829146afc..a2f47da394 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ProvidersLegacyOrderingTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ProvidersLegacyOrderingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -40,11 +40,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Pavel Bucek @@ -134,8 +134,8 @@ public void orderingTest() { Response response = target().request("application/test1").get(Response.class); assertNotNull(response); - assertEquals("Request was not handled correctly, most likely fault in MessageBodyWorker selection.", - 200, response.getStatus()); + assertEquals(200, response.getStatus(), + "Request was not handled correctly, most likely fault in MessageBodyWorker selection."); } catch (Exception e) { fail("Request was not handled correctly, most likely fault in MessageBodyWorker selection."); } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ProvidersOrderingTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ProvidersOrderingTest.java index 18bab2a07b..bab8c37bda 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ProvidersOrderingTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ProvidersOrderingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -48,11 +48,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * @author Pavel Bucek @@ -343,8 +343,8 @@ public void orderingTest() { .put(Entity.entity("test", "application/test1"), Response.class); assertNotNull(response); - assertEquals("Request was not handled correctly, most likely fault in MessageBodyWorker selection.", - 200, response.getStatus()); + assertEquals(200, response.getStatus(), + "Request was not handled correctly, most likely fault in MessageBodyWorker selection."); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); @@ -371,8 +371,8 @@ public void replaceBuiltInProvider() { Response response = target.request().post(Entity.text("replaceBuiltInProvider"), Response.class); assertNotNull(response); - assertEquals("Request was not handled correctly, most likely fault in MessageBodyWorker selection.", - 200, response.getStatus()); + assertEquals(200, response.getStatus(), + "Request was not handled correctly, most likely fault in MessageBodyWorker selection."); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/QueryParamEncodingTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/QueryParamEncodingTest.java index a5991d950c..e3575082cb 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/QueryParamEncodingTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/QueryParamEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Miroslav Fuksa @@ -57,14 +57,14 @@ public String getDecoded(@QueryParam("query") String queryParam) { @Test public void testEncoded() { final Response response = target().path("resource/encoded").queryParam("query", "%dummy23+a").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("true:%25dummy23%2Ba", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("true:%25dummy23%2Ba", response.readEntity(String.class)); } @Test public void testDecoded() { final Response response = target().path("resource/decoded").queryParam("query", "%dummy23+a").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("true:%dummy23+a", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("true:%dummy23+a", response.readEntity(String.class)); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ReaderProviderTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ReaderProviderTest.java index 02392bcdd5..434c5be00a 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ReaderProviderTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ReaderProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -32,9 +32,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Testing {@link Reader} on client and server. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/RequestScopeTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/RequestScopeTest.java index 99a03f00ae..32532b800c 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/RequestScopeTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/RequestScopeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -32,18 +32,18 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * E2E Request Scope Tests. * * @author Michal Gajdos */ -@Ignore("Test Supplier Injection -> this test require dispose() method from Factory") +@Disabled("Test Supplier Injection -> this test require dispose() method from Factory") public class RequestScopeTest extends JerseyTest { @Override diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ResponseLinksTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ResponseLinksTest.java index a63d424882..b9d34c8632 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ResponseLinksTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/ResponseLinksTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,8 +35,8 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Libor Kamolis @@ -97,9 +97,9 @@ public void testGetLink() { WebTarget target = target("test"); Response response = target.path("1").request(MediaType.APPLICATION_JSON).get(); Set links = response.getLinks(); - Assert.assertEquals(1, links.size()); - Assert.assertNotNull(response.getLink("prev")); - Assert.assertTrue(response.getLink("prev").getUri().toString().endsWith("1?limit=50")); + Assertions.assertEquals(1, links.size()); + Assertions.assertNotNull(response.getLink("prev")); + Assertions.assertTrue(response.getLink("prev").getUri().toString().endsWith("1?limit=50")); } /** @@ -110,12 +110,12 @@ public void testGetLinks() { WebTarget target = target("test"); Response response = target.path("2").request(MediaType.APPLICATION_JSON).get(); Set links = response.getLinks(); - Assert.assertEquals(2, links.size()); - Assert.assertNotNull(response.getLink("prev")); - Assert.assertTrue(response.getLink("prev").getUri().toString().endsWith("2?limit=50")); - Assert.assertNotNull(response.getLink("next")); - Assert.assertEquals("next page", response.getLink("next").getTitle()); - Assert.assertTrue(response.getLink("next").getUri().toString().endsWith("2?limit=50&action=next")); + Assertions.assertEquals(2, links.size()); + Assertions.assertNotNull(response.getLink("prev")); + Assertions.assertTrue(response.getLink("prev").getUri().toString().endsWith("2?limit=50")); + Assertions.assertNotNull(response.getLink("next")); + Assertions.assertEquals("next page", response.getLink("next").getTitle()); + Assertions.assertTrue(response.getLink("next").getUri().toString().endsWith("2?limit=50&action=next")); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/UriComponentTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/UriComponentTest.java index a1f5d5414e..526a73c40f 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/UriComponentTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/common/UriComponentTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.uri.UriComponent; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Libor Kamolis @@ -84,9 +84,9 @@ private void testTextImpl(String message, final String text) { String encoded = UriComponent.encode(text, UriComponent.Type.QUERY_PARAM_SPACE_ENCODED); WebTarget target = target("test/text"); Response response = target.queryParam("text", encoded).request().get(); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); String actual = response.readEntity(String.class); - Assert.assertEquals(message, VALUE_PREFIX + text + VALUE_SUFFIX, actual); + Assertions.assertEquals(VALUE_PREFIX + text + VALUE_SUFFIX, actual, message); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/EscapedUriTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/EscapedUriTest.java index 29aa2c96d1..9ea65a1697 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/EscapedUriTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/EscapedUriTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,16 +23,24 @@ import javax.ws.rs.core.UriInfo; import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.spi.TestContainerFactory; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Collection; + +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -public class EscapedUriTest extends JerseyContainerTest { +public class EscapedUriTest { private static final String RESPONSE = "CONTENT"; @@ -41,7 +49,6 @@ public static class EscapedUriResource { private final String context; - @SuppressWarnings("UnusedDeclaration") public EscapedUriResource() { this(""); } @@ -69,18 +76,35 @@ public NonEscapedUriResource() { } } - @Override - protected Application configure() { - return new ResourceConfig(EscapedUriResource.class, NonEscapedUriResource.class); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JerseyContainerTest.parameters().forEach(testContainerFactory -> { + EscapedUriTesmplateTest test = new EscapedUriTesmplateTest(testContainerFactory) {}; + tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName())); + }); + return tests; } - @Test - public void testEscaped() { - assertThat(target("x%20y").request().get(String.class), is(RESPONSE)); - } + public abstract static class EscapedUriTesmplateTest extends JerseyContainerTest { + + public EscapedUriTesmplateTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); + } - @Test - public void testNonEscaped() { - assertThat(target("non/x y").request().get(String.class), is(RESPONSE)); + @Override + protected Application configure() { + return new ResourceConfig(EscapedUriResource.class, NonEscapedUriResource.class); + } + + @Test + public void testEscaped() { + assertThat(target("x%20y").request().get(String.class), is(RESPONSE)); + } + + @Test + public void testNonEscaped() { + assertThat(target("non/x y").request().get(String.class), is(RESPONSE)); + } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/GrizzlySlashesWithContextPathTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/GrizzlySlashesWithContextPathTest.java index 509fdcf895..f1323a79b2 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/GrizzlySlashesWithContextPathTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/GrizzlySlashesWithContextPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test Jersey container implementation of URL resolving. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/GzipContentEncodingTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/GzipContentEncodingTest.java index 61c463e920..2a26a62869 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/GzipContentEncodingTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/GzipContentEncodingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -17,6 +17,8 @@ package org.glassfish.jersey.tests.e2e.container; import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; import java.util.zip.GZIPInputStream; import javax.ws.rs.GET; @@ -34,15 +36,19 @@ import org.glassfish.jersey.message.GZipEncoder; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.filter.EncodingFilter; +import org.glassfish.jersey.test.spi.TestContainerFactory; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -public class GzipContentEncodingTest extends JerseyContainerTest { +public class GzipContentEncodingTest { @Path("/") public static class Resource { @@ -58,37 +64,54 @@ public String post(final String content) { } } - @Override - protected Application configure() { - return new ResourceConfig(Resource.class, EncodingFilter.class, GZipEncoder.class); - } - - @Override - protected void configureClient(final ClientConfig config) { - config.register(new ReaderInterceptor() { - @Override - public Object aroundReadFrom(final ReaderInterceptorContext context) throws IOException, WebApplicationException { - context.setInputStream(new GZIPInputStream(context.getInputStream())); - return context.proceed(); - } + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JerseyContainerTest.parameters().forEach(testContainerFactory -> { + GzipContentEncodingTemplateTest test = new GzipContentEncodingTemplateTest(testContainerFactory) {}; + tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName())); }); + return tests; } - @Test - public void testGet() { - final Response response = target().request() - .header(HttpHeaders.ACCEPT_ENCODING, "gzip") - .get(); + public abstract static class GzipContentEncodingTemplateTest extends JerseyContainerTest { - assertThat(response.readEntity(String.class), is("GET")); - } + public GzipContentEncodingTemplateTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); + } + + @Override + protected Application configure() { + return new ResourceConfig(Resource.class, EncodingFilter.class, GZipEncoder.class); + } - @Test - public void testPost() { - final Response response = target().request() - .header(HttpHeaders.ACCEPT_ENCODING, "gzip") - .post(Entity.text("POST")); + @Override + protected void configureClient(final ClientConfig config) { + config.register(new ReaderInterceptor() { + @Override + public Object aroundReadFrom(final ReaderInterceptorContext context) throws IOException, WebApplicationException { + context.setInputStream(new GZIPInputStream(context.getInputStream())); + return context.proceed(); + } + }); + } + + @Test + public void testGet() { + final Response response = target().request() + .header(HttpHeaders.ACCEPT_ENCODING, "gzip") + .get(); + + assertThat(response.readEntity(String.class), is("GET")); + } + + @Test + public void testPost() { + final Response response = target().request() + .header(HttpHeaders.ACCEPT_ENCODING, "gzip") + .post(Entity.text("POST")); - assertThat(response.readEntity(String.class), is("POST")); + assertThat(response.readEntity(String.class), is("POST")); + } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/HeadTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/HeadTest.java index a143d0f70d..87b5701f67 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/HeadTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/HeadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -31,24 +32,23 @@ import javax.ws.rs.core.Response; import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory; import org.glassfish.jersey.test.jetty.JettyTestContainerFactory; import org.glassfish.jersey.test.simple.SimpleTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) -public class HeadTest extends JerseyContainerTest { +public class HeadTest extends JerseyTest { private static final List FACTORIES = Arrays.asList( new GrizzlyTestContainerFactory(), @@ -56,9 +56,8 @@ public class HeadTest extends JerseyContainerTest { new SimpleTestContainerFactory(), new JettyTestContainerFactory()); - @Parameterized.Parameters(name = "{0}") - public static Collection parameters() throws Exception { - return FACTORIES.stream().map(input -> new TestContainerFactory[]{input}).collect(Collectors.toList()); + public static Stream parameters() throws Exception { + return FACTORIES.stream(); } @Path("/") @@ -88,18 +87,21 @@ protected Application configure() { return new ResourceConfig(Resource.class); } - @Test - public void testHeadString() { + @ParameterizedTest + @MethodSource("parameters") + public void testHeadString(TestContainerFactory factory) { _testHead("string", MediaType.TEXT_PLAIN_TYPE); } - @Test - public void testHeadByte() { + @ParameterizedTest + @MethodSource("parameters") + public void testHeadByte(TestContainerFactory factory) { _testHead("byte", MediaType.APPLICATION_OCTET_STREAM_TYPE); } - @Test - public void testHeadByteArrayInputStream() { + @ParameterizedTest + @MethodSource("parameters") + public void testHeadByteArrayInputStream(TestContainerFactory factory) { _testHead("ByteArrayInputStream", MediaType.APPLICATION_OCTET_STREAM_TYPE); } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JdkSlashesWithContextPathTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JdkSlashesWithContextPathTest.java index b2276f496b..3f7c064d23 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JdkSlashesWithContextPathTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JdkSlashesWithContextPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.test.jdkhttp.JdkHttpServerTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Ignore; -import org.junit.Test; -import static junit.framework.TestCase.assertEquals; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test Jersey container implementation of URL resolving. @@ -83,7 +83,7 @@ public void testSlashesWithBeginningEmptyPathParamWithQueryParams() { } @Test - @Ignore("failing with JDK container.") + @Disabled("failing with JDK container.") public void testEncodedQueryParams() { URI hostPort = UriBuilder.fromUri("http://localhost/").port(getPort()).build(); WebTarget target = client().target(hostPort).path("//" + CONTEXT_PATH + "///encoded") diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/Jersey2462Test.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/Jersey2462Test.java index e2243d49b5..ff5654b494 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/Jersey2462Test.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/Jersey2462Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -42,18 +42,19 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.Suite; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Reproducer tests for JERSEY-2462 on Grizzly, Jetty and Simple HTTP server. * * @author Marek Potociar */ -@RunWith(Suite.class) -@Suite.SuiteClasses({Jersey2462Test.GrizzlyContainerTest.class, +@Suite +@SelectClasses({Jersey2462Test.GrizzlyContainerTest.class, Jersey2462Test.JettyContainerTest.class, Jersey2462Test.SimpleContainerTest.class}) public class Jersey2462Test { diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JerseyContainerTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JerseyContainerTest.java index fe2b087310..cf8603e52c 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JerseyContainerTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JerseyContainerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -17,9 +17,8 @@ package org.glassfish.jersey.tests.e2e.container; import java.util.Arrays; -import java.util.Collection; import java.util.List; -import java.util.stream.Collectors; +import java.util.stream.Stream; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; @@ -28,15 +27,11 @@ import org.glassfish.jersey.test.jetty.JettyTestContainerFactory; import org.glassfish.jersey.test.netty.NettyTestContainerFactory; import org.glassfish.jersey.test.simple.SimpleTestContainerFactory; -import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; /** * @author Michal Gajdos */ -@RunWith(Parameterized.class) public abstract class JerseyContainerTest extends JerseyTest { private static final List FACTORIES = Arrays.asList( @@ -48,17 +43,11 @@ public abstract class JerseyContainerTest extends JerseyTest { new NettyTestContainerFactory() ); - @Parameterized.Parameters(name = "{0}") - public static Collection parameters() throws Exception { - return FACTORIES.stream().map(input -> new TestContainerFactory[]{input}).collect(Collectors.toList()); + public static Stream parameters() { + return FACTORIES.stream(); } - - @Parameterized.Parameter(0) - public TestContainerFactory factory; - - @Override - protected TestContainerFactory getTestContainerFactory() throws TestContainerException { - return factory; + public JerseyContainerTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JettyEmptyHeaderParamTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JettyEmptyHeaderParamTest.java index 4af03c6709..ad20f30c5d 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JettyEmptyHeaderParamTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/JettyEmptyHeaderParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -27,8 +27,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests Jetty getHeader() - returns null in when the header diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/LeadingSlashesTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/LeadingSlashesTest.java index f9b3bd8ae0..d19b2435a1 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/LeadingSlashesTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/LeadingSlashesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -17,6 +17,8 @@ package org.glassfish.jersey.tests.e2e.container; import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; import javax.ws.rs.Encoded; import javax.ws.rs.GET; @@ -30,11 +32,14 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; +import org.glassfish.jersey.test.spi.TestContainerFactory; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; -import static org.junit.Assert.assertNotEquals; - -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test Jersey container implementation of URL resolving. @@ -44,20 +49,10 @@ * * @author Petr Bouda */ -public class LeadingSlashesTest extends JerseyContainerTest { +public class LeadingSlashesTest { public static final String CONTAINER_RESPONSE = "Container-Response"; - @Override - protected Application configure() { - ResourceConfig resourceConfig = new ResourceConfig(SimpleResource.class, - EmptyResource.class, - EmptyPathParamResource.class); - - resourceConfig.property(ServerProperties.REDUCE_CONTEXT_PATH_SLASHES_ENABLED, true); - return resourceConfig; - } - @Path("simple") public static class SimpleResource { @@ -101,53 +96,78 @@ public String getHello() { } } - @Test - public void testSimpleSlashes() { - Response result = call("/simple"); - assertEquals(CONTAINER_RESPONSE, result.readEntity(String.class)); - - result = call("//simple"); - assertNotEquals(CONTAINER_RESPONSE, result.readEntity(String.class)); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JerseyContainerTest.parameters().forEach(testContainerFactory -> { + LeadingSlashesTemplateTest test = new LeadingSlashesTemplateTest(testContainerFactory) {}; + tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName())); + }); + return tests; } - @Test - public void testSlashesWithBeginningEmpty() { - Response result = call("/test"); - assertEquals(CONTAINER_RESPONSE, result.readEntity(String.class)); - } + public abstract static class LeadingSlashesTemplateTest extends JerseyContainerTest { - @Test - public void testSlashesWithBeginningEmptyPathParam() { - Response result = call("///test"); - assertEquals("-", result.readEntity(String.class)); - } + public LeadingSlashesTemplateTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); + } - @Test - public void testSlashesWithBeginningEmptyPathParamWithQueryParams() { - URI hostPort = UriBuilder.fromUri("http://localhost/").port(getPort()).build(); - WebTarget target = client().target(hostPort).path("///testParams") - .queryParam("bar", "Container") - .queryParam("baz", "Response"); + @Override + protected Application configure() { + ResourceConfig resourceConfig = new ResourceConfig(SimpleResource.class, + EmptyResource.class, + EmptyPathParamResource.class); - Response result = target.request().get(); - assertEquals("PATH PARAM: -, QUERY PARAM Container-Response", result.readEntity(String.class)); - } + resourceConfig.property(ServerProperties.REDUCE_CONTEXT_PATH_SLASHES_ENABLED, true); + return resourceConfig; + } - @Test - public void testEncodedQueryParams() { - URI hostPort = UriBuilder.fromUri("http://localhost/").port(getPort()).build(); - WebTarget target = client().target(hostPort).path("///encoded") - .queryParam("query", "%dummy23+a"); + @Test + public void testSimpleSlashes() { + Response result = call("/simple"); + assertEquals(CONTAINER_RESPONSE, result.readEntity(String.class)); - Response response = target.request().get(); - assertEquals(200, response.getStatus()); - assertEquals("true:%25dummy23%2Ba", response.readEntity(String.class)); - } + result = call("//simple"); + assertNotEquals(CONTAINER_RESPONSE, result.readEntity(String.class)); + } + @Test + public void testSlashesWithBeginningEmpty() { + Response result = call("/test"); + assertEquals(CONTAINER_RESPONSE, result.readEntity(String.class)); + } - private Response call(String path) { - URI hostPort = UriBuilder.fromUri("http://localhost/").port(getPort()).build(); - return client().target(hostPort).path(path).request().get(); - } + @Test + public void testSlashesWithBeginningEmptyPathParam() { + Response result = call("///test"); + assertEquals("-", result.readEntity(String.class)); + } + + @Test + public void testSlashesWithBeginningEmptyPathParamWithQueryParams() { + URI hostPort = UriBuilder.fromUri("http://localhost/").port(getPort()).build(); + WebTarget target = client().target(hostPort).path("///testParams") + .queryParam("bar", "Container") + .queryParam("baz", "Response"); + + Response result = target.request().get(); + assertEquals("PATH PARAM: -, QUERY PARAM Container-Response", result.readEntity(String.class)); + } + @Test + public void testEncodedQueryParams() { + URI hostPort = UriBuilder.fromUri("http://localhost/").port(getPort()).build(); + WebTarget target = client().target(hostPort).path("///encoded") + .queryParam("query", "%dummy23+a"); + + Response response = target.request().get(); + assertEquals(200, response.getStatus()); + assertEquals("true:%25dummy23%2Ba", response.readEntity(String.class)); + } + + private Response call(String path) { + URI hostPort = UriBuilder.fromUri("http://localhost/").port(getPort()).build(); + return client().target(hostPort).path(path).request().get(); + } + } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/MatrixParamTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/MatrixParamTest.java index ed96f47550..cf39aa1721 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/MatrixParamTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/MatrixParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -22,15 +22,22 @@ import javax.ws.rs.core.Application; import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.spi.TestContainerFactory; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.ArrayList; +import java.util.Collection; /** * @author Michal Gajdos */ -public class MatrixParamTest extends JerseyContainerTest { +public class MatrixParamTest { @Path("/") public static class Resource { @@ -41,16 +48,34 @@ public String get(@MatrixParam("x") final String x, @MatrixParam("y") final Stri } } - @Override - protected Application configure() { - return new ResourceConfig(Resource.class); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JerseyContainerTest.parameters().forEach(testContainerFactory -> { + MatrixParamTemplateTest test = new MatrixParamTemplateTest(testContainerFactory) {}; + tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName())); + }); + return tests; } - @Test - public void testMatrixParam() { - assertThat(target().matrixParam("y", "1").request().get(String.class), is("1")); - assertThat(target().matrixParam("x", "1").matrixParam("y", "1%20%2B%202").request().get(String.class), is("1 + 2")); - assertThat(target().matrixParam("x", "1").matrixParam("y", "1%20%26%202").request().get(String.class), is("1 & 2")); - assertThat(target().matrixParam("x", "1").matrixParam("y", "1%20%7C%7C%202").request().get(String.class), is("1 || 2")); + public abstract static class MatrixParamTemplateTest extends JerseyContainerTest { + + public MatrixParamTemplateTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); + } + + @Override + protected Application configure() { + return new ResourceConfig(Resource.class); + } + + @Test + public void testMatrixParam() { + assertThat(target().matrixParam("y", "1").request().get(String.class), is("1")); + assertThat(target().matrixParam("x", "1").matrixParam("y", "1%20%2B%202").request().get(String.class), is("1 + 2")); + assertThat(target().matrixParam("x", "1").matrixParam("y", "1%20%26%202").request().get(String.class), is("1 & 2")); + assertThat(target().matrixParam("x", "1").matrixParam("y", "1%20%7C%7C%202").request().get(String.class), + is("1 || 2")); + } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/QueryParamTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/QueryParamTest.java index 7e9547727b..d642c4fe4f 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/QueryParamTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/QueryParamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -22,15 +22,22 @@ import javax.ws.rs.core.Application; import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.spi.TestContainerFactory; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.ArrayList; +import java.util.Collection; /** * @author Michal Gajdos */ -public class QueryParamTest extends JerseyContainerTest { +public class QueryParamTest { @Path("/") public static class Resource { @@ -40,16 +47,33 @@ public String get(@QueryParam("x") final String x, @QueryParam("y") final String } } - @Override - protected Application configure() { - return new ResourceConfig(Resource.class); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JerseyContainerTest.parameters().forEach(testContainerFactory -> { + QueryParamTemplteTest test = new QueryParamTemplteTest(testContainerFactory) {}; + tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName())); + }); + return tests; } - @Test - public void testQueryParam() { - assertThat(target().queryParam("y", "1 %2B 2").request().get(String.class), is("1 + 2")); - assertThat(target().queryParam("x", "1").queryParam("y", "1 + 2").request().get(String.class), is("1 + 2")); - assertThat(target().queryParam("x", "1").queryParam("y", "1 %26 2").request().get(String.class), is("1 & 2")); - assertThat(target().queryParam("x", "1").queryParam("y", "1 %7C%7C 2").request().get(String.class), is("1 || 2")); + public abstract static class QueryParamTemplteTest extends JerseyContainerTest { + + public QueryParamTemplteTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); + } + + @Override + protected Application configure() { + return new ResourceConfig(Resource.class); + } + + @Test + public void testQueryParam() { + assertThat(target().queryParam("y", "1 %2B 2").request().get(String.class), is("1 + 2")); + assertThat(target().queryParam("x", "1").queryParam("y", "1 + 2").request().get(String.class), is("1 + 2")); + assertThat(target().queryParam("x", "1").queryParam("y", "1 %26 2").request().get(String.class), is("1 & 2")); + assertThat(target().queryParam("x", "1").queryParam("y", "1 %7C%7C 2").request().get(String.class), is("1 || 2")); + } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResponseWriterMetadataTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResponseWriterMetadataTest.java index 303548943d..bba1f57962 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResponseWriterMetadataTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResponseWriterMetadataTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,6 +20,8 @@ import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -34,11 +36,14 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ServerProperties; -import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.inmemory.InMemoryTestContainerFactory; -import org.glassfish.jersey.test.jdkhttp.JdkHttpServerTestContainerFactory; +import org.glassfish.jersey.test.spi.TestContainerFactory; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.TestFactory; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; @@ -46,7 +51,7 @@ /** * @author Michal Gajdos */ -public class ResponseWriterMetadataTest extends JerseyContainerTest { +public class ResponseWriterMetadataTest { public static class ValueHolder { @@ -101,23 +106,41 @@ public ValueHolder get() { } } - @Override - protected Application configure() { - return new ResourceConfig(Resource.class, ValueHolderWriter.class) - .property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 1); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JerseyContainerTest.parameters().forEach(testContainerFactory -> { + ResponseWriterMetadataTemplateTest test = new ResponseWriterMetadataTemplateTest(testContainerFactory) {}; + tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName())); + }); + return tests; } - @Test - public void testResponse() { - final Response response = target().request().get(); + public abstract static class ResponseWriterMetadataTemplateTest extends JerseyContainerTest { + public ResponseWriterMetadataTemplateTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); + } + + @Override + protected Application configure() { + return new ResourceConfig(Resource.class, ValueHolderWriter.class) + .property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 1); + } + + @ParameterizedTest + @MethodSource("parameters") + public void testResponse() { + final Response response = target().request().get(); - assertThat(response.readEntity(String.class), is("one")); - assertThat(response.getHeaderString("X-BEFORE-WRITE"), is("foo")); + assertThat(response.readEntity(String.class), is("one")); + assertThat(response.getHeaderString("X-BEFORE-WRITE"), is("foo")); - if (factory instanceof InMemoryTestContainerFactory) { - assertThat(response.getHeaderString("X-AFTER-WRITE"), is("bar")); - } else { - assertThat(response.getHeaderString("X-AFTER-WRITE"), nullValue()); + TestContainerFactory factory = getTestContainerFactory(); + if (factory instanceof InMemoryTestContainerFactory) { + assertThat(response.getHeaderString("X-AFTER-WRITE"), is("bar")); + } else { + assertThat(response.getHeaderString("X-AFTER-WRITE"), nullValue()); + } } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResponseWriterOutputStreamTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResponseWriterOutputStreamTest.java index c88468a8d9..017b0faf12 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResponseWriterOutputStreamTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResponseWriterOutputStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,7 +19,11 @@ import org.glassfish.jersey.server.ContainerRequest; import org.glassfish.jersey.server.ContainerResponse; import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; +import org.glassfish.jersey.test.spi.TestContainerFactory; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -32,20 +36,22 @@ import javax.ws.rs.core.Response; import java.io.IOException; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collection; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * This is really weird approach and test. * * @author Michal Gajdos */ -public class ResponseWriterOutputStreamTest extends JerseyContainerTest { +public class ResponseWriterOutputStreamTest { private static final String CHECK_STRING = "RESOURCE"; @@ -80,40 +86,57 @@ public void post(final ContainerRequest context) throws IOException { } } - @Override - protected Application configure() { - return new ResourceConfig(Resource.class); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JerseyContainerTest.parameters().forEach(testContainerFactory -> { + ResponseWriterOutputStreamTemplateTest test = new ResponseWriterOutputStreamTemplateTest(testContainerFactory) {}; + tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName())); + }); + return tests; } - @Test - public void testGet() { - assertThat(target().request().get(String.class), is(CHECK_STRING)); - } + public abstract static class ResponseWriterOutputStreamTemplateTest extends JerseyContainerTest { - @Test - public void testPost() throws InterruptedException, ExecutionException { - final CountDownLatch controlLatch = new CountDownLatch(1); - final Invocation invocation = target().request().buildPost(Entity.text(CHECK_STRING)); - final Future resp = invocation.submit(new InvocationCallback() { - @Override - public void completed(Response response) { - controlLatch.countDown(); - } - - @Override - public void failed(Throwable throwable) { - controlLatch.countDown(); - - } - }); - controlLatch.await(); - final String response = resp.get().readEntity(String.class); - assertThat(response, is(CHECK_STRING)); - } + public ResponseWriterOutputStreamTemplateTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); + } + + @Override + protected Application configure() { + return new ResourceConfig(Resource.class); + } + + @Test + public void testGet() { + assertThat(target().request().get(String.class), is(CHECK_STRING)); + } - @Test - public void testAll() throws InterruptedException, ExecutionException { - testGet(); - testPost(); + @Test + public void testPost() throws InterruptedException, ExecutionException { + final CountDownLatch controlLatch = new CountDownLatch(1); + final Invocation invocation = target().request().buildPost(Entity.text(CHECK_STRING)); + final Future resp = invocation.submit(new InvocationCallback() { + @Override + public void completed(Response response) { + controlLatch.countDown(); + } + + @Override + public void failed(Throwable throwable) { + controlLatch.countDown(); + + } + }); + controlLatch.await(); + final String response = resp.get().readEntity(String.class); + assertThat(response, is(CHECK_STRING)); + } + + @Test + public void testAll() throws InterruptedException, ExecutionException { + testGet(); + testPost(); + } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/TrailingSlashTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/TrailingSlashTest.java index b55cb381aa..3425ee3c49 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/TrailingSlashTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/TrailingSlashTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -22,15 +22,22 @@ import javax.ws.rs.core.Response; import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.test.spi.TestContainerFactory; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; -import org.junit.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.ArrayList; +import java.util.Collection; /** * @author Michal Gajdos */ -public class TrailingSlashTest extends JerseyContainerTest { +public class TrailingSlashTest { @Path("/") public static class Resource { @@ -42,25 +49,42 @@ public String get() { } } - @Override - protected Application configure() { - return new ResourceConfig(Resource.class); + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + JerseyContainerTest.parameters().forEach(testContainerFactory -> { + TrailingSlashTemplateTest test = new TrailingSlashTemplateTest(testContainerFactory) {}; + tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName())); + }); + return tests; } - @Test - public void testSlash() throws Exception { - _test("get/"); - } + public abstract static class TrailingSlashTemplateTest extends JerseyContainerTest { - @Test - public void testNoSlash() throws Exception { - _test("get"); - } + public TrailingSlashTemplateTest(TestContainerFactory testContainerFactory) { + super(testContainerFactory); + } - private void _test(final String path) { - final Response response = target(path).request().get(); + @Override + protected Application configure() { + return new ResourceConfig(Resource.class); + } - assertThat(response.getStatus(), is(200)); - assertThat(response.readEntity(String.class), is("get")); + @Test + public void testSlash() throws Exception { + _test("get/"); + } + + @Test + public void testNoSlash() throws Exception { + _test("get"); + } + + private void _test(final String path) { + final Response response = target(path).request().get(); + + assertThat(response.getStatus(), is(200)); + assertThat(response.readEntity(String.class), is("get")); + } } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/AccessTokenResource.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/AccessTokenResource.java index be10824a03..849165af3b 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/AccessTokenResource.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/AccessTokenResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -30,9 +30,9 @@ import org.glassfish.jersey.oauth1.signature.OAuth1SignatureException; import org.glassfish.jersey.server.oauth1.internal.OAuthServerRequest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; @Path("/access_token") public class AccessTokenResource { diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OAuth2Test.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OAuth2Test.java index 77323c48f0..2f4fe122ec 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OAuth2Test.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OAuth2Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -51,11 +51,11 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests OAuth 2 client. diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OAuthClientServerTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OAuthClientServerTest.java index 533e724ee9..efdd16502e 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OAuthClientServerTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OAuthClientServerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -51,8 +51,8 @@ import org.glassfish.jersey.server.oauth1.OAuth1ServerProperties; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.sun.security.auth.UserPrincipal; diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OauthClientAuthorizationFlowTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OauthClientAuthorizationFlowTest.java index 147772e5f5..1f22a2c865 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OauthClientAuthorizationFlowTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/OauthClientAuthorizationFlowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -42,11 +42,11 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; public class OauthClientAuthorizationFlowTest extends JerseyTest { diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/PhotosResource.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/PhotosResource.java index e9cc2ced58..131150bfac 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/PhotosResource.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/PhotosResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.oauth1.signature.OAuth1SignatureException; import org.glassfish.jersey.server.oauth1.internal.OAuthServerRequest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; @Path("/photos") public class PhotosResource { diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/RequestTokenResource.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/RequestTokenResource.java index 7455e62554..9fc2ac2ecf 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/RequestTokenResource.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/oauth/RequestTokenResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -30,9 +30,9 @@ import org.glassfish.jersey.oauth1.signature.OAuth1SignatureException; import org.glassfish.jersey.server.oauth1.internal.OAuthServerRequest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; @Path("/request_token") public class RequestTokenResource { diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/NoJAXBNoWadlTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/NoJAXBNoWadlTest.java index 18fdcb9eb7..8e1c5a3e50 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/NoJAXBNoWadlTest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/server/wadl/NoJAXBNoWadlTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -22,10 +22,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.internal.LocalizationMessages; import org.glassfish.jersey.test.JerseyTest; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import javax.ws.rs.PUT; import javax.ws.rs.Path; @@ -41,13 +41,13 @@ public class NoJAXBNoWadlTest extends JerseyTest { private static PrintStream errorStream; private static OutputStream readableStream = new ByteArrayOutputStream(800); - @BeforeClass + @BeforeAll public static void before() { errorStream = System.err; System.setErr(new PrintStream(readableStream)); } - @AfterClass + @AfterAll public static void after() { System.setErr(errorStream); } @@ -70,13 +70,14 @@ public void testOptionsNoWadl() { final boolean shouldHaveJaxb = JdkVersion.getJdkVersion().getMajor() == 1; // Make sure the test does not have JAX-B on a classpath - Assert.assertFalse(ServiceFinder.find("javax.xml.bind.JAXBContext").iterator().hasNext()); + Assertions.assertFalse(ServiceFinder.find("javax.xml.bind.JAXBContext").iterator().hasNext()); try (Response r = target("dummy").request(MediaTypes.WADL_TYPE).options()) { String headers = r.getHeaderString(HttpHeaders.ALLOW); - Assert.assertEquals("OPTIONS,PUT", headers); + Assertions.assertEquals("OPTIONS,PUT", headers); } System.out.println(readableStream.toString()); - Assert.assertEquals(!shouldHaveJaxb, readableStream.toString().contains(LocalizationMessages.WADL_FEATURE_DISABLED())); + Assertions.assertEquals(!shouldHaveJaxb, + readableStream.toString().contains(LocalizationMessages.WADL_FEATURE_DISABLED())); } } diff --git a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/sonar/SonarJerseyE2ETest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/sonar/SonarJerseyE2ETest.java index 832db1e225..c27dfd3d22 100644 --- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/sonar/SonarJerseyE2ETest.java +++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/sonar/SonarJerseyE2ETest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -19,8 +19,8 @@ import org.glassfish.jersey.internal.sonar.SonarJerseyCommon; import org.glassfish.jersey.server.internal.sonar.SonarJerseyServer; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Stepan Vavra @@ -29,11 +29,11 @@ public class SonarJerseyE2ETest { @Test public void testJerseyCommonE2E() { - Assert.assertEquals("common e2e", new SonarJerseyCommon().e2e()); + Assertions.assertEquals("common e2e", new SonarJerseyCommon().e2e()); } @Test public void testJerseyCoreE2E() { - Assert.assertEquals("server e2e", new SonarJerseyServer().e2e()); + Assertions.assertEquals("server e2e", new SonarJerseyServer().e2e()); } } diff --git a/tests/integration/JERSEY-2988/src/test/java/org/glassfish/jersey/tests/integration/jersey2988/Jersey2988ITCase.java b/tests/integration/JERSEY-2988/src/test/java/org/glassfish/jersey/tests/integration/jersey2988/Jersey2988ITCase.java index b5bc49defc..f234a08d14 100644 --- a/tests/integration/JERSEY-2988/src/test/java/org/glassfish/jersey/tests/integration/jersey2988/Jersey2988ITCase.java +++ b/tests/integration/JERSEY-2988/src/test/java/org/glassfish/jersey/tests/integration/jersey2988/Jersey2988ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.fail; /** * JERSEY-2988 reproducer and JERSEY-2990 (duplicate of the previous one) diff --git a/tests/integration/asm/pom.xml b/tests/integration/asm/pom.xml index 90980d0512..533ef36f1a 100644 --- a/tests/integration/asm/pom.xml +++ b/tests/integration/asm/pom.xml @@ -43,8 +43,8 @@ jersey-server - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/tests/integration/asm/src/test/java/org/glassfish/jersey/integration/asm/AnnotatedClassVisitorTest.java b/tests/integration/asm/src/test/java/org/glassfish/jersey/integration/asm/AnnotatedClassVisitorTest.java index 74570b745f..92fc8b09ee 100644 --- a/tests/integration/asm/src/test/java/org/glassfish/jersey/integration/asm/AnnotatedClassVisitorTest.java +++ b/tests/integration/asm/src/test/java/org/glassfish/jersey/integration/asm/AnnotatedClassVisitorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -19,9 +19,10 @@ import jersey.repackaged.org.objectweb.asm.ClassVisitor; import jersey.repackaged.org.objectweb.asm.Opcodes; import org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener; +import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -80,7 +81,7 @@ public void testInheritedMethodsFromClassVisitor() { .println(" not implemented by AnnotationAcceptingListener.AnnotatedClassVisitor"); } } - Assert.assertThat(containsAllMethods, Matchers.is(true)); + MatcherAssert.assertThat(containsAllMethods, Matchers.is(true)); } @Test @@ -100,10 +101,8 @@ public void testCorrectOpcodeAsmIsUsedInAnnotationAcceptingListener() { e.printStackTrace(); } - Assert.assertEquals( - "You need to set: \nAnnotatedClassVisitor() {\n super(Opcodes.ASM" + asmOpcode + ");\n}", - String.valueOf(asmOpcode), aalOpcode - ); + Assertions.assertEquals(String.valueOf(asmOpcode), aalOpcode, + "You need to set: \nAnnotatedClassVisitor() {\n super(Opcodes.ASM" + asmOpcode + ");\n}"); } @Test @@ -127,10 +126,8 @@ public void testWarningOpcodeInClassReaderWrapperSetCorrectly() { e.printStackTrace(); } - Assert.assertEquals( - "You need to set ClassReaderWrapper.WARN_VERSION=Opcodes.V" + jdkVersion, - jdkVersion, warnFieldValue - ); + Assertions.assertEquals(jdkVersion, warnFieldValue, + "You need to set ClassReaderWrapper.WARN_VERSION=Opcodes.V" + jdkVersion); } @Test @@ -156,10 +153,8 @@ public void testLoggerInClassReaderWrapper() throws IOException { } final String message = new String(log.toByteArray()); - Assert.assertTrue( - "The WARNING `" + warningMsg + "` has not been printed for a class with byte code version " + array[7], - message.contains(warningMsg) - ); + Assertions.assertTrue(message.contains(warningMsg), + "The WARNING `" + warningMsg + "` has not been printed for a class with byte code version " + array[7]); } private static int getMaxValueOfField(String fieldPrefix, int initialValue) { diff --git a/tests/integration/async-jersey-filter/src/test/java/org/glassfish/jersey/tests/integration/jersey2730/Jersey2730ITCase.java b/tests/integration/async-jersey-filter/src/test/java/org/glassfish/jersey/tests/integration/jersey2730/Jersey2730ITCase.java index 7e9dbf447e..5c538b0e4d 100644 --- a/tests/integration/async-jersey-filter/src/test/java/org/glassfish/jersey/tests/integration/jersey2730/Jersey2730ITCase.java +++ b/tests/integration/async-jersey-filter/src/test/java/org/glassfish/jersey/tests/integration/jersey2730/Jersey2730ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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,9 +20,9 @@ import org.glassfish.jersey.tests.integration.async.AbstractAsyncJerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; /** * JERSEY-2730 reproducer. @@ -36,9 +36,8 @@ public class Jersey2730ITCase extends AbstractAsyncJerseyTest { private void assertLastThreadNotStuck() { final boolean lastThreadGotStuck = target("/exceptionTest/exception/rpc/lastthreadstuck").request().get(boolean.class); - assertFalse("Thread processing last request got stuck while processing the request for " - + TestExceptionResource.class.getCanonicalName(), - lastThreadGotStuck); + assertFalse(lastThreadGotStuck, "Thread processing last request got stuck while processing the request for " + + TestExceptionResource.class.getCanonicalName()); } @Test diff --git a/tests/integration/async-jersey-filter/src/test/java/org/glassfish/jersey/tests/integration/jersey2812/Jersey2812ITCase.java b/tests/integration/async-jersey-filter/src/test/java/org/glassfish/jersey/tests/integration/jersey2812/Jersey2812ITCase.java index 663aefe630..fe17d5a0c1 100644 --- a/tests/integration/async-jersey-filter/src/test/java/org/glassfish/jersey/tests/integration/jersey2812/Jersey2812ITCase.java +++ b/tests/integration/async-jersey-filter/src/test/java/org/glassfish/jersey/tests/integration/jersey2812/Jersey2812ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -33,11 +33,11 @@ import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder; import org.glassfish.jersey.tests.integration.async.AbstractAsyncJerseyTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * JERSEY-2812 reproducer. @@ -56,7 +56,7 @@ public class Jersey2812ITCase extends AbstractAsyncJerseyTest { private ExecutorService executorService = Executors .newSingleThreadExecutor(new ThreadFactoryBuilder().setDaemon(true).build()); - @Before + @BeforeEach public void triggerTheWaitRequestInSeparateThread() throws Exception { executorService.execute(new Runnable() { @Override @@ -92,17 +92,17 @@ public void asyncSuspendedResourceDoesNotGetStuck() throws Exception { // [1] wait for the /async/wait request to be processed final Response startResponse = target("/asyncTest/async/await").path(uuid).path("started") .queryParam("millis", WAIT_TIMEOUT).request().get(); - assertTrue("The server-side thread handling the request to /async/wait didn't start in timely fashion. " + assertTrue(startResponse.readEntity(Boolean.class), + "The server-side thread handling the request to /async/wait didn't start in timely fashion. " + "This error indicates this test is not executed / designed properly rather than a regression in " - + "JERSEY-2812 fix.", - startResponse.readEntity(Boolean.class)); + + "JERSEY-2812 fix."); // [2] wait for the /async/wait request to finish final Response finishResponse = target("/asyncTest/async/await").path(uuid).path("finished") .queryParam("millis", WAIT_TIMEOUT).request().get(); - assertTrue("The thread processing the /async/wait request did not respond in timely fashion. " - + "Memory leak / thread got stuck detected!", - finishResponse.readEntity(Boolean.class)); + assertTrue(finishResponse.readEntity(Boolean.class), + "The thread processing the /async/wait request did not respond in timely fashion. " + + "Memory leak / thread got stuck detected!"); // [3] release the blocked http call to /async/wait final String releaseResponse = target("/asyncTest/async/release").path(uuid).request().post(null, String.class); @@ -110,18 +110,18 @@ public void asyncSuspendedResourceDoesNotGetStuck() throws Exception { // [4] test whether everything ended as expected executorService.shutdown(); - assertTrue("The test thread did not finish in timely fashion!", - executorService.awaitTermination(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + assertTrue(executorService.awaitTermination(WAIT_TIMEOUT, TimeUnit.MILLISECONDS), + "The test thread did not finish in timely fashion!"); assertEquals("async-OK-" + uuid, asyncResult.get()); } - @After + @AfterEach public void releaseResources() { // release the server-side thread regardless of whether left un-attended target("/asyncTest/async/release").path(uuid).request().post(null); } - @After + @AfterEach public void terminateThread() { // forcibly terminate the test client thread executorService.shutdownNow(); diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/BaseValidationTest.java b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/BaseValidationTest.java index 12a9681428..e09226f55f 100644 --- a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/BaseValidationTest.java +++ b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/BaseValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Common test for resource validation. The same set of tests is used diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/CombinedTest.java b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/CombinedTest.java index b1b2961e26..297ba2751d 100644 --- a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/CombinedTest.java +++ b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/CombinedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -34,12 +34,11 @@ import org.glassfish.grizzly.http.server.HttpHandler; import org.glassfish.grizzly.http.server.HttpServer; -import org.hamcrest.CoreMatchers; import org.jboss.weld.environment.se.Weld; -import org.junit.After; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test both Jersey apps running simultaneously within a single Grizzly HTTP server @@ -69,7 +68,7 @@ public class CombinedTest { Client client; WebTarget cdiTarget, hk2Target; - @Before + @BeforeEach public void before() throws IOException { if (isDefaultTestContainerFactorySet && Hk2InjectionManagerFactory.isImmediateStrategy()) { initializeWeld(); @@ -78,12 +77,12 @@ public void before() throws IOException { } } - @Before + @BeforeEach public void beforeIsImmediate() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } - @After + @AfterEach public void after() { if (isDefaultTestContainerFactorySet && Hk2InjectionManagerFactory.isImmediateStrategy()) { cdiServer.shutdownNow(); @@ -94,69 +93,69 @@ public void after() { @Test public void testParamValidatedResourceNoParam() throws Exception { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testParamValidatedResourceNoParam(cdiTarget); BaseValidationTest._testParamValidatedResourceNoParam(hk2Target); } @Test public void testParamValidatedResourceParamProvided() throws Exception { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testParamValidatedResourceParamProvided(cdiTarget); BaseValidationTest._testParamValidatedResourceParamProvided(hk2Target); } @Test public void testFieldValidatedResourceNoParam() throws Exception { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testFieldValidatedResourceNoParam(cdiTarget); BaseValidationTest._testFieldValidatedResourceNoParam(hk2Target); } @Test public void testFieldValidatedResourceParamProvided() throws Exception { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testFieldValidatedResourceParamProvided(cdiTarget); BaseValidationTest._testFieldValidatedResourceParamProvided(hk2Target); } @Test public void testPropertyValidatedResourceNoParam() throws Exception { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testPropertyValidatedResourceNoParam(cdiTarget); BaseValidationTest._testPropertyValidatedResourceNoParam(hk2Target); } @Test public void testPropertyValidatedResourceParamProvided() throws Exception { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testPropertyValidatedResourceParamProvided(cdiTarget); BaseValidationTest._testPropertyValidatedResourceParamProvided(hk2Target); } @Test public void testOldFashionedResourceNoParam() { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testOldFashionedResourceNoParam(cdiTarget); BaseValidationTest._testOldFashionedResourceNoParam(hk2Target); } @Test public void testOldFashionedResourceParamProvided() throws Exception { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testOldFashionedResourceParamProvided(cdiTarget); BaseValidationTest._testOldFashionedResourceParamProvided(hk2Target); } @Test public void testNonJaxRsValidationFieldValidatedResourceNoParam() { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testNonJaxRsValidationFieldValidatedResourceNoParam(cdiTarget); } @Test public void testNonJaxRsValidationFieldValidatedResourceParamProvided() { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); BaseValidationTest._testNonJaxRsValidationFieldValidatedResourceParamProvided(cdiTarget); } diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/RawCdiTest.java b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/RawCdiTest.java index 8932fc8bbb..c01e09661d 100644 --- a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/RawCdiTest.java +++ b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/RawCdiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -23,9 +23,10 @@ import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** @@ -37,11 +38,12 @@ public class RawCdiTest extends BaseValidationTest { Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -53,6 +55,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { diff --git a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/RawHk2Test.java b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/RawHk2Test.java index 43e551bc1e..29d0a887ba 100644 --- a/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/RawHk2Test.java +++ b/tests/integration/cdi-integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/RawHk2Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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,8 +20,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * Validation result test for raw HK2 environment. diff --git a/tests/integration/cdi-integration/cdi-client-on-server/src/test/java/org/glassfish/jersey/tests/cdi/client/BeanManagerInjectedOnClientTest.java b/tests/integration/cdi-integration/cdi-client-on-server/src/test/java/org/glassfish/jersey/tests/cdi/client/BeanManagerInjectedOnClientTest.java index 6eb906452d..d5db6e2243 100644 --- a/tests/integration/cdi-integration/cdi-client-on-server/src/test/java/org/glassfish/jersey/tests/cdi/client/BeanManagerInjectedOnClientTest.java +++ b/tests/integration/cdi-integration/cdi-client-on-server/src/test/java/org/glassfish/jersey/tests/cdi/client/BeanManagerInjectedOnClientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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,10 +20,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -31,11 +32,12 @@ public class BeanManagerInjectedOnClientTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -47,6 +49,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -65,7 +68,7 @@ protected Application configure() { @Test public void testBeanManagerIsInjected() { try (Response r = target("resource").path("main").request().get()) { - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); System.out.println(r.readEntity(String.class)); } } diff --git a/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiIntoEjbTest.java b/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiIntoEjbTest.java index d98c072a1b..1bd4982121 100644 --- a/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiIntoEjbTest.java +++ b/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiIntoEjbTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,9 +18,9 @@ import javax.ws.rs.client.WebTarget; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test CDI timers injected into EJB beans. @@ -54,7 +54,7 @@ private void _testRequestScoped(final String ejbType) { sleep(2); long secondMillis = _getMillis(target); - assertTrue("Second request should have greater millis!", secondMillis > firstMillis); + assertTrue(secondMillis > firstMillis, "Second request should have greater millis!"); } private void _testAppScoped(final String ejbType) { @@ -64,6 +64,6 @@ private void _testAppScoped(final String ejbType) { sleep(2); long secondMillis = _getMillis(target); - assertTrue("Second request should have the same millis!", secondMillis == firstMillis); + assertTrue(secondMillis == firstMillis, "Second request should have the same millis!"); } } diff --git a/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/EjbIntoCdiTest.java b/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/EjbIntoCdiTest.java index b27b0ce0b6..fa5d73761c 100644 --- a/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/EjbIntoCdiTest.java +++ b/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/EjbIntoCdiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,9 +18,9 @@ import javax.ws.rs.client.WebTarget; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/TestBase.java b/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/TestBase.java index 670e4fc765..8b53ae7c16 100644 --- a/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/TestBase.java +++ b/tests/integration/cdi-integration/cdi-ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/TestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.is; /** diff --git a/tests/integration/cdi-integration/cdi-iface-with-non-jaxrs-impl-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/EchoResourceTest.java b/tests/integration/cdi-integration/cdi-iface-with-non-jaxrs-impl-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/EchoResourceTest.java index 7791a8fb50..cd6063be03 100644 --- a/tests/integration/cdi-integration/cdi-iface-with-non-jaxrs-impl-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/EchoResourceTest.java +++ b/tests/integration/cdi-integration/cdi-iface-with-non-jaxrs-impl-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/EchoResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -25,9 +25,9 @@ import javax.ws.rs.core.UriBuilder; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.startsWith; diff --git a/tests/integration/cdi-integration/cdi-log-check/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiComponentProviderWarningTest.java b/tests/integration/cdi-integration/cdi-log-check/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiComponentProviderWarningTest.java index 24dd4858c6..4f460071b2 100644 --- a/tests/integration/cdi-integration/cdi-log-check/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiComponentProviderWarningTest.java +++ b/tests/integration/cdi-integration/cdi-log-check/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiComponentProviderWarningTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -22,26 +22,28 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import java.util.List; import java.util.logging.Level; import java.util.logging.LogRecord; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CdiComponentProviderWarningTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -53,6 +55,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -84,7 +87,7 @@ public void testWarning() { for (final LogRecord logRecord : getLoggedRecords()) { if (logRecord.getLoggerName().equals("org.glassfish.jersey.internal.Errors") && logRecord.getMessage().contains(searchInLog)) { - Assert.fail("Checking CDI bean is a JAX-RS resource should not cast warnings"); + Assertions.fail("Checking CDI bean is a JAX-RS resource should not cast warnings"); } } } diff --git a/tests/integration/cdi-integration/cdi-manually-bound/src/test/java/org/glassfish/jersey/tests/cdi/manuallybound/CdiServiceInjectTest.java b/tests/integration/cdi-integration/cdi-manually-bound/src/test/java/org/glassfish/jersey/tests/cdi/manuallybound/CdiServiceInjectTest.java index c75dfa749a..56d91aae84 100644 --- a/tests/integration/cdi-integration/cdi-manually-bound/src/test/java/org/glassfish/jersey/tests/cdi/manuallybound/CdiServiceInjectTest.java +++ b/tests/integration/cdi-integration/cdi-manually-bound/src/test/java/org/glassfish/jersey/tests/cdi/manuallybound/CdiServiceInjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -21,10 +21,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -32,11 +33,12 @@ public class CdiServiceInjectTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -48,6 +50,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); @@ -63,7 +66,7 @@ protected Application configure() { public void testCdiServiceIsInjected() { try (Response response = target().request().get()) { String header = response.getStringHeaders().getFirst(NoBeanDefiningAnnotationContainerFilter.class.getSimpleName()); - Assert.assertEquals(CdiServiceImpl.class.getSimpleName(), header); + Assertions.assertEquals(CdiServiceImpl.class.getSimpleName(), header); } } } diff --git a/tests/integration/cdi-integration/cdi-manually-bound/src/test/java/org/glassfish/jersey/tests/cdi/manuallybound/HK2ServiceInjectTest.java b/tests/integration/cdi-integration/cdi-manually-bound/src/test/java/org/glassfish/jersey/tests/cdi/manuallybound/HK2ServiceInjectTest.java index e702bdd4a9..50edb62c22 100644 --- a/tests/integration/cdi-integration/cdi-manually-bound/src/test/java/org/glassfish/jersey/tests/cdi/manuallybound/HK2ServiceInjectTest.java +++ b/tests/integration/cdi-integration/cdi-manually-bound/src/test/java/org/glassfish/jersey/tests/cdi/manuallybound/HK2ServiceInjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -21,10 +21,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -32,11 +33,12 @@ public class HK2ServiceInjectTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -48,6 +50,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); @@ -63,7 +66,7 @@ protected Application configure() { public void testHK2ServiceIsInjected() { try (Response response = target().request().get()) { String header = response.getStringHeaders().getFirst(HK2InjectedFilter.class.getSimpleName()); - Assert.assertEquals(HK2ServiceImpl.class.getSimpleName(), header); + Assertions.assertEquals(HK2ServiceImpl.class.getSimpleName(), header); } } } diff --git a/tests/integration/cdi-integration/cdi-multimodule/war1/src/test/java/org/glassfish/jersey/tests/integration/multimodule/cdi/web1/JaxRsCdiIntegrationTest.java b/tests/integration/cdi-integration/cdi-multimodule/war1/src/test/java/org/glassfish/jersey/tests/integration/multimodule/cdi/web1/JaxRsCdiIntegrationTest.java index aa74ae490f..758be57bfa 100644 --- a/tests/integration/cdi-integration/cdi-multimodule/war1/src/test/java/org/glassfish/jersey/tests/integration/multimodule/cdi/web1/JaxRsCdiIntegrationTest.java +++ b/tests/integration/cdi-integration/cdi-multimodule/war1/src/test/java/org/glassfish/jersey/tests/integration/multimodule/cdi/web1/JaxRsCdiIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -26,7 +26,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/cdi-integration/cdi-multimodule/war2/src/test/java/org/glassfish/jersey/tests/integration/multimodule/cdi/web2/JaxRsCdiIntegrationTest.java b/tests/integration/cdi-integration/cdi-multimodule/war2/src/test/java/org/glassfish/jersey/tests/integration/multimodule/cdi/web2/JaxRsCdiIntegrationTest.java index b6c4f0c833..bc093b17cf 100644 --- a/tests/integration/cdi-integration/cdi-multimodule/war2/src/test/java/org/glassfish/jersey/tests/integration/multimodule/cdi/web2/JaxRsCdiIntegrationTest.java +++ b/tests/integration/cdi-integration/cdi-multimodule/war2/src/test/java/org/glassfish/jersey/tests/integration/multimodule/cdi/web2/JaxRsCdiIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; @@ -75,7 +75,7 @@ public void testUriInfoInjectionAppScopedResourceRequestScopedBean() { _testResource("cdi-multimodule-war2/two/app-scoped/req"); } - @Ignore("until JERSEY-2914 gets resolved") + @Disabled("until JERSEY-2914 gets resolved") @Test public void testUriInfoInjectionAppScopedResourceDependentBean() { diff --git a/tests/integration/cdi-integration/cdi-multipart-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MultipartFeatureTest.java b/tests/integration/cdi-integration/cdi-multipart-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MultipartFeatureTest.java index c5c9250065..ac40505a08 100644 --- a/tests/integration/cdi-integration/cdi-multipart-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MultipartFeatureTest.java +++ b/tests/integration/cdi-integration/cdi-multipart-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MultipartFeatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -17,8 +17,7 @@ package org.glassfish.jersey.tests.cdi.resources; import java.net.URI; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; @@ -32,11 +31,10 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Part of GF-21033 reproducer. Make sure form data processed by the Jersey multi-part @@ -50,23 +48,10 @@ * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class MultipartFeatureTest extends JerseyTest { - final String TestFormDATA; - - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"No matter what"}, - {"You should never"}, - {"ever"}, - {"just give up"} - }); - } - - public MultipartFeatureTest(String TestFormDATA) { - this.TestFormDATA = TestFormDATA; + public static Stream testData() { + return Stream.of("No matter what", "You should never", "ever", "just give up"); } @Override @@ -84,8 +69,9 @@ protected void configureClient(ClientConfig config) { config.register(MultiPartFeature.class); } - @Test - public void testPostFormData() { + @ParameterizedTest + @MethodSource("testData") + public void testPostFormData(String TestFormDATA) { final WebTarget target = target().path("echo"); diff --git a/tests/integration/cdi-integration/cdi-resource-with-at-context/src/test/java/org/glassfish/jersey/tests/cdi/resourceatcontext/ResourceWithConstructorTest.java b/tests/integration/cdi-integration/cdi-resource-with-at-context/src/test/java/org/glassfish/jersey/tests/cdi/resourceatcontext/ResourceWithConstructorTest.java index ace3e0b028..b09db54646 100644 --- a/tests/integration/cdi-integration/cdi-resource-with-at-context/src/test/java/org/glassfish/jersey/tests/cdi/resourceatcontext/ResourceWithConstructorTest.java +++ b/tests/integration/cdi-integration/cdi-resource-with-at-context/src/test/java/org/glassfish/jersey/tests/cdi/resourceatcontext/ResourceWithConstructorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -26,10 +26,11 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; @@ -43,11 +44,12 @@ public class ResourceWithConstructorTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -57,6 +59,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -85,7 +88,7 @@ protected DeploymentContext configureDeployment() { @Test public void testContextInConstructorAndInjectInClass() throws InterruptedException { try (Response r = target().path("get").request().get()) { - Assert.assertEquals("OK", r.readEntity(String.class)); + Assertions.assertEquals("OK", r.readEntity(String.class)); } } } diff --git a/tests/integration/cdi-integration/cdi-singleton/src/test/java/org/glassfish/jersey/tests/cdi/singleton/SingletonTest.java b/tests/integration/cdi-integration/cdi-singleton/src/test/java/org/glassfish/jersey/tests/cdi/singleton/SingletonTest.java index eb5e9c6ca6..90dae9f660 100644 --- a/tests/integration/cdi-integration/cdi-singleton/src/test/java/org/glassfish/jersey/tests/cdi/singleton/SingletonTest.java +++ b/tests/integration/cdi-integration/cdi-singleton/src/test/java/org/glassfish/jersey/tests/cdi/singleton/SingletonTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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,10 +20,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -31,11 +32,12 @@ public class SingletonTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -47,6 +49,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); @@ -62,11 +65,11 @@ protected Application configure() { public void testSingleton() { try (Response response = target().request().get()) { String entity = response.readEntity(String.class); - Assert.assertEquals(SingletonResource.class.getSimpleName(), entity); + Assertions.assertEquals(SingletonResource.class.getSimpleName(), entity); final SingletonResource actualResource = SingletonTestApp.SINGLETON_RESOURCES[1]; - Assert.assertEquals(actualResource, SingletonTestApp.SINGLETON_RESOURCES[0]); - Assert.assertEquals(actualResource, SingletonTestApp.SINGLETON_RESOURCES[2]); + Assertions.assertEquals(actualResource, SingletonTestApp.SINGLETON_RESOURCES[0]); + Assertions.assertEquals(actualResource, SingletonTestApp.SINGLETON_RESOURCES[2]); } } } diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiComponentProviderTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiComponentProviderTest.java index ca9891446a..c84644da1c 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiComponentProviderTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiComponentProviderTest.java @@ -20,7 +20,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.enterprise.inject.Vetoed; import javax.enterprise.inject.spi.BeanManager; @@ -30,11 +32,12 @@ import javax.ws.rs.core.Application; import java.util.Collections; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertFalse; public class CdiComponentProviderTest extends JerseyTest { Weld weld; + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -42,6 +45,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java index 067e2af02e..30011f1337 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,6 +24,8 @@ import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; /** * Test for CDI web application resources. @@ -39,6 +41,7 @@ public class CdiTest extends JerseyTest { Weld weld; + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -46,6 +49,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ConstructorInjectionTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ConstructorInjectionTest.java index f7c85660a5..442d6cc19d 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ConstructorInjectionTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ConstructorInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -19,8 +19,8 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import org.junit.Test; +import static org.hamcrest.MatcherAssert.assertThat; +import org.junit.jupiter.api.Test; /** * Part of JERSEY-2526 reproducer. Without the fix, the application would diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CounterTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CounterTest.java index 0d7e76d445..c7e40accea 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CounterTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CounterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,10 +18,10 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.hamcrest.CoreMatchers.is; /** @@ -45,6 +45,6 @@ public void testGet() { assertThat(secondResponse.getStatus(), is(200)); int secondNumber = Integer.decode(secondResponse.readEntity(String.class)); - assertTrue("Second request should have greater number!", secondNumber > firstNumber); + assertTrue(secondNumber > firstNumber, "Second request should have greater number!"); } } diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/JaxRsInjectedCdiBeanTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/JaxRsInjectedCdiBeanTest.java index 64630ee9e3..a4bfcb78bd 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/JaxRsInjectedCdiBeanTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/JaxRsInjectedCdiBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -19,11 +19,11 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test that a raw CDI managed bean gets JAX-RS injected. diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/NonJaxRsBeanJaxRsInjectionTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/NonJaxRsBeanJaxRsInjectionTest.java index a955785b3d..69ea214f05 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/NonJaxRsBeanJaxRsInjectionTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/NonJaxRsBeanJaxRsInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -34,12 +34,11 @@ import org.glassfish.grizzly.http.server.HttpHandler; import org.glassfish.grizzly.http.server.HttpServer; -import org.hamcrest.CoreMatchers; import org.jboss.weld.environment.se.Weld; -import org.junit.After; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test two Jersey apps running simultaneously within a single Grizzly HTTP server @@ -70,9 +69,9 @@ public class NonJaxRsBeanJaxRsInjectionTest { Client client; WebTarget mainTarget, secondaryTarget; - @Before + @BeforeEach public void before() throws IOException { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); if (isDefaultTestContainerFactorySet) { initializeWeld(); @@ -81,7 +80,7 @@ public void before() throws IOException { } } - @After + @AfterEach public void after() { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { if (isDefaultTestContainerFactorySet) { @@ -94,7 +93,7 @@ public void after() { @Test public void testPathAndHeader() throws Exception { - Assume.assumeThat(isDefaultTestContainerFactorySet, CoreMatchers.is(true)); + Assumptions.assumeTrue(isDefaultTestContainerFactorySet); JaxRsInjectedCdiBeanTest._testPathAndHeader(mainTarget); SecondJaxRsInjectedCdiBeanTest._testPathAndHeader(secondaryTarget); } diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/PerRequestBeanTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/PerRequestBeanTest.java index 973860b710..607d339872 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/PerRequestBeanTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/PerRequestBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019 Payara Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -17,20 +17,18 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.hamcrest.CoreMatchers; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for the request scoped resource. @@ -38,32 +36,15 @@ * @author Jakub Podlesak * @author Patrik Dudits */ -@RunWith(Parameterized.class) public class PerRequestBeanTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"alpha"}, - {"AAA"}, - {"$%^"}, - {"a b"} - }); + public static Stream testData() { + return Stream.of("alpha", "AAA", "$%^", "a b"); } - final String x; - - /** - * Create x new test case based on the above defined parameters. - * - * @param x query parameter value - */ - public PerRequestBeanTest(String x) { - this.x = x; - } - - @Test - public void testGet() { + @ParameterizedTest + @MethodSource("testData") + public void testGet(String x) { final WebTarget target = target().path("jcdibean/per-request").queryParam("x", x); @@ -73,8 +54,9 @@ public void testGet() { assertThat(s, containsString(String.format("queryParam=%s", x))); } - @Test - public void testSingleResponseFilterInvocation() { + @ParameterizedTest + @MethodSource("testData") + public void testSingleResponseFilterInvocation(String x) { final WebTarget target = target().path("jcdibean/per-request").queryParam("x", x); @@ -82,8 +64,8 @@ public void testSingleResponseFilterInvocation() { List invocationIds = response.getHeaders().get("Filter-Invoked"); - assertNotNull("Filter-Invoked header should be set by ResponseFilter", invocationIds); - assertEquals("ResponseFilter should be invoked only once", 1, invocationIds.size()); + assertNotNull(invocationIds, "Filter-Invoked header should be set by ResponseFilter"); + assertEquals(1, invocationIds.size(), "ResponseFilter should be invoked only once"); } } diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/PerRequestDependentBeanTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/PerRequestDependentBeanTest.java index 458e548144..49d4e242f2 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/PerRequestDependentBeanTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/PerRequestDependentBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,48 +16,29 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for the request scoped managed bean resource. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class PerRequestDependentBeanTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"alpha"}, - {"AAA"}, - {"$%^"}, - {"a b"} - }); + public static Stream testData() { + return Stream.of("alpha", "AAA", "$%^", "a b"); } - final String x; - - /** - * Create x new test case based on the above defined parameters. - * - * @param x query parameter value - */ - public PerRequestDependentBeanTest(String x) { - this.x = x; - } - - @Test - public void testGet() { + @ParameterizedTest + @MethodSource("testData") + public void testGet(String x) { final WebTarget target = target().path("jcdibean/dependent/per-request").queryParam("x", x); diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ProducerTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ProducerTest.java index 418067b25c..ad06deb00e 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ProducerTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ProducerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,9 +18,9 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.is; /** diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/QualifiedInjectionSetGetTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/QualifiedInjectionSetGetTest.java index a928b914e4..2a2b8e25f2 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/QualifiedInjectionSetGetTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/QualifiedInjectionSetGetTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -19,9 +19,9 @@ import javax.inject.Qualifier; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.is; /** diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ReverseEchoTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ReverseEchoTest.java index d7ce046100..5adf08f7e8 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ReverseEchoTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ReverseEchoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,49 +16,34 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for qualified injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class ReverseEchoTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"alpha", "ahpla"}, - {"gogol", "logog"}, - {"elcaro", "oracle"} - }); + public static Stream testData() { + return Stream.of( + Arguments.of("alpha", "ahpla"), + Arguments.of("gogol", "logog"), + Arguments.of("elcaro", "oracle") + ); } - final String in, out; - - /** - * Construct instance with the above test data injected. - * - * @param in query parameter. - * @param out expected output. - */ - public ReverseEchoTest(String in, String out) { - this.in = in; - this.out = out; - } - - @Test - public void testGet() { + @ParameterizedTest + @MethodSource("testData") + public void testGet(String in, String out) { WebTarget reverseService = target().path("reverse").queryParam("s", in); String s = reverseService.request().get(String.class); assertThat(s, equalTo(out)); diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SecondJaxRsInjectedCdiBeanTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SecondJaxRsInjectedCdiBeanTest.java index 5b86192b80..e416d070c2 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SecondJaxRsInjectedCdiBeanTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SecondJaxRsInjectedCdiBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -26,11 +26,12 @@ import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test that a raw CDI managed bean gets JAX-RS injected. @@ -40,6 +41,7 @@ public class SecondJaxRsInjectedCdiBeanTest extends JerseyTest { Weld weld; + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -47,6 +49,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SingletonBeanTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SingletonBeanTest.java index 1dcf301f5a..9e1e4f9f53 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SingletonBeanTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SingletonBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,51 +16,36 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for the application scoped resource. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class SingletonBeanTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"alpha", "beta"}, - {"1", "2"} - }); + public static Stream testData() { + return Stream.of( + Arguments.of("alpha", "beta"), + Arguments.of("1", "2") + ); } - final String p, x; - - /** - * Construct instance with the above test data injected. - * - * @param p path parameter. - * @param x query parameter. - */ - public SingletonBeanTest(String p, String x) { - this.p = p; - this.x = x; - } - - @Test - public void testGet() { + @ParameterizedTest + @MethodSource("testData") + public void testGet(String p, String x) { final WebTarget singleton = target().path("jcdibean/singleton").path(p).queryParam("x", x); String s = singleton.request().get(String.class); assertThat(s, containsString(singleton.getUri().toString())); @@ -68,8 +53,9 @@ public void testGet() { assertThat(s, containsString(String.format("queryParam=%s", x))); } - @Test - public void testCounter() { + @ParameterizedTest + @MethodSource("testData") + public void testCounter(String p, String x) { final WebTarget counter = target().path("jcdibean/singleton").path(p).queryParam("x", x).path("counter"); @@ -92,8 +78,9 @@ public void testCounter() { counter.request().put(Entity.text("10")); } - @Test - public void testException() { + @ParameterizedTest + @MethodSource("testData") + public void testException(String p, String x) { final WebTarget exception = target().path("jcdibean/singleton").path(p).queryParam("x", x).path("exception"); assertThat(exception.request().get().readEntity(String.class), containsString("JDCIBeanException")); } diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SingletonDependentBeanTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SingletonDependentBeanTest.java index 056c3c5268..126ce4d38d 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SingletonDependentBeanTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/SingletonDependentBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,51 +16,36 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for the application scoped managed bean resource. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class SingletonDependentBeanTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"alpha", "beta"}, - {"1", "2"} - }); + public static Stream testData() { + return Stream.of( + Arguments.of("alpha", "beta"), + Arguments.of("1", "2") + ); } - final String p, x; - - /** - * Construct instance with the above test data injected. - * - * @param p path parameter. - * @param x query parameter. - */ - public SingletonDependentBeanTest(String p, String x) { - this.p = p; - this.x = x; - } - - @Test - public void testGet() { + @ParameterizedTest + @MethodSource("testData") + public void testGet(String p, String x) { final WebTarget singleton = target().path("jcdibean/dependent/singleton").path(p).queryParam("x", x); String s = singleton.request().get(String.class); assertThat(s, containsString(singleton.getUri().toString())); @@ -68,8 +53,9 @@ public void testGet() { assertThat(s, containsString(String.format("queryParam=%s", x))); } - @Test - public void testCounter() { + @ParameterizedTest + @MethodSource("testData") + public void testCounter(String p, String x) { final WebTarget counter = target().path("jcdibean/dependent/singleton").path(p).queryParam("x", x).path("counter"); @@ -92,8 +78,9 @@ public void testCounter() { counter.request().put(Entity.text("10")); } - @Test - public void testException() { + @ParameterizedTest + @MethodSource("testData") + public void testException(String p, String x) { final WebTarget exception = target().path("jcdibean/dependent/singleton").path(p).queryParam("x", x).path("exception"); assertThat(exception.request().get().readEntity(String.class), containsString("JDCIBeanDependentException")); } diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/StutterEchoTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/StutterEchoTest.java index b8655a6133..ba2d1fd3ea 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/StutterEchoTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/StutterEchoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,47 +16,32 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for qualified injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class StutterEchoTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][]{ - {"alpha", "alphaalpha"}, - {"gogol", "gogolgogol"}, - {"elcaro", "elcaroelcaro"} - }); - }; - - final String in, out; - - /** - * Construct instance with the above test data injected. - * - * @param in query parameter. - * @param out expected output. - */ - public StutterEchoTest(String in, String out) { - this.in = in; - this.out = out; + public static Stream testData() { + return Stream.of( + Arguments.of("alpha", "alphaalpha"), + Arguments.of("gogol", "gogolgogol"), + Arguments.of("elcaro", "elcaroelcaro") + ); } - @Test - public void testGet() { + @ParameterizedTest + @MethodSource("testData") + public void testGet(String in, String out) { String s = target().path("stutter").queryParam("s", in).request().get(String.class); assertThat(s, equalTo(out)); } diff --git a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/TimerTest.java b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/TimerTest.java index 94eee9f928..ec1b8220d3 100644 --- a/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/TimerTest.java +++ b/tests/integration/cdi-integration/cdi-test-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/TimerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,10 +20,10 @@ import java.util.logging.Logger; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.hamcrest.CoreMatchers.is; /** @@ -47,7 +47,7 @@ public void testGet() { assertThat(secondResponse.getStatus(), is(200)); long secondMillis = Long.decode(secondResponse.readEntity(String.class)); - assertTrue("Second request should have greater millis!", secondMillis > firstMillis); + assertTrue(secondMillis > firstMillis, "Second request should have greater millis!"); } private void sleep(long ms) { diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java index e050cff430..0c35ea2167 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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,51 +18,35 @@ import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test custom HK2 injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class CustomInjectionTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"}, - }); - } - - final String resource; - - /** - * Construct instance with the above test data injected. - * - * @param resource query parameter. - */ - public CustomInjectionTest(final String resource) { - this.resource = resource; + public static Stream testData() { + return Stream.of("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } /** * Check that for one no NPE happens on the server side, * and the custom bound instance of {@link Hk2InjectedType} gets injected. */ - @Test - public void testCustomHk2Injection1() { + @ParameterizedTest + @MethodSource("testData") + public void testCustomHk2Injection1(String resource) { final WebTarget target = target().path(resource).path("custom"); final Response response = target.request().get(); assertThat(response.getStatus(), equalTo(200)); @@ -73,8 +57,9 @@ public void testCustomHk2Injection1() { * Check that for one no NPE happens on the server side, * and the custom bound instance of {@link MyApplication.MyInjection} gets injected. */ - @Test - public void testCustomHk2Injection2() { + @ParameterizedTest + @MethodSource("testData") + public void testCustomHk2Injection2(String resource) { final WebTarget target = target().path(resource).path("custom2"); final Response response = target.request().get(); assertThat(response.getStatus(), equalTo(200)); diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java index 6319cad201..c372fe858d 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,53 +16,34 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for exception mapper injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class ExceptionMappersTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"}, - }); - } - - final String resource; - - /** - * Construct instance with the above test data injected. - * - * @param resource query parameter. - */ - public ExceptionMappersTest(final String resource) { - this.resource = resource; + public static Stream testData() { + return Stream.of("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } /** * Check that for one no NPE happens on the server side, and for two * the injected mappers remains the same across requests. */ - @Test - public void testMappersNotNull() { + @ParameterizedTest + @MethodSource("testData") + public void testMappersNotNull(String resource) { final WebTarget target = target().path(resource).path("mappers"); final Response firstResponse = target.request().get(); assertThat(firstResponse.getStatus(), equalTo(200)); diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java index c8de729902..e27e71e749 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,44 +16,24 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for monitoring statistics injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class MonitoringTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"} - }); - } - - final String resource; - - /** - * Construct instance with the above test data injected. - * - * @param resource uri of resource to be tested. - */ - public MonitoringTest(final String resource) { - this.resource = resource; + public static Stream testData() { + return Stream.of("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } /** @@ -61,8 +41,9 @@ public MonitoringTest(final String resource) { * * @throws Exception in case of unexpected test failure. */ - @Test - public void testRequestCount() throws Exception { + @ParameterizedTest + @MethodSource("testData") + public void testRequestCount(String resource) throws Exception { final WebTarget target = target().path(resource).path("requestCount"); Thread.sleep(1000); // this is to allow statistics on the server side to get updated final int start = Integer.decode(target.request().get(String.class)); diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java index 93370c55b3..5c90a3d5e1 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-cfg-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,64 +16,48 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test injection of request depending instances works as expected. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class RequestSensitiveTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected", "alpha", "App: alpha"}, - {"app-field-injected", "gogol", "App: gogol"}, - {"app-field-injected", "elcaro", "App: elcaro"}, - {"app-ctor-injected", "alpha", "App: alpha"}, - {"app-ctor-injected", "gogol", "App: gogol"}, - {"app-ctor-injected", "elcaro", "App: elcaro"}, - {"request-field-injected", "alpha", "Request: alpha"}, - {"request-field-injected", "gogol", "Request: gogol"}, - {"request-field-injected", "oracle", "Request: oracle"}, - {"request-ctor-injected", "alpha", "Request: alpha"}, - {"request-ctor-injected", "gogol", "Request: gogol"}, - {"request-ctor-injected", "oracle", "Request: oracle"} - }); + public static Stream testData() { + return Stream.of( + Arguments.of("app-field-injected", "alpha", "App: alpha"), + Arguments.of("app-field-injected", "gogol", "App: gogol"), + Arguments.of("app-field-injected", "elcaro", "App: elcaro"), + Arguments.of("app-ctor-injected", "alpha", "App: alpha"), + Arguments.of("app-ctor-injected", "gogol", "App: gogol"), + Arguments.of("app-ctor-injected", "elcaro", "App: elcaro"), + Arguments.of("request-field-injected", "alpha", "Request: alpha"), + Arguments.of("request-field-injected", "gogol", "Request: gogol"), + Arguments.of("request-field-injected", "oracle", "Request: oracle"), + Arguments.of("request-ctor-injected", "alpha", "Request: alpha"), + Arguments.of("request-ctor-injected", "gogol", "Request: gogol"), + Arguments.of("request-ctor-injected", "oracle", "Request: oracle") + ); } - final String resource, straight, echoed; - - /** - * Construct instance with the above test data injected. - * - * @param resource uri of the resource to be tested. - * @param straight request specific input. - * @param echoed CDI injected service should produce this out of previous, straight, parameter. - */ - public RequestSensitiveTest(final String resource, final String straight, final String echoed) { - this.resource = resource; - this.straight = straight; - this.echoed = echoed; - } - - @Test - public void testCdiInjection() { + @ParameterizedTest + @MethodSource("testData") + public void testCdiInjection(String resource, String straight, String echoed) { final String s = target().path(resource).queryParam("s", straight).request().get(String.class); assertThat(s, equalTo(echoed)); } - @Test - public void testHk2Injection() { + @ParameterizedTest + @MethodSource("testData") + public void testHk2Injection(String resource, String straight, String echoed) { final String s = target().path(resource).path("path").path(straight).request().get(String.class); assertThat(s, equalTo(String.format("%s/path/%s", resource, straight))); } diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java index 2399a21cb1..411b1d1498 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -33,7 +33,7 @@ * * @author Jakub Podlesak */ -public class CdiTest extends JerseyTest { +public abstract class CdiTest extends JerseyTest { @Override protected Application configure() { diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java index ccdd99362e..6c7faa068b 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,68 +16,73 @@ package org.glassfish.jersey.tests.cdi.resources; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; + import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test custom HK2 injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) -public class CustomInjectionTest extends CdiTest { +public class CustomInjectionTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"}, - }); + public static List testData() { + return Arrays.asList("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } - final String resource; - - /** - * Construct instance with the above test data injected. - * - * @param resource query parameter. - */ - public CustomInjectionTest(final String resource) { - this.resource = resource; + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + for (String resource : testData()) { + CustomInjectionTemplateTest test = new CustomInjectionTemplateTest(resource) {}; + tests.add(TestHelper.toTestContainer(test, + String.format("%s (%s)", CustomInjectionTemplateTest.class.getSimpleName(), resource))); + } + return tests; } - /** - * Check that for one no NPE happens on the server side, - * and the custom bound instance of {@link CdiInjectedType} gets CDI injected. - */ - @Test - public void testCustomHk2Injection1() { - final WebTarget target = target().path(resource).path("custom"); - final Response response = target.request().get(); - assertThat(response.getStatus(), equalTo(200)); - assertThat(response.readEntity(String.class), equalTo("CDI injected")); - } + public abstract static class CustomInjectionTemplateTest extends CdiTest { + String resource; + + public CustomInjectionTemplateTest(String resource) { + this.resource = resource; + } + + /** + * Check that for one no NPE happens on the server side, + * and the custom bound instance of {@link CdiInjectedType} gets CDI injected. + */ + @Test + public void testCustomHk2Injection1() { + final WebTarget target = target().path(resource).path("custom"); + final Response response = target.request().get(); + assertThat(response.getStatus(), equalTo(200)); + assertThat(response.readEntity(String.class), equalTo("CDI injected")); + } - /** - * Check that for one no NPE happens on the server side, - * and the custom bound instance of {@link MyApplication.MyInjection} gets CDI injected. - */ - @Test - public void testCustomHk2Injection2() { - final WebTarget target = target().path(resource).path("custom2"); - final Response response = target.request().get(); - assertThat(response.getStatus(), equalTo(200)); - assertThat(response.readEntity(String.class), equalTo("CDI would love this")); + /** + * Check that for one no NPE happens on the server side, + * and the custom bound instance of {@link MyApplication.MyInjection} gets CDI injected. + */ + @Test + public void testCustomHk2Injection2(String resource) { + final WebTarget target = target().path(resource).path("custom2"); + final Response response = target.request().get(); + assertThat(response.getStatus(), equalTo(200)); + assertThat(response.readEntity(String.class), equalTo("CDI would love this")); + } } } diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java index 00001e026e..878aec1308 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,57 +16,60 @@ package org.glassfish.jersey.tests.cdi.resources; +import java.util.ArrayList; import java.util.Arrays; -import java.util.List; +import java.util.Collection; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for exception mapper injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) -public class ExceptionMappersTest extends CdiTest { +public class ExceptionMappersTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"} - }); + public static Collection testData() { + return Arrays.asList("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } - final String resource; - - /** - * Construct instance with the above test data injected. - * - * @param resource query parameter. - */ - public ExceptionMappersTest(final String resource) { - this.resource = resource; + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + for (String resource : testData()) { + ExceptionMappersTemplateTest test = new ExceptionMappersTemplateTest(resource) {}; + tests.add(TestHelper.toTestContainer(test, + String.format("%s (%s)", ExceptionMappersTemplateTest.class.getSimpleName(), resource))); + } + return tests; } - /** - * Check that for one no NPE happens on the server side, and for two - * the injected mappers remains the same across requests. - */ - @Test - public void testMappersNotNull() { - final WebTarget target = target().path(resource).path("mappers"); - final Response firstResponse = target.request().get(); - assertThat(firstResponse.getStatus(), equalTo(200)); - final String firstValue = firstResponse.readEntity(String.class); - assertThat(target.request().get(String.class), equalTo(firstValue)); + public abstract static class ExceptionMappersTemplateTest extends CdiTest { + String resource; + + public ExceptionMappersTemplateTest(String resource) { + this.resource = resource; + } + + /** + * Check that for one no NPE happens on the server side, and for two + * the injected mappers remains the same across requests. + */ + @Test + public void testMappersNotNull() { + final WebTarget target = target().path(resource).path("mappers"); + final Response firstResponse = target.request().get(); + assertThat(firstResponse.getStatus(), equalTo(200)); + final String firstValue = firstResponse.readEntity(String.class); + assertThat(target.request().get(String.class), equalTo(firstValue)); + } } } diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java index c8de729902..52a64e3ead 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,60 +16,63 @@ package org.glassfish.jersey.tests.cdi.resources; +import java.util.ArrayList; import java.util.Arrays; -import java.util.List; +import java.util.Collection; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for monitoring statistics injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) -public class MonitoringTest extends CdiTest { +public class MonitoringTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"} - }); + public static Collection testData() { + return Arrays.asList("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } - final String resource; - - /** - * Construct instance with the above test data injected. - * - * @param resource uri of resource to be tested. - */ - public MonitoringTest(final String resource) { - this.resource = resource; + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + for (String resource : testData()) { + MonitoringTemplateTest test = new MonitoringTemplateTest(resource) {}; + tests.add(TestHelper.toTestContainer(test, + String.format("%s (%s)", MonitoringTemplateTest.class.getSimpleName(), resource))); + } + return tests; } - /** - * Make several requests and check the counter keeps incrementing. - * - * @throws Exception in case of unexpected test failure. - */ - @Test - public void testRequestCount() throws Exception { - final WebTarget target = target().path(resource).path("requestCount"); - Thread.sleep(1000); // this is to allow statistics on the server side to get updated - final int start = Integer.decode(target.request().get(String.class)); - for (int i = 1; i < 4; i++) { + public abstract static class MonitoringTemplateTest extends CdiTest { + String resource; + + public MonitoringTemplateTest(String resource) { + this.resource = resource; + } + + /** + * Make several requests and check the counter keeps incrementing. + * + * @throws Exception in case of unexpected test failure. + */ + @Test + public void testRequestCount() throws Exception { + final WebTarget target = target().path(resource).path("requestCount"); Thread.sleep(1000); // this is to allow statistics on the server side to get updated - final int next = Integer.decode(target.request().get(String.class)); - assertThat(String.format("testing %s", resource), next, equalTo(start + i)); + final int start = Integer.decode(target.request().get(String.class)); + for (int i = 1; i < 4; i++) { + Thread.sleep(1000); // this is to allow statistics on the server side to get updated + final int next = Integer.decode(target.request().get(String.class)); + assertThat(String.format("testing %s", resource), next, equalTo(start + i)); + } } } } diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java index 93370c55b3..d8f18dff2c 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-custom-hk2-banned-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,65 +16,73 @@ package org.glassfish.jersey.tests.cdi.resources; +import java.util.ArrayList; import java.util.Arrays; -import java.util.List; +import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.glassfish.jersey.test.spi.TestHelper; +import org.junit.jupiter.api.DynamicContainer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestFactory; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test injection of request depending instances works as expected. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) -public class RequestSensitiveTest extends CdiTest { +public class RequestSensitiveTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected", "alpha", "App: alpha"}, - {"app-field-injected", "gogol", "App: gogol"}, - {"app-field-injected", "elcaro", "App: elcaro"}, - {"app-ctor-injected", "alpha", "App: alpha"}, - {"app-ctor-injected", "gogol", "App: gogol"}, - {"app-ctor-injected", "elcaro", "App: elcaro"}, - {"request-field-injected", "alpha", "Request: alpha"}, - {"request-field-injected", "gogol", "Request: gogol"}, - {"request-field-injected", "oracle", "Request: oracle"}, - {"request-ctor-injected", "alpha", "Request: alpha"}, - {"request-ctor-injected", "gogol", "Request: gogol"}, - {"request-ctor-injected", "oracle", "Request: oracle"} - }); + public static Collection testData() { + return Arrays.asList( + new String[] {"app-field-injected", "alpha", "App: alpha"}, + new String[] {"app-field-injected", "gogol", "App: gogol"}, + new String[] {"app-field-injected", "elcaro", "App: elcaro"}, + new String[] {"app-ctor-injected", "alpha", "App: alpha"}, + new String[] {"app-ctor-injected", "gogol", "App: gogol"}, + new String[] {"app-ctor-injected", "elcaro", "App: elcaro"}, + new String[] {"request-field-injected", "alpha", "Request: alpha"}, + new String[] {"request-field-injected", "gogol", "Request: gogol"}, + new String[] {"request-field-injected", "oracle", "Request: oracle"}, + new String[] {"request-ctor-injected", "alpha", "Request: alpha"}, + new String[] {"request-ctor-injected", "gogol", "Request: gogol"}, + new String[] {"request-ctor-injected", "oracle", "Request: oracle"} + ); } - final String resource, straight, echoed; - - /** - * Construct instance with the above test data injected. - * - * @param resource uri of the resource to be tested. - * @param straight request specific input. - * @param echoed CDI injected service should produce this out of previous, straight, parameter. - */ - public RequestSensitiveTest(final String resource, final String straight, final String echoed) { - this.resource = resource; - this.straight = straight; - this.echoed = echoed; + @TestFactory + public Collection generateTests() { + Collection tests = new ArrayList<>(); + for (String[] args : testData()) { + RequestSensitiveTemplateTest test = new RequestSensitiveTemplateTest(args[0], args[1], args[2]) {}; + tests.add(TestHelper.toTestContainer(test, + String.format("%s (%s)", RequestSensitiveTemplateTest.class.getSimpleName(), Arrays.toString(args)))); + } + return tests; } - @Test - public void testCdiInjection() { - final String s = target().path(resource).queryParam("s", straight).request().get(String.class); - assertThat(s, equalTo(echoed)); - } + public abstract static class RequestSensitiveTemplateTest extends CdiTest { + String resource; + String straight; + String echoed; + + public RequestSensitiveTemplateTest(String resource, String straight, String echoed) { + this.resource = resource; + this.straight = straight; + this.echoed = echoed; + } + + @Test + public void testCdiInjection() { + final String s = target().path(resource).queryParam("s", straight).request().get(String.class); + assertThat(s, equalTo(echoed)); + } - @Test - public void testHk2Injection() { - final String s = target().path(resource).path("path").path(straight).request().get(String.class); - assertThat(s, equalTo(String.format("%s/path/%s", resource, straight))); + @Test + public void testHk2Injection() { + final String s = target().path(resource).path("path").path(straight).request().get(String.class); + assertThat(s, equalTo(String.format("%s/path/%s", resource, straight))); + } } } diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java index ffc79adb61..2225702a39 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/CustomInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,53 +16,34 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test custom HK2 injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class CustomInjectionTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"} - }); - } - - final String resource; - - /** - * Construct instance with the above test data injected. - * - * @param resource query parameter. - */ - public CustomInjectionTest(String resource) { - this.resource = resource; + public static Stream testData() { + return Stream.of("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } /** * Check that for one no NPE happens on the server side, * and the custom bound instance gets injected. */ - @Test - public void testCustomHk2InjectionNull() { + @ParameterizedTest + @MethodSource("testData") + public void testCustomHk2InjectionNull(String resource) { WebTarget target = target().path(resource).path("custom"); final Response response = target.request().get(); assertThat(response.getStatus(), equalTo(200)); diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java index 0dc333df1b..8eb9726f1a 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/ExceptionMappersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,53 +16,34 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for exception mapper injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class ExceptionMappersTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"} - }); - } - - final String resource; - - /** - * Construct instance with the above test data injected. - * - * @param resource query parameter. - */ - public ExceptionMappersTest(String resource) { - this.resource = resource; + public static Stream testData() { + return Stream.of("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } /** * Check that for one no NPE happens on the server side, and for two * the injected mappers remains the same across requests. */ - @Test - public void testMappersNotNull() { + @ParameterizedTest + @MethodSource("testData") + public void testMappersNotNull(String resource) { WebTarget target = target().path(resource).path("mappers"); final Response firstResponse = target.request().get(); assertThat(firstResponse.getStatus(), equalTo(200)); diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java index ff7de3978d..0835dfa41e 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/MonitoringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,33 +16,24 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test for monitoring statistics injection. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class MonitoringTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected"}, - {"app-ctor-injected"}, - {"request-field-injected"}, - {"request-ctor-injected"} - }); + public static Stream testData() { + return Stream.of("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected"); } final String resource; @@ -61,8 +52,9 @@ public MonitoringTest(String resource) { * * @throws Exception in case of unexpected test failure. */ - @Test - public void testRequestCount() throws Exception { + @ParameterizedTest + @MethodSource("testData") + public void testRequestCount(String resource) throws Exception { WebTarget target = target().path(resource).path("requestCount"); Thread.sleep(1000); // this is to allow statistics on the server side to get updated int start = Integer.decode(target.request().get(String.class)); diff --git a/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java b/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java index 930eb37583..1ac7e2a3e6 100644 --- a/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java +++ b/tests/integration/cdi-integration/cdi-with-jersey-injection-webapp/src/test/java/org/glassfish/jersey/tests/cdi/resources/RequestSensitiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,64 +16,48 @@ package org.glassfish.jersey.tests.cdi.resources; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Test injection of request depending instances works as expected. * * @author Jakub Podlesak */ -@RunWith(Parameterized.class) public class RequestSensitiveTest extends CdiTest { - @Parameterized.Parameters - public static List testData() { - return Arrays.asList(new Object[][] { - {"app-field-injected", "alpha", "App: alpha"}, - {"app-field-injected", "gogol", "App: gogol"}, - {"app-field-injected", "elcaro", "App: elcaro"}, - {"app-ctor-injected", "alpha", "App: alpha"}, - {"app-ctor-injected", "gogol", "App: gogol"}, - {"app-ctor-injected", "elcaro", "App: elcaro"}, - {"request-field-injected", "alpha", "Request: alpha"}, - {"request-field-injected", "gogol", "Request: gogol"}, - {"request-field-injected", "oracle", "Request: oracle"}, - {"request-ctor-injected", "alpha", "Request: alpha"}, - {"request-ctor-injected", "gogol", "Request: gogol"}, - {"request-ctor-injected", "oracle", "Request: oracle"} - }); + public static Stream testData() { + return Stream.of( + Arguments.of("app-field-injected", "alpha", "App: alpha"), + Arguments.of("app-field-injected", "gogol", "App: gogol"), + Arguments.of("app-field-injected", "elcaro", "App: elcaro"), + Arguments.of("app-ctor-injected", "alpha", "App: alpha"), + Arguments.of("app-ctor-injected", "gogol", "App: gogol"), + Arguments.of("app-ctor-injected", "elcaro", "App: elcaro"), + Arguments.of("request-field-injected", "alpha", "Request: alpha"), + Arguments.of("request-field-injected", "gogol", "Request: gogol"), + Arguments.of("request-field-injected", "oracle", "Request: oracle"), + Arguments.of("request-ctor-injected", "alpha", "Request: alpha"), + Arguments.of("request-ctor-injected", "gogol", "Request: gogol"), + Arguments.of("request-ctor-injected", "oracle", "Request: oracle") + ); } - final String resource, straight, echoed; - - /** - * Construct instance with the above test data injected. - * - * @param resource uri of the resource to be tested. - * @param straight request specific input. - * @param echoed CDI injected service should produce this out of previous, straight, parameter. - */ - public RequestSensitiveTest(String resource, String straight, String echoed) { - this.resource = resource; - this.straight = straight; - this.echoed = echoed; - } - - @Test - public void testCdiInjection() { + @ParameterizedTest + @MethodSource("testData") + public void testCdiInjection(String resource, String straight, String echoed) { String s = target().path(resource).queryParam("s", straight).request().get(String.class); assertThat(s, equalTo(echoed)); } - @Test - public void testHk2Injection() { + @ParameterizedTest + @MethodSource("testData") + public void testHk2Injection(String resource, String straight, String echoed) { String s = target().path(resource).path("path").path(straight).request().get(String.class); assertThat(s, equalTo(String.format("%s/path/%s", resource, straight))); } diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/NonScopedApplicationInjectTest.java b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/NonScopedApplicationInjectTest.java index 95c0ae1292..fe9a30771b 100644 --- a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/NonScopedApplicationInjectTest.java +++ b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/NonScopedApplicationInjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -25,10 +25,11 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -36,11 +37,12 @@ public class NonScopedApplicationInjectTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -50,6 +52,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -80,7 +83,7 @@ public void testIsInjectedOnApplication() { try (Response r = target(InjectionChecker.ROOT).path("nonscoped").path("inject").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } @@ -89,7 +92,7 @@ public void testIsContextedOnApplication() { try (Response r = target(InjectionChecker.ROOT).path("nonscoped").path("context").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } } diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/NonScopedInjectionTest.java b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/NonScopedInjectionTest.java index acb77b4088..35b6bc9188 100644 --- a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/NonScopedInjectionTest.java +++ b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/NonScopedInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -25,10 +25,11 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -36,11 +37,12 @@ public class NonScopedInjectionTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -50,6 +52,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -81,7 +84,7 @@ public void testIsInjectedOnResource() { try (Response r = target(InjectionChecker.ROOT).path("nonscope").path("injected").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } @@ -90,7 +93,7 @@ public void testIsContextedOnResource() { try (Response r = target(InjectionChecker.ROOT).path("nonscope").path("contexted").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } @@ -99,7 +102,7 @@ public void testNegativeContext() { try (Response r = target(InjectionChecker.ROOT).path("nonexisting").path("contexted").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.EXPECTATION_FAILED.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.EXPECTATION_FAILED.getStatusCode(), r.getStatus()); } } @@ -108,7 +111,7 @@ public void testNegativeInject() { try (Response r = target(InjectionChecker.ROOT).path("nonexisting").path("injected").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.EXPECTATION_FAILED.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.EXPECTATION_FAILED.getStatusCode(), r.getStatus()); } } @@ -117,7 +120,7 @@ public void testIsInjectedMapper() { try (Response r = target(InjectionChecker.ROOT).path("nonscope").path("iae").path("injected").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } @@ -126,7 +129,7 @@ public void testIsContextedMapper() { try (Response r = target(InjectionChecker.ROOT).path("nonscope").path("iae").path("contexted").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } } diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ScopedApplicationInjectTest.java b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ScopedApplicationInjectTest.java index 155c80a6ee..2d02d15736 100644 --- a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ScopedApplicationInjectTest.java +++ b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ScopedApplicationInjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -25,10 +25,11 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -36,11 +37,12 @@ public class ScopedApplicationInjectTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -50,6 +52,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -80,7 +83,7 @@ public void testIsInjectedOnApplication() { try (Response r = target(InjectionChecker.ROOT).path("scoped").path("inject").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } @@ -89,7 +92,7 @@ public void testIsContextedOnApplication() { try (Response r = target(InjectionChecker.ROOT).path("scoped").path("context").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } } diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ScopedInjectionTest.java b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ScopedInjectionTest.java index fc15cb147a..91da43221d 100644 --- a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ScopedInjectionTest.java +++ b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ScopedInjectionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -25,10 +25,11 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.Response; @@ -36,11 +37,12 @@ public class ScopedInjectionTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -50,6 +52,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -80,7 +83,7 @@ public void testIsInjectedOnResource() { try (Response r = target(InjectionChecker.ROOT).path("scope").path("injected").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } @@ -89,7 +92,7 @@ public void testIsContextedOnResource() { try (Response r = target(InjectionChecker.ROOT).path("scope").path("contexted").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } @@ -98,7 +101,7 @@ public void testNegativeContext() { try (Response r = target(InjectionChecker.ROOT).path("nonexisting").path("contexted").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.EXPECTATION_FAILED.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.EXPECTATION_FAILED.getStatusCode(), r.getStatus()); } } @@ -107,7 +110,7 @@ public void testNegativeInject() { try (Response r = target(InjectionChecker.ROOT).path("nonexisting").path("injected").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.EXPECTATION_FAILED.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.EXPECTATION_FAILED.getStatusCode(), r.getStatus()); } } @@ -116,7 +119,7 @@ public void testIsInjectedMapper() { try (Response r = target(InjectionChecker.ROOT).path("scope").path("iae").path("injected").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } @@ -125,7 +128,7 @@ public void testIsContextedMapper() { try (Response r = target(InjectionChecker.ROOT).path("scope").path("iae").path("contexted").request() .header(InjectionChecker.HEADER, InjectionChecker.HEADER).get()) { System.out.println(r.readEntity(String.class)); - Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); + Assertions.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus()); } } } diff --git a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/SseTest.java b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/SseTest.java index 331cf3b512..8ed3e3149f 100644 --- a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/SseTest.java +++ b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/SseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -25,10 +25,11 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; @@ -44,11 +45,12 @@ public class SseTest extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -58,6 +60,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -112,19 +115,19 @@ private void testSse(String injectType) throws InterruptedException { }); source.open(); registerLatch.await(5000, TimeUnit.MILLISECONDS); - Assert.assertEquals(0, registerLatch.getCount()); + Assertions.assertEquals(0, registerLatch.getCount()); try (Response response = target(InjectionChecker.ROOT).path("broadcast").path(injectType) .request() .post(Entity.entity(entity, MediaType.MULTIPART_FORM_DATA_TYPE))) { String readEntity = response.readEntity(String.class); // System.out.println(readEntity); - Assert.assertEquals(readEntity, response.getStatus(), Response.Status.NO_CONTENT.getStatusCode()); + Assertions.assertEquals(response.getStatus(), Response.Status.NO_CONTENT.getStatusCode(), readEntity); } broadcastLatch.await(5000, TimeUnit.MILLISECONDS); } - Assert.assertTrue(byteArrayOutputStream.toString().contains(entity)); - Assert.assertEquals(0, broadcastLatch.getCount()); + Assertions.assertTrue(byteArrayOutputStream.toString().contains(entity)); + Assertions.assertEquals(0, broadcastLatch.getCount()); } } diff --git a/tests/integration/cdi-integration/gf-cdi-inject/pom.xml b/tests/integration/cdi-integration/gf-cdi-inject/pom.xml index dc889cf4c3..22279891da 100644 --- a/tests/integration/cdi-integration/gf-cdi-inject/pom.xml +++ b/tests/integration/cdi-integration/gf-cdi-inject/pom.xml @@ -34,14 +34,12 @@ ${project.build.directory}/payara5 ${glassfish.home}/glassfish/modules ${gf.impl.version} - 5.7.2 org.junit.jupiter junit-jupiter - ${junit.jupiter.version} test @@ -79,7 +77,7 @@ org.jboss.arquillian.junit5 arquillian-junit5-container - 1.7.0.Alpha10 + 1.7.0.Alpha12 test diff --git a/tests/integration/client-connector-provider/src/test/java/org/glassfish/jersey/tests/integration/client/connector/provider/CustomConnectorProviderTest.java b/tests/integration/client-connector-provider/src/test/java/org/glassfish/jersey/tests/integration/client/connector/provider/CustomConnectorProviderTest.java index 677cc275ec..a86d98a66a 100644 --- a/tests/integration/client-connector-provider/src/test/java/org/glassfish/jersey/tests/integration/client/connector/provider/CustomConnectorProviderTest.java +++ b/tests/integration/client-connector-provider/src/test/java/org/glassfish/jersey/tests/integration/client/connector/provider/CustomConnectorProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -21,10 +21,10 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/integration/ejb-multimodule-reload/war1/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/reload/web1/ReloadTest.java b/tests/integration/ejb-multimodule-reload/war1/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/reload/web1/ReloadTest.java index 0fcfe45a87..ab5956aece 100644 --- a/tests/integration/ejb-multimodule-reload/war1/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/reload/web1/ReloadTest.java +++ b/tests/integration/ejb-multimodule-reload/war1/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/reload/web1/ReloadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,7 +24,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/ejb-multimodule-reload/war2/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/reload/web2/JaxRsFromEjbLibraryTest.java b/tests/integration/ejb-multimodule-reload/war2/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/reload/web2/JaxRsFromEjbLibraryTest.java index 58ee352912..f751078216 100644 --- a/tests/integration/ejb-multimodule-reload/war2/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/reload/web2/JaxRsFromEjbLibraryTest.java +++ b/tests/integration/ejb-multimodule-reload/war2/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/reload/web2/JaxRsFromEjbLibraryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/ejb-multimodule/war/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/web1/JaxRsFromEjbLibraryTest.java b/tests/integration/ejb-multimodule/war/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/web1/JaxRsFromEjbLibraryTest.java index a2dbf02161..f69a61eef6 100644 --- a/tests/integration/ejb-multimodule/war/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/web1/JaxRsFromEjbLibraryTest.java +++ b/tests/integration/ejb-multimodule/war/src/test/java/org/glassfish/jersey/tests/integration/multimodule/ejb/web1/JaxRsFromEjbLibraryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/ejb/resources/EjbTest.java b/tests/integration/ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/ejb/resources/EjbTest.java index 777d28d716..83c41a4e86 100644 --- a/tests/integration/ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/ejb/resources/EjbTest.java +++ b/tests/integration/ejb-test-webapp/src/test/java/org/glassfish/jersey/tests/ejb/resources/EjbTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,7 +26,7 @@ import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.is; diff --git a/tests/integration/externalproperties/pom.xml b/tests/integration/externalproperties/pom.xml index 05e8225cf2..519e3b046b 100644 --- a/tests/integration/externalproperties/pom.xml +++ b/tests/integration/externalproperties/pom.xml @@ -33,8 +33,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/tests/integration/externalproperties/src/test/java/org/glassfish/jersey/tests/externalproperties/HttpProxyTest.java b/tests/integration/externalproperties/src/test/java/org/glassfish/jersey/tests/externalproperties/HttpProxyTest.java index f74a55da14..56792d3f8a 100644 --- a/tests/integration/externalproperties/src/test/java/org/glassfish/jersey/tests/externalproperties/HttpProxyTest.java +++ b/tests/integration/externalproperties/src/test/java/org/glassfish/jersey/tests/externalproperties/HttpProxyTest.java @@ -22,9 +22,9 @@ import org.glassfish.jersey.ExternalProperties; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -54,7 +54,7 @@ protected Application configure() { return new ResourceConfig(ProxyTestResource.class); } - @Before + @BeforeEach public void startFakeProxy() { System.setProperty(ExternalProperties.HTTP_PROXY_HOST, PROXY_HOST); System.setProperty(ExternalProperties.HTTP_PROXY_PORT, PROXY_PORT); @@ -73,7 +73,7 @@ public void testProxy() { Response response = target("resource").request().get(); - Assert.assertEquals(407, response.getStatus()); + Assertions.assertEquals(407, response.getStatus()); } @Test @@ -82,9 +82,9 @@ public void testNonProxy() { Response response = target("resource").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("OK", response.readEntity(String.class)); - Assert.assertFalse(proxyHit); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("OK", response.readEntity(String.class)); + Assertions.assertFalse(proxyHit); } class ProxyHandler extends AbstractHandler { diff --git a/tests/integration/j-376/src/test/java/org/glassfish/jersey/tests/integration/j376/J376Test.java b/tests/integration/j-376/src/test/java/org/glassfish/jersey/tests/integration/j376/J376Test.java index 91b6c50418..784069db5d 100644 --- a/tests/integration/j-376/src/test/java/org/glassfish/jersey/tests/integration/j376/J376Test.java +++ b/tests/integration/j-376/src/test/java/org/glassfish/jersey/tests/integration/j376/J376Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,11 +22,11 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Adam Lindenthal @@ -35,12 +35,12 @@ public class J376Test { final Client client = ClientBuilder.newClient(); final WebTarget target = client.target(GrizzlyApp.getBaseUri()); - @BeforeClass + @BeforeAll public static void setUpTest() { GrizzlyApp.start(); } - @AfterClass + @AfterAll public static void tearDownTest() { GrizzlyApp.stop(); } diff --git a/tests/integration/j-441/war1/src/test/java/org/glassfish/jersey/tests/integration/j441/one/ContextPathTest.java b/tests/integration/j-441/war1/src/test/java/org/glassfish/jersey/tests/integration/j441/one/ContextPathTest.java index 285859ed27..d6320f6a11 100644 --- a/tests/integration/j-441/war1/src/test/java/org/glassfish/jersey/tests/integration/j441/one/ContextPathTest.java +++ b/tests/integration/j-441/war1/src/test/java/org/glassfish/jersey/tests/integration/j441/one/ContextPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -23,7 +23,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/j-441/war2/src/test/java/org/glassfish/jersey/tests/integration/j441/two/ContextPathTest.java b/tests/integration/j-441/war2/src/test/java/org/glassfish/jersey/tests/integration/j441/two/ContextPathTest.java index bb4f68b71e..b7b2c78898 100644 --- a/tests/integration/j-441/war2/src/test/java/org/glassfish/jersey/tests/integration/j441/two/ContextPathTest.java +++ b/tests/integration/j-441/war2/src/test/java/org/glassfish/jersey/tests/integration/j441/two/ContextPathTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -23,7 +23,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/j-59/war/src/test/java/org/glassfish/jersey/tests/integration/j59/cdi/web/NameBeanTest.java b/tests/integration/j-59/war/src/test/java/org/glassfish/jersey/tests/integration/j59/cdi/web/NameBeanTest.java index 8335282f41..8a1abf87ee 100644 --- a/tests/integration/j-59/war/src/test/java/org/glassfish/jersey/tests/integration/j59/cdi/web/NameBeanTest.java +++ b/tests/integration/j-59/war/src/test/java/org/glassfish/jersey/tests/integration/j59/cdi/web/NameBeanTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -24,7 +24,7 @@ import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; diff --git a/tests/integration/jaxrs-component-inject/src/test/java/org/glassfish/jersey/tests/jaxrs/inject/ApplicationInjectITCase.java b/tests/integration/jaxrs-component-inject/src/test/java/org/glassfish/jersey/tests/jaxrs/inject/ApplicationInjectITCase.java index 50c1ff8bbf..f68c289bdb 100644 --- a/tests/integration/jaxrs-component-inject/src/test/java/org/glassfish/jersey/tests/jaxrs/inject/ApplicationInjectITCase.java +++ b/tests/integration/jaxrs-component-inject/src/test/java/org/glassfish/jersey/tests/jaxrs/inject/ApplicationInjectITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests {@link javax.ws.rs.core.Context} injection into JAX-RS components Provider, Resource, Application. diff --git a/tests/integration/jersey-1107/src/test/java/org/glassfish/jersey/tests/integration/jersey1107/ApplicationHandlerITCase.java b/tests/integration/jersey-1107/src/test/java/org/glassfish/jersey/tests/integration/jersey1107/ApplicationHandlerITCase.java index 11cb216d08..28420c6ce2 100644 --- a/tests/integration/jersey-1107/src/test/java/org/glassfish/jersey/tests/integration/jersey1107/ApplicationHandlerITCase.java +++ b/tests/integration/jersey-1107/src/test/java/org/glassfish/jersey/tests/integration/jersey1107/ApplicationHandlerITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -30,9 +30,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests for JERSEY-1107: Thread gets stuck if no MessageBodyWriter is found in ApplicationHandler#writeResponse. diff --git a/tests/integration/jersey-1223/src/test/java/org/glassfish/jersey/tests/integration/jersey1223/ApplicationHandlerITCase.java b/tests/integration/jersey-1223/src/test/java/org/glassfish/jersey/tests/integration/jersey1223/ApplicationHandlerITCase.java index 6ea3471364..a198102694 100644 --- a/tests/integration/jersey-1223/src/test/java/org/glassfish/jersey/tests/integration/jersey1223/ApplicationHandlerITCase.java +++ b/tests/integration/jersey-1223/src/test/java/org/glassfish/jersey/tests/integration/jersey1223/ApplicationHandlerITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests JERSEY issue 1223. diff --git a/tests/integration/jersey-1604/src/test/java/org/glassfish/jersey/tests/integration/jersey1604/ConnectionCloseITCase.java b/tests/integration/jersey-1604/src/test/java/org/glassfish/jersey/tests/integration/jersey1604/ConnectionCloseITCase.java index 067cbff023..b4e79b8081 100644 --- a/tests/integration/jersey-1604/src/test/java/org/glassfish/jersey/tests/integration/jersey1604/ConnectionCloseITCase.java +++ b/tests/integration/jersey-1604/src/test/java/org/glassfish/jersey/tests/integration/jersey1604/ConnectionCloseITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,7 +26,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-1667/src/test/java/org/glassfish/jersey/tests/integration/jersey1667/Jersey1667ITCase.java b/tests/integration/jersey-1667/src/test/java/org/glassfish/jersey/tests/integration/jersey1667/Jersey1667ITCase.java index 4e9523ed4e..0475085d1a 100644 --- a/tests/integration/jersey-1667/src/test/java/org/glassfish/jersey/tests/integration/jersey1667/Jersey1667ITCase.java +++ b/tests/integration/jersey-1667/src/test/java/org/glassfish/jersey/tests/integration/jersey1667/Jersey1667ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,7 +35,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-1829/src/test/java/org/glassfish/jersey/tests/integration/jersey1829/ApplicationHandlerITCase.java b/tests/integration/jersey-1829/src/test/java/org/glassfish/jersey/tests/integration/jersey1829/ApplicationHandlerITCase.java index 11f81af671..b983ea2785 100644 --- a/tests/integration/jersey-1829/src/test/java/org/glassfish/jersey/tests/integration/jersey1829/ApplicationHandlerITCase.java +++ b/tests/integration/jersey-1829/src/test/java/org/glassfish/jersey/tests/integration/jersey1829/ApplicationHandlerITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests JERSEY issue 1744. Custom status reason phrase returned from the resource method was not propagated out of the @@ -48,15 +48,15 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc @Test public void testCustomResponse428() { final Response response = target().path("resource/428").request().get(); - Assert.assertEquals(428, response.getStatusInfo().getStatusCode()); - Assert.assertEquals("my-phrase", response.getStatusInfo().getReasonPhrase()); + Assertions.assertEquals(428, response.getStatusInfo().getStatusCode()); + Assertions.assertEquals("my-phrase", response.getStatusInfo().getReasonPhrase()); } @Test public void testCustomResponse428WithEntity() { final Response response = target().path("resource/428-entity").request().get(); - Assert.assertEquals(428, response.getStatusInfo().getStatusCode()); - Assert.assertEquals("my-phrase", response.getStatusInfo().getReasonPhrase()); + Assertions.assertEquals(428, response.getStatusInfo().getStatusCode()); + Assertions.assertEquals("my-phrase", response.getStatusInfo().getReasonPhrase()); } } diff --git a/tests/integration/jersey-1883/src/test/java/org/glassfish/jersey/tests/integration/jersey1883/Jersey1883ITCase.java b/tests/integration/jersey-1883/src/test/java/org/glassfish/jersey/tests/integration/jersey1883/Jersey1883ITCase.java index 703543d041..9e0610edf6 100644 --- a/tests/integration/jersey-1883/src/test/java/org/glassfish/jersey/tests/integration/jersey1883/Jersey1883ITCase.java +++ b/tests/integration/jersey-1883/src/test/java/org/glassfish/jersey/tests/integration/jersey1883/Jersey1883ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -26,9 +26,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; @@ -37,9 +37,9 @@ */ public class Jersey1883ITCase extends JerseyTest { - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } @Override diff --git a/tests/integration/jersey-1928/src/test/java/org/glassfish/jersey/tests/integration/jersey1928/Jersey1928ITCase.java b/tests/integration/jersey-1928/src/test/java/org/glassfish/jersey/tests/integration/jersey1928/Jersey1928ITCase.java index 8fa797b5b3..0ae62bdfa9 100644 --- a/tests/integration/jersey-1928/src/test/java/org/glassfish/jersey/tests/integration/jersey1928/Jersey1928ITCase.java +++ b/tests/integration/jersey-1928/src/test/java/org/glassfish/jersey/tests/integration/jersey1928/Jersey1928ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,7 +24,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-1960/src/test/java/org/glassfish/jersey/tests/integration/jersey1960/Jersey1960ITCase.java b/tests/integration/jersey-1960/src/test/java/org/glassfish/jersey/tests/integration/jersey1960/Jersey1960ITCase.java index d4317ac7e2..cb52a3f575 100644 --- a/tests/integration/jersey-1960/src/test/java/org/glassfish/jersey/tests/integration/jersey1960/Jersey1960ITCase.java +++ b/tests/integration/jersey-1960/src/test/java/org/glassfish/jersey/tests/integration/jersey1960/Jersey1960ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Reproducer tests for JERSEY-1960. diff --git a/tests/integration/jersey-1964/src/test/java/org/glassfish/jersey/tests/integration/jersey1964/Jersey1964ITCase.java b/tests/integration/jersey-1964/src/test/java/org/glassfish/jersey/tests/integration/jersey1964/Jersey1964ITCase.java index 8329fd5a2a..874390cf15 100644 --- a/tests/integration/jersey-1964/src/test/java/org/glassfish/jersey/tests/integration/jersey1964/Jersey1964ITCase.java +++ b/tests/integration/jersey-1964/src/test/java/org/glassfish/jersey/tests/integration/jersey1964/Jersey1964ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,10 +29,11 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Reproducer tests for JERSEY-1964. @@ -59,31 +60,35 @@ public void testJackson2JsonPut() throws Exception { assertThat(response.readEntity(Issue1964Resource.JsonStringWrapper.class).getValue(), equalTo("foo")); } - @Test(expected = ConnectException.class) + @Test public void testJackson2JsonGetInvalidEndpoint() throws Throwable { - try { - ClientBuilder.newClient() - .target("http://localhost:1234") - .request() - .get(); + assertThrows(ConnectException.class, () -> { + try { + ClientBuilder.newClient() + .target("http://localhost:1234") + .request() + .get(); - fail("End-point shouldn't exist."); - } catch (final ProcessingException pe) { - throw pe.getCause(); - } + fail("End-point shouldn't exist."); + } catch (final ProcessingException pe) { + throw pe.getCause(); + } + }); } - @Test(expected = ConnectException.class) + @Test public void testJackson2JsonPutInvalidEndpoint() throws Throwable { - try { - ClientBuilder.newClient() - .target("http://localhost:1234") - .request() - .put(Entity.json(new Issue1964Resource.JsonStringWrapper("foo"))); + assertThrows(ConnectException.class, () -> { + try { + ClientBuilder.newClient() + .target("http://localhost:1234") + .request() + .put(Entity.json(new Issue1964Resource.JsonStringWrapper("foo"))); - fail("End-point shouldn't exist."); - } catch (final ProcessingException pe) { - throw pe.getCause(); - } + fail("End-point shouldn't exist."); + } catch (final ProcessingException pe) { + throw pe.getCause(); + } + }); } } diff --git a/tests/integration/jersey-2031/src/test/java/org/glassfish/jersey/tests/integration/jersey2031/Jersey2031ITCase.java b/tests/integration/jersey-2031/src/test/java/org/glassfish/jersey/tests/integration/jersey2031/Jersey2031ITCase.java index 594129bfb7..3038675d6a 100644 --- a/tests/integration/jersey-2031/src/test/java/org/glassfish/jersey/tests/integration/jersey2031/Jersey2031ITCase.java +++ b/tests/integration/jersey-2031/src/test/java/org/glassfish/jersey/tests/integration/jersey2031/Jersey2031ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,7 +24,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-2136/src/test/java/org/glassfish/jersey/tests/integration/jersey2136/Jersey2136ITCase.java b/tests/integration/jersey-2136/src/test/java/org/glassfish/jersey/tests/integration/jersey2136/Jersey2136ITCase.java index 418666ace5..026939f93f 100644 --- a/tests/integration/jersey-2136/src/test/java/org/glassfish/jersey/tests/integration/jersey2136/Jersey2136ITCase.java +++ b/tests/integration/jersey-2136/src/test/java/org/glassfish/jersey/tests/integration/jersey2136/Jersey2136ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; @@ -50,7 +50,7 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc // which was causing intermittent problems with hanging app engine process. // After un-ignoring this test, make sure to uncomment the app engine plugin // execution in the project's pom.xml - @Ignore + @Disabled @Test public void testGet() throws Exception { final Response response = target().request().get(); diff --git a/tests/integration/jersey-2137/src/test/java/org/glassfish/jersey/tests/integration/jersey2137/WaeExceptionMappingTest.java b/tests/integration/jersey-2137/src/test/java/org/glassfish/jersey/tests/integration/jersey2137/WaeExceptionMappingTest.java index 3759b0f73c..f5c3301f13 100644 --- a/tests/integration/jersey-2137/src/test/java/org/glassfish/jersey/tests/integration/jersey2137/WaeExceptionMappingTest.java +++ b/tests/integration/jersey-2137/src/test/java/org/glassfish/jersey/tests/integration/jersey2137/WaeExceptionMappingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,9 +26,9 @@ import javax.ws.rs.core.UriBuilder; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.equalTo; /** diff --git a/tests/integration/jersey-2154/src/test/java/org/glassfish/jersey/tests/integration/jersey2154/EjbExceptionMappingTest.java b/tests/integration/jersey-2154/src/test/java/org/glassfish/jersey/tests/integration/jersey2154/EjbExceptionMappingTest.java index 2c81076178..c5713a6bfe 100644 --- a/tests/integration/jersey-2154/src/test/java/org/glassfish/jersey/tests/integration/jersey2154/EjbExceptionMappingTest.java +++ b/tests/integration/jersey-2154/src/test/java/org/glassfish/jersey/tests/integration/jersey2154/EjbExceptionMappingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,9 +26,9 @@ import javax.ws.rs.core.UriBuilder; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.core.StringContains.containsString; diff --git a/tests/integration/jersey-2160/src/test/java/org/glassfish/jersey/tests/integration/jersey2160/Jersey2160ITCase.java b/tests/integration/jersey-2160/src/test/java/org/glassfish/jersey/tests/integration/jersey2160/Jersey2160ITCase.java index 788a76bd7d..12556db7bf 100644 --- a/tests/integration/jersey-2160/src/test/java/org/glassfish/jersey/tests/integration/jersey2160/Jersey2160ITCase.java +++ b/tests/integration/jersey-2160/src/test/java/org/glassfish/jersey/tests/integration/jersey2160/Jersey2160ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Reproducer tests for JERSEY-2160. diff --git a/tests/integration/jersey-2164/src/test/java/org/glassfish/jersey/tests/integration/jersey2164/Jersey2164ITCase.java b/tests/integration/jersey-2164/src/test/java/org/glassfish/jersey/tests/integration/jersey2164/Jersey2164ITCase.java index 79c24c9c5a..683a69e468 100644 --- a/tests/integration/jersey-2164/src/test/java/org/glassfish/jersey/tests/integration/jersey2164/Jersey2164ITCase.java +++ b/tests/integration/jersey-2164/src/test/java/org/glassfish/jersey/tests/integration/jersey2164/Jersey2164ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,7 +29,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-2167/src/test/java/org/glassfish/jersey/tests/integration/jersey2167/Jersey2167ITCase.java b/tests/integration/jersey-2167/src/test/java/org/glassfish/jersey/tests/integration/jersey2167/Jersey2167ITCase.java index b090745f72..354a3eb86e 100644 --- a/tests/integration/jersey-2167/src/test/java/org/glassfish/jersey/tests/integration/jersey2167/Jersey2167ITCase.java +++ b/tests/integration/jersey-2167/src/test/java/org/glassfish/jersey/tests/integration/jersey2167/Jersey2167ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Reproducer tests for JERSEY-2167. @@ -53,7 +53,7 @@ public void testResourceMethodCall() throws Exception { // that hk2 injected the parameter and invoked the method preliminary and during Jersey-driven invocation, // there was no parameter injection any more. If parameter was injected and Response.Status.OK (200) returned, // the resource method was called only once (by Jersey). - assertEquals("Parameter not injected into resource method. Resource method could have been called twice. ", - response.getStatus(), Response.Status.OK.getStatusCode()); + assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), + "Parameter not injected into resource method. Resource method could have been called twice. "); } } diff --git a/tests/integration/jersey-2176/src/test/java/org/glassfish/jersey/tests/integration/jersey2176/Jersey2176ITCaseBase.java b/tests/integration/jersey-2176/src/test/java/org/glassfish/jersey/tests/integration/jersey2176/Jersey2176ITCaseBase.java index 42105024ce..e1ccf7442c 100644 --- a/tests/integration/jersey-2176/src/test/java/org/glassfish/jersey/tests/integration/jersey2176/Jersey2176ITCaseBase.java +++ b/tests/integration/jersey-2176/src/test/java/org/glassfish/jersey/tests/integration/jersey2176/Jersey2176ITCaseBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Reproducer tests for JERSEY-2176. @@ -120,18 +120,18 @@ private void testGetContent(int uc, boolean responseEntity) { final Response response = builder.get(); final String assertMessage = uc + "|" + responseEntity; - Assert.assertEquals(assertMessage, uc, response.getStatus()); + Assertions.assertEquals(uc, response.getStatus(), assertMessage); if (!sendErrorExpected(uc, responseEntity)) { - Assert.assertEquals(assertMessage, "OK", response.getHeaderString(TraceResponseFilter.X_STATUS_HEADER)); - Assert.assertNotNull(assertMessage, response.getHeaderString(TraceResponseFilter.X_SERVER_DURATION_HEADER)); + Assertions.assertEquals("OK", response.getHeaderString(TraceResponseFilter.X_STATUS_HEADER), assertMessage); + Assertions.assertNotNull(response.getHeaderString(TraceResponseFilter.X_SERVER_DURATION_HEADER), assertMessage); if (responseEntity) { - Assert.assertEquals(assertMessage, expectedContent, response.readEntity(String.class)); - Assert.assertEquals(assertMessage, String.valueOf(expectedContent.length()), - response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); + Assertions.assertEquals(expectedContent, response.readEntity(String.class), assertMessage); + Assertions.assertEquals(String.valueOf(expectedContent.length()), + response.getHeaderString(HttpHeaders.CONTENT_LENGTH), assertMessage); } } else { - Assert.assertNull(assertMessage, response.getHeaderString(TraceResponseFilter.X_STATUS_HEADER)); - Assert.assertNull(assertMessage, response.getHeaderString(TraceResponseFilter.X_SERVER_DURATION_HEADER)); + Assertions.assertNull(response.getHeaderString(TraceResponseFilter.X_STATUS_HEADER), assertMessage); + Assertions.assertNull(response.getHeaderString(TraceResponseFilter.X_SERVER_DURATION_HEADER), assertMessage); } } @@ -147,16 +147,16 @@ private void testGetException(int uc, int expectedStatus, boolean fail) { final String expectedContent = "[FILTER][/FILTER]"; final String assertMessage = uc + ":" + expectedStatus + "|" + fail; - Assert.assertEquals(assertMessage, expectedStatus, response.getStatus()); + Assertions.assertEquals(expectedStatus, response.getStatus(), assertMessage); if (!sendErrorExpected(expectedStatus, false)) { - Assert.assertEquals(assertMessage, expectedStatus == 500 ? "FAIL" : "OK", - response.getHeaderString(TraceResponseFilter.X_STATUS_HEADER)); - Assert.assertNotNull(assertMessage, response.getHeaderString(TraceResponseFilter.X_SERVER_DURATION_HEADER)); - Assert.assertEquals(assertMessage, String.valueOf(expectedContent.length()), - response.getHeaderString(HttpHeaders.CONTENT_LENGTH)); + Assertions.assertEquals(expectedStatus == 500 ? "FAIL" : "OK", + response.getHeaderString(TraceResponseFilter.X_STATUS_HEADER), assertMessage); + Assertions.assertNotNull(response.getHeaderString(TraceResponseFilter.X_SERVER_DURATION_HEADER), assertMessage); + Assertions.assertEquals(String.valueOf(expectedContent.length()), + response.getHeaderString(HttpHeaders.CONTENT_LENGTH), assertMessage); } else { - Assert.assertNull(assertMessage, response.getHeaderString(TraceResponseFilter.X_STATUS_HEADER)); - Assert.assertNull(assertMessage, response.getHeaderString(TraceResponseFilter.X_SERVER_DURATION_HEADER)); + Assertions.assertNull(response.getHeaderString(TraceResponseFilter.X_STATUS_HEADER), assertMessage); + Assertions.assertNull(response.getHeaderString(TraceResponseFilter.X_SERVER_DURATION_HEADER), assertMessage); } } diff --git a/tests/integration/jersey-2184/src/test/java/org/glassfish/jersey/tests/integration/jersey2184/Jersey2184ITCase.java b/tests/integration/jersey-2184/src/test/java/org/glassfish/jersey/tests/integration/jersey2184/Jersey2184ITCase.java index 8aa9544674..ecfc37b2d4 100644 --- a/tests/integration/jersey-2184/src/test/java/org/glassfish/jersey/tests/integration/jersey2184/Jersey2184ITCase.java +++ b/tests/integration/jersey-2184/src/test/java/org/glassfish/jersey/tests/integration/jersey2184/Jersey2184ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,10 +28,10 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests the JERSEY-2184 fix (the ability to inject ServletContext into application subclass constructor). @@ -40,9 +40,9 @@ */ public class Jersey2184ITCase extends JerseyTest { - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } @Override diff --git a/tests/integration/jersey-2255/src/test/java/org/glassfish/jersey/tests/integration/jersey2255/Jersey2255ITCase.java b/tests/integration/jersey-2255/src/test/java/org/glassfish/jersey/tests/integration/jersey2255/Jersey2255ITCase.java index a996eba613..061db6bc43 100644 --- a/tests/integration/jersey-2255/src/test/java/org/glassfish/jersey/tests/integration/jersey2255/Jersey2255ITCase.java +++ b/tests/integration/jersey-2255/src/test/java/org/glassfish/jersey/tests/integration/jersey2255/Jersey2255ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -27,10 +27,10 @@ import org.glassfish.jersey.tests.integration.jersey2255.Issue2255Resource.A; import org.glassfish.jersey.tests.integration.jersey2255.Issue2255Resource.B; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Reproducer tests for JERSEY-2255. diff --git a/tests/integration/jersey-2322/src/test/java/org/glassfish/jersey/tests/integration/jersey2322/Jersey2322ITCase.java b/tests/integration/jersey-2322/src/test/java/org/glassfish/jersey/tests/integration/jersey2322/Jersey2322ITCase.java index f3700cf416..f25b9ce105 100644 --- a/tests/integration/jersey-2322/src/test/java/org/glassfish/jersey/tests/integration/jersey2322/Jersey2322ITCase.java +++ b/tests/integration/jersey-2322/src/test/java/org/glassfish/jersey/tests/integration/jersey2322/Jersey2322ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-2335/src/test/java/org/glassfish/jersey/tests/integration/jersey2335/Jersey2335ITCase.java b/tests/integration/jersey-2335/src/test/java/org/glassfish/jersey/tests/integration/jersey2335/Jersey2335ITCase.java index 6face63a92..cabb45e911 100644 --- a/tests/integration/jersey-2335/src/test/java/org/glassfish/jersey/tests/integration/jersey2335/Jersey2335ITCase.java +++ b/tests/integration/jersey-2335/src/test/java/org/glassfish/jersey/tests/integration/jersey2335/Jersey2335ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -29,10 +29,10 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** * Reproducer tests for JERSEY-2335. diff --git a/tests/integration/jersey-2421/pom.xml b/tests/integration/jersey-2421/pom.xml index 50afcf600d..3690c69b0c 100644 --- a/tests/integration/jersey-2421/pom.xml +++ b/tests/integration/jersey-2421/pom.xml @@ -43,8 +43,14 @@ - junit - junit + org.junit.jupiter + junit-jupiter + test + + + org.hamcrest + hamcrest + test diff --git a/tests/integration/jersey-2421/src/test/java/org/glassfish/jersey/tests/integration/jersey2421/Jersey2421Test.java b/tests/integration/jersey-2421/src/test/java/org/glassfish/jersey/tests/integration/jersey2421/Jersey2421Test.java index dc711852ac..1bf3cb76de 100644 --- a/tests/integration/jersey-2421/src/test/java/org/glassfish/jersey/tests/integration/jersey2421/Jersey2421Test.java +++ b/tests/integration/jersey-2421/src/test/java/org/glassfish/jersey/tests/integration/jersey2421/Jersey2421Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -41,9 +41,10 @@ import org.glassfish.jersey.message.internal.NullOutputStream; import org.glassfish.jersey.message.internal.OutboundMessageContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; /** * Reproducer tests for JERSEY-2421. @@ -115,8 +116,8 @@ public void testMultiPartFeatureOnClient() throws Exception { /** * Test that classes from jersey-server module cannot be loaded. */ - @Test(expected = ClassNotFoundException.class) + @Test public void testLoadJerseyServerClass() throws Exception { - Class.forName("org.glassfish.jersey.server.ResourceConfig"); + assertThrows(ClassNotFoundException.class, () -> Class.forName("org.glassfish.jersey.server.ResourceConfig")); } } diff --git a/tests/integration/jersey-2551/src/test/java/org/glassfish/jersey/tests/integration/jersey2551/Jersey2551ITCase.java b/tests/integration/jersey-2551/src/test/java/org/glassfish/jersey/tests/integration/jersey2551/Jersey2551ITCase.java index a45e1b4d90..03c0028cfa 100644 --- a/tests/integration/jersey-2551/src/test/java/org/glassfish/jersey/tests/integration/jersey2551/Jersey2551ITCase.java +++ b/tests/integration/jersey-2551/src/test/java/org/glassfish/jersey/tests/integration/jersey2551/Jersey2551ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,7 +23,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-2612/src/test/java/org/glassfish/jersey/tests/integration/jersey2612/Jersey2612ITCase.java b/tests/integration/jersey-2612/src/test/java/org/glassfish/jersey/tests/integration/jersey2612/Jersey2612ITCase.java index 0ffbad5825..d50dda825c 100644 --- a/tests/integration/jersey-2612/src/test/java/org/glassfish/jersey/tests/integration/jersey2612/Jersey2612ITCase.java +++ b/tests/integration/jersey-2612/src/test/java/org/glassfish/jersey/tests/integration/jersey2612/Jersey2612ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,7 +23,7 @@ import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-2637/src/test/java/org/glassfish/jersey/tests/integration/jersey2637/Jersey2637DisabledITCase.java b/tests/integration/jersey-2637/src/test/java/org/glassfish/jersey/tests/integration/jersey2637/Jersey2637DisabledITCase.java index de6b68e21d..f2dcca3568 100644 --- a/tests/integration/jersey-2637/src/test/java/org/glassfish/jersey/tests/integration/jersey2637/Jersey2637DisabledITCase.java +++ b/tests/integration/jersey-2637/src/test/java/org/glassfish/jersey/tests/integration/jersey2637/Jersey2637DisabledITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -26,7 +26,7 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/tests/integration/jersey-2637/src/test/java/org/glassfish/jersey/tests/integration/jersey2637/Jersey2637EnabledITCase.java b/tests/integration/jersey-2637/src/test/java/org/glassfish/jersey/tests/integration/jersey2637/Jersey2637EnabledITCase.java index 1240bc11da..8cd4f0b637 100644 --- a/tests/integration/jersey-2637/src/test/java/org/glassfish/jersey/tests/integration/jersey2637/Jersey2637EnabledITCase.java +++ b/tests/integration/jersey-2637/src/test/java/org/glassfish/jersey/tests/integration/jersey2637/Jersey2637EnabledITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,8 +16,7 @@ package org.glassfish.jersey.tests.integration.jersey2637; -import java.util.Arrays; -import java.util.Collection; +import java.util.stream.Stream; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; @@ -29,26 +28,20 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; /** * Reproducer tests for JERSEY-2637 - Query params can be injected using {@link javax.ws.rs.FormParam}. */ -@RunWith(Parameterized.class) public class Jersey2637EnabledITCase extends JerseyTest { - @Parameterized.Parameters(name = "path = {0}") - public static Collection paths() { - return Arrays.asList(new Object[][]{{"defaut"}, {"enabled"}}); + public static Stream paths() { + return Stream.of("defaut", "enabled"); } - @Parameterized.Parameter - public String path; - @Override protected Application configure() { return new Jersey2637(); @@ -59,8 +52,9 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc return new ExternalTestContainerFactory(); } - @Test - public void testFormParams() throws Exception { + @ParameterizedTest + @MethodSource("paths") + public void testFormParams(String path) throws Exception { final Form form = new Form() .param("username", "user") .param("password", "pass"); @@ -70,8 +64,9 @@ public void testFormParams() throws Exception { assertThat(response.readEntity(String.class), is("user_pass")); } - @Test - public void testQueryParams() throws Exception { + @ParameterizedTest + @MethodSource("paths") + public void testQueryParams(String path) throws Exception { final Response response = target(path) .queryParam("username", "user").queryParam("password", "pass") .request() @@ -80,8 +75,9 @@ public void testQueryParams() throws Exception { assertThat(response.readEntity(String.class), is("user_pass")); } - @Test - public void testDoubleQueryParams() throws Exception { + @ParameterizedTest + @MethodSource("paths") + public void testDoubleQueryParams(String path) throws Exception { final Response response = target(path) .queryParam("username", "user").queryParam("password", "pass") .queryParam("username", "user").queryParam("password", "pass") @@ -91,8 +87,9 @@ public void testDoubleQueryParams() throws Exception { assertThat(response.readEntity(String.class), is("user_pass")); } - @Test - public void testEncodedQueryParams() throws Exception { + @ParameterizedTest + @MethodSource("paths") + public void testEncodedQueryParams(String path) throws Exception { final Response response = target(path) .queryParam("username", "us%20er").queryParam("password", "pass") .request() @@ -101,8 +98,9 @@ public void testEncodedQueryParams() throws Exception { assertThat(response.readEntity(String.class), is("us er_pass")); } - @Test - public void testFormAndQueryParams() throws Exception { + @ParameterizedTest + @MethodSource("paths") + public void testFormAndQueryParams(String path) throws Exception { final Form form = new Form() .param("username", "user") .param("password", "pass"); diff --git a/tests/integration/jersey-2654/src/test/java/org/glassfish/jersey/tests/integration/jersey2654/Jersey2654ITCase.java b/tests/integration/jersey-2654/src/test/java/org/glassfish/jersey/tests/integration/jersey2654/Jersey2654ITCase.java index c6793b6faa..e2afbc80d9 100644 --- a/tests/integration/jersey-2654/src/test/java/org/glassfish/jersey/tests/integration/jersey2654/Jersey2654ITCase.java +++ b/tests/integration/jersey-2654/src/test/java/org/glassfish/jersey/tests/integration/jersey2654/Jersey2654ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Reproducer for JERSEY-2654 diff --git a/tests/integration/jersey-2673/src/test/java/org/glassfish/jersey/tests/integration/jersey2673/Jersey2673ITCase.java b/tests/integration/jersey-2673/src/test/java/org/glassfish/jersey/tests/integration/jersey2673/Jersey2673ITCase.java index f157001651..48911efe0b 100644 --- a/tests/integration/jersey-2673/src/test/java/org/glassfish/jersey/tests/integration/jersey2673/Jersey2673ITCase.java +++ b/tests/integration/jersey-2673/src/test/java/org/glassfish/jersey/tests/integration/jersey2673/Jersey2673ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Reproducer for JERSEY-2673: 400 errors generated by a ValidationException are returning default error page instead of diff --git a/tests/integration/jersey-2689/src/test/java/org/glassfish/jersey/tests/integration/jersey2689/Jersey2689ITCase.java b/tests/integration/jersey-2689/src/test/java/org/glassfish/jersey/tests/integration/jersey2689/Jersey2689ITCase.java index 2db2efa4f6..b773a5f85e 100644 --- a/tests/integration/jersey-2689/src/test/java/org/glassfish/jersey/tests/integration/jersey2689/Jersey2689ITCase.java +++ b/tests/integration/jersey-2689/src/test/java/org/glassfish/jersey/tests/integration/jersey2689/Jersey2689ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -32,9 +32,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; diff --git a/tests/integration/jersey-2704/src/test/java/org/glassfish/jersey/tests/integration/jersey2704/Jersey2704ITCase.java b/tests/integration/jersey-2704/src/test/java/org/glassfish/jersey/tests/integration/jersey2704/Jersey2704ITCase.java index 2ed829e686..c5b2c4382d 100644 --- a/tests/integration/jersey-2704/src/test/java/org/glassfish/jersey/tests/integration/jersey2704/Jersey2704ITCase.java +++ b/tests/integration/jersey-2704/src/test/java/org/glassfish/jersey/tests/integration/jersey2704/Jersey2704ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.test.spi.TestContainerFactory; import org.glassfish.jersey.tests.integration.jersey2704.services.HappyService; import org.glassfish.jersey.tests.integration.jersey2704.services.SadService; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** @@ -82,7 +82,7 @@ private int test(Class service) throws IOException { */ @Test public void testCorrectInjection() throws IOException { - Assert.assertEquals(200, test(HappyService.class)); + Assertions.assertEquals(200, test(HappyService.class)); } /** @@ -93,6 +93,6 @@ public void testCorrectInjection() throws IOException { */ @Test public void testMisingInjection() throws IOException { - Assert.assertEquals(600, test(SadService.class)); + Assertions.assertEquals(600, test(SadService.class)); } } diff --git a/tests/integration/jersey-2776/src/test/java/org/glassfish/jersey/tests/integration/jersey2776/Jersey2776ITCase.java b/tests/integration/jersey-2776/src/test/java/org/glassfish/jersey/tests/integration/jersey2776/Jersey2776ITCase.java index 7a6d2afed2..ac57a9394b 100644 --- a/tests/integration/jersey-2776/src/test/java/org/glassfish/jersey/tests/integration/jersey2776/Jersey2776ITCase.java +++ b/tests/integration/jersey-2776/src/test/java/org/glassfish/jersey/tests/integration/jersey2776/Jersey2776ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -36,17 +36,17 @@ import org.apache.cxf.jaxrs.ext.multipart.AttachmentBuilder; import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition; import org.apache.cxf.jaxrs.ext.multipart.MultipartBody; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Code under test: {@link MultiPartReaderClientSide} (unquoteMediaTypeParameters) * * @author Jonatan Jönsson (jontejj at gmail.com) */ -@Ignore +@Disabled public class Jersey2776ITCase extends JerseyTest { @Override diff --git a/tests/integration/jersey-2794/src/test/java/org/glassfish/jersey/tests/integration/jersey2794/Jersey2794ITCase.java b/tests/integration/jersey-2794/src/test/java/org/glassfish/jersey/tests/integration/jersey2794/Jersey2794ITCase.java index 60a54ca3d5..27f2ffb84e 100644 --- a/tests/integration/jersey-2794/src/test/java/org/glassfish/jersey/tests/integration/jersey2794/Jersey2794ITCase.java +++ b/tests/integration/jersey-2794/src/test/java/org/glassfish/jersey/tests/integration/jersey2794/Jersey2794ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -35,9 +35,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * JERSEY-2794 reproducer. diff --git a/tests/integration/jersey-2846/src/test/java/org/glassfish/jersey/tests/integration/jersey2846/Jersey2846ITCase.java b/tests/integration/jersey-2846/src/test/java/org/glassfish/jersey/tests/integration/jersey2846/Jersey2846ITCase.java index 0aecaa2fb6..7656af8455 100644 --- a/tests/integration/jersey-2846/src/test/java/org/glassfish/jersey/tests/integration/jersey2846/Jersey2846ITCase.java +++ b/tests/integration/jersey-2846/src/test/java/org/glassfish/jersey/tests/integration/jersey2846/Jersey2846ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -41,9 +41,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * JERSEY-2846 reproducer. diff --git a/tests/integration/jersey-2878/src/test/java/org/glassfish/jersey/tests/integration/jersey2878/Jersey2878ITCase.java b/tests/integration/jersey-2878/src/test/java/org/glassfish/jersey/tests/integration/jersey2878/Jersey2878ITCase.java index a31f49fb6c..2a15d4a99a 100644 --- a/tests/integration/jersey-2878/src/test/java/org/glassfish/jersey/tests/integration/jersey2878/Jersey2878ITCase.java +++ b/tests/integration/jersey-2878/src/test/java/org/glassfish/jersey/tests/integration/jersey2878/Jersey2878ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -33,8 +33,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.fail; public class Jersey2878ITCase extends JerseyTest { diff --git a/tests/integration/jersey-2892/src/test/java/org/glassfish/jersey/tests/integration/jersey2892/AbstractJerseyEntityFilteringITCase.java b/tests/integration/jersey-2892/src/test/java/org/glassfish/jersey/tests/integration/jersey2892/AbstractJerseyEntityFilteringITCase.java index 4b32ba9534..73ac0a30a2 100644 --- a/tests/integration/jersey-2892/src/test/java/org/glassfish/jersey/tests/integration/jersey2892/AbstractJerseyEntityFilteringITCase.java +++ b/tests/integration/jersey-2892/src/test/java/org/glassfish/jersey/tests/integration/jersey2892/AbstractJerseyEntityFilteringITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * Tests whether classes repeating in the object graph are filtered out correctly. @@ -57,8 +57,8 @@ public void testWhetherSubSubFiledIsNotFilteredOut() { final TestResource.Persons persons = response.readEntity(TestResource.Persons.class); - Assert.assertEquals("Amphitheatre Pkwy", persons.first.address.street.name); - Assert.assertEquals("Microsoft Way", persons.second.address.street.name); + Assertions.assertEquals("Amphitheatre Pkwy", persons.first.address.street.name); + Assertions.assertEquals("Microsoft Way", persons.second.address.street.name); } /** @@ -71,8 +71,8 @@ public void testWhetherSubSubSubFieldIsNotFilteredOut() { final TestResource.Pointer pointer = response.readEntity(TestResource.Pointer.class); - Assert.assertEquals("Amphitheatre Pkwy", pointer.persons.first.address.street.name); - Assert.assertEquals("Microsoft Way", pointer.persons.second.address.street.name); + Assertions.assertEquals("Amphitheatre Pkwy", pointer.persons.first.address.street.name); + Assertions.assertEquals("Microsoft Way", pointer.persons.second.address.street.name); } /** @@ -84,7 +84,7 @@ public void testWhetherReferenceCycleIsDetected() { final TestResource.Recursive recursive = response.readEntity(TestResource.Recursive.class); - Assert.assertEquals("c", recursive.subField.subSubField.idSubSubField); + Assertions.assertEquals("c", recursive.subField.subSubField.idSubSubField); } /** diff --git a/tests/integration/jersey-3662/pom.xml b/tests/integration/jersey-3662/pom.xml index 0d7dbb71c1..8ac75ea91e 100644 --- a/tests/integration/jersey-3662/pom.xml +++ b/tests/integration/jersey-3662/pom.xml @@ -40,8 +40,8 @@ ${project.version} - junit - junit + org.junit.jupiter + junit-jupiter diff --git a/tests/integration/jersey-3670/src/test/java/org/glassfish/jersey/tests/integration/jersey3670/ExternalApplicationParamConverterTest.java b/tests/integration/jersey-3670/src/test/java/org/glassfish/jersey/tests/integration/jersey3670/ExternalApplicationParamConverterTest.java index a166ed18ca..963b4b5284 100644 --- a/tests/integration/jersey-3670/src/test/java/org/glassfish/jersey/tests/integration/jersey3670/ExternalApplicationParamConverterTest.java +++ b/tests/integration/jersey-3670/src/test/java/org/glassfish/jersey/tests/integration/jersey3670/ExternalApplicationParamConverterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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,11 +20,11 @@ import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ExternalApplicationParamConverterTest extends JerseyTest { diff --git a/tests/integration/jersey-3796/src/test/java/org/glassfish/jersey/tests/integration/jersey3796/Jersey3796ITCase.java b/tests/integration/jersey-3796/src/test/java/org/glassfish/jersey/tests/integration/jersey3796/Jersey3796ITCase.java index 7d552e8e2e..ebe4c528eb 100644 --- a/tests/integration/jersey-3796/src/test/java/org/glassfish/jersey/tests/integration/jersey3796/Jersey3796ITCase.java +++ b/tests/integration/jersey-3796/src/test/java/org/glassfish/jersey/tests/integration/jersey3796/Jersey3796ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; @@ -48,14 +48,14 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc public void testSameInstanceForProviders() { final Map response = target("/myresource").request(MediaType.APPLICATION_JSON_TYPE).get(Map.class); //Map shall not be null - Assert.assertNotNull(response); + Assertions.assertNotNull(response); //Map shall contain exactly three elements - Assert.assertEquals(3, response.size()); + Assertions.assertEquals(3, response.size()); //Map shall contain ony keys Feature, Request and Response //Values of that keys shall be equals. //Equality of all values indicates the class is only one per all tested providers - Assert.assertEquals(response.get("Feature"), response.get("Request")); - Assert.assertEquals(response.get("Feature"), response.get("Response")); - Assert.assertEquals(response.get("Response"), response.get("Request")); + Assertions.assertEquals(response.get("Feature"), response.get("Request")); + Assertions.assertEquals(response.get("Feature"), response.get("Response")); + Assertions.assertEquals(response.get("Response"), response.get("Request")); } } diff --git a/tests/integration/jersey-3992/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java b/tests/integration/jersey-3992/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java index c6ad8e5af5..212a1159c8 100644 --- a/tests/integration/jersey-3992/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java +++ b/tests/integration/jersey-3992/src/test/java/org/glassfish/jersey/tests/cdi/resources/CdiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the @@ -23,6 +23,8 @@ import javax.ws.rs.core.UriBuilder; import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; /** * Test for CDI web application resources. @@ -38,6 +40,7 @@ public class CdiTest extends JerseyTest { Weld weld; + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -45,6 +48,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { weld.shutdown(); diff --git a/tests/integration/jersey-3992/src/test/java/org/glassfish/jersey/tests/cdi/resources/InheritanceTest.java b/tests/integration/jersey-3992/src/test/java/org/glassfish/jersey/tests/cdi/resources/InheritanceTest.java index 24479fb77d..a05656bd36 100644 --- a/tests/integration/jersey-3992/src/test/java/org/glassfish/jersey/tests/cdi/resources/InheritanceTest.java +++ b/tests/integration/jersey-3992/src/test/java/org/glassfish/jersey/tests/cdi/resources/InheritanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022 Payara Foundation 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,8 +18,8 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; -import org.junit.Test; -import static org.junit.Assert.assertThat; +import org.junit.jupiter.api.Test; +import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.CoreMatchers.is; /** diff --git a/tests/integration/jersey-4003/src/test/java/org/glassfish/jersey/tests/integration/jersey4003/LostResponseTest.java b/tests/integration/jersey-4003/src/test/java/org/glassfish/jersey/tests/integration/jersey4003/LostResponseTest.java index 1780d05a8d..2bc3a12952 100644 --- a/tests/integration/jersey-4003/src/test/java/org/glassfish/jersey/tests/integration/jersey4003/LostResponseTest.java +++ b/tests/integration/jersey-4003/src/test/java/org/glassfish/jersey/tests/integration/jersey4003/LostResponseTest.java @@ -41,9 +41,9 @@ import org.glassfish.jersey.client.HttpUrlConnectorProvider; import org.glassfish.jersey.client.JerseyClientBuilder; import org.glassfish.jersey.client.JerseyCompletionStageRxInvoker; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; public class LostResponseTest { @@ -54,7 +54,7 @@ public class LostResponseTest { private Client client; private Entity bodyEntity; - @Before + @BeforeEach public void setup() throws IOException { HttpUrlConnectorProvider.ConnectionFactory connectionFactory = Mockito.mock(HttpUrlConnectorProvider.ConnectionFactory.class); @@ -85,10 +85,10 @@ public void setup() throws IOException { public void putEntityFailure() { try { client.target(DUMMY_URL).request().put(bodyEntity); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } } @@ -97,10 +97,10 @@ public void putEntityFailure() { public void putEntityAndClassTypeFailure() { try { client.target(DUMMY_URL).request().put(bodyEntity, String.class); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } } @@ -109,10 +109,10 @@ public void putEntityAndClassTypeFailure() { public void putEntityAndGenericTypeTypeFailure() { try { client.target(DUMMY_URL).request().put(bodyEntity, new GenericType(){}); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } } @@ -122,13 +122,13 @@ public void asyncPutEntityFailure() throws InterruptedException { try { Future future = client.target(DUMMY_URL).request().async().put(bodyEntity); future.get(); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ExecutionException ee) { try { throw (RuntimeException) ee.getCause(); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } } @@ -139,13 +139,13 @@ public void asyncPutEntityAndClassFailure() throws InterruptedException { try { Future future = client.target(DUMMY_URL).request().async().put(bodyEntity, String.class); future.get(); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ExecutionException ee) { try { throw (RuntimeException) ee.getCause(); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } } @@ -156,13 +156,13 @@ public void asyncPutEntityAndGenericTypeTypeFailure() throws InterruptedExceptio try { Future future = client.target(DUMMY_URL).request().async().put(bodyEntity, new GenericType(){}); future.get(); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ExecutionException ee) { try { throw (RuntimeException) ee.getCause(); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } } @@ -177,7 +177,7 @@ public void asyncPutEntityWithCallbackFailure() throws InterruptedException { client.target(DUMMY_URL).request().async().put(bodyEntity, new InvocationCallback() { @Override public void completed(Response response) { - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } @Override @@ -187,20 +187,20 @@ public void failed(Throwable throwable) { } }); future.get(); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ExecutionException ee) { try { throw (RuntimeException) ee.getCause(); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } failedLatch.await(5000, TimeUnit.MILLISECONDS); Throwable ct = callbackThrowable.get(); - Assert.assertTrue("Callback has not been hit", ct != null); - Assert.assertTrue("The exception is " + ct.getClass().getName(), - ResponseProcessingException.class.isInstance(ct)); + Assertions.assertTrue(ct != null, "Callback has not been hit"); + Assertions.assertTrue(ResponseProcessingException.class.isInstance(ct), + "The exception is " + ct.getClass().getName()); } } @@ -209,13 +209,13 @@ public void rxPutEntityFailure() throws InterruptedException { try { CompletionStage future = client.target(DUMMY_URL).request().rx().put(bodyEntity); future.toCompletableFuture().get(); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ExecutionException ee) { try { throw (RuntimeException) ee.getCause(); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } } @@ -231,7 +231,7 @@ public void rxPutEntityWithCallbackFailure() throws InterruptedException { .put(bodyEntity, new InvocationCallback() { @Override public void completed(Response response) { - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } @Override @@ -241,20 +241,20 @@ public void failed(Throwable throwable) { } }); future.get(); - Assert.fail("Expected ResponseProcessing exception has not been thrown"); + Assertions.fail("Expected ResponseProcessing exception has not been thrown"); } catch (ExecutionException ee) { try { throw (RuntimeException) ee.getCause(); } catch (ResponseProcessingException rpe) { try (Response response = rpe.getResponse()) { - Assert.assertEquals(RESPONSE_CODE, response.getStatus()); + Assertions.assertEquals(RESPONSE_CODE, response.getStatus()); } } failedLatch.await(5000, TimeUnit.MILLISECONDS); Throwable ct = callbackThrowable.get(); - Assert.assertTrue("Callback has not been hit", ct != null); - Assert.assertTrue("The exception is " + ct.getClass().getName(), - ResponseProcessingException.class.isInstance(ct)); + Assertions.assertTrue(ct != null, "Callback has not been hit"); + Assertions.assertTrue(ResponseProcessingException.class.isInstance(ct), + "The exception is " + ct.getClass().getName()); } } } diff --git a/tests/integration/jersey-4099/src/test/java/org/glassfish/jersey/tests/integration/jersey4099/PriorityAnnotationOnExceptionMappersTest.java b/tests/integration/jersey-4099/src/test/java/org/glassfish/jersey/tests/integration/jersey4099/PriorityAnnotationOnExceptionMappersTest.java index 3d9ca2effd..25e1899941 100644 --- a/tests/integration/jersey-4099/src/test/java/org/glassfish/jersey/tests/integration/jersey4099/PriorityAnnotationOnExceptionMappersTest.java +++ b/tests/integration/jersey-4099/src/test/java/org/glassfish/jersey/tests/integration/jersey4099/PriorityAnnotationOnExceptionMappersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Christian Kaltepoth. All rights reserved. + * Copyright (c) 2019, 2022 Christian Kaltepoth. 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 @@ -19,15 +19,18 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.jboss.weld.environment.se.Weld; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; public class PriorityAnnotationOnExceptionMappersTest extends JerseyTest { private Weld weld; + @BeforeEach @Override public void setUp() throws Exception { weld = new Weld(); @@ -35,6 +38,7 @@ public void setUp() throws Exception { super.setUp(); } + @AfterEach @Override public void tearDown() throws Exception { super.tearDown(); diff --git a/tests/integration/jersey-4321/src/test/java/org/glassfish/jersey/tests/integration/jersey4321/StreamingTest.java b/tests/integration/jersey-4321/src/test/java/org/glassfish/jersey/tests/integration/jersey4321/StreamingTest.java index 93c441c4fd..5c4be42ec7 100644 --- a/tests/integration/jersey-4321/src/test/java/org/glassfish/jersey/tests/integration/jersey4321/StreamingTest.java +++ b/tests/integration/jersey-4321/src/test/java/org/glassfish/jersey/tests/integration/jersey4321/StreamingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -21,7 +21,7 @@ import org.glassfish.jersey.server.ChunkedOutput; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import javax.inject.Singleton; import javax.ws.rs.GET; @@ -33,7 +33,7 @@ import java.io.IOException; import java.io.InputStream; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Brought over from Apache connector module, Jersey 2.28 style diff --git a/tests/integration/jersey-4507/src/test/java/org/glassfish/jersey/tests/integration/jersey4507/SSETest.java b/tests/integration/jersey-4507/src/test/java/org/glassfish/jersey/tests/integration/jersey4507/SSETest.java index b02eda5392..f111e44373 100644 --- a/tests/integration/jersey-4507/src/test/java/org/glassfish/jersey/tests/integration/jersey4507/SSETest.java +++ b/tests/integration/jersey-4507/src/test/java/org/glassfish/jersey/tests/integration/jersey4507/SSETest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -27,8 +27,9 @@ import org.glassfish.jersey.media.sse.SseFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Assert; -import org.junit.Test; +import org.hamcrest.MatcherAssert; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Application; @@ -99,8 +100,8 @@ public List call() throws Exception { } }); - Assert.assertTrue("Waiting for receiver thread to start has timed out.", - startLatch.await(15000, TimeUnit.SECONDS)); + Assertions.assertTrue(startLatch.await(15000, TimeUnit.SECONDS), + "Waiting for receiver thread to start has timed out."); for (int i = 0; i < MAX_MESSAGES; i++) { target(App.ROOT_PATH).request().post(Entity.text("message " + i)); @@ -108,7 +109,7 @@ public List call() throws Exception { int i = 0; for (String message : futureMessages.get(50, TimeUnit.SECONDS)) { - Assert.assertThat("Unexpected SSE event data value.", message, equalTo("message " + i++)); + MatcherAssert.assertThat("Unexpected SSE event data value.", message, equalTo("message " + i++)); } } finally { executor.shutdownNow(); @@ -125,8 +126,8 @@ public void testInboundEventReaderMultiple() throws Exception { closeLatch.await(15_000, TimeUnit.MILLISECONDS); // One ClientConfig is on the Client // + COUNT of them is created by .register(SseFeature.class) - Assert.assertEquals(COUNT + 1, atomicInteger.get()); - Assert.assertEquals(0, closeLatch.getCount()); + Assertions.assertEquals(COUNT + 1, atomicInteger.get()); + Assertions.assertEquals(0, closeLatch.getCount()); } diff --git a/tests/integration/jersey-4542/src/test/java/org.glassfish.jersey.tests.integration.jersey4542/ProgrammaticValidationTest.java b/tests/integration/jersey-4542/src/test/java/org.glassfish.jersey.tests.integration.jersey4542/ProgrammaticValidationTest.java index ba34e635b9..41ff2e3985 100644 --- a/tests/integration/jersey-4542/src/test/java/org.glassfish.jersey.tests.integration.jersey4542/ProgrammaticValidationTest.java +++ b/tests/integration/jersey-4542/src/test/java/org.glassfish.jersey.tests.integration.jersey4542/ProgrammaticValidationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -30,13 +30,14 @@ import org.glassfish.jersey.server.model.Resource; import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.jboss.weld.environment.se.Weld; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Bean Validation tests for programmatically created resources. @@ -47,11 +48,12 @@ public class ProgrammaticValidationTest extends JerseyTest { Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -63,6 +65,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { diff --git a/tests/integration/jersey-4697/src/test/java/org/glassfish/jersey/tests/integration/jersey4697/MonitoringEventListenerTest.java b/tests/integration/jersey-4697/src/test/java/org/glassfish/jersey/tests/integration/jersey4697/MonitoringEventListenerTest.java index 308d34215a..cfc4d2334b 100644 --- a/tests/integration/jersey-4697/src/test/java/org/glassfish/jersey/tests/integration/jersey4697/MonitoringEventListenerTest.java +++ b/tests/integration/jersey-4697/src/test/java/org/glassfish/jersey/tests/integration/jersey4697/MonitoringEventListenerTest.java @@ -46,15 +46,16 @@ import org.glassfish.jersey.server.monitoring.RequestEvent; import org.glassfish.jersey.server.monitoring.RequestEventListener; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MonitoringEventListenerTest extends JerseyTest { private static final long TIMEOUT = 1000; + private static final String APPLICATION_NAME = "MonitoringEventListenerTest"; private static final String MBEAN_EXCEPTION = - "org.glassfish.jersey:type=MonitoringEventListenerTest,subType=Global,exceptions=ExceptionMapper"; + "org.glassfish.jersey:type=" + APPLICATION_NAME + ",subType=Global,exceptions=ExceptionMapper"; @Path("/example") public static class ExampleResource { @@ -118,7 +119,7 @@ protected Application configure() { resourceConfig.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true); // Scheduler will process 1000 events per second resourceConfig.property(ServerProperties.MONITORING_STATISTICS_REFRESH_INTERVAL, 1); - resourceConfig.setApplicationName("MonitoringEventListenerTest"); + resourceConfig.setApplicationName(APPLICATION_NAME); return resourceConfig; } diff --git a/tests/integration/jersey-4722/src/test/java/org/glassfish/jersey/tests/integration/jersey4722/Jersey4722Test.java b/tests/integration/jersey-4722/src/test/java/org/glassfish/jersey/tests/integration/jersey4722/Jersey4722Test.java index 277aea0fe2..74a367bd6f 100644 --- a/tests/integration/jersey-4722/src/test/java/org/glassfish/jersey/tests/integration/jersey4722/Jersey4722Test.java +++ b/tests/integration/jersey-4722/src/test/java/org/glassfish/jersey/tests/integration/jersey4722/Jersey4722Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.test.ServletDeploymentContext; import org.glassfish.jersey.test.grizzly.GrizzlyWebTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.client.Entity; import javax.ws.rs.core.HttpHeaders; @@ -52,7 +52,7 @@ public void testDefaultProducesMediaType() { try (Response response = target().request() .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) .put(Entity.entity("ENTITY", MediaType.TEXT_PLAIN_TYPE))) { - Assert.assertEquals(204, response.getStatus()); + Assertions.assertEquals(204, response.getStatus()); } } @@ -60,7 +60,7 @@ public void testDefaultProducesMediaType() { public void testDefaultConsumesMediaType() { try (Response response = target().request() .put(Entity.entity("ENTITY", new MediaType("TEST", "TEST415")))) { - Assert.assertEquals(204, response.getStatus()); + Assertions.assertEquals(204, response.getStatus()); } } } diff --git a/tests/integration/jersey-4949/src/test/java/org/glassfish/jersey/tests/integration/jersey4949/Jersey4949ITCase.java b/tests/integration/jersey-4949/src/test/java/org/glassfish/jersey/tests/integration/jersey4949/Jersey4949ITCase.java index 9ddaa1e800..592a761ea0 100644 --- a/tests/integration/jersey-4949/src/test/java/org/glassfish/jersey/tests/integration/jersey4949/Jersey4949ITCase.java +++ b/tests/integration/jersey-4949/src/test/java/org/glassfish/jersey/tests/integration/jersey4949/Jersey4949ITCase.java @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; @@ -57,9 +57,9 @@ public void testJersey4949Fix() { assertThat(response.getStatus(), is(200)); String entity = response.readEntity(String.class); - Assert.assertTrue(entity.contains(CONTEXT_PATH)); - Assert.assertTrue(entity.contains(SERVLET_PATH)); - Assert.assertTrue(entity.contains(Issue4949Resource.PATH)); + Assertions.assertTrue(entity.contains(CONTEXT_PATH)); + Assertions.assertTrue(entity.contains(SERVLET_PATH)); + Assertions.assertTrue(entity.contains(Issue4949Resource.PATH)); } } } diff --git a/tests/integration/jersey-780/src/test/java/org/glassfish/jersey/tests/integration/jersey780/HelloWorldResourceITCase.java b/tests/integration/jersey-780/src/test/java/org/glassfish/jersey/tests/integration/jersey780/HelloWorldResourceITCase.java index f54d531d83..a849fd4d1d 100644 --- a/tests/integration/jersey-780/src/test/java/org/glassfish/jersey/tests/integration/jersey780/HelloWorldResourceITCase.java +++ b/tests/integration/jersey-780/src/test/java/org/glassfish/jersey/tests/integration/jersey780/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -29,8 +29,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Michal Gajdos @@ -65,9 +65,9 @@ public void testInvalidUrl() throws Exception { connection.disconnect(); - assertTrue("Wrong response status code: " + statusCode, - expectedCodes.contains(statusCode)); - assertTrue("Wrong response status reason: " + statusMessage, - expectedPhrases.contains(statusMessage)); + assertTrue(expectedCodes.contains(statusCode), + "Wrong response status code: " + statusCode); + assertTrue(expectedPhrases.contains(statusMessage), + "Wrong response status reason: " + statusMessage); } } diff --git a/tests/integration/jetty-response-close/pom.xml b/tests/integration/jetty-response-close/pom.xml index 2b04641b88..5ab2bb1816 100644 --- a/tests/integration/jetty-response-close/pom.xml +++ b/tests/integration/jetty-response-close/pom.xml @@ -59,4 +59,14 @@ -Djava.security.manager -Djava.security.policy=${project.build.directory}/test-classes/surefire.policy + + + + maven-surefire-plugin + + none + + + + \ No newline at end of file diff --git a/tests/integration/microprofile/config/helidon/src/test/java/org/glassfish/jersey/tests/integration/config/HelidonConfigApplicationTest.java b/tests/integration/microprofile/config/helidon/src/test/java/org/glassfish/jersey/tests/integration/config/HelidonConfigApplicationTest.java index 0543f63183..4c6dd4edf4 100644 --- a/tests/integration/microprofile/config/helidon/src/test/java/org/glassfish/jersey/tests/integration/config/HelidonConfigApplicationTest.java +++ b/tests/integration/microprofile/config/helidon/src/test/java/org/glassfish/jersey/tests/integration/config/HelidonConfigApplicationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Application; import javax.ws.rs.core.MediaType; @@ -44,6 +44,6 @@ public void testGetConfigProperty() { final String response = target("/config/getProperty/{name}") .resolveTemplate("name", "jersey.config.disableMetainfServicesLookup") .request(MediaType.TEXT_PLAIN).get(String.class); - Assert.assertEquals("true", response); + Assertions.assertEquals("true", response); } } \ No newline at end of file diff --git a/tests/integration/microprofile/rest-client/pom.xml b/tests/integration/microprofile/rest-client/pom.xml index e5b78cf2d7..e764c0130a 100644 --- a/tests/integration/microprofile/rest-client/pom.xml +++ b/tests/integration/microprofile/rest-client/pom.xml @@ -64,8 +64,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test @@ -173,7 +173,7 @@ uk.co.deliverymind wiremock-maven-plugin - 2.7.0 + 2.11.0 test-compile diff --git a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/ConnectorTest.java b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/ConnectorTest.java index 6a3cb19caa..a516052c3b 100644 --- a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/ConnectorTest.java +++ b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/ConnectorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -29,7 +29,7 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.testng.Assert.assertEquals; diff --git a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/ConsumesAndProducesTest.java b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/ConsumesAndProducesTest.java index 24a1c89cf1..0c5f7a2cfa 100644 --- a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/ConsumesAndProducesTest.java +++ b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/ConsumesAndProducesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -33,11 +33,12 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Created by David Kral. @@ -98,7 +99,7 @@ public void testMethodWithRegexPathParam() throws URISyntaxException { .baseUri(new URI("http://localhost:9998")) .build(ApplicationResource.class); - assertEquals(app.regex("bar"), "bar"); + assertEquals("bar", app.regex("bar")); } @Test @@ -110,13 +111,15 @@ public void testMethodWithRegexPathParam0() throws URISyntaxException { assertEquals(app.regex0("foo", "1234"), "foo_1234"); } - @Test(expected = WebApplicationException.class) + @Test public void testMethodWithRegexPathParam0Failure() throws URISyntaxException { - ApplicationResource app = RestClientBuilder.newBuilder() - .baseUri(new URI("http://localhost:9998")) - .build(ApplicationResource.class); + assertThrows(WebApplicationException.class, () -> { + ApplicationResource app = RestClientBuilder.newBuilder() + .baseUri(new URI("http://localhost:9998")) + .build(ApplicationResource.class); - app.regex0("foo", "12345"); + app.regex0("foo", "12345"); + }); } private static class TestClientRequestFilter implements ClientRequestFilter { diff --git a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/InboundHeadersProviderTest.java b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/InboundHeadersProviderTest.java index 23aee87fd3..922de9e3eb 100644 --- a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/InboundHeadersProviderTest.java +++ b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/InboundHeadersProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -41,10 +41,10 @@ import org.glassfish.jersey.microprofile.restclient.InboundHeadersProvider; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests if {@link InboundHeadersProvider} is called when it is actually needed. @@ -60,7 +60,7 @@ protected ResourceConfig configure() { return new ResourceConfig(HeaderProviderTestResource.class); } - @BeforeClass + @BeforeAll public static void clientSetup() { clientWithoutProvider = RestClientBuilder.newBuilder() .baseUri(URI.create("http://localhost:9998")) diff --git a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/RestClientModelTest.java b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/RestClientModelTest.java index 186b3c6045..07189c690e 100644 --- a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/RestClientModelTest.java +++ b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/restclient/RestClientModelTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Created by David Kral. diff --git a/tests/integration/microprofile/rest-client14-compatibility/pom.xml b/tests/integration/microprofile/rest-client14-compatibility/pom.xml index fc40862acd..99b6681b7d 100644 --- a/tests/integration/microprofile/rest-client14-compatibility/pom.xml +++ b/tests/integration/microprofile/rest-client14-compatibility/pom.xml @@ -91,8 +91,8 @@ - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/tests/integration/microprofile/rest-client14-compatibility/src/test/java/org/glassfish/jersey/tests/restclient/compatibility/Compatibility14Test.java b/tests/integration/microprofile/rest-client14-compatibility/src/test/java/org/glassfish/jersey/tests/restclient/compatibility/Compatibility14Test.java index 8507722de5..bb58885640 100644 --- a/tests/integration/microprofile/rest-client14-compatibility/src/test/java/org/glassfish/jersey/tests/restclient/compatibility/Compatibility14Test.java +++ b/tests/integration/microprofile/rest-client14-compatibility/src/test/java/org/glassfish/jersey/tests/restclient/compatibility/Compatibility14Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2022 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 @@ -24,10 +24,11 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; import org.jboss.weld.environment.se.Weld; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; @@ -41,11 +42,12 @@ public class Compatibility14Test extends JerseyTest { private Weld weld; - @Before + @BeforeEach public void setup() { - Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); + Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy()); } + @BeforeEach @Override public void setUp() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -55,6 +57,7 @@ public void setUp() throws Exception { } } + @AfterEach @Override public void tearDown() throws Exception { if (Hk2InjectionManagerFactory.isImmediateStrategy()) { @@ -104,7 +107,7 @@ public void testCompatibility() { try (Response r = target("/resource").request().get()) { String entity = r.readEntity(String.class); - Assert.assertEquals(new InnerResource().get(), entity); + Assertions.assertEquals(new InnerResource().get(), entity); } int warningCounts = 0; @@ -114,6 +117,6 @@ public void testCompatibility() { } } - Assert.assertEquals(3, warningCounts); + Assertions.assertEquals(3, warningCounts); } } diff --git a/tests/integration/portability-jersey-2/src/test/java/org/glassfish/jersey/tests/integration/portability/PortabilityITCase.java b/tests/integration/portability-jersey-2/src/test/java/org/glassfish/jersey/tests/integration/portability/PortabilityITCase.java index b158fda501..dc0cba35a5 100644 --- a/tests/integration/portability-jersey-2/src/test/java/org/glassfish/jersey/tests/integration/portability/PortabilityITCase.java +++ b/tests/integration/portability-jersey-2/src/test/java/org/glassfish/jersey/tests/integration/portability/PortabilityITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula diff --git a/tests/integration/property-check/pom.xml b/tests/integration/property-check/pom.xml index ee47d73a87..a03d3d29ca 100644 --- a/tests/integration/property-check/pom.xml +++ b/tests/integration/property-check/pom.xml @@ -58,9 +58,8 @@ test - junit - junit - 4.13.1 + org.junit.jupiter + junit-jupiter test diff --git a/tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java b/tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java index f943686620..2a072801b2 100644 --- a/tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java +++ b/tests/integration/property-check/src/test/java/org/glassfish/jersey/internal/config/SystemPropertiesConfigurationModelTest.java @@ -16,9 +16,9 @@ package org.glassfish.jersey.internal.config; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.google.common.reflect.ClassPath; @@ -44,7 +44,7 @@ import org.glassfish.jersey.server.oauth1.OAuth1ServerProperties; import org.glassfish.jersey.servlet.ServletProperties; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class SystemPropertiesConfigurationModelTest { @@ -70,9 +70,9 @@ public void allPropertyClassLoaded() throws IOException { containsAnnotation).stream().map(Class::getName).collect(Collectors.toList()); assertFalse(propertyClasses.isEmpty()); propertyClasses.removeAll(JerseySystemPropertiesConfigurationModel.PROPERTY_CLASSES); - assertEquals("New properties have been found. " + assertEquals(0, propertyClasses.size(), "New properties have been found. " + "Make sure you add next classes in SystemPropertiesConfigurationModel.PROPERTY_CLASSES: " - + propertyClasses, 0, propertyClasses.size()); + + propertyClasses); } } diff --git a/tests/integration/property-check/src/test/java/org/glassfish/jersey/tests/integration/propertycheck/PropertyOverlappingCheckTest.java b/tests/integration/property-check/src/test/java/org/glassfish/jersey/tests/integration/propertycheck/PropertyOverlappingCheckTest.java index 9eba3faa00..6b5eb3d739 100644 --- a/tests/integration/property-check/src/test/java/org/glassfish/jersey/tests/integration/propertycheck/PropertyOverlappingCheckTest.java +++ b/tests/integration/property-check/src/test/java/org/glassfish/jersey/tests/integration/propertycheck/PropertyOverlappingCheckTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -40,8 +40,8 @@ import org.glassfish.jersey.servlet.ServletProperties; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test, that there are no properties with overlapping names in known Jersey {@code *Properties} and {@code *Feature} diff --git a/tests/integration/reactive-streams/sse/pom.xml b/tests/integration/reactive-streams/sse/pom.xml index 021862adce..a5808423db 100644 --- a/tests/integration/reactive-streams/sse/pom.xml +++ b/tests/integration/reactive-streams/sse/pom.xml @@ -40,8 +40,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/tests/integration/reactive-streams/sse/src/test/java/org/glassfish/jersey/media/sse/internal/SseSubscriberTest.java b/tests/integration/reactive-streams/sse/src/test/java/org/glassfish/jersey/media/sse/internal/SseSubscriberTest.java index 27c06b1237..d7a3afd1ec 100644 --- a/tests/integration/reactive-streams/sse/src/test/java/org/glassfish/jersey/media/sse/internal/SseSubscriberTest.java +++ b/tests/integration/reactive-streams/sse/src/test/java/org/glassfish/jersey/media/sse/internal/SseSubscriberTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -40,14 +40,14 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.sse.SseEventSource; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import io.reactivex.Flowable; import org.glassfish.jersey.internal.jsr166.Flow; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * @author Daniel Kec diff --git a/tests/integration/security-digest/src/test/java/org/glassfish/jersey/tests/integration/securitydigest/SecurityDigestAuthenticationITCase.java b/tests/integration/security-digest/src/test/java/org/glassfish/jersey/tests/integration/securitydigest/SecurityDigestAuthenticationITCase.java index 22b422cd16..28c8613914 100644 --- a/tests/integration/security-digest/src/test/java/org/glassfish/jersey/tests/integration/securitydigest/SecurityDigestAuthenticationITCase.java +++ b/tests/integration/security-digest/src/test/java/org/glassfish/jersey/tests/integration/securitydigest/SecurityDigestAuthenticationITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -32,8 +32,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Miroslav Fuksa @@ -69,8 +69,8 @@ public void _testResourceGet(HttpAuthenticationFeature feature) { final Response response = target().path("rest/resource") .register(feature).request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("homer/scheme:DIGEST", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("homer/scheme:DIGEST", response.readEntity(String.class)); } @Test @@ -83,7 +83,7 @@ public void _testResourceGet401(HttpAuthenticationFeature feature) { final Response response = target().path("rest/resource") .register(feature).request().get(); - Assert.assertEquals(401, response.getStatus()); + Assertions.assertEquals(401, response.getStatus()); } @Test @@ -97,8 +97,8 @@ public void _testResourcePost(HttpAuthenticationFeature feature) { .register(feature).request() .post(Entity.entity("helloworld", MediaType.TEXT_PLAIN_TYPE)); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("post-helloworld-homer/scheme:DIGEST", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("post-helloworld-homer/scheme:DIGEST", response.readEntity(String.class)); } @Test @@ -111,7 +111,7 @@ public void _testResourceSubGet403(HttpAuthenticationFeature feature) { final Response response = target().path("rest/resource/sub") .register(feature).request().get(); - Assert.assertEquals(403, response.getStatus()); + Assertions.assertEquals(403, response.getStatus()); } @Test @@ -124,8 +124,8 @@ public void _testResourceSubGet2(HttpAuthenticationFeature feature) { final Response response = target().path("rest/resource/sub") .register(feature).request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("subget-bart/scheme:DIGEST", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("subget-bart/scheme:DIGEST", response.readEntity(String.class)); } @Test @@ -139,8 +139,8 @@ public void _testResourceLocatorGet(HttpAuthenticationFeature feature) { final Response response = target().path("rest/resource/locator") .register(feature).request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("locator-bart/scheme:DIGEST", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("locator-bart/scheme:DIGEST", response.readEntity(String.class)); } @Test @@ -154,23 +154,23 @@ public void _testResourceMultipleRequestsWithOneFilter(HttpAuthenticationFeature .register(haf); Response response = target.request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("homer/scheme:DIGEST", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("homer/scheme:DIGEST", response.readEntity(String.class)); response = target.request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("homer/scheme:DIGEST", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("homer/scheme:DIGEST", response.readEntity(String.class)); response = target.path("sub").request().get(); - Assert.assertEquals(403, response.getStatus()); + Assertions.assertEquals(403, response.getStatus()); response = target.request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("homer/scheme:DIGEST", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("homer/scheme:DIGEST", response.readEntity(String.class)); response = target.path("locator").request().get(); - Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals("locator-homer/scheme:DIGEST", response.readEntity(String.class)); + Assertions.assertEquals(200, response.getStatus()); + Assertions.assertEquals("locator-homer/scheme:DIGEST", response.readEntity(String.class)); } } diff --git a/tests/integration/servlet-2.5-autodiscovery-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_autodiscovery_1/LanguageVariantResourceITCase.java b/tests/integration/servlet-2.5-autodiscovery-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_autodiscovery_1/LanguageVariantResourceITCase.java index af45d99bec..80806a94fb 100644 --- a/tests/integration/servlet-2.5-autodiscovery-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_autodiscovery_1/LanguageVariantResourceITCase.java +++ b/tests/integration/servlet-2.5-autodiscovery-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_autodiscovery_1/LanguageVariantResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/integration/servlet-2.5-autodiscovery-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_autodiscovery_2/ValidationResourceITCase.java b/tests/integration/servlet-2.5-autodiscovery-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_autodiscovery_2/ValidationResourceITCase.java index 646aedacc5..4bb02059b3 100644 --- a/tests/integration/servlet-2.5-autodiscovery-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_autodiscovery_2/ValidationResourceITCase.java +++ b/tests/integration/servlet-2.5-autodiscovery-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_autodiscovery_2/ValidationResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/integration/servlet-2.5-filter/src/test/java/org/glassfish/jersey/tests/integration/servlet_2_5_filter/MyResourceITCase.java b/tests/integration/servlet-2.5-filter/src/test/java/org/glassfish/jersey/tests/integration/servlet_2_5_filter/MyResourceITCase.java index 7bff80f797..4b11bcf990 100644 --- a/tests/integration/servlet-2.5-filter/src/test/java/org/glassfish/jersey/tests/integration/servlet_2_5_filter/MyResourceITCase.java +++ b/tests/integration/servlet-2.5-filter/src/test/java/org/glassfish/jersey/tests/integration/servlet_2_5_filter/MyResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Adam Lindenthal diff --git a/tests/integration/servlet-2.5-inflector-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_inflector_1/InflectorInjectionTestITCase.java b/tests/integration/servlet-2.5-inflector-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_inflector_1/InflectorInjectionTestITCase.java index 9ccb2cb102..77e5d16bab 100644 --- a/tests/integration/servlet-2.5-inflector-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_inflector_1/InflectorInjectionTestITCase.java +++ b/tests/integration/servlet-2.5-inflector-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_inflector_1/InflectorInjectionTestITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/integration/servlet-2.5-init-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_1/Servlet25Init1ITCase.java b/tests/integration/servlet-2.5-init-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_1/Servlet25Init1ITCase.java index 48324c9d1a..97ef64c49a 100644 --- a/tests/integration/servlet-2.5-init-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_1/Servlet25Init1ITCase.java +++ b/tests/integration/servlet-2.5-init-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_1/Servlet25Init1ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -28,11 +28,11 @@ import org.glassfish.jersey.test.spi.TestContainerFactory; import org.glassfish.jersey.uri.UriTemplate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Servlet 2.5 initialization test #01. @@ -61,10 +61,9 @@ public void testHelloWorld() throws Exception { @Test public void testHelloWorldAtWrongPath() { Response r = target().path("application_path/helloworld").request().get(); - assertTrue( + assertTrue(r.getStatus() >= 400, "Request to application_path/helloworld should have failed, but did not. That means two applications are " - + "registered.", - r.getStatus() >= 400); + + "registered."); } @Test @@ -76,13 +75,13 @@ public void testHelloWorldViaClientInResource() throws Exception { @Test public void testUnreachableResource() { Response r = target().path("servlet_path/unreachable").request().get(); - assertTrue("Managed to reach a resource that is not registered in the application.", r.getStatus() >= 400); + assertTrue(r.getStatus() >= 400, "Managed to reach a resource that is not registered in the application."); } @Test public void testUnreachableResourceAtWrongPath() { Response r = target().path("application_path/unreachable").request().get(); - assertTrue("Managed to reach a resource that is not registered in the application.", r.getStatus() >= 400); + assertTrue(r.getStatus() >= 400, "Managed to reach a resource that is not registered in the application."); } @Test diff --git a/tests/integration/servlet-2.5-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResourceITCase.java b/tests/integration/servlet-2.5-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResourceITCase.java index 6d97207068..b6c5a7465e 100644 --- a/tests/integration/servlet-2.5-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-2.5-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_2/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-2.5-init-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_3/HelloWorldResourceITCase.java b/tests/integration/servlet-2.5-init-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_3/HelloWorldResourceITCase.java index b87c5392fa..3a63913600 100644 --- a/tests/integration/servlet-2.5-init-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_3/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-2.5-init-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_3/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-2.5-init-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_4/HelloWorldResourceITCase.java b/tests/integration/servlet-2.5-init-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_4/HelloWorldResourceITCase.java index 1efb8441d2..ea791df30c 100644 --- a/tests/integration/servlet-2.5-init-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_4/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-2.5-init-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_4/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-2.5-init-5/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_5/HelloWorldResourceITCase.java b/tests/integration/servlet-2.5-init-5/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_5/HelloWorldResourceITCase.java index ab485e1fc2..a6f30ae09c 100644 --- a/tests/integration/servlet-2.5-init-5/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_5/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-2.5-init-5/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_5/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,10 +24,10 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek @@ -53,22 +53,21 @@ public void testHelloWorld() throws Exception { @Test public void testHelloWorldAtWrongPath() { Response r = target().path("application_path/filter_path/helloworld").request().get(); - assertTrue( + assertTrue(r.getStatus() >= 400, "Request to application_path/helloworld should have failed, but did not. That means two applications are " - + "registered.", - r.getStatus() >= 400); + + "registered."); } @Test - @Ignore + @Disabled public void testUnreachableResource() { Response r = target().path("filter_path/unreachable").request().get(); - assertTrue("Managed to reach a resource that is not registered in the application.", r.getStatus() >= 400); + assertTrue(r.getStatus() >= 400, "Managed to reach a resource that is not registered in the application."); } @Test public void testUnreachableResourceAtWrongPath() { Response r = target().path("application_path/filter_path/unreachable").request().get(); - assertTrue("Managed to reach a resource that is not registered in the application.", r.getStatus() >= 400); + assertTrue(r.getStatus() >= 400, "Managed to reach a resource that is not registered in the application."); } } diff --git a/tests/integration/servlet-2.5-init-6/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_6/HelloWorldResourceITCase.java b/tests/integration/servlet-2.5-init-6/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_6/HelloWorldResourceITCase.java index a8d2c8c5e9..3d8e2b754b 100644 --- a/tests/integration/servlet-2.5-init-6/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_6/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-2.5-init-6/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_6/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-2.5-init-7/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_7/HelloWorldResourceITCase.java b/tests/integration/servlet-2.5-init-7/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_7/HelloWorldResourceITCase.java index c40a8cf70d..ba4570bf6b 100644 --- a/tests/integration/servlet-2.5-init-7/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_7/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-2.5-init-7/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_7/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-2.5-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_8/HelloWorldResourceITCase.java b/tests/integration/servlet-2.5-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_8/HelloWorldResourceITCase.java index 418e5fa94e..9b50ba7596 100644 --- a/tests/integration/servlet-2.5-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_8/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-2.5-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_init_8/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/BookstoreITCase.java b/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/BookstoreITCase.java index a751b9c53a..40b1ab9b25 100644 --- a/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/BookstoreITCase.java +++ b/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/BookstoreITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -22,10 +22,10 @@ import org.glassfish.jersey.tests.integration.servlet_25_mvc_1.resource.Bookstore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BookstoreITCase extends TestSupport { @@ -42,8 +42,8 @@ public void testResourceAsHtml() throws Exception { public void testResourceAsXml() throws Exception { final Bookstore response = target().request("application/xml").get(Bookstore.class); - assertNotNull("Should have returned a bookstore!", response); - assertEquals("bookstore name", "Czech Bookstore", response.getName()); + assertNotNull(response, "Should have returned a bookstore!"); + assertEquals("Czech Bookstore", response.getName(), "bookstore name"); } @Test @@ -54,12 +54,12 @@ public void testSingleContentTypeAndContentLengthValueInXmlResponse() throws Exc } private void assertStatusContentTypeAndLength(Response response) { - assertEquals("Should have returned a 200 response!", 200, response.getStatus()); - assertTrue("Should contain a Content-Type header!", response.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)); - assertEquals("Should have a single Content-Type header!", 1, response.getHeaders().get(HttpHeaders.CONTENT_TYPE).size()); - assertTrue("Should contain a Content-Length header!", response.getHeaders().containsKey(HttpHeaders.CONTENT_LENGTH)); - assertEquals("Should have a single Content-Length header!", - 1, response.getHeaders().get(HttpHeaders.CONTENT_LENGTH).size()); + assertEquals(200, response.getStatus(), "Should have returned a 200 response!"); + assertTrue(response.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE), "Should contain a Content-Type header!"); + assertEquals(1, response.getHeaders().get(HttpHeaders.CONTENT_TYPE).size(), "Should have a single Content-Type header!"); + assertTrue(response.getHeaders().containsKey(HttpHeaders.CONTENT_LENGTH), "Should contain a Content-Length header!"); + assertEquals(1, response.getHeaders().get(HttpHeaders.CONTENT_LENGTH).size(), + "Should have a single Content-Length header!"); } @Test diff --git a/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/ItemITCase.java b/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/ItemITCase.java index 90d9118f8c..0fa94d5425 100644 --- a/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/ItemITCase.java +++ b/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/ItemITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,10 +21,10 @@ import org.glassfish.jersey.tests.integration.servlet_25_mvc_1.resource.Book; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class ItemITCase extends TestSupport { @@ -44,8 +44,8 @@ public void testResourceAsXml() throws Exception { System.out.println("Item XML is: " + text); final Book response = item1resource().request("application/xml").get(Book.class); - assertNotNull("Should have returned an item!", response); - assertEquals("item title", "Svejk", response.getTitle()); + assertNotNull(response, "Should have returned an item!"); + assertEquals("Svejk", response.getTitle(), "item title"); } @Test diff --git a/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/TestSupport.java b/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/TestSupport.java index 0ae958fef2..50b8938b98 100644 --- a/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/TestSupport.java +++ b/tests/integration/servlet-2.5-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_1/TestSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * A base class for test cases which boots up a GlassFish server for in container testing of RESTful resources. @@ -45,13 +45,13 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc } protected void assertHtmlResponse(String response) { - assertNotNull("No text returned!", response); + assertNotNull(response, "No text returned!"); assertResponseContains(response, ""); assertResponseContains(response, ""); } protected void assertResponseContains(String response, String text) { - assertTrue("Response should contain " + text + " but was: " + response, response.contains(text)); + assertTrue(response.contains(text), "Response should contain " + text + " but was: " + response); } } diff --git a/tests/integration/servlet-2.5-mvc-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_2/BookstoreITCase.java b/tests/integration/servlet-2.5-mvc-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_2/BookstoreITCase.java index 0d20972962..5089322c05 100644 --- a/tests/integration/servlet-2.5-mvc-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_2/BookstoreITCase.java +++ b/tests/integration/servlet-2.5-mvc-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_2/BookstoreITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,9 +20,9 @@ import org.glassfish.jersey.tests.integration.servlet_25_mvc_2.resource.Bookstore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class BookstoreITCase extends TestSupport { @@ -45,7 +45,7 @@ public void testResourceAsHtmlUsingWebKitAcceptHeaders() throws Exception { } protected void assertBookstoreXmlResponse(final Bookstore response) { - assertNotNull("Should have returned a bookstore!", response); - assertEquals("bookstore name", "Czech Bookstore", response.getName()); + assertNotNull(response, "Should have returned a bookstore!"); + assertEquals("Czech Bookstore", response.getName(), "bookstore name"); } } diff --git a/tests/integration/servlet-2.5-mvc-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_2/ItemITCase.java b/tests/integration/servlet-2.5-mvc-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_2/ItemITCase.java index e4a793bd59..62dab08753 100644 --- a/tests/integration/servlet-2.5-mvc-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_2/ItemITCase.java +++ b/tests/integration/servlet-2.5-mvc-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_2/ItemITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,9 +21,9 @@ import org.glassfish.jersey.tests.integration.servlet_25_mvc_2.resource.Book; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class ItemITCase extends TestSupport { @@ -48,8 +48,8 @@ public void testResourceAsHtmlUsingWebKitAcceptHeaders() throws Exception { } private void assertItemXmlResponse(final Book response) { - assertNotNull("Should have returned an item!", response); - assertEquals("item title", "Svejk", response.getTitle()); + assertNotNull(response, "Should have returned an item!"); + assertEquals("Svejk", response.getTitle(), "item title"); } protected WebTarget item1resource() { diff --git a/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/BookstoreITCase.java b/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/BookstoreITCase.java index 11f57e4ec3..35ddcede8c 100644 --- a/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/BookstoreITCase.java +++ b/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/BookstoreITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,10 +20,10 @@ import org.glassfish.jersey.tests.integration.servlet_25_mvc_3.resource.Bookstore; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class BookstoreITCase extends TestSupport { @@ -40,8 +40,8 @@ public void testResourceAsHtml() throws Exception { public void testResourceAsXml() throws Exception { final Bookstore response = target().request("application/xml").get(Bookstore.class); - assertNotNull("Should have returned a bookstore!", response); - assertEquals("bookstore name", "Czech Bookstore", response.getName()); + assertNotNull(response, "Should have returned a bookstore!"); + assertEquals("Czech Bookstore", response.getName(), "bookstore name"); } @Test diff --git a/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/ItemITCase.java b/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/ItemITCase.java index 0cb6d97727..d0c3ba2ad1 100644 --- a/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/ItemITCase.java +++ b/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/ItemITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,14 +21,14 @@ import javax.ws.rs.core.Response; import org.glassfish.jersey.tests.integration.servlet_25_mvc_3.resource.Book; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.nio.charset.Charset; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class ItemITCase extends TestSupport { @@ -52,7 +52,7 @@ public void testResourceAsHtmlUtf8() throws Exception { } @Test - @Ignore("Jetty 9 is ignoring the charset") + @Disabled("Jetty 9 is ignoring the charset") public void testResourceAsHtmlIso88592() throws Exception { final Response response = item1resource().path("iso").request().get(); response.bufferEntity(); @@ -60,13 +60,13 @@ public void testResourceAsHtmlIso88592() throws Exception { final String htmlUtf8 = response.readEntity(String.class); assertItemHtmlResponse(htmlUtf8); - assertFalse("Response shouldn't contain Ha\u0161ek but was: " + htmlUtf8, htmlUtf8.contains("Ha\u0161ek")); + assertFalse(htmlUtf8.contains("Ha\u0161ek"), "Response shouldn't contain Ha\u0161ek but was: " + htmlUtf8); final byte[] bytes = response.readEntity(byte[].class); final String htmlIso = new String(bytes, "ISO-8859-2"); assertItemHtmlResponse(htmlIso); - assertFalse("Response shouldn't contain Ha\u0161ek but was: " + htmlIso, htmlIso.contains("Ha\u0161ek")); + assertFalse(htmlIso.contains("Ha\u0161ek"), "Response shouldn't contain Ha\u0161ek but was: " + htmlIso); assertResponseContains(htmlIso, new String("Ha\u0161ek".getBytes(Charset.forName("UTF-8")), "ISO-8859-2")); } @@ -76,8 +76,8 @@ public void testResourceAsXml() throws Exception { System.out.println("Item XML is: " + text); final Book response = item1resource().request("application/xml").get(Book.class); - assertNotNull("Should have returned an item!", response); - assertEquals("item title", "Svejk", response.getTitle()); + assertNotNull(response, "Should have returned an item!"); + assertEquals("Svejk", response.getTitle(), "item title"); } @Test diff --git a/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/TestSupport.java b/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/TestSupport.java index 69121eec8c..eb101a22cb 100644 --- a/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/TestSupport.java +++ b/tests/integration/servlet-2.5-mvc-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_mvc_3/TestSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * A base class for test cases which boots up a GlassFish server for in container testing of RESTful resources. @@ -48,13 +48,13 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc } protected void assertHtmlResponse(final String response) { - assertNotNull("No text returned!", response); + assertNotNull(response, "No text returned!"); assertResponseContains(response, ""); assertResponseContains(response, ""); } protected void assertResponseContains(final String response, final String text) { - assertTrue("Response should contain " + text + " but was: " + response, response.contains(text)); + assertTrue(response.contains(text), "Response should contain " + text + " but was: " + response); } } diff --git a/tests/integration/servlet-2.5-reload/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_config_reload/ReloadTestIT.java b/tests/integration/servlet-2.5-reload/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_config_reload/ReloadTestIT.java index 67095bb87d..21b86d4054 100644 --- a/tests/integration/servlet-2.5-reload/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_config_reload/ReloadTestIT.java +++ b/tests/integration/servlet-2.5-reload/src/test/java/org/glassfish/jersey/tests/integration/servlet_25_config_reload/ReloadTestIT.java @@ -24,10 +24,10 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Jakub Podlesak @@ -45,7 +45,7 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc } @Test - @Ignore //TODO - fix after 2.36 + @Disabled //TODO - fix after 2.36 public void testReload() throws Exception { Response response = target().path("helloworld").request().get(); assertEquals(200, response.getStatus()); diff --git a/tests/integration/servlet-3-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncServletResourceITCase.java b/tests/integration/servlet-3-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncServletResourceITCase.java index fb202afead..e7ba9a62d8 100644 --- a/tests/integration/servlet-3-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncServletResourceITCase.java +++ b/tests/integration/servlet-3-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncServletResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -40,9 +40,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Asynchronous servlet-deployed resource test. @@ -139,8 +139,8 @@ private void get() { if (debugMode) { getRequestLatch.await(); } else { - assertTrue("Waiting for all GET requests to complete has timed out.", getRequestLatch.await(LATCH_WAIT_TIMEOUT, - TimeUnit.SECONDS)); + assertTrue(getRequestLatch.await(LATCH_WAIT_TIMEOUT, TimeUnit.SECONDS), + "Waiting for all GET requests to complete has timed out."); } } finally { executor.shutdownNow(); @@ -156,12 +156,10 @@ private void get() { assertEquals(MAX_MESSAGES, getResponses.size()); for (Map.Entry entry : getResponses.entrySet()) { - assertEquals( - "Unexpected GET response status for request " + entry.getKey(), - 200, entry.getValue().status); - assertEquals( - "Unexpected GET response message for request " + entry.getKey(), - expectedResponse, entry.getValue().message); + assertEquals(200, entry.getValue().status, + "Unexpected GET response status for request " + entry.getKey()); + assertEquals(expectedResponse, entry.getValue().message, + "Unexpected GET response message for request " + entry.getKey()); } } @@ -253,10 +251,10 @@ private void post() throws ProcessingException { postRequestLatch.await(); getRequestLatch.await(); } else { - assertTrue("Waiting for all POST requests to complete has timed out.", - postRequestLatch.await(LATCH_WAIT_TIMEOUT, TimeUnit.SECONDS)); - assertTrue("Waiting for all GET requests to complete has timed out.", getRequestLatch.await(LATCH_WAIT_TIMEOUT, - TimeUnit.SECONDS)); + assertTrue(postRequestLatch.await(LATCH_WAIT_TIMEOUT, TimeUnit.SECONDS), + "Waiting for all POST requests to complete has timed out."); + assertTrue(getRequestLatch.await(LATCH_WAIT_TIMEOUT, TimeUnit.SECONDS), + "Waiting for all GET requests to complete has timed out."); } } finally { executor.shutdownNow(); @@ -278,17 +276,16 @@ private void post() throws ProcessingException { assertEquals(MAX_MESSAGES, postResponses.size()); for (Map.Entry postResponseEntry : postResponses.entrySet()) { - assertTrue("Unexpected POST notification response for message " + postResponseEntry.getKey(), - postResponseEntry.getValue().startsWith(AsyncServletResource.CANCELED)); + assertTrue(postResponseEntry.getValue().startsWith(AsyncServletResource.CANCELED), + "Unexpected POST notification response for message " + postResponseEntry.getKey()); } assertEquals(MAX_MESSAGES, getResponses.size()); final Collection getResponseKeys = getResponses.keySet(); for (int i = 0; i < MAX_MESSAGES; i++) { - assertTrue("Detected a GET message response loss: " + i, getResponseKeys.contains(i)); + assertTrue(getResponseKeys.contains(i), "Detected a GET message response loss: " + i); final String getResponseEntry = getResponses.get(i); - assertTrue("Unexpected canceled GET response status for request " + i, - getResponseEntry.startsWith("503: ")); + assertTrue(getResponseEntry.startsWith("503: "), "Unexpected canceled GET response status for request " + i); } } } diff --git a/tests/integration/servlet-3-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncTimeoutResourceITCase.java b/tests/integration/servlet-3-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncTimeoutResourceITCase.java index 8bfb646dd1..ee941a31a8 100644 --- a/tests/integration/servlet-3-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncTimeoutResourceITCase.java +++ b/tests/integration/servlet-3-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncTimeoutResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -29,9 +29,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Asynchronous servlet-deployed resource for testing {@link javax.ws.rs.container.AsyncResponse async response} timeouts. diff --git a/tests/integration/servlet-3-chunked-io/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_chunked_io/ChunkedInputOutputITCase.java b/tests/integration/servlet-3-chunked-io/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_chunked_io/ChunkedInputOutputITCase.java index e71406d5b2..a4dcefc732 100644 --- a/tests/integration/servlet-3-chunked-io/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_chunked_io/ChunkedInputOutputITCase.java +++ b/tests/integration/servlet-3-chunked-io/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_chunked_io/ChunkedInputOutputITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -35,8 +35,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Chunked I/O integration tests. @@ -83,11 +83,10 @@ protected URI getBaseUri() { public void testChunkedOutputToSingleString() throws Exception { final String response = target().path("test/from-string").request(MediaType.APPLICATION_JSON_TYPE).get(String.class); - assertEquals("Unexpected value of chunked response unmarshalled as a single string.", - "{\"id\":0,\"data\":\"test\"}\r\n" + assertEquals("{\"id\":0,\"data\":\"test\"}\r\n" + "{\"id\":1,\"data\":\"test\"}\r\n" + "{\"id\":2,\"data\":\"test\"}\r\n", - response); + response, "Unexpected value of chunked response unmarshalled as a single string."); } /** @@ -104,11 +103,11 @@ public void testChunkedOutputToChunkInputFromString() throws Exception { int counter = 0; Message chunk; while ((chunk = input.read()) != null) { - assertEquals("Unexpected value of chunk " + counter, new Message(counter, "test"), chunk); + assertEquals(new Message(counter, "test"), chunk, "Unexpected value of chunk " + counter); counter++; } - assertEquals("Unexpected numbed of received chunks.", 3, counter); + assertEquals(3, counter, "Unexpected numbed of received chunks."); } /** @@ -125,11 +124,11 @@ public void testChunkedOutputToChunkInputFromPojo() throws Exception { int counter = 0; Message chunk; while ((chunk = input.read()) != null) { - assertEquals("Unexpected value of chunk " + counter, new Message(counter, "test"), chunk); + assertEquals(new Message(counter, "test"), chunk, "Unexpected value of chunk " + counter); counter++; } - assertEquals("Unexpected numbed of received chunks.", 3, counter); + assertEquals(3, counter, "Unexpected numbed of received chunks."); } /** @@ -144,11 +143,11 @@ public void chunkedOutputWithAsyncResponse() throws Exception { int counter = 0; Message chunk; while ((chunk = input.read()) != null) { - assertEquals("Unexpected value of chunk " + counter, new Message(counter, "test"), chunk); + assertEquals(new Message(counter, "test"), chunk, "Unexpected value of chunk " + counter); counter++; } - assertEquals("Unexpected numbed of received chunks.", 3, counter); + assertEquals(3, counter, "Unexpected numbed of received chunks."); } /** @@ -169,10 +168,10 @@ public void checkConnectionIsClosedUrlConnection() throws Exception { String line; int counter = 0; while ((line = reader.readLine()) != null) { - assertEquals("Unexpected value of chunk " + counter, new Message(counter, "test").toString(), line); + assertEquals(new Message(counter, "test").toString(), line, "Unexpected value of chunk " + counter); counter++; } - assertEquals("Unexpected numbed of received chunks.", 3, counter); + assertEquals(3, counter, "Unexpected numbed of received chunks."); } } diff --git a/tests/integration/servlet-3-filter/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_filter/MyResourceITCase.java b/tests/integration/servlet-3-filter/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_filter/MyResourceITCase.java index e3eb454e7c..31eab22e07 100644 --- a/tests/integration/servlet-3-filter/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_filter/MyResourceITCase.java +++ b/tests/integration/servlet-3-filter/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_filter/MyResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Adam Lindenthal diff --git a/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncCancelTimeoutResourceTest.java b/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncCancelTimeoutResourceTest.java index 57353172ac..9ac8798d24 100644 --- a/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncCancelTimeoutResourceTest.java +++ b/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncCancelTimeoutResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Asynchronous servlet-deployed resource for testing {@link javax.ws.rs.container.AsyncResponse async response} timeouts. diff --git a/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncResumeTimeoutResourceTest.java b/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncResumeTimeoutResourceTest.java index a40976a1e9..ddcb4e860b 100644 --- a/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncResumeTimeoutResourceTest.java +++ b/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncResumeTimeoutResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -31,9 +31,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Asynchronous servlet-deployed resource for testing {@link javax.ws.rs.container.AsyncResponse async response} timeouts. diff --git a/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncServletResourceTest.java b/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncServletResourceTest.java index 3656086d2e..e583eb9f45 100644 --- a/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncServletResourceTest.java +++ b/tests/integration/servlet-3-gf-async/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_async/AsyncServletResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -42,9 +42,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Asynchronous servlet-deployed resource test. @@ -144,8 +144,8 @@ private void get() { if (debugMode) { getRequestLatch.await(); } else { - assertTrue("Waiting for all GET requests to complete has timed out.", - getRequestLatch.await(LATCH_WAIT_TIMEOUT * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS)); + assertTrue(getRequestLatch.await(LATCH_WAIT_TIMEOUT * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), + "Waiting for all GET requests to complete has timed out."); } } finally { executor.shutdownNow(); @@ -160,9 +160,9 @@ private void get() { assertEquals(MAX_MESSAGES, getResponses.size()); for (final Map.Entry entry : getResponses.entrySet()) { - assertEquals("Unexpected GET response status for request " + entry.getKey(), 200, entry.getValue().status); - assertEquals("Unexpected GET response message for request " + entry.getKey(), expectedResponse, - entry.getValue().message); + assertEquals(200, entry.getValue().status, "Unexpected GET response status for request " + entry.getKey()); + assertEquals(expectedResponse, entry.getValue().message, + "Unexpected GET response message for request " + entry.getKey()); } } @@ -254,11 +254,10 @@ private void post() throws ProcessingException { postRequestLatch.await(); getRequestLatch.await(); } else { - assertTrue("Waiting for all POST requests to complete has timed out.", - postRequestLatch.await(LATCH_WAIT_TIMEOUT * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS)); - assertTrue("Waiting for all GET requests to complete has timed out.", - getRequestLatch.await(LATCH_WAIT_TIMEOUT * getAsyncTimeoutMultiplier(), - TimeUnit.SECONDS)); + assertTrue(postRequestLatch.await(LATCH_WAIT_TIMEOUT * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), + "Waiting for all POST requests to complete has timed out."); + assertTrue(getRequestLatch.await(LATCH_WAIT_TIMEOUT * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS), + "Waiting for all GET requests to complete has timed out."); } } finally { executor.shutdownNow(); @@ -278,16 +277,16 @@ private void post() throws ProcessingException { assertEquals(MAX_MESSAGES, postResponses.size()); for (final Map.Entry postResponseEntry : postResponses.entrySet()) { - assertTrue("Unexpected POST notification response for message " + postResponseEntry.getKey(), - postResponseEntry.getValue().startsWith(AsyncServletResource.CANCELED)); + assertTrue(postResponseEntry.getValue().startsWith(AsyncServletResource.CANCELED), + "Unexpected POST notification response for message " + postResponseEntry.getKey()); } assertEquals(MAX_MESSAGES, getResponses.size()); final Collection getResponseKeys = getResponses.keySet(); for (int i = 0; i < MAX_MESSAGES; i++) { - assertTrue("Detected a GET message response loss: " + i, getResponseKeys.contains(i)); + assertTrue(getResponseKeys.contains(i), "Detected a GET message response loss: " + i); final String getResponseEntry = getResponses.get(i); - assertTrue("Unexpected canceled GET response status for request " + i, getResponseEntry.startsWith("503: ")); + assertTrue(getResponseEntry.startsWith("503: "), "Unexpected canceled GET response status for request " + i); } } } diff --git a/tests/integration/servlet-3-inflector-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_inflector_1/InflectorInjectionTestITCase.java b/tests/integration/servlet-3-inflector-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_inflector_1/InflectorInjectionTestITCase.java index 4dff377c92..651e2a5d08 100644 --- a/tests/integration/servlet-3-inflector-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_inflector_1/InflectorInjectionTestITCase.java +++ b/tests/integration/servlet-3-inflector-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_inflector_1/InflectorInjectionTestITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/integration/servlet-3-init-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_1/HelloWorldResourceITCase.java b/tests/integration/servlet-3-init-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_1/HelloWorldResourceITCase.java index bbfb9a9467..83ecd1c597 100644 --- a/tests/integration/servlet-3-init-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_1/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-3-init-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_1/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek @@ -57,6 +57,6 @@ public void testHelloWorld() throws Exception { @Test public void testUnreachableResource() { Response r = target().path("unreachable").request().get(); - assertEquals("Managed to reach a resource that is not registered in the application.", 404, r.getStatus()); + assertEquals(404, r.getStatus(), "Managed to reach a resource that is not registered in the application."); } } diff --git a/tests/integration/servlet-3-init-2/pom.xml b/tests/integration/servlet-3-init-2/pom.xml index e76eb65f53..e2987374f4 100644 --- a/tests/integration/servlet-3-init-2/pom.xml +++ b/tests/integration/servlet-3-init-2/pom.xml @@ -41,9 +41,8 @@ jersey-container-servlet - junit - junit - 4.13.1 + org.junit.jupiter + junit-jupiter compile diff --git a/tests/integration/servlet-3-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_2/HelloWorldResourceITCase.java b/tests/integration/servlet-3-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_2/HelloWorldResourceITCase.java index fd8388fdd5..5395717f29 100644 --- a/tests/integration/servlet-3-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_2/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-3-init-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_2/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-3-init-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_3/EmptyApplicationTestITCase.java b/tests/integration/servlet-3-init-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_3/EmptyApplicationTestITCase.java index f76257654a..417f3102f8 100644 --- a/tests/integration/servlet-3-init-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_3/EmptyApplicationTestITCase.java +++ b/tests/integration/servlet-3-init-3/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_3/EmptyApplicationTestITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.tests.integration.servlet_3_init_3.resource.ResourceOne; import org.glassfish.jersey.tests.integration.servlet_3_init_3.resource.ResourceTwo; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/integration/servlet-3-init-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_4/EmptyApplicationTestITCase.java b/tests/integration/servlet-3-init-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_4/EmptyApplicationTestITCase.java index 4c3b2b6126..c723b0cf70 100644 --- a/tests/integration/servlet-3-init-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_4/EmptyApplicationTestITCase.java +++ b/tests/integration/servlet-3-init-4/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_4/EmptyApplicationTestITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.tests.integration.servlet_3_init_4.resource.ResourceOne; import org.glassfish.jersey.tests.integration.servlet_3_init_4.resource.ResourceTwo; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Michal Gajdos diff --git a/tests/integration/servlet-3-init-5/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_5/HelloWorldResourceITCase.java b/tests/integration/servlet-3-init-5/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_5/HelloWorldResourceITCase.java index 0eaa27db22..d5a6e546a2 100644 --- a/tests/integration/servlet-3-init-5/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_5/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-3-init-5/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_5/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-3-init-6/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_6/EmptyApplicationITCase.java b/tests/integration/servlet-3-init-6/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_6/EmptyApplicationITCase.java index c85d8bb5b0..c4c09270b7 100644 --- a/tests/integration/servlet-3-init-6/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_6/EmptyApplicationITCase.java +++ b/tests/integration/servlet-3-init-6/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_6/EmptyApplicationITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -26,9 +26,9 @@ import org.glassfish.jersey.tests.integration.servlet_3_init_6.resource.ResourceOne; import org.glassfish.jersey.tests.integration.servlet_3_init_6.resource.ResourceTwo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos diff --git a/tests/integration/servlet-3-init-7/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_7/HelloWorldResourceITCase.java b/tests/integration/servlet-3-init-7/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_7/HelloWorldResourceITCase.java index 4955e483ab..d85bb3343e 100644 --- a/tests/integration/servlet-3-init-7/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_7/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-3-init-7/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_7/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-3-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_8/HelloWorldResourceITCase.java b/tests/integration/servlet-3-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_8/HelloWorldResourceITCase.java index ba14d28fd5..c28aa23422 100644 --- a/tests/integration/servlet-3-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_8/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-3-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_8/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,8 +16,7 @@ package org.glassfish.jersey.tests.integration.servlet_3_init_8; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Application; @@ -29,43 +28,34 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test reachable resources. * * @author Libor Kramolis */ -@RunWith(Parameterized.class) public class HelloWorldResourceITCase extends JerseyTest { - private final String appPath; - private final String resourcePath; - private final String helloName; - - public HelloWorldResourceITCase(String appPath, String resourcePath, String helloName) { - this.appPath = appPath; - this.resourcePath = resourcePath; - this.helloName = helloName; - } - - @Parameterized.Parameters(name = "{index}: {0}/{1} \"{2}\"") - public static List testData() { - return Arrays.asList(new Object[][] { - {"/app1", "helloworld1", "World 1"}, //app1 - overridden using a servlet-mapping element in the web.xml - {"/app2ann", "helloworld2", "World 2"}, //app2ann - no servlet-mapping in the web.xml, used ApplicationPath.value - {"/app3ann", "helloworld3", "World 3"}, //app3ann - no servlet in the web.xml, used ApplicationPath.value - {"/app4", "helloworld4", "World 4"}, //app4 - fully configured in web.xml + public static Stream testData() { + return Stream.of( + //app1 - overridden using a servlet-mapping element in the web.xml + Arguments.of("/app1", "helloworld1", "World 1"), + //app2ann - no servlet-mapping in the web.xml, used ApplicationPath.value + Arguments.of("/app2ann", "helloworld2", "World 2"), + //app3ann - no servlet in the web.xml, used ApplicationPath.value + Arguments.of("/app3ann", "helloworld3", "World 3"), + Arguments.of("/app4", "helloworld4", "World 4"), //app4 - fully configured in web.xml //app5 - automatic registration of all resources, no explicit classes/singletons provided by Servlet3Init8App5 - {"/app5", "helloworld1", "World 1"}, - {"/app5", "helloworld2", "World 2"}, - {"/app5", "helloworld3", "World 3"}, - {"/app5", "helloworld4", "World 4"}, - {"/app5", "unreachable", "Unreachable"}, - }); + Arguments.of("/app5", "helloworld1", "World 1"), + Arguments.of("/app5", "helloworld2", "World 2"), + Arguments.of("/app5", "helloworld3", "World 3"), + Arguments.of("/app5", "helloworld4", "World 4"), + Arguments.of("/app5", "unreachable", "Unreachable") + ); } @Override @@ -78,8 +68,9 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc return new ExternalTestContainerFactory(); } - @Test - public void testHelloWorld() throws Exception { + @ParameterizedTest(name = "{index}: {0}/{1} \"{2}\"") + @MethodSource("testData") + public void testHelloWorld(String appPath, String resourcePath, String helloName) throws Exception { WebTarget t = target(appPath); t.register(LoggingFeature.class); Response r = t.path(resourcePath).request().get(); diff --git a/tests/integration/servlet-3-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_8/HelloWorldResourceUnreachableITCase.java b/tests/integration/servlet-3-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_8/HelloWorldResourceUnreachableITCase.java index 4a2b21ca39..6a56d188cd 100644 --- a/tests/integration/servlet-3-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_8/HelloWorldResourceUnreachableITCase.java +++ b/tests/integration/servlet-3-init-8/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_8/HelloWorldResourceUnreachableITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -16,8 +16,7 @@ package org.glassfish.jersey.tests.integration.servlet_3_init_8; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Application; @@ -28,38 +27,27 @@ import org.glassfish.jersey.test.external.ExternalTestContainerFactory; import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test unreachable resources. * * @author Libor Kramolis */ -@RunWith(Parameterized.class) public class HelloWorldResourceUnreachableITCase extends JerseyTest { - private final String appPath; - private final String resourcePath; - - public HelloWorldResourceUnreachableITCase(String appPath, - String resourcePath) { - this.appPath = appPath; - this.resourcePath = resourcePath; - } - - @Parameterized.Parameters(name = "{index}: {0}/{1}") - public static List testData() { - return Arrays.asList(new Object[][] { - {"/app1", "unreachable"}, //unreachable - no explicitly mentioned resource - {"/app1ann", "helloworld1"}, //app1ann - overridden using a servlet-mapping element in the web.xml - {"/app2ann", "unreachable"}, //unreachable - no explicitly mentioned resource - {"/app3ann", "unreachable"}, //unreachable - no explicitly mentioned resource - {"/app4", "unreachable"}, //unreachable - no explicitly mentioned resource - }); + public static Stream testData() { + return Stream.of( + Arguments.of("/app1", "unreachable"), //unreachable - no explicitly mentioned resource + Arguments.of("/app1ann", "helloworld1"), //app1ann - overridden using a servlet-mapping element in the web.xml + Arguments.of("/app2ann", "unreachable"), //unreachable - no explicitly mentioned resource + Arguments.of("/app3ann", "unreachable"), //unreachable - no explicitly mentioned resource + Arguments.of("/app4", "unreachable") //unreachable - no explicitly mentioned resource + ); } @Override @@ -72,8 +60,9 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc return new ExternalTestContainerFactory(); } - @Test - public void testUnreachableResource() { + @ParameterizedTest(name = "{index}: {0}/{1}") + @MethodSource("testData") + public void testUnreachableResource(String appPath, String resourcePath) { WebTarget t = target(appPath); t.register(LoggingFeature.class); Response r = t.path(resourcePath).request().get(); diff --git a/tests/integration/servlet-3-init-9/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_9/HelloWorldResourceITCase.java b/tests/integration/servlet-3-init-9/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_9/HelloWorldResourceITCase.java index de329a19f8..c36f22a39f 100644 --- a/tests/integration/servlet-3-init-9/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_9/HelloWorldResourceITCase.java +++ b/tests/integration/servlet-3-init-9/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_9/HelloWorldResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertTrue; public class HelloWorldResourceITCase extends JerseyTest { diff --git a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/AbstractHelloWorldResourceTest.java b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/AbstractHelloWorldResourceTest.java index 259dd8d972..69acc848a5 100644 --- a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/AbstractHelloWorldResourceTest.java +++ b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/AbstractHelloWorldResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import org.junit.Assert; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Assertions; import javax.ws.rs.NotFoundException; @@ -51,15 +51,15 @@ public void testHelloWorld() throws Exception { try { String actual = target("application" + getIndex()).path("helloworld" + i).request().get(String.class); if (i == getIndex()) { - Assert.assertEquals("Hello World #" + getIndex() + "!", actual); + Assertions.assertEquals("Hello World #" + getIndex() + "!", actual); } else { - Assert.fail("i: " + i + " | [" + actual + "]"); + Assertions.fail("i: " + i + " | [" + actual + "]"); } } catch (NotFoundException ex) { if (i != getIndex()) { - Assert.assertEquals(404, ex.getResponse().getStatus()); + Assertions.assertEquals(404, ex.getResponse().getStatus()); } else { - Assert.fail("!!! i: " + i); + Assertions.fail("!!! i: " + i); } } } diff --git a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld1ResourceITCase.java b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld1ResourceITCase.java index ef833d10ca..6ac5fe285b 100644 --- a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld1ResourceITCase.java +++ b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld1ResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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,8 +18,8 @@ import javax.ws.rs.client.WebTarget; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Libor Kramolis @@ -37,7 +37,7 @@ protected int getIndex() { @Test public void testRegisteredServletNames() throws Exception { WebTarget target = target("application" + getIndex()).path("helloworld" + getIndex()).path("servlets"); - Assert.assertEquals(AbstractHelloWorldResource.NUMBER_OF_APPLICATIONS, (int) target.request().get(Integer.TYPE)); + Assertions.assertEquals(AbstractHelloWorldResource.NUMBER_OF_APPLICATIONS, (int) target.request().get(Integer.TYPE)); target = target.path("{name}"); testRegisteredServletNames(target, "org.glassfish.jersey.tests.integration.servlet_3_init_provider.Application1"); @@ -48,13 +48,13 @@ public void testRegisteredServletNames() throws Exception { } private void testRegisteredServletNames(WebTarget target, String servletName) throws Exception { - Assert.assertTrue(target.resolveTemplate("name", servletName).request().get(Boolean.TYPE)); + Assertions.assertTrue(target.resolveTemplate("name", servletName).request().get(Boolean.TYPE)); } @Test public void testImmutableServletNames() { WebTarget target = target("application" + getIndex()).path("helloworld" + getIndex()).path("immutableServletNames"); - Assert.assertTrue(target.request().get(Boolean.TYPE)); + Assertions.assertTrue(target.request().get(Boolean.TYPE)); } } diff --git a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld3ResourceITCase.java b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld3ResourceITCase.java index 27f7b64512..139bae49b2 100644 --- a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld3ResourceITCase.java +++ b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld3ResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.tests.integration.servlet_3_init_provider; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.client.WebTarget; @@ -37,7 +37,7 @@ protected int getIndex() { @Test public void testStartupContainers() throws Exception { WebTarget target = target("application" + getIndex()).path("helloworld" + getIndex()).path("containers"); - Assert.assertEquals(AbstractHelloWorldResource.NUMBER_OF_APPLICATIONS, (int) target.request().get(Integer.TYPE)); + Assertions.assertEquals(AbstractHelloWorldResource.NUMBER_OF_APPLICATIONS, (int) target.request().get(Integer.TYPE)); } } diff --git a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld4ResourceITCase.java b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld4ResourceITCase.java index d393170b05..ae45408ac0 100644 --- a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld4ResourceITCase.java +++ b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld4ResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.tests.integration.servlet_3_init_provider; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import javax.ws.rs.core.Response; @@ -37,7 +37,7 @@ protected int getIndex() { @Test public void testRegisterFilter() throws Exception { Response response = target("application" + getIndex()).path("helloworld" + getIndex()).path("filter").request().get(); - Assert.assertEquals(404, response.getStatus()); + Assertions.assertEquals(404, response.getStatus()); } } diff --git a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld5ResourceITCase.java b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld5ResourceITCase.java index ab503493df..9a423ce414 100644 --- a/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld5ResourceITCase.java +++ b/tests/integration/servlet-3-init-provider/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_init_provider/HelloWorld5ResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -16,8 +16,8 @@ package org.glassfish.jersey.tests.integration.servlet_3_init_provider; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Libor Kramolis @@ -36,7 +36,7 @@ protected int getIndex() { public void testRegisterFilter() throws Exception { String actual = target("application" + getIndex()).path("helloworld" + getIndex()).path("filter").request() .get(String.class); - Assert.assertEquals(TestServletContainerProvider.TEST_FILTER, actual); + Assertions.assertEquals(TestServletContainerProvider.TEST_FILTER, actual); } } diff --git a/tests/integration/servlet-3-params/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_params/ParamsTestITCase.java b/tests/integration/servlet-3-params/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_params/ParamsTestITCase.java index cf00cc1bca..f1e897f9e8 100644 --- a/tests/integration/servlet-3-params/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_params/ParamsTestITCase.java +++ b/tests/integration/servlet-3-params/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_params/ParamsTestITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Pavel Bucek diff --git a/tests/integration/servlet-3-sse-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_sse_1/ItemStoreResourceITCase.java b/tests/integration/servlet-3-sse-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_sse_1/ItemStoreResourceITCase.java index 63ca57b9be..6c01e0aafe 100644 --- a/tests/integration/servlet-3-sse-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_sse_1/ItemStoreResourceITCase.java +++ b/tests/integration/servlet-3-sse-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_3_sse_1/ItemStoreResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -48,22 +48,22 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.describedAs; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.hasItems; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Item store test. * * @author Marek Potociar */ -@Ignore +@Disabled public class ItemStoreResourceITCase extends JerseyTest { private static final Logger LOGGER = Logger.getLogger(ItemStoreResourceITCase.class.getName()); @@ -151,9 +151,9 @@ public void onEvent(InboundEvent inboundEvent) { postItem(itemsTarget, item); } - assertTrue("Waiting to receive all events has timed out.", - latch.await((1000 + MAX_LISTENERS * EventSource.RECONNECT_DEFAULT) * getAsyncTimeoutMultiplier(), - TimeUnit.MILLISECONDS)); + assertTrue(latch.await((1000 + MAX_LISTENERS * EventSource.RECONNECT_DEFAULT) * getAsyncTimeoutMultiplier(), + TimeUnit.MILLISECONDS), + "Waiting to receive all events has timed out."); // need to force disconnect on server in order for EventSource.close(...) to succeed with HttpUrlConnection sendCommand(itemsTarget, "disconnect"); @@ -163,19 +163,19 @@ public void onEvent(InboundEvent inboundEvent) { String postedItems = itemsTarget.request().get(String.class); for (String item : items) { - assertTrue("Item '" + item + "' not stored on server.", postedItems.contains(item)); + assertTrue(postedItems.contains(item), "Item '" + item + "' not stored on server."); } int queueId = 0; for (Queue indexes : indexQueues) { for (int i = 0; i < items.size(); i++) { - assertTrue("Event for '" + items.get(i) + "' not received in queue " + queueId, indexes.contains(i)); + assertTrue(indexes.contains(i), "Event for '" + items.get(i) + "' not received in queue " + queueId); } - assertEquals("Not received the expected number of events in queue " + queueId, items.size(), indexes.size()); + assertEquals(items.size(), indexes.size(), "Not received the expected number of events in queue " + queueId); queueId++; } - assertEquals("Number of received 'size' events does not match.", items.size() * MAX_LISTENERS, sizeEventsCount.get()); + assertEquals(items.size() * MAX_LISTENERS, sizeEventsCount.get(), "Number of received 'size' events does not match."); } /** @@ -242,8 +242,8 @@ public void onEvent(InboundEvent inboundEvent) { sendCommand(itemsTarget, "reconnect now"); - assertTrue("Waiting to receive all events has timed out.", - latch.await((1 + MAX_LISTENERS * (MAX_ITEMS + 1) * reconnectDelay) * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS)); + assertTrue(latch.await((1 + MAX_LISTENERS * (MAX_ITEMS + 1) * reconnectDelay) * getAsyncTimeoutMultiplier(), + TimeUnit.SECONDS), "Waiting to receive all events has timed out."); // need to force disconnect on server in order for EventSource.close(...) to succeed with HttpUrlConnection sendCommand(itemsTarget, "disconnect"); @@ -267,7 +267,7 @@ public void onEvent(InboundEvent inboundEvent) { private static void postItem(final WebTarget itemsTarget, final String item) { final Response response = itemsTarget.request().post(Entity.form(new Form("name", item))); - assertEquals("Posting new item has failed.", 204, response.getStatus()); + assertEquals(204, response.getStatus(), "Posting new item has failed."); LOGGER.info("[-i-] POSTed item: '" + item + "'"); } @@ -283,7 +283,7 @@ private static void close(final EventSource[] sources) { int i = 0; for (EventSource source : sources) { if (source.isOpen()) { - assertTrue("Waiting to close a source has timed out.", source.close(1, TimeUnit.SECONDS)); + assertTrue(source.close(1, TimeUnit.SECONDS), "Waiting to close a source has timed out."); // source.close(100, TimeUnit.MILLISECONDS); LOGGER.info("[<--] SOURCE " + i++ + " closed."); } @@ -292,7 +292,7 @@ private static void close(final EventSource[] sources) { private static void sendCommand(final WebTarget itemsTarget, final String command) { final Response response = itemsTarget.path("commands").request().post(Entity.text(command)); - assertEquals("'" + command + "' command has failed.", 200, response.getStatus()); + assertEquals(200, response.getStatus(), "'" + command + "' command has failed."); LOGGER.info("[-!-] COMMAND '" + command + "' has been processed."); } } diff --git a/tests/integration/servlet-4.0-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_40_mvc_1/GzipITCase.java b/tests/integration/servlet-4.0-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_40_mvc_1/GzipITCase.java index 9db8de7c58..3509be6438 100644 --- a/tests/integration/servlet-4.0-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_40_mvc_1/GzipITCase.java +++ b/tests/integration/servlet-4.0-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_40_mvc_1/GzipITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -16,13 +16,13 @@ package org.glassfish.jersey.tests.integration.servlet_40_mvc_1; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import javax.ws.rs.core.Response; import org.glassfish.jersey.message.GZipEncoder; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class GzipITCase extends TestSupport { diff --git a/tests/integration/servlet-4.0-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_40_mvc_1/TestSupport.java b/tests/integration/servlet-4.0-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_40_mvc_1/TestSupport.java index 4185a64ce1..9e00fe2b66 100644 --- a/tests/integration/servlet-4.0-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_40_mvc_1/TestSupport.java +++ b/tests/integration/servlet-4.0-mvc-1/src/test/java/org/glassfish/jersey/tests/integration/servlet_40_mvc_1/TestSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerFactory; import org.glassfish.jersey.tests.integration.servlet_40_mvc_1.MyApplication; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public abstract class TestSupport extends JerseyTest { @@ -43,13 +43,13 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc } protected void assertHtmlResponse(final String response) { - assertNotNull("No text returned!", response); + assertNotNull(response, "No text returned!"); assertResponseContains(response, ""); assertResponseContains(response, ""); } protected void assertResponseContains(final String response, final String text) { - assertTrue("Response should contain " + text + " but was: " + response, response.contains(text)); + assertTrue(response.contains(text), "Response should contain " + text + " but was: " + response); } } diff --git a/tests/integration/servlet-request-wrapper-binding-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_request_wrapper2/AbstractRequestResponseTypeTest.java b/tests/integration/servlet-request-wrapper-binding-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_request_wrapper2/AbstractRequestResponseTypeTest.java index 9756521fc0..d81deb5a75 100644 --- a/tests/integration/servlet-request-wrapper-binding-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_request_wrapper2/AbstractRequestResponseTypeTest.java +++ b/tests/integration/servlet-request-wrapper-binding-2/src/test/java/org/glassfish/jersey/tests/integration/servlet_request_wrapper2/AbstractRequestResponseTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,7 +22,7 @@ import org.glassfish.jersey.test.spi.TestContainerFactory; import org.glassfish.jersey.tests.integration.servlet_request_wrapper_binding2.RequestResponseWrapperProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; diff --git a/tests/integration/servlet-request-wrapper-binding/src/test/java/org/glassfish/jersey/tests/integration/servlet_request_wrapper/AbstractRequestResponseTypeTest.java b/tests/integration/servlet-request-wrapper-binding/src/test/java/org/glassfish/jersey/tests/integration/servlet_request_wrapper/AbstractRequestResponseTypeTest.java index 29cda9d5a4..f21144fb9f 100644 --- a/tests/integration/servlet-request-wrapper-binding/src/test/java/org/glassfish/jersey/tests/integration/servlet_request_wrapper/AbstractRequestResponseTypeTest.java +++ b/tests/integration/servlet-request-wrapper-binding/src/test/java/org/glassfish/jersey/tests/integration/servlet_request_wrapper/AbstractRequestResponseTypeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -26,7 +26,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.equalTo; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Make sure that injected request/response instances diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/CacheControlOn404ITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/CacheControlOn404ITCase.java index 215292799c..710dd5b288 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/CacheControlOn404ITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/CacheControlOn404ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,9 +25,9 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test class related to issue JERSEY-1189. diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/Custom404MediaTypeITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/Custom404MediaTypeITCase.java index 291224306c..c0a66d5de1 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/Custom404MediaTypeITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/Custom404MediaTypeITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Miroslav Fuksa @@ -70,18 +70,18 @@ private void testCustom404Impl(final boolean suppressContentLength) { .queryParam(SuppressContentLengthFilter.PARAMETER_NAME_SUPPRESS_CONTENT_LENGTH, suppressContentLength) .request() .get(); - Assert.assertEquals(404, response.getStatus()); - Assert.assertEquals("application/something", response.getMediaType().toString()); - Assert.assertEquals("not found custom entity", response.readEntity(String.class)); + Assertions.assertEquals(404, response.getStatus()); + Assertions.assertEquals("application/something", response.getMediaType().toString()); + Assertions.assertEquals("not found custom entity", response.readEntity(String.class)); } private void testCustom404WithEmtpyEntityStringImpl(final boolean suppressContentLength) { final Response response = target().path("custom404/resource404/content-type-empty-entity") .queryParam(SuppressContentLengthFilter.PARAMETER_NAME_SUPPRESS_CONTENT_LENGTH, suppressContentLength) .request().get(); - Assert.assertEquals(404, response.getStatus()); - Assert.assertEquals("application/something", response.getMediaType().toString()); - Assert.assertEquals("", response.readEntity(String.class)); + Assertions.assertEquals(404, response.getStatus()); + Assertions.assertEquals("application/something", response.getMediaType().toString()); + Assertions.assertEquals("", response.readEntity(String.class)); } } diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/DuplicateHeaderITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/DuplicateHeaderITCase.java index 4de9039c03..715eda769b 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/DuplicateHeaderITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/DuplicateHeaderITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -30,8 +30,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Libor Kramolis @@ -71,7 +71,7 @@ private void testDuplicateHeaderImpl(final int headerCount, int expectedResponse connection.addRequestProperty(headerName, "N/A"); } connection.connect(); - assertEquals(path + " [" + headerName + ":" + headerCount + "x]", expectedResponseCode, connection.getResponseCode()); + assertEquals(expectedResponseCode, connection.getResponseCode(), path + " [" + headerName + ":" + headerCount + "x]"); } finally { connection.disconnect(); } diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/FilterContextPathITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/FilterContextPathITCase.java index 60e99d3268..e9072a5473 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/FilterContextPathITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/FilterContextPathITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/FormConsumptionITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/FormConsumptionITCase.java index af7a5f9c5d..46f461cf31 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/FormConsumptionITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/FormConsumptionITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/ForwardOn404ITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/ForwardOn404ITCase.java index 1bc99e9f52..fa01a8e09c 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/ForwardOn404ITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/ForwardOn404ITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/InvalidRequestUriITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/InvalidRequestUriITCase.java index db67e95585..94289f2058 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/InvalidRequestUriITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/InvalidRequestUriITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test class related to issue JERSEY-2680. diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/RolesAllowedFilterITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/RolesAllowedFilterITCase.java index a22f0c88c5..ee9bee9f32 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/RolesAllowedFilterITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/RolesAllowedFilterITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Petr Bouda diff --git a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/StaticContentRegexITCase.java b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/StaticContentRegexITCase.java index 70647e284b..346dd34bc9 100644 --- a/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/StaticContentRegexITCase.java +++ b/tests/integration/servlet-tests/src/test/java/org/glassfish/jersey/tests/integration/servlettests/StaticContentRegexITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -25,8 +25,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author Martin Matula diff --git a/tests/integration/sonar-test/src/test/java/org/glassfish/jersey/tests/integration/sonar/JerseySonarITCase.java b/tests/integration/sonar-test/src/test/java/org/glassfish/jersey/tests/integration/sonar/JerseySonarITCase.java index 5f0c65440c..418804fec0 100644 --- a/tests/integration/sonar-test/src/test/java/org/glassfish/jersey/tests/integration/sonar/JerseySonarITCase.java +++ b/tests/integration/sonar-test/src/test/java/org/glassfish/jersey/tests/integration/sonar/JerseySonarITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -26,8 +26,8 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Stepan Vavra @@ -38,14 +38,14 @@ public class JerseySonarITCase extends JerseyTest { public void testIntegrationServerJvm() { final String string = target("test").request().get(String.class); - Assert.assertEquals("common server jvm server server jvm", string); + Assertions.assertEquals("common server jvm server server jvm", string); } @Test public void testIntegrationTestJvm() { final String string = new SonarJerseyCommon().integrationTestJvm() + " " + new SonarJerseyServer().integrationTestJvm(); - Assert.assertEquals("common test jvm server test jvm", string); + Assertions.assertEquals("common test jvm server test jvm", string); } @Override diff --git a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java index c9f9f1718f..939928c62c 100644 --- a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java +++ b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.test.spi.TestContainerFactory; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class AccountResourceITCase extends JerseyTest { diff --git a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java index 5c7774b43e..81822d2ab5 100644 --- a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java +++ b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -22,10 +22,10 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Base class for JAX-RS resource tests. diff --git a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java index 4815e0efdd..07cecfb7f8 100644 --- a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java +++ b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Jersey managed JAX-RS resources. diff --git a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java index cbe42c6c86..d722371c80 100644 --- a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java +++ b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources with @Controller archetype. diff --git a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java index fe96090eac..42bbe48dd1 100644 --- a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java +++ b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources with custom composite diff --git a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java index 5eea4296b0..732a5a223a 100644 --- a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java +++ b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources. diff --git a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java index 5302a9eeaa..95203188a1 100644 --- a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java +++ b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources with @Repository archetype. diff --git a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java index 633ceeaf0f..fd94e439fa 100644 --- a/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java +++ b/tests/integration/spring4/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources with @Service archetype. diff --git a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java index 370faf2c3d..939928c62c 100644 --- a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java +++ b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.test.spi.TestContainerFactory; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class AccountResourceITCase extends JerseyTest { diff --git a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java index f63fd1216c..81822d2ab5 100644 --- a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java +++ b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -22,10 +22,10 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Base class for JAX-RS resource tests. diff --git a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java index f7eccef515..07cecfb7f8 100644 --- a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java +++ b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Jersey managed JAX-RS resources. diff --git a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java index 05aaea81d6..d722371c80 100644 --- a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java +++ b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources with @Controller archetype. diff --git a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java index 986abc831e..42bbe48dd1 100644 --- a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java +++ b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources with custom composite diff --git a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java index 5ddf2a6588..732a5a223a 100644 --- a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java +++ b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources. diff --git a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java index 7b1d2005c4..95203188a1 100644 --- a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java +++ b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources with @Repository archetype. diff --git a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java index 0404467675..fd94e439fa 100644 --- a/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java +++ b/tests/integration/spring5/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -21,8 +21,8 @@ import org.glassfish.jersey.server.ResourceConfig; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests for Spring managed JAX-RS resources with @Service archetype. diff --git a/tests/integration/tracing-support/src/test/java/org/glassfish/jersey/tests/integration/tracing/AllTracingSupportITCase.java b/tests/integration/tracing-support/src/test/java/org/glassfish/jersey/tests/integration/tracing/AllTracingSupportITCase.java index 0983d0035d..03dd1a8300 100644 --- a/tests/integration/tracing-support/src/test/java/org/glassfish/jersey/tests/integration/tracing/AllTracingSupportITCase.java +++ b/tests/integration/tracing-support/src/test/java/org/glassfish/jersey/tests/integration/tracing/AllTracingSupportITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -17,8 +17,7 @@ package org.glassfish.jersey.tests.integration.tracing; import java.io.IOException; -import java.util.Arrays; -import java.util.List; +import java.util.stream.Stream; import javax.ws.rs.client.Entity; import javax.ws.rs.client.Invocation; @@ -35,31 +34,19 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * 'ALL' tracing support test that is running in external Jetty container. * * @author Libor Kramolis */ -@RunWith(Parameterized.class) public class AllTracingSupportITCase extends JerseyTest { - private final String resourcePath; - - public AllTracingSupportITCase(String resourcePath) { - this.resourcePath = resourcePath; - } - - @Parameterized.Parameters(name = "{index}: {0}") - public static List testData() { - return Arrays.asList(new Object[][] { - {"/root"}, - {"/async"}, - }); + public static Stream testData() { + return Stream.of("/root", "/async"); } // @@ -88,16 +75,18 @@ protected TestContainerFactory getTestContainerFactory() throws TestContainerExc // tests // - @Test - public void testGet() { + @ParameterizedTest + @MethodSource("testData") + public void testGet(String resourcePath) { Invocation.Builder builder = resource(resourcePath).path("NAME").request(); Response response = builder.get(); assertXJerseyTrace(response, false); assertEquals(200, response.getStatus()); } - @Test - public void testRuntimeException() { + @ParameterizedTest + @MethodSource("testData") + public void testRuntimeException(String resourcePath) { Invocation.Builder builder = resource(resourcePath).path("runtime-exception").request(); Response response = builder.get(); @@ -105,8 +94,9 @@ public void testRuntimeException() { assertEquals(500, response.getStatus()); } - @Test - public void testMappedException() throws InterruptedException, IOException { + @ParameterizedTest + @MethodSource("testData") + public void testMappedException(String resourcePath) throws InterruptedException, IOException { Invocation.Builder builder = resource(resourcePath).path("mapped-exception").request(); Response response = builder.get(); @@ -114,8 +104,9 @@ public void testMappedException() throws InterruptedException, IOException { assertEquals(501, response.getStatus()); } - @Test - public void testGet405() { + @ParameterizedTest + @MethodSource("testData") + public void testGet405(String resourcePath) { Invocation.Builder builder = resource(resourcePath).request(); Response response = builder.get(); @@ -123,8 +114,9 @@ public void testGet405() { assertEquals(405, response.getStatus()); } - @Test - public void testPostSubResourceMethod() { + @ParameterizedTest + @MethodSource("testData") + public void testPostSubResourceMethod(String resourcePath) { Invocation.Builder builder = resource(resourcePath).path("sub-resource-method").request(); Response response = builder.post(Entity.entity(new Message("POST"), Utils.APPLICATION_X_JERSEY_TEST)); @@ -132,8 +124,9 @@ public void testPostSubResourceMethod() { assertEquals("TSOP", response.readEntity(Message.class).getText()); } - @Test - public void testPostSubResourceLocator() { + @ParameterizedTest + @MethodSource("testData") + public void testPostSubResourceLocator(String resourcePath) { Invocation.Builder builder = resource(resourcePath).path("sub-resource-locator").request(); Response response = builder.post(Entity.entity(new Message("POST"), Utils.APPLICATION_X_JERSEY_TEST)); @@ -141,16 +134,18 @@ public void testPostSubResourceLocator() { assertEquals("TSOP", response.readEntity(Message.class).getText()); } - @Test - public void testPostSubResourceLocatorNull() { + @ParameterizedTest + @MethodSource("testData") + public void testPostSubResourceLocatorNull(String resourcePath) { Invocation.Builder builder = resource(resourcePath).path("sub-resource-locator-null").request(); Response response = builder.post(Entity.entity(new Message("POST"), Utils.APPLICATION_X_JERSEY_TEST)); assertEquals(404, response.getStatus()); } - @Test - public void testPostSubResourceLocatorSubResourceMethod() { + @ParameterizedTest + @MethodSource("testData") + public void testPostSubResourceLocatorSubResourceMethod(String resourcePath) { Invocation.Builder builder = resource(resourcePath).path("sub-resource-locator").path("sub-resource-method").request(); Response response = builder.post(Entity.entity(new Message("POST"), Utils.APPLICATION_X_JERSEY_TEST)); @@ -158,27 +153,29 @@ public void testPostSubResourceLocatorSubResourceMethod() { assertEquals("TSOP", response.readEntity(Message.class).getText()); } - @Test - public void testTraceInnerException() { + @ParameterizedTest + @MethodSource("testData") + public void testTraceInnerException(String resourcePath) { // PRE_MATCHING_REQUEST_FILTER - testTraceInnerExceptionImpl(Utils.TestAction.PRE_MATCHING_REQUEST_FILTER_THROW_WEB_APPLICATION, 500, false); - testTraceInnerExceptionImpl(Utils.TestAction.PRE_MATCHING_REQUEST_FILTER_THROW_PROCESSING, 500, true); - testTraceInnerExceptionImpl(Utils.TestAction.PRE_MATCHING_REQUEST_FILTER_THROW_ANY, 500, true); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.PRE_MATCHING_REQUEST_FILTER_THROW_WEB_APPLICATION, 500, false); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.PRE_MATCHING_REQUEST_FILTER_THROW_PROCESSING, 500, true); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.PRE_MATCHING_REQUEST_FILTER_THROW_ANY, 500, true); // MESSAGE_BODY_WRITER - testTraceInnerExceptionImpl(Utils.TestAction.MESSAGE_BODY_WRITER_THROW_WEB_APPLICATION, 500, false); - testTraceInnerExceptionImpl(Utils.TestAction.MESSAGE_BODY_WRITER_THROW_PROCESSING, 500, true); - testTraceInnerExceptionImpl(Utils.TestAction.MESSAGE_BODY_WRITER_THROW_ANY, 500, true); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.MESSAGE_BODY_WRITER_THROW_WEB_APPLICATION, 500, false); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.MESSAGE_BODY_WRITER_THROW_PROCESSING, 500, true); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.MESSAGE_BODY_WRITER_THROW_ANY, 500, true); // MESSAGE_BODY_READER - testTraceInnerExceptionImpl(Utils.TestAction.MESSAGE_BODY_READER_THROW_WEB_APPLICATION, 500, false); - testTraceInnerExceptionImpl(Utils.TestAction.MESSAGE_BODY_READER_THROW_PROCESSING, 500, true); - testTraceInnerExceptionImpl(Utils.TestAction.MESSAGE_BODY_READER_THROW_ANY, 500, true); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.MESSAGE_BODY_READER_THROW_WEB_APPLICATION, 500, false); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.MESSAGE_BODY_READER_THROW_PROCESSING, 500, true); + testTraceInnerExceptionImpl(resourcePath, Utils.TestAction.MESSAGE_BODY_READER_THROW_ANY, 500, true); } // // utils // - private void testTraceInnerExceptionImpl(Utils.TestAction testAction, int expectedStatus, boolean exceptionExpected) { + private void testTraceInnerExceptionImpl(String resourcePath, Utils.TestAction testAction, + int expectedStatus, boolean exceptionExpected) { Invocation.Builder builder = resource(resourcePath).request(); builder.header(Utils.HEADER_TEST_ACTION, testAction); @@ -201,11 +198,11 @@ private void assertXJerseyTrace(Response response, boolean exceptionExpected) { } } } - assertEquals("Just one FINISHED expected!", 1, finished); + assertEquals(1, finished, "Just one FINISHED expected!"); if (exceptionExpected) { - assertEquals("EXCEPTION expected!", 1, exceptionMapping); + assertEquals(1, exceptionMapping, "EXCEPTION expected!"); } else { - assertEquals("EXCEPTION NOT expected!", 0, exceptionMapping); + assertEquals(0, exceptionMapping, "EXCEPTION NOT expected!"); } } diff --git a/tests/integration/tracing-support/src/test/java/org/glassfish/jersey/tests/integration/tracing/OnDemandTracingSupportITCase.java b/tests/integration/tracing-support/src/test/java/org/glassfish/jersey/tests/integration/tracing/OnDemandTracingSupportITCase.java index 63532566d1..003a629395 100644 --- a/tests/integration/tracing-support/src/test/java/org/glassfish/jersey/tests/integration/tracing/OnDemandTracingSupportITCase.java +++ b/tests/integration/tracing-support/src/test/java/org/glassfish/jersey/tests/integration/tracing/OnDemandTracingSupportITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2022 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 @@ -31,10 +31,10 @@ import org.glassfish.jersey.test.spi.TestContainerException; import org.glassfish.jersey.test.spi.TestContainerFactory; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * 'ON_DEMAND' tracing support test that is running in external Jetty container. diff --git a/tests/jmockit/pom.xml b/tests/jmockit/pom.xml index 7c1a51afe8..54a6034956 100644 --- a/tests/jmockit/pom.xml +++ b/tests/jmockit/pom.xml @@ -59,8 +59,8 @@ test - junit - junit + org.junit.jupiter + junit-jupiter test diff --git a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/media/multipart/internal/FormDataMultiPartReaderWriterTest.java b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/media/multipart/internal/FormDataMultiPartReaderWriterTest.java index 3c99d0089f..c76e233f99 100644 --- a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/media/multipart/internal/FormDataMultiPartReaderWriterTest.java +++ b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/media/multipart/internal/FormDataMultiPartReaderWriterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -27,7 +27,7 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.jvnet.mimepull.MIMEMessage; import org.jvnet.mimepull.MIMEParsingException; @@ -49,8 +49,8 @@ import java.net.URL; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.hamcrest.MatcherAssert.assertThat; /** * Tests for multipart {@code MessageBodyReader} and {@code MessageBodyWriter} as well as {@code FormDataMultiPart} and {@code diff --git a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/ResourceConfigTest.java b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/ResourceConfigTest.java index 39f3311856..0f8bafdada 100644 --- a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/ResourceConfigTest.java +++ b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/ResourceConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -23,11 +23,13 @@ import org.glassfish.jersey.tests.jmockit.server.innerstatic.InnerStaticClass; import org.glassfish.jersey.tests.jmockit.server.toplevel.PublicRootResourceClass; import org.glassfish.jersey.tests.jmockit.server.toplevelinnerstatic.PublicRootResourceInnerStaticClass; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * @author Pavel Bucek */ +@Disabled("@Mocked cannot be used with Iterator (since 1.45)") public class ResourceConfigTest { /** diff --git a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java index f8f56684e8..00d614de3f 100644 --- a/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java +++ b/tests/jmockit/src/test/java/org/glassfish/jersey/tests/jmockit/server/internal/scanning/PackageNamesScannerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2022 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 @@ -16,14 +16,14 @@ package org.glassfish.jersey.tests.jmockit.server.internal.scanning; -import mockit.Expectations; import mockit.Injectable; +import mockit.MockUp; import mockit.Tested; import mockit.Verifications; import org.glassfish.jersey.server.internal.scanning.PackageNamesScanner; import org.glassfish.jersey.server.internal.scanning.ResourceFinderException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -37,8 +37,9 @@ import java.util.Vector; import java.util.jar.JarInputStream; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Unit tests for {@link PackageNamesScanner}. @@ -52,7 +53,7 @@ public class PackageNamesScannerTest { private String jaxRsApiPath; - @Before + @BeforeEach public void setUp() throws Exception { final String classPath = System.getProperty("java.class.path"); final String[] entries = classPath.split(System.getProperty("path.separator")); @@ -71,27 +72,27 @@ public void setUp() throws Exception { @Test public void testWsJarScheme() { - assertTrue("Expected at least one class to be found.", - new PackageNamesScanner(createTestClassLoader("wsjar", createTestURLStreamHandler("wsjar"), jaxRsApiPath), - packages, false).hasNext()); + assertTrue(new PackageNamesScanner(createTestClassLoader("wsjar", createTestURLStreamHandler("wsjar"), jaxRsApiPath), + packages, false).hasNext(), "Expected at least one class to be found."); } @Test public void testJarScheme() { // Uses default class loader - assertTrue("Expected at least one class to be found.", new PackageNamesScanner(packages, false).hasNext()); + assertTrue(new PackageNamesScanner(packages, false).hasNext(), "Expected at least one class to be found."); } @Test public void testZipScheme() { - assertTrue("Expected at least one class to be found.", - new PackageNamesScanner(createTestClassLoader("zip", createTestURLStreamHandler("zip"), jaxRsApiPath), - packages, false).hasNext()); + assertTrue(new PackageNamesScanner(createTestClassLoader("zip", createTestURLStreamHandler("zip"), jaxRsApiPath), + packages, false).hasNext(), "Expected at least one class to be found."); } - @Test(expected = ResourceFinderException.class) + @Test public void testInvalidScheme() { - new PackageNamesScanner(createTestClassLoader("bad", createTestURLStreamHandler("bad"), jaxRsApiPath), packages, false); + assertThrows(ResourceFinderException.class, + () -> new PackageNamesScanner( + createTestClassLoader("bad", createTestURLStreamHandler("bad"), jaxRsApiPath), packages, false)); } @@ -110,7 +111,7 @@ public void testInputStreamClosedAfterReset() throws Exception { JarInputStream stream = new JarInputStream( new ByteArrayInputStream("test".getBytes(), 0, 4)); - new Expectations(InputStream.class){}; + new MockUp(InputStream.class){}; scanner1.reset(); @@ -134,7 +135,7 @@ public void testInputStreamClosedAfterClose() throws Exception { JarInputStream stream = new JarInputStream( new ByteArrayInputStream("test".getBytes(), 0, 4)); - new Expectations(JarInputStream.class){}; + new MockUp(JarInputStream.class){}; scanner1.close(); @@ -159,9 +160,8 @@ public void testInputStreamClosedAfterIteration(@Injectable("false") boolean rec JarInputStream stream = new JarInputStream( new ByteArrayInputStream("test".getBytes(), 0, 4)); - new Expectations(JarInputStream.class) {{ + new MockUp(JarInputStream.class) {{ stream.getNextJarEntry(); - result = null; stream.close(); }}; diff --git a/tests/mem-leaks/test-cases/bean-param-leak/src/test/java/org/glassfish/jersey/tests/memleaks/beanparam/BeanParamLeakResourceITCase.java b/tests/mem-leaks/test-cases/bean-param-leak/src/test/java/org/glassfish/jersey/tests/memleaks/beanparam/BeanParamLeakResourceITCase.java index ef9c1775ee..ae7c1b6d4e 100644 --- a/tests/mem-leaks/test-cases/bean-param-leak/src/test/java/org/glassfish/jersey/tests/memleaks/beanparam/BeanParamLeakResourceITCase.java +++ b/tests/mem-leaks/test-cases/bean-param-leak/src/test/java/org/glassfish/jersey/tests/memleaks/beanparam/BeanParamLeakResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -21,13 +21,13 @@ import org.glassfish.jersey.test.memleak.common.AbstractMemoryLeakWebAppTest; import org.glassfish.jersey.test.memleak.common.MemoryLeakSucceedingTimeout; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.InvocationInterceptor; +import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.Timeout; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; /** * This is an integration test that reproduces JERSEY-2800 by calling RESTful resource {@link BeanParamLeakResource} @@ -42,13 +42,13 @@ protected Application configure() { return new TestApplication(); } - @Rule - public Timeout globalTimeout = new MemoryLeakSucceedingTimeout(300_000); + @RegisterExtension + public InvocationInterceptor globalTimeout = new MemoryLeakSucceedingTimeout(300_000); @Test public void testTheLeakResourceOnce() { final Response response = target("beanparam/invoke").queryParam("q", "hello").request().post(null); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); assertEquals("hello", response.readEntity(String.class)); } diff --git a/tests/mem-leaks/test-cases/leaking-test-app/src/test/java/org/glassfish/jersey/tests/memleaks/testleak/MemoryLeakingResourceITCase.java b/tests/mem-leaks/test-cases/leaking-test-app/src/test/java/org/glassfish/jersey/tests/memleaks/testleak/MemoryLeakingResourceITCase.java index 3b7b9ab87f..16ec2e4e44 100644 --- a/tests/mem-leaks/test-cases/leaking-test-app/src/test/java/org/glassfish/jersey/tests/memleaks/testleak/MemoryLeakingResourceITCase.java +++ b/tests/mem-leaks/test-cases/leaking-test-app/src/test/java/org/glassfish/jersey/tests/memleaks/testleak/MemoryLeakingResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,12 +22,12 @@ import org.glassfish.jersey.test.memleak.common.AbstractMemoryLeakWebAppTest; import org.glassfish.jersey.test.memleak.common.MemoryLeakSucceedingTimeout; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.InvocationInterceptor; +import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.Timeout; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** * Performs the test of a memory leaking RESTful resource. @@ -36,8 +36,8 @@ */ public class MemoryLeakingResourceITCase extends AbstractMemoryLeakWebAppTest { - @Rule - public Timeout globalTimeout = new MemoryLeakSucceedingTimeout(100_000); + @RegisterExtension + public InvocationInterceptor globalTimeout = new MemoryLeakSucceedingTimeout(100_000); @Override protected Application configure() { @@ -53,7 +53,7 @@ public void testTheLeak() { final WebTarget webTarget = target("invoke").queryParam("size", 1024 * 1024); System.out.println(webTarget.getUri()); final Response response = webTarget.request().post(null); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); } /** diff --git a/tests/mem-leaks/test-cases/shutdown-hook-leak-client/src/test/java/org/glassfish/jersey/tests/memleaks/shutdownleak/client/EndlessShutdownHookLeakTest.java b/tests/mem-leaks/test-cases/shutdown-hook-leak-client/src/test/java/org/glassfish/jersey/tests/memleaks/shutdownleak/client/EndlessShutdownHookLeakTest.java index 8b6c24fcbf..3032a8ab03 100644 --- a/tests/mem-leaks/test-cases/shutdown-hook-leak-client/src/test/java/org/glassfish/jersey/tests/memleaks/shutdownleak/client/EndlessShutdownHookLeakTest.java +++ b/tests/mem-leaks/test-cases/shutdown-hook-leak-client/src/test/java/org/glassfish/jersey/tests/memleaks/shutdownleak/client/EndlessShutdownHookLeakTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -25,10 +25,9 @@ import org.glassfish.jersey.test.memleak.common.AbstractMemoryLeakSimpleTest; import org.glassfish.jersey.test.memleak.common.MemoryLeakSucceedingTimeout; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.Timeout; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.InvocationInterceptor; +import org.junit.jupiter.api.extension.RegisterExtension; /** * Reproducer for JERSEY-2786. @@ -39,8 +38,8 @@ public class EndlessShutdownHookLeakTest extends AbstractMemoryLeakSimpleTest { private static final Logger LOGGER = Logger.getLogger(EndlessShutdownHookLeakTest.class.getName()); - @Rule - public Timeout globalTimeout = new MemoryLeakSucceedingTimeout(); + @RegisterExtension + public InvocationInterceptor globalTimeout = new MemoryLeakSucceedingTimeout(); final Client client = ClientBuilder.newClient(); final WebTarget target = client.target("http://example.com"); diff --git a/tests/mem-leaks/test-cases/shutdown-hook-leak/src/test/java/org/glassfish/jersey/tests/memleaks/shutdownhook/ShutdownLeakResourceITCase.java b/tests/mem-leaks/test-cases/shutdown-hook-leak/src/test/java/org/glassfish/jersey/tests/memleaks/shutdownhook/ShutdownLeakResourceITCase.java index 955d5673d4..de3451ab92 100644 --- a/tests/mem-leaks/test-cases/shutdown-hook-leak/src/test/java/org/glassfish/jersey/tests/memleaks/shutdownhook/ShutdownLeakResourceITCase.java +++ b/tests/mem-leaks/test-cases/shutdown-hook-leak/src/test/java/org/glassfish/jersey/tests/memleaks/shutdownhook/ShutdownLeakResourceITCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -21,12 +21,12 @@ import org.glassfish.jersey.test.memleak.common.AbstractMemoryLeakWebAppTest; import org.glassfish.jersey.test.memleak.common.MemoryLeakSucceedingTimeout; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.InvocationInterceptor; +import org.junit.jupiter.api.extension.RegisterExtension; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.Timeout; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.fail; /** * This is an integration test that reproduces JERSEY-2786 by calling RESTful resource {@link ClientShutdownLeakResource} @@ -41,13 +41,13 @@ protected Application configure() { return new TestApplication(); } - @Rule - public Timeout globalTimeout = new MemoryLeakSucceedingTimeout(20_000); + @RegisterExtension + public InvocationInterceptor globalTimeout = new MemoryLeakSucceedingTimeout(20_000); @Test public void testTheLeakResourceOnce() { final Response response = target("client/invoke").request().post(null); - Assert.assertEquals(200, response.getStatus()); + Assertions.assertEquals(200, response.getStatus()); } @Test diff --git a/tests/osgi/functional/pom.xml b/tests/osgi/functional/pom.xml index 5b0a8893d6..117688a52a 100644 --- a/tests/osgi/functional/pom.xml +++ b/tests/osgi/functional/pom.xml @@ -382,6 +382,12 @@ jakarta.xml.bind-api test + + junit + junit + ${junit4.version} + test + diff --git a/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/AbstractJsonOsgiIntegrationTest.java b/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/AbstractJsonOsgiIntegrationTest.java index cf3f3e732d..1be5ad5a34 100644 --- a/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/AbstractJsonOsgiIntegrationTest.java +++ b/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/basic/AbstractJsonOsgiIntegrationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2022 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 @@ -34,7 +34,7 @@ import org.junit.runner.RunWith; import org.ops4j.pax.exam.junit.PaxExam; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * Abstract JSON OSGi integration test. diff --git a/tests/performance/benchmarks/src/test/java/org/glassfish/jersey/tests/performance/benchmark/server/JacksonTest.java b/tests/performance/benchmarks/src/test/java/org/glassfish/jersey/tests/performance/benchmark/server/JacksonTest.java index b611d34d46..c432ff96a2 100644 --- a/tests/performance/benchmarks/src/test/java/org/glassfish/jersey/tests/performance/benchmark/server/JacksonTest.java +++ b/tests/performance/benchmarks/src/test/java/org/glassfish/jersey/tests/performance/benchmark/server/JacksonTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.test.TestProperties; import org.glassfish.jersey.tests.performance.benchmark.entity.json.JacksonApplication; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos diff --git a/tests/performance/benchmarks/src/test/java/org/glassfish/jersey/tests/performance/benchmark/server/LocatorTest.java b/tests/performance/benchmarks/src/test/java/org/glassfish/jersey/tests/performance/benchmark/server/LocatorTest.java index ea70157b00..29ae667747 100644 --- a/tests/performance/benchmarks/src/test/java/org/glassfish/jersey/tests/performance/benchmark/server/LocatorTest.java +++ b/tests/performance/benchmarks/src/test/java/org/glassfish/jersey/tests/performance/benchmark/server/LocatorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -23,9 +23,9 @@ import org.glassfish.jersey.test.JerseyTest; import org.glassfish.jersey.test.TestProperties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.hamcrest.MatcherAssert.assertThat; /** * @author Michal Gajdos diff --git a/tests/performance/test-cases/filter-dynamic/src/test/java/org/glassfish/jersey/tests/performance/filter/dynamic/FilterTest.java b/tests/performance/test-cases/filter-dynamic/src/test/java/org/glassfish/jersey/tests/performance/filter/dynamic/FilterTest.java index 2cc9b58bc9..71a8499c34 100644 --- a/tests/performance/test-cases/filter-dynamic/src/test/java/org/glassfish/jersey/tests/performance/filter/dynamic/FilterTest.java +++ b/tests/performance/test-cases/filter-dynamic/src/test/java/org/glassfish/jersey/tests/performance/filter/dynamic/FilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for intercepted text plain resource. diff --git a/tests/performance/test-cases/filter-global/src/test/java/org/glassfish/jersey/tests/performance/filter/global/FilterTest.java b/tests/performance/test-cases/filter-global/src/test/java/org/glassfish/jersey/tests/performance/filter/global/FilterTest.java index 2580e502d1..96ebe5968a 100644 --- a/tests/performance/test-cases/filter-global/src/test/java/org/glassfish/jersey/tests/performance/filter/global/FilterTest.java +++ b/tests/performance/test-cases/filter-global/src/test/java/org/glassfish/jersey/tests/performance/filter/global/FilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for intercepted text plain resource. diff --git a/tests/performance/test-cases/filter-name/src/test/java/org/glassfish/jersey/tests/performance/filter/name/FilterTest.java b/tests/performance/test-cases/filter-name/src/test/java/org/glassfish/jersey/tests/performance/filter/name/FilterTest.java index 2f6cd37962..5ab301a89e 100644 --- a/tests/performance/test-cases/filter-name/src/test/java/org/glassfish/jersey/tests/performance/filter/name/FilterTest.java +++ b/tests/performance/test-cases/filter-name/src/test/java/org/glassfish/jersey/tests/performance/filter/name/FilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for intercepted text plain resource. diff --git a/tests/performance/test-cases/interceptor-dynamic/src/test/java/org/glassfish/jersey/tests/performance/interceptor/dynamic/InterceptorTest.java b/tests/performance/test-cases/interceptor-dynamic/src/test/java/org/glassfish/jersey/tests/performance/interceptor/dynamic/InterceptorTest.java index 14a770a7ad..6f4db87b9a 100644 --- a/tests/performance/test-cases/interceptor-dynamic/src/test/java/org/glassfish/jersey/tests/performance/interceptor/dynamic/InterceptorTest.java +++ b/tests/performance/test-cases/interceptor-dynamic/src/test/java/org/glassfish/jersey/tests/performance/interceptor/dynamic/InterceptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for intercepted text plain resource. diff --git a/tests/performance/test-cases/interceptor-global/src/test/java/org/glassfish/jersey/tests/performance/interceptor/global/InterceptorTest.java b/tests/performance/test-cases/interceptor-global/src/test/java/org/glassfish/jersey/tests/performance/interceptor/global/InterceptorTest.java index cb417c8e39..bf547041e3 100644 --- a/tests/performance/test-cases/interceptor-global/src/test/java/org/glassfish/jersey/tests/performance/interceptor/global/InterceptorTest.java +++ b/tests/performance/test-cases/interceptor-global/src/test/java/org/glassfish/jersey/tests/performance/interceptor/global/InterceptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for intercepted text plain resource. diff --git a/tests/performance/test-cases/interceptor-name/src/test/java/org/glassfish/jersey/tests/performance/interceptor/name/InterceptorTest.java b/tests/performance/test-cases/interceptor-name/src/test/java/org/glassfish/jersey/tests/performance/interceptor/name/InterceptorTest.java index a18c1b0407..25b8b7f93f 100644 --- a/tests/performance/test-cases/interceptor-name/src/test/java/org/glassfish/jersey/tests/performance/interceptor/name/InterceptorTest.java +++ b/tests/performance/test-cases/interceptor-name/src/test/java/org/glassfish/jersey/tests/performance/interceptor/name/InterceptorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for intercepted text plain resource. diff --git a/tests/performance/test-cases/mbw-custom-provider/src/test/java/org/glassfish/jersey/tests/performance/mbw/custom/PersonEntityTest.java b/tests/performance/test-cases/mbw-custom-provider/src/test/java/org/glassfish/jersey/tests/performance/mbw/custom/PersonEntityTest.java index c2044b65e0..86a5a9c0b7 100644 --- a/tests/performance/test-cases/mbw-custom-provider/src/test/java/org/glassfish/jersey/tests/performance/mbw/custom/PersonEntityTest.java +++ b/tests/performance/test-cases/mbw-custom-provider/src/test/java/org/glassfish/jersey/tests/performance/mbw/custom/PersonEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -23,8 +23,8 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test for json resource. diff --git a/tests/performance/test-cases/mbw-json-jackson/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java b/tests/performance/test-cases/mbw-json-jackson/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java index 249e367fc6..79bbdbb5af 100644 --- a/tests/performance/test-cases/mbw-json-jackson/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java +++ b/tests/performance/test-cases/mbw-json-jackson/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for json resource. diff --git a/tests/performance/test-cases/mbw-json-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java b/tests/performance/test-cases/mbw-json-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java index b01c00df0a..4279874443 100644 --- a/tests/performance/test-cases/mbw-json-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java +++ b/tests/performance/test-cases/mbw-json-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/json/JsonEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.moxy.json.MoxyJsonFeature; import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for json resource. diff --git a/tests/performance/test-cases/mbw-kryo/src/test/java/org/glassfish/jersey/tests/performance/mbw/kryo/PersonResourceTest.java b/tests/performance/test-cases/mbw-kryo/src/test/java/org/glassfish/jersey/tests/performance/mbw/kryo/PersonResourceTest.java index 7d1d1e51b8..e4cd73a37e 100644 --- a/tests/performance/test-cases/mbw-kryo/src/test/java/org/glassfish/jersey/tests/performance/mbw/kryo/PersonResourceTest.java +++ b/tests/performance/test-cases/mbw-kryo/src/test/java/org/glassfish/jersey/tests/performance/mbw/kryo/PersonResourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.kryo.KryoFeature; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test for kryo resource. diff --git a/tests/performance/test-cases/mbw-text-plain/src/test/java/org/glassfish/jersey/tests/performance/mbw/text/TextEntityTest.java b/tests/performance/test-cases/mbw-text-plain/src/test/java/org/glassfish/jersey/tests/performance/mbw/text/TextEntityTest.java index c513571988..00fcdbfa73 100644 --- a/tests/performance/test-cases/mbw-text-plain/src/test/java/org/glassfish/jersey/tests/performance/mbw/text/TextEntityTest.java +++ b/tests/performance/test-cases/mbw-text-plain/src/test/java/org/glassfish/jersey/tests/performance/mbw/text/TextEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for text plain resource. diff --git a/tests/performance/test-cases/mbw-xml-jaxb/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java b/tests/performance/test-cases/mbw-xml-jaxb/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java index 4f87ab121e..2f181180c6 100644 --- a/tests/performance/test-cases/mbw-xml-jaxb/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java +++ b/tests/performance/test-cases/mbw-xml-jaxb/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -22,8 +22,8 @@ import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for XML resource. diff --git a/tests/performance/test-cases/mbw-xml-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java b/tests/performance/test-cases/mbw-xml-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java index d1f6e5636a..03d4ac0ff6 100644 --- a/tests/performance/test-cases/mbw-xml-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java +++ b/tests/performance/test-cases/mbw-xml-moxy/src/test/java/org/glassfish/jersey/tests/performance/mbw/xml/XmlEntityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2022 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 @@ -24,8 +24,8 @@ import org.glassfish.jersey.moxy.xml.MoxyXmlFeature; import org.glassfish.jersey.test.JerseyTest; -import static org.junit.Assert.assertEquals; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; /** * Test for XML resource. diff --git a/tests/performance/test-cases/monitoring/pom.xml b/tests/performance/test-cases/monitoring/pom.xml index 9b499ffed7..c4076c2a7d 100644 --- a/tests/performance/test-cases/monitoring/pom.xml +++ b/tests/performance/test-cases/monitoring/pom.xml @@ -1,7 +1,7 @@