Merge JUnit 4 -> 5 bump into origin/3.x
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
new file mode 100644
index 0000000..ffc0492
--- /dev/null
+++ b/.github/workflows/maven.yml
@@ -0,0 +1,45 @@
+#
+# Copyright (c) 2022 Contributors to the Eclipse Foundation
+#
+# 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,
+# or the Eclipse Distribution License v. 1.0 which is available at
+# http://www.eclipse.org/org/documents/edl-v10.php.
+#
+# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
+#
+
+name: Jersey
+
+on: [push, pull_request]
+
+jobs:
+ build:
+ name: Build on JDK ${{ matrix.java_version }} with ${{matrix.test_profiles}} profile
+ runs-on: ubuntu-latest
+ env:
+ script-directory: $GITHUB_WORKSPACE/etc/jenkins
+
+ strategy:
+ matrix:
+ java_version: [ 11 ]
+ verify_profiles: [ '-Plicense_check' ]
+ continue-on-error: false
+
+ steps:
+ - name: Checkout for build
+ uses: actions/checkout@v2.3.4
+ with:
+ fetch-depth: 0
+ - name: Set up JDK
+ uses: actions/setup-java@v2
+ with:
+ distribution: 'zulu'
+ java-version: ${{ matrix.java_version }}
+ - name: configure JDK
+ run: |
+ secLoc=`find $JAVA_HOME -name java.security`
+ sed -i 's/jdk.tls.disabledAlgorithms/# jdk.tls.disabledAlgorithms/g' -i $secLoc
+ - name: Build
+ run: mvn -V -U -B ${{matrix.verify_profiles}} org.eclipse.dash:license-tool-plugin:license-check -DexcludeArtifactIds=bsh,jmh-core,jmh-generator-annprocess,swing-layout
\ No newline at end of file
diff --git a/NOTICE.md b/NOTICE.md
index 5533ac7..13bba9b 100644
--- a/NOTICE.md
+++ b/NOTICE.md
@@ -61,7 +61,7 @@
* License: Apache License, 2.0
* Copyright (C) 2009 The Guava Authors
-javax.inject Version: 1
+jakarta.inject Version: 1
* License: Apache License, 2.0
* Copyright (C) 2009 The JSR-330 Expert Group
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 f856c8c..3ed409e 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 42416bb..9dcb68b 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 @@
</dependency>
-->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <version>\${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -77,6 +77,7 @@
<properties>
<jersey.version>${project.version}</jersey.version>
+ <junit-jupiter.version>5.9.1</junit-jupiter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
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 6ae6807..0b5f5c7 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 @@
target = c.target(Main.BASE_URI);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
server.stop();
}
diff --git a/bundles/apidocs/pom.xml b/bundles/apidocs/pom.xml
index 083b14b..bb7ddb3 100644
--- a/bundles/apidocs/pom.xml
+++ b/bundles/apidocs/pom.xml
@@ -230,7 +230,7 @@
<jdk>1.8</jdk>
</activation>
<properties>
- <jetty.version>9.4.28.v20200408</jetty.version>
+ <jetty.version>${jetty9.version}</jetty.version>
</properties>
<dependencies>
<dependency>
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 b44600f..952fe83 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, 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
@@ -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 @@
}
});
- 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 d892abd..507749d 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, 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
@@ -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 @@
}
@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 @@
}
@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 d4d3c57..d94c8b3 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, 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
@@ -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 c51e895..77ff3e0 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, 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
@@ -27,7 +27,7 @@
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.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 @@
@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 c8be54d..b77564e 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, 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
@@ -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 085fd3f..830b358 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, 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
@@ -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 1aed5d7..ea04a8f 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, 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
@@ -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 f6d13ff..2c4a5b6 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, 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
@@ -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 @@
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 @@
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 5e33f6e..9c33ade 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 jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
@@ -65,8 +65,8 @@
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 @@
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 73905eb..41da2b3 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, 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
@@ -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 4c64831..c0743ef 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 db0a88f..7d6c764 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, 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
@@ -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 @@
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 8515e01..6304991 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, 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
@@ -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 2e0a35c..5be48c8 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, 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
@@ -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 f306c2f..48d0d29 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, 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
@@ -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 9c4771f..b572519 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, 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
@@ -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 @@
@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 b93f967..a8521d7 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, 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
@@ -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 f88ac29..7e05fd0 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, 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
@@ -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 57171c1..651cb16 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, 2020 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 @@
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 @@
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 1d756df..ad7771f 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, 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.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 @@
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 bcbb183..5d9704f 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, 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.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 @@
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 88edc8a..249ad82 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 @@
}
});
- 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 c39b7d1..130a2b3 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 @@
}
@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 @@
}
@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 a5ffbed..a92271e 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 8a32278..8b23445 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 jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.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 @@
@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 f9d725a..85b2408 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 ab1f655..cb8932a 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 2ed3541..d1e43fd 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 3407cbe..96114cb 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 @@
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 @@
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 7b32627..9e08aa8 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 jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
@@ -66,8 +66,8 @@
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 @@
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 8a2e91e..16e135a 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 e5dee0e..107faad 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 bd8d992..1173941 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 @@
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 f1ed320..3ab8a2a 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 e42eb53..cff230d 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 59ccdbc..234c10d 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 2171132..0007ead 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 @@
@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 4d69723..4a38280 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 f6b2d52..3dda5ec 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 4b85c23..a1fcb93 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 @@
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 @@
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 6f0938b..02a21e1 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 @@
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 6b5fc6f..b487a82 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 @@
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 73ad108..0818c7e 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, 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
@@ -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 be60e79..b987fc0 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, 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
@@ -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 e563910..e313b10 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, 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
@@ -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 2c010ed..2b8cdf2 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 9b207e6..650eea5 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 jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -30,8 +30,8 @@
import jakarta.ws.rs.core.Application;
import jakarta.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 f82474c..4e15b4e 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, 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
@@ -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 75c6dbe..1987d91 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, 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
@@ -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 @@
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 04c8977..5066426 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, 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
@@ -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 a1241e5..2a3fb44 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, 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
@@ -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 @@
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 @@
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 8e86fa5..031baaa 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, 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
@@ -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 @@
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 604a989..4370213 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 jakarta.ws.rs.GET;
import jakarta.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 7fe036d..6634678 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 jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
@@ -45,7 +46,9 @@
import jakarta.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 static List<String> 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 @@
}
}
- @Override
- protected Application configure() {
- return new ResourceConfig(BasicResource.class, AsyncResource.class)
- .property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, "WARNING");
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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 {
- @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));
+ private final String entityType;
+
+ 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<String, Object> 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 testAsyncGet() throws ExecutionException, InterruptedException {
- Future<Response> 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 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 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));
+ }
}
- 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 testRxGet() throws ExecutionException, InterruptedException {
- CompletableFuture<Response> 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));
- }
- }
-
- @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();
- }
- }
-
- // -----------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 testHeaders() {
+ String[][] headers = new String[][]{{"X-TEST-ONE", "ONE"}, {"X-TEST-TWO", "TWO"}, {"X-TEST-THREE", "THREE"}};
+ MultivaluedHashMap<String, Object> 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]));
+ }
+ }
}
- ClientConfig config = new ClientConfig();
- config.connectorProvider(new HelidonConnectorProvider());
+ @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());
+ }
- 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();
-
- Future<Response> futureLongResponse = longRequest.async().get();
- Future<Response> futureShortResponse = shortRequest.async().get();
-
- try (Response shortResponse = futureShortResponse.get()) {
- Assert.assertEquals(200, shortResponse.getStatus());
- Assert.assertEquals("short", shortResponse.readEntity(String.class));
+ 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));
+ }
}
- try (Response longResponse = futureLongResponse.get()) {
- Assert.assertEquals(200, longResponse.getStatus());
- Assert.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 testAsyncGet() throws ExecutionException, InterruptedException {
+ Future<Response> 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));
+ }
}
- Invocation.Builder longRequest = target().path("async/long").request();
- Invocation.Builder shortRequest = target().path("async/short").request();
+ @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());
+ }
- Future<Response> futureLongResponse = longRequest.async().get();
- Future<Response> futureShortResponse = shortRequest.async().get();
-
- try (Response shortResponse = futureShortResponse.get()) {
- Assert.assertEquals(200, shortResponse.getStatus());
- Assert.assertEquals("short", shortResponse.readEntity(String.class));
+ 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));
+ }
}
- try (Response longResponse = futureLongResponse.get()) {
- Assert.assertEquals(200, longResponse.getStatus());
- Assert.assertEquals("long", longResponse.readEntity(String.class));
- }
- }
+ @Test
+ public void testRxGet() throws ExecutionException, InterruptedException {
+ CompletableFuture<Response> futureResponse =
+ target("basic").path("get").request().rx(JerseyCompletionStageRxInvoker.class).get();
- @Test
- public void testOptionsWithEntity() {
- Response response = target("basic").path("get").request().build("OPTIONS", Entity.text("OPTIONS")).invoke();
- assertEquals(200, response.getStatus());
- response.close();
+ 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()) {
+ Assertions.assertEquals(200, response.getStatus());
+ InputStream is = response.readEntity(InputStream.class);
+ Assertions.assertEquals('o', is.read());
+ Assertions.assertEquals('k', is.read());
+ is.close();
+ }
+ }
+
+ // -----------Async
+
+ @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());
+
+ 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();
+
+ Future<Response> futureLongResponse = longRequest.async().get();
+ Future<Response> futureShortResponse = shortRequest.async().get();
+
+ try (Response shortResponse = futureShortResponse.get()) {
+ Assertions.assertEquals(200, shortResponse.getStatus());
+ Assertions.assertEquals("short", shortResponse.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()) {
+ Assertions.assertEquals(204, resetResponse.getStatus());
+ }
+
+ Invocation.Builder longRequest = target().path("async/long").request();
+ Invocation.Builder shortRequest = target().path("async/short").request();
+
+ Future<Response> futureLongResponse = longRequest.async().get();
+ Future<Response> futureShortResponse = shortRequest.async().get();
+
+ try (Response shortResponse = futureShortResponse.get()) {
+ Assertions.assertEquals(200, shortResponse.getStatus());
+ Assertions.assertEquals("short", shortResponse.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();
+ }
}
}
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 e2449fe..09ac4e1 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 jakarta.ws.rs.GET;
import jakarta.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/HelidonPropertiesTest.java b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/HelidonPropertiesTest.java
index a858e67..0011ca6 100644
--- a/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/HelidonPropertiesTest.java
+++ b/connectors/helidon-connector/src/test/java/org/glassfish/jersey/helidon/connector/HelidonPropertiesTest.java
@@ -17,8 +17,9 @@
package org.glassfish.jersey.helidon.connector;
import io.helidon.jersey.connector.HelidonProperties;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class HelidonPropertiesTest {
@@ -26,6 +27,6 @@
public void testHelidonStrings() {
String jerseyValue = HelidonClientProperties.CONFIG;
String helidonConfig = HelidonProperties.CONFIG;
- Assert.assertEquals(jerseyValue, helidonConfig);
+ assertEquals(jerseyValue, helidonConfig);
}
}
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 8f39529..86f1c69 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 jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
@@ -106,9 +106,8 @@
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 742e7e1..67d8682 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 jakarta.ws.rs.GET;
import jakarta.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 @@
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 67d72dc..ff3235a 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 jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -29,8 +29,8 @@
import jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
- @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 de8edd2..1ad2e15 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 jakarta.ws.rs.GET;
import jakarta.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 @@
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 @@
}
// 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 67cdc89..ca1a5c6 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
@@ -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 jakarta.annotation.PostConstruct;
import jakarta.inject.Singleton;
@@ -119,8 +119,8 @@
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 @@
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 @@
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/pom.xml b/connectors/jdk-connector/pom.xml
index 57d0421..32b2fb0 100644
--- a/connectors/jdk-connector/pom.xml
+++ b/connectors/jdk-connector/pom.xml
@@ -50,6 +50,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
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 8a1d647..109fa90 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 jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -30,8 +30,8 @@
import jakarta.ws.rs.core.Application;
import jakarta.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 3d64abe..f67aa01 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 2feea43..e936df7 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 474e9e9..a54345b 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 37a9cce..fa7b4d1 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, 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
@@ -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 4c034d1..f981f31 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 @@
.get();
// Issue 4678 happens here. HttpParser splits the headers value by comma.
List<Object> 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 304199d..869ca51 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, 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
@@ -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 f73d56f..fde3192 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, 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
@@ -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 @@
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 3dccc76..f3ed35a 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 @@
private HttpParser httpParser;
- @Before
+ @BeforeEach
public void prepare() {
httpParser = new HttpParser(1000, 1000);
}
@@ -350,7 +350,7 @@
/**
* 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 125779c..4b1ba7a 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, 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
@@ -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 ac5e267..c9fd9f5 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, 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
@@ -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 @@
.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 bad52fe..d020c09 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, 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
@@ -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 0f4fe53..80adc9c 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, 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,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 e7cce45..1e708c0 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, 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
@@ -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 e264653..701790b 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, 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
@@ -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/SslFilterTLS13Test.java b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTLS13Test.java
index aff6033..57f3528 100644
--- a/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTLS13Test.java
+++ b/connectors/jdk-connector/src/test/java/org/glassfish/jersey/jdk/connector/internal/SslFilterTLS13Test.java
@@ -20,12 +20,12 @@
import javax.net.ssl.SSLContext;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
public class SslFilterTLS13Test extends SslFilterTest {
- @BeforeClass
+ @BeforeAll
public static void setup() throws Exception {
final SSLContext context = SSLContext.getInstance("TLS");
context.init(null, null, null);
@@ -36,7 +36,7 @@
}
}
- @AfterClass
+ @AfterAll
public static void tearDown() {
System.clearProperty("jdk.tls.server.protocols");
System.clearProperty("jdk.tls.client.protocols");
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 0a9dc13..7cef70b 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/pom.xml b/connectors/jetty-connector/pom.xml
index 234e0ae..d898cc7 100644
--- a/connectors/jetty-connector/pom.xml
+++ b/connectors/jetty-connector/pom.xml
@@ -44,10 +44,22 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
@@ -130,18 +142,30 @@
<jdk>1.8</jdk>
</activation>
<properties>
- <jetty.version>9.4.28.v20200408</jetty.version>
+ <jetty.version>${jetty9.version}</jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${jetty.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
<build>
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 fc7e439..0cb1ad0 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, 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
@@ -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 1f709cf..3fb1b5f 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, 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
@@ -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 9e86168..f0bfb60 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, 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
@@ -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 28b7e51..2a49c00 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, 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
@@ -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 f3b3d9c..3f46241 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, 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
@@ -27,7 +27,7 @@
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.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 @@
@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 7b44c7d..c706a60 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, 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
@@ -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 74e147f..5b90710 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, 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
@@ -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 4e43ae5..ae1d07b 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, 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
@@ -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 610f120..1f8a7dd 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, 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
@@ -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 1d7b350..21008db 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, 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
@@ -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 e871f04..fd16bcd 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, 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
@@ -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 @@
@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 c931819..a48e555 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, 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
@@ -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 055eb09..2c0c92c 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 bd75bfa..6fcb14c 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, 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
@@ -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 0038107..ad08a64 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 jakarta.ws.rs.GET;
import jakarta.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 e1ea028..040b194 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 @@
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 bf0b9b9..ee4a2d4 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, 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
@@ -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 @@
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 @@
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 6f8d312..058bd57 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, 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,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 @@
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 724082f..b982048 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, 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
@@ -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 41cd087..df38e11 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, 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
@@ -28,7 +28,7 @@
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.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 @@
@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 6eb2d93..f675270 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 c0ca937..93fd9f8 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 bf9ad69..2eb3658 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 0ee9fae..49fccc2 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, 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
@@ -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 85e395f..53818f2 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 57ddf6e..bda9e18 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, 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,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 128c377..1b784bf 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, 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,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 @@
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 0b0813a..42f948d 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 8721921..268b08b 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, 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
@@ -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 @@
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 @@
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 4721017..a3e14db 100644
--- a/connectors/pom.xml
+++ b/connectors/pom.xml
@@ -61,8 +61,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpServerTest.java b/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpServerTest.java
index 5fb5e08..812b480 100644
--- a/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpServerTest.java
+++ b/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/GrizzlyHttpServerTest.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -26,15 +27,15 @@
import org.glassfish.jersey.grizzly2.httpserver.test.tools.ClientThread.ClientThreadSettings;
import org.glassfish.jersey.grizzly2.httpserver.test.tools.JdkHttpClientThread;
import org.glassfish.jersey.grizzly2.httpserver.test.tools.ServerManager;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
-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;
/**
@@ -57,10 +58,7 @@
private AtomicInteger counter;
private ServerManager server;
- @Rule
- public TestName testName = new TestName();
-
- @BeforeClass
+ @BeforeAll
public static void printSettings() {
System.out.println("Client implementation: " + CLIENT_IMPLEMENTATION);
System.out.println("Count of clients: " + COUNT_OF_CLIENTS);
@@ -68,16 +66,16 @@
}
- @Before
+ @BeforeEach
public void init() {
this.counter = new AtomicInteger();
}
- @After
- public void cleanup() {
+ @AfterEach
+ public void cleanup(TestInfo testInfo) {
error = null;
- System.out.println(String.format("Server processed %s requests of test %s.", counter, testName.getMethodName()));
+ System.out.println(String.format("Server processed %s requests of test %s.", counter, testInfo.getDisplayName()));
if (server != null) {
server.close();
}
@@ -120,9 +118,11 @@
*
* @throws Throwable
*/
- @Test(expected = IllegalArgumentException.class)
- public void http2() throws Throwable {
- this.server = new ServerManager(false, true);
+ @Test
+ public void http2() {
+ Assertions.assertThrows(IllegalArgumentException.class,
+ () ->
+ this.server = new ServerManager(false, true));
}
@@ -159,7 +159,7 @@
if (error.get() != null) {
throw error.get();
}
- assertTrue("No requests processed.", counter.get() > 0);
+ assertTrue(counter.get() > 0, "No requests processed.");
}
@@ -177,7 +177,7 @@
final Class<ClientThread> clazz = (Class<ClientThread>) Class.forName(CLIENT_IMPLEMENTATION);
final Constructor<ClientThread> constructor = clazz.getConstructor(ClientThreadSettings.class,
AtomicInteger.class, AtomicReference.class);
- assertNotNull("constructor for " + CLIENT_IMPLEMENTATION, constructor);
+ assertNotNull(constructor, "constructor for " + CLIENT_IMPLEMENTATION);
final ClientThreadSettings settings = new ClientThreadSettings(id, secured, useHttp2,
server.getApplicationServiceEndpoint());
return constructor.newInstance(settings, counter, error);
diff --git a/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JdkHttpClientThread.java b/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JdkHttpClientThread.java
index 8e9d543..58ea74a 100644
--- a/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JdkHttpClientThread.java
+++ b/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JdkHttpClientThread.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -27,7 +28,7 @@
import jakarta.ws.rs.core.MediaType;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* JDK11+ has it's own {@link HttpClient} implementation supporting both HTTP 1.1 and HTTP/2.
diff --git a/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JerseyHttpClientThread.java b/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JerseyHttpClientThread.java
index 0edb6b8..385c479 100644
--- a/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JerseyHttpClientThread.java
+++ b/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JerseyHttpClientThread.java
@@ -28,7 +28,7 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.Response;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Jersey doesn't support HTTP/2 at this moment, but this class may be extended later.
diff --git a/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JettyHttpClientThread.java b/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JettyHttpClientThread.java
index 171d534..6a09e52 100644
--- a/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JettyHttpClientThread.java
+++ b/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JettyHttpClientThread.java
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 Payara Foundation and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
@@ -27,7 +28,7 @@
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Jetty {@link HttpClient} supports both HTTP 1.1 and HTTP/2.
diff --git a/containers/jdk-http/pom.xml b/containers/jdk-http/pom.xml
index c9d9559..a1473b5 100644
--- a/containers/jdk-http/pom.xml
+++ b/containers/jdk-http/pom.xml
@@ -39,6 +39,11 @@
<scope>test</scope>
<version>${commons.io.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
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 c7cd54b..4f769f2 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, 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
@@ -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 @@
}
}
- @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 db63b5f..aebd902 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, 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,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 @@
}
}
- @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 f6b58b3..cd5c821 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, 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
@@ -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 1185b81..0ad2944 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 @@
* 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 @@
* 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));
+ 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();
- }
+ // 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 @@
* 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();
+ 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();
- }
+ 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 @@
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 efad451..2409946 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, 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
@@ -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 @@
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 2313766..7c8a05c 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, 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
@@ -28,9 +28,9 @@
import jakarta.ws.rs.core.UriBuilder;
import jakarta.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 dc04527..b447180 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 @@
@Override
public Value<Integer> 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 b4476fc..b69603d 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 62a849c..51c093f 100644
--- a/containers/jetty-http/pom.xml
+++ b/containers/jetty-http/pom.xml
@@ -45,9 +45,18 @@
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-jakarta-servlet-api</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${servlet5.version}</version>
@@ -56,12 +65,23 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -113,18 +133,30 @@
<jdk>1.8</jdk>
</activation>
<properties>
- <jetty.version>9.4.28.v20200408</jetty.version>
+ <jetty.version>${jetty9.version}</jetty.version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${jetty.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
<build>
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 32ffbcd..1d7cac2 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, 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
@@ -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 @@
}
}
- @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 0a393cb..808e2ea 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, 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
@@ -31,12 +31,12 @@
import jakarta.ws.rs.container.TimeoutHandler;
import jakarta.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 @@
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 bfe462c..4d7c43e 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 jakarta.ws.rs.GET;
import jakarta.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 40add85..90a0e66 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -29,9 +29,9 @@
import jakarta.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 @@
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 0925cc9..1580a0a 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, 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
@@ -16,7 +16,7 @@
package org.glassfish.jersey.jetty;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -25,8 +25,8 @@
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.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/jetty-servlet/pom.xml b/containers/jetty-servlet/pom.xml
index ef1cff9..f42e7b3 100644
--- a/containers/jetty-servlet/pom.xml
+++ b/containers/jetty-servlet/pom.xml
@@ -81,7 +81,7 @@
<java8.sourceDirectory>${project.basedir}/src/main/java8</java8.sourceDirectory>
<java11.build.outputDirectory>${project.basedir}/target11</java11.build.outputDirectory>
<java11.sourceDirectory>${project.basedir}/src/main/java11</java11.sourceDirectory>
- <jetty.javax.version>9.4.28.v20200408</jetty.javax.version>
+ <jetty.javax.version>${jetty9.version}</jetty.javax.version>
</properties>
<profiles>
@@ -107,6 +107,10 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -162,6 +166,12 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
diff --git a/containers/pom.xml b/containers/pom.xml
index d1d9d1f..a83b270 100644
--- a/containers/pom.xml
+++ b/containers/pom.xml
@@ -61,11 +61,17 @@
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/containers/simple-http/pom.xml b/containers/simple-http/pom.xml
index 442093f..1bbbee0 100644
--- a/containers/simple-http/pom.xml
+++ b/containers/simple-http/pom.xml
@@ -49,6 +49,11 @@
<groupId>org.simpleframework</groupId>
<artifactId>simple-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
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 3df302e..d36c54f 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, 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
@@ -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 @@
}
}
- @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 1fcd788..5faf09b 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, 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
@@ -31,12 +31,12 @@
import jakarta.ws.rs.container.TimeoutHandler;
import jakarta.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 @@
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 cc4e5b2..7672d3f 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, 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
@@ -25,8 +25,8 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.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 03be7d8..c99e3b1 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, 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,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 @@
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 6856b93..a93d872 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, 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
@@ -23,13 +23,13 @@
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.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 @@
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 6e9e27d..d328fc1 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, 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
@@ -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 17346a8..46a669c 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, 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
@@ -23,13 +23,13 @@
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.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 @@
private Client client;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
startServerNoLoggingFilter(HelloWorldResource.class, UserResource.class); // disable crude
// LoggingFilter
@@ -66,7 +66,7 @@
}
@Override
- @After
+ @AfterEach
public void tearDown() {
super.tearDown();
client = null;
diff --git a/core-client/pom.xml b/core-client/pom.xml
index e9a5124..348f3e2 100644
--- a/core-client/pom.xml
+++ b/core-client/pom.xml
@@ -127,8 +127,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
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 e158a07..d228409 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, 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
@@ -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 @@
* {@link jakarta.ws.rs.core.Feature} will be notified when {@link jakarta.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 @@
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 8f301f2..8ab88e7 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, 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
@@ -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 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 @@
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 b432d91..a877f69 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 @@
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 @@
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 @@
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 54726cd..4a151c7 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 jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.ClientRequestFilter;
@@ -37,27 +37,27 @@
}
};
- 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 8efd74c..5ffc940 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 @@
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 @@
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 @@
// 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 @@
.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 @@
.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 @@
.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 @@
.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 86f2736..ea039b7 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, 2020 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 d0ef2bd..973637b 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 16b956f..326a3f4 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 936d6a4..1c8f0b4 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 7a00f1f..4199f4f 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 @@
* 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 @@
* 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 @@
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 f56bc26..1d1583b 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 jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
@@ -27,8 +27,8 @@
import jakarta.ws.rs.core.FeatureContext;
import jakarta.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 31211b2..c79ce08 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, 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
@@ -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 jakarta.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 @@
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 @@
assertNull(contracts);
}
- @Test(expected = Test.None.class) //no exception shall be thrown
+ @Test
public void testRegisterIrrelevantImmutableContractsMap() {
final ClientBuilder clientBuilder = ClientBuilder.newBuilder();
final Map<Class<?>, Integer> contracts = new HashMap<>();
@@ -251,17 +248,19 @@
@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 58ac48d..05ac6ea 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, 2020 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 JerseyClientTest() {
}
- @Before
+ @BeforeEach
public void setUp() {
this.client = (JerseyClient) ClientBuilder.newClient();
}
- @After
+ @AfterEach
public void tearDown() {
}
@@ -114,9 +115,9 @@
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 c898ae0..b55f9e8 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, 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
@@ -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 @@
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 @@
.build());
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
executor.shutdown();
client.close();
@@ -70,7 +71,7 @@
}
@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 @@
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
- // jakarta.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
+ // jakarta.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<String>() {
- })
- .toCompletableFuture()
- .get();
- } catch (final Exception expected) {
- // java.util.concurrent.ExecutionException
- throw expected
- // jakarta.ws.rs.NotFoundException
- .getCause();
- }
+ Assertions.assertThrows(NotFoundException.class, () ->{
+ try {
+ client.target("http://jersey.java.net")
+ .request()
+ .header("Response-Status", 404)
+ .rx()
+ .get(new GenericType<String>() {
+ })
+ .toCompletableFuture()
+ .get();
+ } catch (final Exception expected) {
+ // java.util.concurrent.ExecutionException
+ throw expected
+ // jakarta.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 de3531a..c8058c3 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, 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,14 +43,14 @@
import jakarta.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 @@
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 152835d..ad16237 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, 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
@@ -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 @@
private JerseyClient client;
private JerseyWebTarget target;
- @Before
+ @BeforeEach
public void setUp() {
this.client = (JerseyClient) ClientBuilder.newClient();
this.target = client.target("/");
@@ -377,46 +378,58 @@
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 e7d4026..baa10df 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, 2020 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 jakarta.ws.rs.client.Entity;
import jakarta.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 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 d18f7e9..6cd2360 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, 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,10 +24,10 @@
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.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 b3e9c9a..abc7d1a 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, 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
@@ -20,9 +20,9 @@
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.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 284e87c..b7a80b6 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 @@
"basic toto=\"tutu\""
}));
- Assert.assertNull(ds);
+ Assertions.assertNull(ds);
}
@Test
@@ -55,9 +55,9 @@
"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 @@
"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 @@
" 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 @@
" 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 344879a..3900e5d 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, 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
@@ -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 579f3f3..b4b830f 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, 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
@@ -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 6187afa..23b737d 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, 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
@@ -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 @@
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 @@
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 38857ec..a2a65b2 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, 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
@@ -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 459ae85..9282586 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, 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
@@ -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 0107975..b11eb3a 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 jakarta.annotation.Priority;
import jakarta.ws.rs.Priorities;
@@ -55,7 +55,7 @@
@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 44e03c9..ef45853 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, 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
@@ -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 jakarta.annotation.Priority;
import jakarta.ws.rs.client.ClientBuilder;
@@ -48,7 +49,7 @@
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 @@
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 @@
}
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 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 @@
)
);
- 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 8195e6b..e69267d 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 jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.ClientBuilder;
@@ -44,7 +44,7 @@
private AtomicInteger counter;
- @Before
+ @BeforeEach
public void setup() {
counter = new AtomicInteger();
}
@@ -55,10 +55,10 @@
.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 @@
}))
.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 @@
}))
.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 @@
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 @@
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 @@
200)
.build().target(URL).request();
try (Response response = builder.get()) {
- Assert.fail();
+ Assertions.fail();
} catch (IllegalStateException pe) {
// expected
}
@@ -189,9 +189,9 @@
(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 @@
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 @@
.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 @@
}))
.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 @@
.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 @@
@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 @@
@Override
public void afterRequest(ClientRequestContext requestContext, ClientResponseContext responseContext) {
- Assert.assertTrue(afterRequest.test(requestContext, responseContext));
+ Assertions.assertTrue(afterRequest.test(requestContext, responseContext));
counter.getAndIncrement();
}
@Override
public void onException(ClientRequestContext requestContext, ExceptionContext exceptionContext) {
- Assert.assertTrue(onException.test(requestContext, exceptionContext));
+ Assertions.assertTrue(onException.test(requestContext, exceptionContext));
counter.addAndGet(1000);
}
}
@@ -317,7 +317,7 @@
@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 2fe5548..2df0307 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 jakarta.annotation.Priority;
import jakarta.ws.rs.ProcessingException;
@@ -43,7 +43,7 @@
private AtomicInteger counter;
- @Before
+ @BeforeEach
public void setup() {
counter = new AtomicInteger();
}
@@ -55,7 +55,7 @@
.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 @@
.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 @@
.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 @@
.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 @@
.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 @@
.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 @@
.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 @@
.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 @@
.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 @@
.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 @@
.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 @@
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
- Assert.assertTrue(consumer.test(counter));
+ Assertions.assertTrue(consumer.test(counter));
counter.getAndIncrement();
}
}
@@ -231,7 +231,7 @@
@Override
public void beforeRequest(ClientRequestContext requestContext) {
- Assert.assertTrue(predicate.test(counter));
+ Assertions.assertTrue(predicate.test(counter));
counter.getAndIncrement();
}
}
@@ -245,7 +245,7 @@
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
- Assert.assertTrue(predicate.test(requestContext));
+ Assertions.assertTrue(predicate.test(requestContext));
}
}
@@ -258,7 +258,7 @@
@Override
public void beforeRequest(ClientRequestContext requestContext) {
- Assert.assertTrue(predicate.test(requestContext));
+ Assertions.assertTrue(predicate.test(requestContext));
}
}
@@ -268,8 +268,8 @@
@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 b6282d3..725c4e6 100644
--- a/core-common/pom.xml
+++ b/core-common/pom.xml
@@ -172,6 +172,29 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <configuration>
+ <excludes>
+ <exclude>**/ByteBufferInputStreamTest.java</exclude>
+ </excludes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>tests-with-additional-permissions</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <argLine>-Djava.security.policy=${project.build.directory}/test-classes/surefire-jdk17.policy</argLine>
+ <includes>
+ <include>**/ByteBufferInputStreamTest.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
<configuration>
<!-- Execute test classes in parallel - 1 thread per CPU core. -->
<parallel>classesAndMethods</parallel>
@@ -212,8 +235,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 cfae326..4c90296 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 @@
*/
@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 821b62c..55884e1 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, 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
@@ -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 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 1cc853e..09a8581 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 @@
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 @@
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 b09804a..c514c0b 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, 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
@@ -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 jakarta.ws.rs.RuntimeType;
import java.util.HashMap;
@@ -55,11 +55,11 @@
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 @@
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 f6e6758..6f1f7b1 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 @@
/**
* 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 @@
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 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 @@
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 b86833c..1581f98 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, 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
@@ -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 b4147cd..2372607 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, 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
@@ -24,10 +24,10 @@
import jakarta.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 06a97ad..3a0557c 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 @@
@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 b083ad9..2878f79 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 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 @@
+ "/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 423ab0a..47781d5 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 b0e8c4d..306a760 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<Object[]> provideVersions() {
- return Arrays.asList(new Object[][]{
+ public static Stream<Arguments> 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 029da42..e951692 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, 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
@@ -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}.
@@ -165,28 +165,6 @@
assertFalse(deadSubscriber.isCompleted());
}
- @Test
- public void testCascadingClose() throws InterruptedException {
- final CountDownLatch openLatch = new CountDownLatch(1);
- final CountDownLatch writeLatch = new CountDownLatch(1);
- final CountDownLatch closeLatch = new CountDownLatch(1);
-
- final JerseyPublisher<String> publisher =
- new JerseyPublisher<>(JerseyPublisher.PublisherStrategy.BLOCKING);
- final PublisherTestSubscriber subscriber =
- new PublisherTestSubscriber("SUBSCRIBER", openLatch, writeLatch, closeLatch);
- publisher.subscribe(subscriber);
- assertTrue(openLatch.await(200, TimeUnit.MILLISECONDS));
-
- subscriber.receive(1);
- publisher.publish("Zero");
- assertTrue(writeLatch.await(1000, TimeUnit.MILLISECONDS));
-
- publisher.close(false); // must not call onComplete()
- Thread.sleep(10000);
- assertFalse(subscriber.isCompleted());
- }
-
class PublisherTestSubscriber implements Flow.Subscriber<String> {
private final String name;
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 fe3de0c..f71f9b4 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 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 827505e..67df369 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 jakarta.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 edeef20..8074527 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 @@
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 02ba36a..d0f51fd 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 fa008dd..6faf736 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 b5fbeba..6890b02 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 @@
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 @@
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 @@
}
}
- 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 @@
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 @@
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 @@
}
}
- 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 @@
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 @@
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 @@
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 @@
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 9d71c1d..fcafac5 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 48000b0..9e8ec18 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 11bb457..c7be09d 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 3cd15cb..39773c6 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 jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.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 796faec..ed4d5dc 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 11a3a97..161b9b1 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 880c42b..e7e58ca 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, 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
@@ -35,7 +35,7 @@
import jakarta.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 43d81bc..d453668 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 9c5a132..052ab28 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 cb6587c..16e7935 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, 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
@@ -27,10 +27,10 @@
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.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 111c7dd..dd79bd3 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, 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
@@ -27,10 +27,10 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.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 f8be769..bb82964 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 @@
_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 cffeaa0..2ce4d80 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, 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
@@ -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 @@
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 @@
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 1856c92..3cf9bac 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<Object[]> 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<Arguments> 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<String, String> result;
+ @ParameterizedTest
+ @MethodSource("data")
+ public void testEnhanceWithQualityParameter(Locale locale) {
+ try {
+ Locale.setDefault(locale);
+ Map<String, String> 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<String, String> parameters;
+ Map<String, String> 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 f855dcb..ec4421b 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, 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
@@ -21,10 +21,10 @@
import jakarta.ws.rs.core.Response.Status.Family;
import jakarta.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 0b1627d..dc9fc02 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 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 e6baf4c..55976fe 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 @@
} 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 f8e253c..77e70d5 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, 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
@@ -22,9 +22,9 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.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 25e82fa..3cf996d 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, 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
@@ -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 e876ae2..460db0e 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 @@
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 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 @@
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 @@
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 35853f8..0c205bf 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, 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,9 +21,9 @@
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.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 e696602..7826506 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 @@
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 @@
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 @@
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 @@
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 @@
final String uri = tmpl.createURI(values);
assertEquals(
- "query string is set",
"/test",
- uri
+ uri,
+ "query string is set"
);
}
@@ -571,9 +571,9 @@
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 @@
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 @@
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 @@
final String uri = tmpl.createURI(values);
assertEquals(
- "query string is set",
"/test/other",
- uri
+ uri,
+ "query string is set"
);
}
@@ -700,17 +700,17 @@
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<String, ?> 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 @@
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<String, ?> 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 4822e4a..ec9bc99 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 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 0000000..a960a3d
--- /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 5eaea68..5ad4e4d 100644
--- a/core-server/pom.xml
+++ b/core-server/pom.xml
@@ -220,8 +220,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 d35b356..7177420 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, 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
@@ -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 c14dbe3..8be58b4 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, 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
@@ -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 @@
/**
* 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 697b119..dbdfef7 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, 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
@@ -23,7 +23,7 @@
import jakarta.ws.rs.Path;
import jakarta.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 9fa40f5..1974aca 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, 2020 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 @@
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 ad7b02b..732c0d7 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, 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
@@ -35,11 +35,11 @@
import jakarta.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 @@
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 @@
} catch (Exception e) {
// ok - should throw an exception
}
- assertTrue("onError().", flags.onCompletionCalledWithError);
+ assertTrue(flags.onCompletionCalledWithError, "onError().");
}
@Test
@@ -117,8 +117,8 @@
@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 @@
@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 1d1973a..84f74c7 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, 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
@@ -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 d78ee38..499ecef 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, 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
@@ -33,11 +33,12 @@
import jakarta.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 @@
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 d3ce619..86c12f9 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, 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
@@ -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 1ac3403..194898d 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 jakarta.ws.rs.container.DynamicFeature;
import jakarta.ws.rs.container.ResourceInfo;
@@ -47,8 +47,8 @@
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 @@
.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 ee78313..379e47f 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, 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
@@ -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/ResourceConfigTest.java b/core-server/src/test/java/org/glassfish/jersey/server/ResourceConfigTest.java
index 24682c0..ec88461 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, 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
@@ -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 @@
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 eea5fc9..67653da 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, 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
@@ -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 c611b1b..6533a7b 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, 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
@@ -28,10 +28,10 @@
import jakarta.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 f30e6fb..b5f18e5 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 @@
*/
@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 643ce59..4d4b298 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, 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
@@ -23,8 +23,8 @@
import jakarta.ws.rs.core.Context;
import jakarta.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 4031d21..8e12d53 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, 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
@@ -23,8 +23,8 @@
import jakarta.ws.rs.core.Context;
import jakarta.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 220a72f..d301bcf 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, 2020 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 @@
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 @@
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 @@
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 @@
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 b16757e..457f1b6 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, 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
@@ -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 f7b7832..7f26ec3 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, 2020 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 @@
}
}
- @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 9e47b57..1d8b4b5 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, 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
@@ -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 jakarta.ws.rs.WebApplicationException;
import jakarta.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 442c17c..952bfed 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, 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
@@ -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 802bb49..ad50f9b 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, 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
@@ -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 7a362fe..0cdfe36 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, 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
@@ -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 57367ab..ab35ec3 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, 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
@@ -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 static class FilterTwo implements ContainerRequestFilter, ContainerResponseFilter {
public void filter(ContainerRequestContext requestContext) throws IOException {
List<String> 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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 f87d9f8..9a1680e 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, 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
@@ -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 @@
}
}
- @Before
+ @BeforeEach
public void setUp() {
Map<String, MediaType> 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 4f4c86d..e50df63 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, 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
@@ -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 e339d4c..194d9fe 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, 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
@@ -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 @@
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 d86017e..acda391 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 d66a999..c8c346c 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, 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
@@ -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 5a49cbb..3b81936 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, 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
@@ -19,9 +19,9 @@
import jakarta.ws.rs.core.Application;
import jakarta.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 1acc946..b70c4ba 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 f6ba9cc..ea77ed4 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, 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
@@ -27,7 +27,7 @@
import jakarta.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 34d90d9..3686bfd 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 5fbd7ae..780a906 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, 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
@@ -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 2e5bb8d..436ef49 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, 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
@@ -24,9 +24,9 @@
import jakarta.ws.rs.PathParam;
import jakarta.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 26fea60..cbb2e40 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, 2020 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 jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.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<String[]> 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<Arguments> 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<ContainerRequestContext, Response> {
@@ -112,7 +101,7 @@
private ApplicationHandler app;
- @Before
+ @BeforeEach
public void setupApplication() {
ResourceConfig rc = new ResourceConfig();
@@ -128,8 +117,9 @@
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 9617215..6508650 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, 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
@@ -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 224f8f7..020a13a 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, 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
@@ -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 c60eed1..94d4142 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, 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
@@ -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 35df417..07e8200 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, 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
@@ -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 c0acc07..8658594 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, 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
@@ -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 39aa570..34f29d6 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, 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
@@ -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 69b719d..32f2dc5 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, 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
@@ -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 c677b07..c7fe147 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, 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
@@ -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 c328eca..5dde66d 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, 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
@@ -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 fe9938f..b7b8a18 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, 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
@@ -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 2dbc762..d8d4c8c 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, 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
@@ -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 a2c2949..596fbff 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, 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
@@ -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 326d1df..ddb1797 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, 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
@@ -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 bbd4e48..41019d0 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, 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
@@ -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 2ab513f..1f14c63 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.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 5cd8568..b1f1ff8 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 @@
final ParamConverter<Date> 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 6233fd6..fa81bb8 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, 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
@@ -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 400d810..3d8f612 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, 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
@@ -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 9f71219..4256e14 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, 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
@@ -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 c65383c..163ce0a 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, 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
@@ -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 8758606..0f8665e 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, 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
@@ -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 a8caf00..83d71ea 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, 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,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 a1207a2..de0381b 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, 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
@@ -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 1e7b47c..ac286b2 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, 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
@@ -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 f04a8ed..c312002 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, 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
@@ -25,9 +25,9 @@
import jakarta.ws.rs.Produces;
import jakarta.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 86a792b..5124c33 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, 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
@@ -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 3b5d009..5d3ac29 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, 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
@@ -25,9 +25,9 @@
import jakarta.ws.rs.Produces;
import jakarta.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 444191c..10264b4 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, 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
@@ -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 dd02517..8412f24 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, 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
@@ -22,8 +22,8 @@
import jakarta.ws.rs.Path;
import jakarta.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 bb3c1ba..9f983f2 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, 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
@@ -23,8 +23,8 @@
import jakarta.ws.rs.Path;
import jakarta.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 df5620e..d8a73d8 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, 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
@@ -25,9 +25,9 @@
import jakarta.ws.rs.Path;
import jakarta.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 7404768..353c9fa 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, 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
@@ -25,9 +25,9 @@
import jakarta.ws.rs.Path;
import jakarta.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 490a363..d665397 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, 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
@@ -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 156d311..dd402a2 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, 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
@@ -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 abdc102..9147d5c 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 @@
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 3dd917e..07a735b 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 @@
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 fe0d5c6..989bff1 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, 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
@@ -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 @@
final MonitoringStatisticsImpl stats = getSimpleStats();
final Set<String> keys = stats.getUriStatistics().keySet();
final Iterator<String> 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 @@
final Set<Class<?>> keys = stats.getResourceClassStatistics().keySet();
final Iterator<Class<?>> 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 @@
final Set<Class<?>> keys = stats.getResourceClassStatistics().keySet();
final Iterator<Class<?>> 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 @@
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 @@
private void check(Iterator<Map.Entry<String, ResourceStatistics>> it,
String expectedUri, int expectedMethods) {
Map.Entry<String, ResourceStatistics> 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 1b637fe..a9419a5 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, 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
@@ -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 @@
@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 f983204..58e3943 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 @@
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 ebec4db..696b1e8 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 fc02ae7..c6f42d7 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 d8f9a8c..c4ac193 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 @@
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 35e0c3d..e7ea1e8 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, 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
@@ -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 6f76785..84b5269 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, 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
@@ -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 36ee3ef..30cf738 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, 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
@@ -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
@@ -81,8 +81,7 @@
final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
final ContainerResponse response = applicationHandler.apply(
- RequestContextBuilder.from("/resource/subresource/sub", "POST")
- .type("text/plain").header("Accept", "text/plain").build()).get();
+ RequestContextBuilder.from("/resource/subresource/sub", "POST").header("Accept", "text/plain").build()).get();
assertThat(response.getStatus(), equalTo(200));
assertThat(response.getHeaderString("Content-Type"), equalTo("text/plain"));
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 efe1e4f..c09ff52 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, 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
@@ -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 @@
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 d485dd9..0a5a01e 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, 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
@@ -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 @@
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 a741efd..d39d719 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, 2020 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 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 5315f69..ae7e072 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 @@
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 @@
@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 @@
*
* @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 ef817be..d9afad4 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 2bad207..f9463e8 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 @@
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, "jakarta/ws/r", recursive);
- assertFalse("Unexpectedly found package 'jakarta.ws.r' in jakarta.ws.rs-api", jarFileScanner.hasNext());
+ assertFalse(jarFileScanner.hasNext(), "Unexpectedly found package 'jakarta.ws.r' in jakarta.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, "jakarta/ws/rs/GE", recursive);
- assertFalse("Unexpectedly found package 'jakarta.ws.rs.GE' in jakarta.ws.rs-api", jarFileScanner.hasNext());
+ assertFalse(jarFileScanner.hasNext(), "Unexpectedly found package 'jakarta.ws.rs.GE' in jakarta.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 11305b0..903f150 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, 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
@@ -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 @@
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 0c0090d..7595dc7 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 @@
@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 e18d5ed..dcfe76d 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, 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
@@ -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 78bb54b..56712a2 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
// 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 @@
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 dc192cf..a586712 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 e1605f1..d80e2cc 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, 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
@@ -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 202f5e8..c8acd9b 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 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 @@
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<String> methods = Arrays.asList(containerResponse.getEntity().toString().split(", "));
assertThat(methods, hasItems("POST", "GET", "OPTIONS", "HEAD"));
@@ -277,8 +277,8 @@
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 @@
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<String> methods = Arrays.asList(containerResponse.getEntity().toString().split(", "));
assertThat(methods, hasItems("PUT", "GET", "OPTIONS", "HEAD"));
@@ -300,7 +300,7 @@
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 5e7d591..0ccab0c 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, 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
@@ -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 7d5d7ef..af63f98 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, 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
@@ -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.
@@ -87,11 +87,11 @@
ContainerResponse response;
// making sure the JVM optimization does not swap the order of the calls.
synchronized (this) {
- app.apply(RequestContextBuilder.from("/", "POST").type(foo).entity("Foo").build());
+ app.apply(RequestContextBuilder.from("/", "POST").entity("Foo").build());
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 86ddbf6..bb84534 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, 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
@@ -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 bd4cf3c..2584acf 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, 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
@@ -32,8 +32,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;
/**
* 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 26c306c..fd064f2 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, 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,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 e77857d..fe698a5 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, 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
@@ -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 @@
@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 e893f18..43a389c 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, 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
@@ -24,8 +24,8 @@
import jakarta.ws.rs.POST;
import jakarta.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 a48a75c..94587e9 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, 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
@@ -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 124cd60..24fb867 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, 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
@@ -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 48d5eed..58e3de4 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, 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
@@ -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 5934f4a..b618c59 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 16f7aeb..3419166 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, 2020 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 ecd2f2f..6cbe808 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, 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
@@ -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 efb4e41..02a297b 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
@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 @@
@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 @@
@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 @@
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 @@
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<String> strings = response.getStringHeaders().get(HttpHeaders.ALLOW);
for (String allow : strings) {
- Assert.assertFalse(allow.contains("HEAD"));
+ Assertions.assertFalse(allow.contains("HEAD"));
}
}
@@ -301,9 +301,9 @@
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 @@
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 1519588..a66a601 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, 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
@@ -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 229051e..fab6521 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, 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
@@ -23,8 +23,8 @@
import jakarta.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 @@
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 00c766d..29166f6 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, 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
@@ -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 @@
}
// FIXME
- @Ignore
+ @Disabled
@Test
public void testPathErrors() {
List<ResourceModelIssue> issues = initiateWebApplication(PathErrorsResource.class);
@@ -92,7 +92,7 @@
}
@Test
- @Ignore
+ @Disabled
// TODO add cross-resource validation & un-ignore the test
public void testConflictingRootResourceErrors() {
ResourceConfig resourceConfig = new ResourceConfig(
@@ -105,7 +105,7 @@
}
@Test
- @Ignore
+ @Disabled
// TODO add cross-resource validation & un-ignore the test
public void testConflictingRootResourceErrors2() {
ResourceConfig resourceConfig = new ResourceConfig();
@@ -397,7 +397,7 @@
}
// FIXME: trailing slashes should not matter
- @Ignore
+ @Disabled
@Test
public void testAmbiguousSubResourceLocatorsWithSlashResource() {
final List<ResourceModelIssue> 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 a850d5f..b056734 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, 2020 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 336aa91..5d8dcee 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, 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
@@ -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 2c8d503..bd66231 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, 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
@@ -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 1c62eb1..92e63df 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, 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
@@ -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 3047d07..f9fbdc5 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, 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
@@ -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 4c334f8..cdf7e35 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, 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
@@ -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 10e130d..7ba753b 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 a361130..631e95e 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, 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,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 cec264e..958a01a 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, 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
@@ -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 4d875d2..2cd92b5 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, 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
@@ -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 b39d399..17062b8 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, 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
@@ -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 b499cfb..7cb8d40 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, 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,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 ade7f0c..f342ba0 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, 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
@@ -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 aced9f9..bdd2ac6 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, 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
@@ -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 59a1977..dcf8b32 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, 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
@@ -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 @@
}
@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 @@
}
@Test
- @Ignore
+ @Disabled
// TODO: need to add validation to detect ambiguous problems of ResourceSubPathRoot and two other resources.
public void testTwoOverlappingSubResourceValidation() throws Exception {
List<ResourceModelIssue> issues = testResourceValidation(ResourceRoot.class, ResourceSubPathRoot.class);
@@ -1022,7 +1022,7 @@
}
@Test
- @Ignore
+ @Disabled
public void testTwoOverlappingResourceValidation() throws Exception {
List<ResourceModelIssue> 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 6b01f4e..a2c5b47 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, 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
@@ -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 454f139..bbf8345 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, 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
@@ -22,8 +22,8 @@
import jakarta.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 @@
@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 @@
}
});
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 4855bf9..35c83be 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, 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
@@ -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 @@
private ResourceMethodDispatcherFactory rmdf;
private ResourceMethodInvocationHandlerFactory rmihf;
- @Before
+ @BeforeEach
public void setupApplication() {
TestInjectionManagerFactory.BootstrapResult result = TestInjectionManagerFactory.createInjectionManager();
@@ -73,8 +73,8 @@
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 7c2ae7c..0b28702 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, 2020 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 @@
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 @@
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 e882ce8..b8ba55c 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 41d237c..3a28c2a 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, 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
@@ -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 @@
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 @@
.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 @@
.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 @@
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 @@
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 ee1169f..25ca25a 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, 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
@@ -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 @@
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 @@
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 bf9dd65..85589d3 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
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 ebde234..5ad8577 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, 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
@@ -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/custom-di.xml b/docs/src/main/docbook/custom-di.xml
index 6b0f83a..6e83b52 100644
--- a/docs/src/main/docbook/custom-di.xml
+++ b/docs/src/main/docbook/custom-di.xml
@@ -245,7 +245,7 @@
<programlisting language="java">import jakarta.inject.Inject;
import jakarta.inject.Named;
-import javax.servlet.http.HttpSession;
+import jakarta.servlet.http.HttpSession;
import org.glassfish.hk2.api.InjectionResolver;
import org.glassfish.hk2.api.ServiceHandle;
@@ -393,8 +393,8 @@
<programlisting language="java">import jakarta.inject.Inject;
import jakarta.inject.Provider;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpSession;
...
import org.glassfish.hk2.api.DynamicConfiguration;
import org.glassfish.hk2.api.DynamicConfigurationService;
diff --git a/docs/src/main/docbook/getting-started.xml b/docs/src/main/docbook/getting-started.xml
index 41eba64..47adf87 100644
--- a/docs/src/main/docbook/getting-started.xml
+++ b/docs/src/main/docbook/getting-started.xml
@@ -151,7 +151,7 @@
private HttpServer server;
private WebTarget target;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
server = Main.startServer();
@@ -159,7 +159,7 @@
target = c.target(Main.BASE_URI);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
server.stop();
}
@@ -590,7 +590,7 @@
[INFO] Copying jetty-util-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-util-9.0.6.v20130930.jar
[INFO] Copying jetty-webapp-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-webapp-9.0.6.v20130930.jar
[INFO] Copying jetty-xml-9.0.6.v20130930.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jetty-xml-9.0.6.v20130930.jar
- [INFO] Copying javax.servlet-3.0.0.v201112011016.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/javax.servlet-3.0.0.v201112011016.jar
+ [INFO] Copying jakarta.servlet-3.0.0.v201112011016.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/jakarta.servlet-3.0.0.v201112011016.jar
[INFO] Copying hk2-api-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/hk2-api-2.2.0-b21.jar
[INFO] Copying hk2-locator-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/hk2-locator-2.2.0-b21.jar
[INFO] Copying hk2-utils-2.2.0-b21.jar to /tmp/build_992cc747-26d6-4800-bdb1-add47b9583cd/target/dependency/hk2-utils-2.2.0-b21.jar
diff --git a/etc/jenkins/Jenkinsfile_ci_build b/etc/jenkins/Jenkinsfile_ci_build
index f7076ca..3a0298b 100644
--- a/etc/jenkins/Jenkinsfile_ci_build
+++ b/etc/jenkins/Jenkinsfile_ci_build
@@ -1,6 +1,10 @@
pipeline {
agent none
+ options {
+ timeout(time: 30, activity: true, unit: 'HOURS')
+ }
+
stages {
stage('Jersey build') {
parallel {
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 d9d6845..1ec119a 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, 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 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 7c28f54..11cc4df 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, 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
@@ -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 abecf27..0b25af3 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 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 90273e7..48735a6 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, 2020 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 jakarta.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 @@
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 46bd535..533594e 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, 2020 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 void assertHtmlResponse(String response) {
- assertNotNull("No text returned!", response);
+ assertNotNull(response, "No text returned!");
assertResponseContains(response, "<html>");
assertResponseContains(response, "</html>");
}
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 187f121..b4dbfa1 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, 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 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 @@
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 @@
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 9ac3c5b..8d93375 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, 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 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 jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"alpha", "beta"},
- {"AAA", "BBB"},
- {"b", "a"},
- {"1$s", "2&d"}
- });
+ public static Stream<Arguments> 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 42549fb..4f6ad30 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, 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 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 jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"alpha"},
- {"AAA"},
- {"b"},
- {"1"}
- });
+ public static Stream<String> testData() {
+ return Stream.of("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;
- }
-
- @Test
- public void testEchoResource() {
+ @ParameterizedTest
+ @MethodSource("testData")
+ public void testEchoResource(String a) {
final WebTarget target = target().path("echo").path(a);
@@ -61,8 +43,9 @@
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 006634c..3ebf7a7 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 cac6160..b5a157e 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, 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 Distribution License v. 1.0, which is available at
@@ -13,7 +13,7 @@
import jakarta.ws.rs.client.Entity;
import jakarta.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 cdc5533..b43602d 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, 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 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 jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"gamma", "delta"},
- {"CC C", "D DD"},
- {"d", "c"},
- {"@^&", "?!:"}
- });
+ public static Stream<Arguments> 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 594df17..a94557d 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, 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 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 jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"one"},
- {"too"},
- {"much"}
- });
+ public static Stream<String> 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 039bcd8..e1daf92 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, 2020 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 1d428fb..7fe0b3c 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, 2020 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 @@
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 6298f44..21b6a1a 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, 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
@@ -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 @@
.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<Object> 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/pom.xml b/examples/entity-filtering-security/pom.xml
index a92d294..9f31085 100644
--- a/examples/entity-filtering-security/pom.xml
+++ b/examples/entity-filtering-security/pom.xml
@@ -30,6 +30,12 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
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 2a0e3e6..59e2e4b 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, 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 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 jakarta.ws.rs.core.Feature;
import jakarta.ws.rs.core.Response;
@@ -23,10 +21,15 @@
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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
@@ -37,111 +40,122 @@
*
* @author Michal Gajdos
*/
-@RunWith(Parameterized.class)
-public class RestrictedResourceTest extends JerseyTest {
+public class RestrictedResourceTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}/*, {JacksonFeature.class}*/});
+ public static Iterable<Class<? extends Feature>> providers() {
+ return Arrays.asList(MoxyJsonFeature.class);
}
- public RestrictedResourceTest(final Class<Feature> filteringProvider) {
- super(new ResourceConfig(SecurityEntityFilteringFeature.class)
- .packages("org.glassfish.jersey.examples.entityfiltering.security")
- .register(filteringProvider));
-
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.LOG_TRAFFIC);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ providers().forEach(feature -> {
+ RestrictedResourceTemplateTest test = new RestrictedResourceTemplateTest(feature);
+ tests.add(TestHelper.toTestContainer(test, feature.getSimpleName()));
+ });
+ return tests;
}
- @Test
- public void testDenyAll() throws Exception {
- assertThat(target("restricted-resource").path("denyAll").request().get().getStatus(),
- equalTo(Response.Status.FORBIDDEN.getStatusCode()));
- }
+ public static class RestrictedResourceTemplateTest extends JerseyTest {
+ public RestrictedResourceTemplateTest(final Class<? extends Feature> filteringProvider) {
+ super(new ResourceConfig(SecurityEntityFilteringFeature.class)
+ .packages("org.glassfish.jersey.examples.entityfiltering.security")
+ .register(filteringProvider));
- @Test
- public void testPermitAll() throws Exception {
- final RestrictedEntity entity = target("restricted-resource").path("permitAll").request().get(RestrictedEntity.class);
- final RestrictedSubEntity mixedField = entity.getMixedField();
+ enable(TestProperties.DUMP_ENTITY);
+ enable(TestProperties.LOG_TRAFFIC);
+ }
- // Not null values.
- assertThat(entity.getSimpleField(), notNullValue());
- assertThat(entity.getPermitAll(), notNullValue());
+ @Test
+ public void testDenyAll() throws Exception {
+ assertThat(target("restricted-resource").path("denyAll").request().get().getStatus(),
+ equalTo(Response.Status.FORBIDDEN.getStatusCode()));
+ }
- // Null values.
- assertThat(entity.getDenyAll(), nullValue());
- assertThat(mixedField, nullValue());
- }
+ @Test
+ public void testPermitAll() throws Exception {
+ final RestrictedEntity entity = target("restricted-resource").path("permitAll").request().get(RestrictedEntity.class);
+ final RestrictedSubEntity mixedField = entity.getMixedField();
- @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());
- // 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, nullValue());
+ }
- // Null values.
- assertThat(entity.getDenyAll(), nullValue());
- assertThat(mixedField.getUserField(), nullValue());
- }
+ @Test
+ public void testRolesAllowed() throws Exception {
+ final RestrictedEntity entity = target("restricted-resource").path("rolesAllowed")
+ .request().get(RestrictedEntity.class);
+ final RestrictedSubEntity mixedField = entity.getMixedField();
- @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.getManagerField(), notNullValue());
- // 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.getUserField(), nullValue());
+ }
- // Null values.
- assertThat(entity.getDenyAll(), nullValue());
- assertThat(mixedField.getManagerField(), 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();
- @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());
- // 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());
+ assertThat(mixedField.getManagerField(), nullValue());
+ }
- // Null values.
- assertThat(entity.getDenyAll(), 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();
- @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());
+ assertThat(mixedField, notNullValue());
+ assertThat(mixedField.getUserField(), notNullValue());
+ assertThat(mixedField.getManagerField(), notNullValue());
- // Not null values.
- assertThat(entity.getSimpleField(), notNullValue());
- assertThat(entity.getPermitAll(), notNullValue());
+ // Null values.
+ assertThat(entity.getDenyAll(), nullValue());
+ }
- // Null values.
- assertThat(entity.getDenyAll(), nullValue());
- assertThat(mixedField, 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());
+ }
}
}
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 aeebc96..55e47fc 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, 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 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 jakarta.ws.rs.core.Feature;
import org.glassfish.jersey.examples.entityfiltering.security.domain.RestrictedEntity;
@@ -22,10 +20,15 @@
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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -35,36 +38,46 @@
*
* @author Michal Gajdos
*/
-@RunWith(Parameterized.class)
-public class UnrestrictedResourceTest extends JerseyTest {
+public class UnrestrictedResourceTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}/*, {JacksonFeature.class}*/});
+ public static Iterable<Class<? extends Feature>> providers() {
+ return Arrays.asList(MoxyJsonFeature.class);
}
- public UnrestrictedResourceTest(final Class<Feature> filteringProvider) {
- super(new ResourceConfig(SecurityEntityFilteringFeature.class)
- .packages("org.glassfish.jersey.examples.entityfiltering.security")
- .register(filteringProvider));
-
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.LOG_TRAFFIC);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ providers().forEach(feature -> {
+ UnrestrictedResourceTemplateTest test = new UnrestrictedResourceTemplateTest(feature) {};
+ tests.add(TestHelper.toTestContainer(test, feature.getSimpleName()));
+ });
+ return tests;
}
- @Test
- public void testRestrictedEntity() throws Exception {
- final RestrictedEntity entity = target("unrestricted-resource").request().get(RestrictedEntity.class);
- final RestrictedSubEntity mixedField = entity.getMixedField();
+ public static class UnrestrictedResourceTemplateTest extends JerseyTest {
+ public UnrestrictedResourceTemplateTest(final Class<? extends Feature> filteringProvider) {
+ super(new ResourceConfig(SecurityEntityFilteringFeature.class)
+ .packages("org.glassfish.jersey.examples.entityfiltering.security")
+ .register(filteringProvider));
- // Not null values.
- assertThat(entity.getSimpleField(), notNullValue());
- assertThat(entity.getPermitAll(), notNullValue());
- assertThat(mixedField, notNullValue());
- assertThat(mixedField.getManagerField(), notNullValue());
+ enable(TestProperties.DUMP_ENTITY);
+ enable(TestProperties.LOG_TRAFFIC);
+ }
- // Null values.
- assertThat(entity.getDenyAll(), nullValue());
- assertThat(mixedField.getUserField(), nullValue());
+ @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());
+
+ // Null values.
+ assertThat(entity.getDenyAll(), nullValue());
+ assertThat(mixedField.getUserField(), nullValue());
+ }
}
}
diff --git a/examples/entity-filtering-selectable/pom.xml b/examples/entity-filtering-selectable/pom.xml
index 986200a..4933e5f 100644
--- a/examples/entity-filtering-selectable/pom.xml
+++ b/examples/entity-filtering-selectable/pom.xml
@@ -30,6 +30,12 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
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 a1b8c46..92b7340 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, 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 Distribution License v. 1.0, which is available at
@@ -10,7 +10,9 @@
package org.glassfish.jersey.examples.entityfiltering.selectable;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -21,16 +23,17 @@
import org.glassfish.jersey.examples.entityfiltering.selectable.domain.Person;
import org.glassfish.jersey.examples.entityfiltering.selectable.domain.PhoneNumber;
import org.glassfish.jersey.examples.entityfiltering.selectable.resource.PersonResource;
-// import org.glassfish.jersey.jackson.JacksonFeature;
+import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.message.filtering.SelectableEntityFilteringFeature;
import org.glassfish.jersey.moxy.json.MoxyJsonFeature;
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.hamcrest.MatcherAssert.assertThat;
@@ -41,164 +44,173 @@
* @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<Class[]> providers() {
- return Arrays.asList(new Class[][]{{MoxyJsonFeature.class} /*, {JacksonFeature.class} */});
+ public static Iterable<Class<? extends Feature>> providers() {
+ return Arrays.asList(MoxyJsonFeature.class, JacksonFeature.class);
}
- private final Class<Feature> filteringProvider;
-
- public PersonResourceTest(final Class<Feature> filteringProvider) {
- super(new ResourceConfig(SelectableEntityFilteringFeature.class)
- .packages("org.glassfish.jersey.examples.entityfiltering.selectable")
- .property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select")
- .register(filteringProvider));
-
- this.filteringProvider = filteringProvider;
-
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.LOG_TRAFFIC);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ providers().forEach(feature -> {
+ PersonResourceTemplateTest test = new PersonResourceTemplateTest(feature);
+ tests.add(TestHelper.toTestContainer(test, feature.getSimpleName()));
+ });
+ return tests;
}
- @Override
- protected void configureClient(final ClientConfig config) {
- config.register(filteringProvider);
+ public static class PersonResourceTemplateTest extends JerseyTest {
+ private final Class<? extends Feature> filteringProvider;
+
+ public PersonResourceTemplateTest(final Class<? extends Feature> filteringProvider) {
+ super(new ResourceConfig(SelectableEntityFilteringFeature.class)
+ .packages("org.glassfish.jersey.examples.entityfiltering.selectable")
+ .property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select")
+ .register(filteringProvider));
+
+ this.filteringProvider = filteringProvider;
+
+ enable(TestProperties.DUMP_ENTITY);
+ enable(TestProperties.LOG_TRAFFIC);
+ }
+
+ @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<Address> 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<String, PhoneNumber> 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 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 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
- 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<Address> 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<String, PhoneNumber> 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 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 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());
- }
-
}
diff --git a/examples/entity-filtering/pom.xml b/examples/entity-filtering/pom.xml
index b6d5870..3040752 100644
--- a/examples/entity-filtering/pom.xml
+++ b/examples/entity-filtering/pom.xml
@@ -30,6 +30,12 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
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 8590d92..89c8616 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, 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 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 jakarta.ws.rs.core.Feature;
@@ -23,10 +25,12 @@
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.Nested;
+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.hamcrest.MatcherAssert.assertThat;
@@ -36,60 +40,71 @@
*
* @author Michal Gajdos
*/
-@RunWith(Parameterized.class)
-public class ProjectsResourceTest extends JerseyTest {
+public class ProjectsResourceTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][]{{MoxyJsonFeature.class} /*, {JacksonFeature.class} */});
+ public static Iterable<Class<? extends Feature>> providers() {
+ return Arrays.asList(MoxyJsonFeature.class);
}
- public ProjectsResourceTest(final Class<Feature> 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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ providers().forEach(feature -> {
+ ProjectsResourceTemplateTest test = new ProjectsResourceTemplateTest(feature);
+ tests.add(TestHelper.toTestContainer(test, feature.getSimpleName()));
+ });
+ return tests;
}
- @Test
- public void testProjects() throws Exception {
- for (final Project project : target("projects").request().get(new GenericType<List<Project>>() {})) {
- testProject(project, false);
+ public static class ProjectsResourceTemplateTest extends JerseyTest {
+ public ProjectsResourceTemplateTest(final Class<? extends Feature> 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 testProjects() throws Exception {
+ for (final Project project : target("projects").request().get(new GenericType<List<Project>>() {})) {
+ testProject(project, 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<List<Project>>() {})) {
+ 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 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<List<Project>>() {})) {
- 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());
- }
- }
}
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 8cb28bb..ed34790 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, 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 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 jakarta.ws.rs.core.Feature;
@@ -23,10 +25,11 @@
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.hamcrest.MatcherAssert.assertThat;
@@ -36,60 +39,70 @@
*
* @author Michal Gajdos
*/
-@RunWith(Parameterized.class)
-public class TaskResourceTest extends JerseyTest {
+public class TaskResourceTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}/*, {JacksonFeature.class}*/});
+ public static Iterable<Class<? extends Feature>> providers() {
+ return Arrays.asList(MoxyJsonFeature.class);
}
- public TaskResourceTest(final Class<Feature> 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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ providers().forEach(feature -> {
+ TaskResourceTemplateTest test = new TaskResourceTemplateTest(feature) {};
+ tests.add(TestHelper.toTestContainer(test, feature.getSimpleName()));
+ });
+ return tests;
}
- @Test
- public void testTasks() throws Exception {
- for (final Task task : target("tasks").request().get(new GenericType<List<Task>>() {})) {
- testTask(task, false);
+ public abstract static class TaskResourceTemplateTest extends JerseyTest {
+ public TaskResourceTemplateTest(final Class<? extends Feature> 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 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<List<Task>>() {})) {
- testTask(task, true);
+ @Test
+ public void testTasks() throws Exception {
+ for (final Task task : target("tasks").request().get(new GenericType<List<Task>>() {})) {
+ testTask(task, false);
+ }
}
- }
- @Test
- public void testDetailedTask() throws Exception {
- testTask(target("tasks").path("1").queryParam("detailed", true).request().get(Task.class), true);
- }
+ @Test
+ public void testTask() throws Exception {
+ testTask(target("tasks").path("1").request().get(Task.class), false);
+ }
- 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());
+ @Test
+ public void testDetailedTasks() throws Exception {
+ for (final Task task : target("tasks").path("detailed").request().get(new GenericType<List<Task>>() {})) {
+ testTask(task, true);
+ }
+ }
- // 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);
+ }
+
+ 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());
+ }
}
}
}
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 c8201da..60b0608 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, 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 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 jakarta.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<Class[]> providers() {
- return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}/*, {JacksonFeature.class}*/});
+ public static Iterable<Class<? extends Feature>> providers() {
+ return Arrays.asList(MoxyJsonFeature.class);
}
- public UsersResourceTest(final Class<Feature> 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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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<List<User>>() {})) {
- testUser(user, false);
+ public abstract static class UsersResourceTemplateTest extends JerseyTest {
+ public UsersResourceTemplateTest(final Class<? extends Feature> 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 testDetailedUsers() throws Exception {
- for (final User user : target("users").queryParam("detailed", true).request().get(new GenericType<List<User>>() {})) {
- testUser(user, true);
+ @Test
+ public void testUsers() throws Exception {
+ for (final User user : target("users").request().get(new GenericType<List<User>>() {})) {
+ testUser(user, false);
+ }
}
- }
- @Test
- public void testDetailedUser() throws Exception {
- testUser(target("users").path("1").queryParam("detailed", true).request().get(User.class), true);
- }
+ @Test
+ public void testUser() throws Exception {
+ testUser(target("users").path("1").request().get(User.class), false);
+ }
- 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());
+ @Test
+ public void testDetailedUsers() throws Exception {
+ for (final User user : target("users").queryParam("detailed", true).request().get(new GenericType<List<User>>() {})) {
+ testUser(user, true);
+ }
+ }
- // 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());
+ @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());
+
+ // 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/etc/gf-project-src-pom.xsl b/examples/etc/gf-project-src-pom.xsl
index f43d606..a800edd 100644
--- a/examples/etc/gf-project-src-pom.xsl
+++ b/examples/etc/gf-project-src-pom.xsl
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- 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
@@ -35,7 +35,7 @@
or pom:groupId='org.codehaus.jettison'
or pom:groupId='jakarta.annotation'
or pom:groupId='jakarta.enterprise'
- or pom:groupId='javax.servlet'
+ or pom:groupId='jakarta.servlet'
or pom:groupId='jakarta.ws.rs']/pom:scope[text()!=test]">
<scope>provided</scope>
</xsl:template>
@@ -53,7 +53,7 @@
or pom:groupId='org.codehaus.jettison'
or pom:groupId='jakarta.annotation'
or pom:groupId='jakarta.enterprise'
- or pom:groupId='javax.servlet'
+ or pom:groupId='jakarta.servlet'
or pom:groupId='jakarta.ws.rs']">
<xsl:copy>
<xsl:apply-templates />
@@ -108,8 +108,8 @@
</exclusion>
<exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</artifactId>
</exclusion>
</exclusions>
</xsl:copy>
diff --git a/examples/etc/wls-project-src-pom.xsl b/examples/etc/wls-project-src-pom.xsl
index 0e7294f..ff9a34c 100644
--- a/examples/etc/wls-project-src-pom.xsl
+++ b/examples/etc/wls-project-src-pom.xsl
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- 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 Distribution License v. 1.0, which is available at
@@ -33,7 +33,7 @@
or pom:artifactId='jersey-media-multipart'
or pom:artifactId='jersey-media-sse'
or pom:groupId='com.sun.xml.bind'
- or pom:groupId='javax.servlet']/pom:scope[text()!=test]">
+ or pom:groupId='jakarta.servlet']/pom:scope[text()!=test]">
<scope>provided</scope>
</xsl:template>
@@ -47,7 +47,7 @@
or pom:artifactId='jersey-media-multipart'
or pom:artifactId='jersey-media-sse'
or pom:groupId='com.sun.xml.bind'
- or pom:groupId='javax.servlet']">
+ or pom:groupId='jakarta.servlet']">
<xsl:copy>
<xsl:apply-templates />
<xsl:if test="count(pom:scope)=0">
diff --git a/examples/etc/wls1213-project-src-pom.xsl b/examples/etc/wls1213-project-src-pom.xsl
index 81e292e..bc752cf 100644
--- a/examples/etc/wls1213-project-src-pom.xsl
+++ b/examples/etc/wls1213-project-src-pom.xsl
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- 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 Distribution License v. 1.0, which is available at
@@ -32,7 +32,7 @@
or pom:artifactId='jersey-media-multipart'
or pom:artifactId='jersey-media-sse'
or pom:groupId='com.sun.xml.bind'
- or pom:groupId='javax.servlet']/pom:scope[text()!=test]">
+ or pom:groupId='jakarta.servlet']/pom:scope[text()!=test]">
<scope>provided</scope>
</xsl:template>
@@ -45,7 +45,7 @@
or pom:artifactId='jersey-media-multipart'
or pom:artifactId='jersey-media-sse'
or pom:groupId='com.sun.xml.bind'
- or pom:groupId='javax.servlet']">
+ or pom:groupId='jakarta.servlet']">
<xsl:copy>
<xsl:apply-templates />
<xsl:if test="count(pom:scope)=0">
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 0b641f1..31ded3c 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, 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
@@ -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 e0c1304..0ada5be 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, 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
@@ -12,22 +12,20 @@
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.WebTarget;
-import jakarta.ws.rs.core.HttpHeaders;
-import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder;
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.
@@ -55,7 +53,7 @@
@Test
public void testPingAndFilter() {
WebTarget t = client().target(UriBuilder.fromUri(getBaseUri()).path(App.ROOT_PATH).build());
- Response r = t.request(MediaType.TEXT_PLAIN).header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_PLAIN).get();
+ Response r = t.request("text/plain").get();
assertEquals(200, r.getStatus());
assertTrue(r.readEntity(String.class).contains(MyResponseFilter.class.getSimpleName()));
}
diff --git a/examples/extended-wadl-webapp/pom.xml b/examples/extended-wadl-webapp/pom.xml
index 2373bd4..a6bf0d2 100644
--- a/examples/extended-wadl-webapp/pom.xml
+++ b/examples/extended-wadl-webapp/pom.xml
@@ -90,6 +90,12 @@
<artifactId>pax-exam-link-mvn</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- OSGi runtime - Felix -->
<dependency>
@@ -249,6 +255,13 @@
<exclude>org/glassfish/jersey/examples/extendedwadl/ExtendedWadlWebappOsgiTest.java</exclude>
</excludes>
</configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<plugin>
<groupId>org.ops4j.pax.exam</groupId>
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 14d5296..03d44bb 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
@@ -304,7 +304,7 @@
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 da00ef4..abfeb24 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, 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
@@ -120,7 +120,7 @@
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 0c36394..85634a0 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, 2020 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 76965f8..2038f89 100644
--- a/examples/groovy/pom.xml
+++ b/examples/groovy/pom.xml
@@ -45,6 +45,12 @@
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.8.2</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
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 bf87f97..8d73db4 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, 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 Distribution License v. 1.0, which is available at
@@ -13,10 +13,10 @@
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 jakarta.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 465638b..92cf5aa 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, 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 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 9017419..42f8128 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 0bba28a..2880426 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 db6fe09..3135841 100644
--- a/examples/helloworld-netty/pom.xml
+++ b/examples/helloworld-netty/pom.xml
@@ -59,6 +59,9 @@
<mainClass>org.glassfish.jersey.examples.helloworld.netty.App</mainClass>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
</plugins>
</build>
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 4f9efca..db33a7a 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, 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
@@ -22,7 +22,7 @@
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.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 @@
@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 3fe216b..84d7561 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;
+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;
-@RunWith(ConcurrentRunner.class)
+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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
+ @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ)
public void testMissingResourceNotFound() {
Response response;
@@ -165,7 +184,7 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 0141e8b..13ec198 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, 2020 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 9a6627e..c020e0f 100644
--- a/examples/helloworld-pure-jax-rs/pom.xml
+++ b/examples/helloworld-pure-jax-rs/pom.xml
@@ -40,8 +40,8 @@
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 a1429d6..361f0c5 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, 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 Distribution License v. 1.0, which is available at
@@ -14,8 +14,8 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.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 8c111ca..1d9ec92 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, 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 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 @@
@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 7948f93..44e8d1b 100644
--- a/examples/helloworld-spring-webapp/pom.xml
+++ b/examples/helloworld-spring-webapp/pom.xml
@@ -90,7 +90,7 @@
<version>1.2</version>
<exclusions>
<exclusion>
- <groupId>javax.servlet</groupId>
+ <groupId>jakarta.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
@@ -103,8 +103,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 f72795a..9a83a96 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, 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 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 e8e482c..d9b28d0 100644
--- a/examples/helloworld-weld/pom.xml
+++ b/examples/helloworld-weld/pom.xml
@@ -92,6 +92,9 @@
<mainClass>org.glassfish.jersey.examples.helloworld.App</mainClass>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
</plugins>
</build>
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 64f8c07..73d8b9e 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, 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 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 @@
Weld weld;
+ @BeforeEach
@Override
public void setUp() throws Exception {
weld = new Weld();
@@ -38,6 +40,7 @@
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 a979377..ae3a105 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, 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 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 @@
private Weld weld;
+ @BeforeEach
@Override
public void setUp() throws Exception {
weld = new Weld();
@@ -36,6 +38,7 @@
super.setUp();
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
weld.shutdown();
@@ -55,8 +58,9 @@
@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 339280b..5ad769e 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, 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 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 jakarta.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 @@
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 d876213..0821761 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, 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 Distribution License v. 1.0, which is available at
@@ -13,21 +13,26 @@
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 jakarta.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.AfterEach;
+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 +41,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 +60,11 @@
*
* @return iterable test input data
*/
- @Parameterized.Parameters
- public static Iterable<Object[]> data() {
- return new Iterable<Object[]>() {
-
+ public static Stream<Arguments> data() {
+ Iterable<Arguments> iterable = new Iterable<Arguments>() {
@Override
- public Iterator<Object[]> iterator() {
- return new Iterator<Object[]>() {
+ public Iterator<Arguments> iterator() {
+ return new Iterator<Arguments>() {
@Override
public boolean hasNext() {
@@ -69,11 +72,9 @@
}
@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,20 +84,22 @@
};
}
};
+ 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
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
System.out.printf("SYNC: %d, ASYNC: %d, STRAIGHT: %d%n",
@@ -114,7 +117,9 @@
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 +144,7 @@
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 f667648..efbfb00 100644
--- a/examples/helloworld/pom.xml
+++ b/examples/helloworld/pom.xml
@@ -65,6 +65,9 @@
<mainClass>org.glassfish.jersey.examples.helloworld.App</mainClass>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ </plugin>
</plugins>
</build>
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 42e3d45..cf09651 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, 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 Distribution License v. 1.0, which is available at
@@ -21,7 +21,7 @@
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.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 @@
@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 2c0421f..354cc3e 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, 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
@@ -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 @@
// }
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
+ @ResourceLock(value = "dummy", mode = ResourceAccessMode.READ)
public void testMissingResourceNotFound() {
Response response;
@@ -161,7 +179,7 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 fa8d4d8..d55d0af 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, 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 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.
@@ -62,7 +62,7 @@
// initial precondition check
final State expected = new State();
- assertEquals(expected, target.request(MediaType.APPLICATION_JSON).get(State.class));
+ assertEquals(expected, target.request("application/json").get(State.class));
// apply first patch
expected.setMessage("patchedMessage");
@@ -94,7 +94,7 @@
assertEquals(expected, target.request()
.method("PATCH",
Entity.entity(patch_1, MediaType.APPLICATION_JSON_PATCH_JSON), State.class));
- assertEquals(expected, target.request(MediaType.APPLICATION_JSON).get(State.class));
+ assertEquals(expected, target.request("application/json").get(State.class));
// apply second patch
expected.getList().add("three");
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 33d3887..065ebcf 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, 2020 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 @@
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 @@
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 d6274d1..f14f81c 100644
--- a/examples/https-clientserver-grizzly/pom.xml
+++ b/examples/https-clientserver-grizzly/pom.xml
@@ -54,8 +54,8 @@
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 16618d2..b21a96d 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, 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
@@ -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 @@
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 @@
}
}
- @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 fb0b1fe..10b9ab1 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, 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 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 5c04e06..2c563e5 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, 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 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 17109c6..246f156 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, 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
@@ -16,7 +16,6 @@
import jakarta.ws.rs.core.GenericType;
import static jakarta.ws.rs.client.Entity.xml;
-import jakarta.ws.rs.core.MediaType;
import jakarta.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
@@ -24,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.
@@ -50,8 +49,7 @@
@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
@@ -78,7 +76,7 @@
JAXBElement<JaxbXmlType> e1 = target().path("jaxb/JAXBElement").request().get(genericType);
- JAXBElement<JaxbXmlType> e2 = target().path("jaxb/JAXBElement").request(MediaType.APPLICATION_XML)
+ JAXBElement<JaxbXmlType> e2 = target().path("jaxb/JAXBElement").request("application/xml")
.post(xml(e1), genericType);
assertEquals(e1.getValue(), e2.getValue());
@@ -92,7 +90,7 @@
new QName("jaxbXmlRootElement"),
JaxbXmlType.class,
t1);
- JaxbXmlType t2 = target().path("jaxb/XmlType").request(MediaType.APPLICATION_XML)
+ JaxbXmlType t2 = target().path("jaxb/XmlType").request("application/xml")
.post(xml(e), JaxbXmlType.class);
assertEquals(t1, t2);
@@ -105,7 +103,7 @@
new GenericType<Collection<JaxbXmlRootElement>>() {};
Collection<JaxbXmlRootElement> ce1 = target().path("jaxb/collection/XmlRootElement").request().get(genericType);
- Collection<JaxbXmlRootElement> ce2 = target().path("jaxb/collection/XmlRootElement").request(MediaType.APPLICATION_XML)
+ Collection<JaxbXmlRootElement> ce2 = target().path("jaxb/collection/XmlRootElement").request("application/xml")
.post(xml(new GenericEntity<Collection<JaxbXmlRootElement>>(ce1) {}), genericType);
assertEquals(ce1, ce2);
@@ -119,20 +117,23 @@
new GenericType<Collection<JaxbXmlType>>() {
};
- Collection<JaxbXmlRootElement> ce1 = target().path("jaxb/collection/XmlRootElement").request().get(genericRootElement);
+ Collection<JaxbXmlRootElement> ce1 = target().path("jaxb/collection/XmlRootElement").request()
+ .get(genericRootElement);
- Collection<JaxbXmlType> ct1 = target().path("jaxb/collection/XmlType").request(MediaType.APPLICATION_XML)
+ Collection<JaxbXmlType> ct1 = target().path("jaxb/collection/XmlType").request("application/xml")
.post(xml(new GenericEntity<Collection<JaxbXmlRootElement>>(ce1) {}), genericXmlType);
- Collection<JaxbXmlType> ct2 = target().path("jaxb/collection/XmlRootElement").request().get(genericXmlType);
+ Collection<JaxbXmlType> ct2 = target().path("jaxb/collection/XmlRootElement").request()
+ .get(genericXmlType);
assertEquals(ct1, ct2);
}
@Test
public void testRootElementArray() {
- JaxbXmlRootElement[] ae1 = target().path("jaxb/array/XmlRootElement").request().get(JaxbXmlRootElement[].class);
- JaxbXmlRootElement[] ae2 = target().path("jaxb/array/XmlRootElement").request(MediaType.APPLICATION_XML)
+ JaxbXmlRootElement[] ae1 = target().path("jaxb/array/XmlRootElement").request()
+ .get(JaxbXmlRootElement[].class);
+ JaxbXmlRootElement[] ae2 = target().path("jaxb/array/XmlRootElement").request("application/xml")
.post(xml(ae1), JaxbXmlRootElement[].class);
assertEquals(ae1.length, ae2.length);
@@ -143,12 +144,14 @@
@Test
public void testXmlTypeArray() {
- JaxbXmlRootElement[] ae1 = target().path("jaxb/array/XmlRootElement").request().get(JaxbXmlRootElement[].class);
+ JaxbXmlRootElement[] ae1 = target().path("jaxb/array/XmlRootElement").request()
+ .get(JaxbXmlRootElement[].class);
- JaxbXmlType[] at1 = target().path("jaxb/array/XmlType").request(MediaType.APPLICATION_XML)
+ JaxbXmlType[] at1 = target().path("jaxb/array/XmlType").request("application/xml")
.post(xml(ae1), JaxbXmlType[].class);
- JaxbXmlType[] at2 = target().path("jaxb/array/XmlRootElement").request().get(JaxbXmlType[].class);
+ JaxbXmlType[] at2 = target().path("jaxb/array/XmlRootElement").request()
+ .get(JaxbXmlType[].class);
assertEquals(at1.length, at2.length);
for (int i = 0; i < at1.length; i++) {
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 93c1a32..f2c8562 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, 2020 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 @@
.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 @@
.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 @@
.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 6712daa..aa12d67 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, 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 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 @@
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 @@
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 @@
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 3dcfd77..36d7a0e 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, 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
@@ -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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testEmptyArrayBean() {
WebTarget target = target();
EmptyArrayBean responseMsg = target.path("emptyArrayResource").request(MediaType.APPLICATION_JSON)
@@ -87,6 +93,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testCombinedAnnotationBean() {
WebTarget target = target();
CombinedAnnotationBean responseMsg = target.path("combinedAnnotations").request("application/json")
@@ -95,7 +102,8 @@
}
@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 @@
* <p/>
*/
@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 @@
* 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-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 1725784..d5372b5 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, 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
@@ -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 @@
config.register(new JettisonFeature()).register(JaxbContextResolver.class);
}
- @Before
+ @BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
@@ -60,7 +60,7 @@
@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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// get the initial representation
List<AircraftType> 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 78896a4..5d3be6e 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, 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 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 ef21a7b..ed6db6a 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, 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 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
@@ -86,7 +86,8 @@
// Get.
final String id = ids.get(0).toString();
final WebTarget documentTarget = target("document").path(id);
- final JsonObject storedDocument = documentTarget.request(MediaType.APPLICATION_JSON).get(JsonObject.class);
+ final JsonObject storedDocument = documentTarget.request(MediaType.APPLICATION_JSON)
+ .get(JsonObject.class);
assertEquals(document, storedDocument);
// Remove.
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 5381e47..ddaa447 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, 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
@@ -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 @@
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 @@
// get the initial representation
List<ChangeRecordBean> 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 ee24338..93fe827 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, 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
@@ -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 99dad4b..9395443 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, 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 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 6637277..250715a 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, 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 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 892a260..bc4fbad 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, 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 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 b2c0969..235d65b 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, 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 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 bdce853..6103b1e 100644
--- a/examples/osgi-helloworld-webapp/functional-test/pom.xml
+++ b/examples/osgi-helloworld-webapp/functional-test/pom.xml
@@ -123,6 +123,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
<scope>test</scope>
</dependency>
diff --git a/examples/osgi-http-service/functional-test/pom.xml b/examples/osgi-http-service/functional-test/pom.xml
index 29f843b..e7f09fb 100644
--- a/examples/osgi-http-service/functional-test/pom.xml
+++ b/examples/osgi-http-service/functional-test/pom.xml
@@ -122,6 +122,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
<scope>test</scope>
</dependency>
@@ -216,9 +217,9 @@
<configuration>
<excludes>
<!--
- excluded due to javax.servlet-api collision -
+ excluded due to jakarta.servlet-api collision -
more than one version is required, so it is not possible to execute that test.
- (since pax-exam version 4.13.4)
+ (since pax-exam version 4.13.5)
-->
<exclude>org.glassfish.jersey.examples.osgihttpservice.test.GrizzlyHttpServiceFelixTest</exclude>
</excludes>
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 7bdc1cf..816f1a5 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, 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 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 @@
// 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 @@
// 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 249f10f..06c775d 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, 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 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 78d6fd2..edd96c8 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, 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
@@ -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 @@
LOGGER.info(messageBuilder.toString());
for (Map.Entry<Integer, String> 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 @@
LOGGER.info(messageBuilder.toString());
for (Map.Entry<Integer, Integer> 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<Integer> lost = new LinkedList<Integer>();
diff --git a/examples/server-async-standalone/client/pom.xml b/examples/server-async-standalone/client/pom.xml
index 19447be..a72f935 100644
--- a/examples/server-async-standalone/client/pom.xml
+++ b/examples/server-async-standalone/client/pom.xml
@@ -46,8 +46,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 2826e44..240b53a 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 319cdd9..03d8e56 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, 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
@@ -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 @@
LOGGER.info(messageBuilder.toString());
for (Map.Entry<Integer, String> 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<Integer> lost = new LinkedList<Integer>();
@@ -309,9 +308,8 @@
LOGGER.info(messageBuilder.toString());
for (Map.Entry<Integer, String> 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 308bf47..27845c3 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, 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 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 @@
return client;
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
super.tearDown();
@@ -89,8 +90,8 @@
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 5dd06f0..32e6f65 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, 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 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 @@
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 @@
}
});
- 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/org/glassfish/jersey/examples/servlet3/webapp/Servlet3WebappTestCase.java b/examples/servlet3-webapp/src/test/java/org/glassfish/jersey/examples/servlet3/webapp/Servlet3WebappTestCase.java
index a89f951..8412cb5 100644
--- a/examples/servlet3-webapp/src/test/java/org/glassfish/jersey/examples/servlet3/webapp/Servlet3WebappTestCase.java
+++ b/examples/servlet3-webapp/src/test/java/org/glassfish/jersey/examples/servlet3/webapp/Servlet3WebappTestCase.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 Distribution License v. 1.0, which is available at
@@ -12,18 +12,13 @@
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.TestProperties;
-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 jakarta.ws.rs.core.Application;
-import jakarta.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 6c9f049..6a21668 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 @@
@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 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 @@
@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 cdabad0..f67cc65 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, 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 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 @@
return client.get();
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
super.tearDown();
@@ -161,9 +163,8 @@
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 @@
}
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 @@
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 @@
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 @@
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 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 f59b438..f29123a 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, 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 Distribution License v. 1.0, which is available at
@@ -40,16 +40,15 @@
import org.glassfish.jersey.test.external.ExternalTestContainerFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.junit.Ignore;
-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.
@@ -141,9 +140,8 @@
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");
@@ -153,19 +151,19 @@
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<Integer> 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.");
}
/**
@@ -229,9 +227,8 @@
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");
@@ -255,7 +252,7 @@
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 + "'");
}
@@ -271,7 +268,7 @@
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.");
}
@@ -280,7 +277,7 @@
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 aa72d53..54c9607 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, 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 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.
@@ -41,7 +41,6 @@
@Test
public void testGetPropertyNames() {
PropertyNamesResource propertyNamesResource = WebResourceFactory.newResource(PropertyNamesResource.class, target());
-
Set<String> propertyNames = propertyNamesResource.getPropertyNames();
assertEquals(System.getProperties().stringPropertyNames(), propertyNames);
}
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 0b95c32..9bbda92 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, 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
@@ -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 4b6e83a..5e379a9 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 874234f..f371697 100644
--- a/ext/cdi/jersey-cdi1x/pom.xml
+++ b/ext/cdi/jersey-cdi1x/pom.xml
@@ -59,6 +59,12 @@
<artifactId>jmockit</artifactId>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
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 24ab3c3..995c758 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, 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
@@ -33,9 +33,9 @@
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.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 8ae41f2..6a30227 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 8c5fa49..19112b9 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 21edda4..46c7bee 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 @@
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 b65cb99..4c296d2 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, 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
@@ -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/pom.xml b/ext/metainf-services/pom.xml
index 7b43b47..82c42a6 100644
--- a/ext/metainf-services/pom.xml
+++ b/ext/metainf-services/pom.xml
@@ -90,6 +90,13 @@
</instructions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <test>**/MetaInfServicesTest*</test>
+ </configuration>
+ </plugin>
</plugins>
</build>
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 7901d03..db18e3b 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, 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,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 7a49dfc..7eec9b5 100644
--- a/ext/microprofile/mp-config/pom.xml
+++ b/ext/microprofile/mp-config/pom.xml
@@ -63,8 +63,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 6b2aecd..f269cff 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 @@
private static final String EMPTY_PROPERTY_NAME = "EMPTY_PROPERTY";
- @Before
+ @BeforeEach
public void before() {
System.setProperty(EMPTY_PROPERTY_NAME, "");
}
@@ -36,7 +36,7 @@
final ConfigurationProvider provider = new ConfigurationProvider();
final Map<String, Object> 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 84da52c..58f7bd7 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, 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
@@ -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 jakarta.inject.Singleton;
import jakarta.ws.rs.GET;
@@ -84,7 +84,7 @@
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 @@
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/InterfaceUtilTest.java b/ext/microprofile/mp-rest-client/src/test/java/org/glassfish/jersey/microprofile/restclient/InterfaceUtilTest.java
index 466b870..c1e11e6 100644
--- a/ext/microprofile/mp-rest-client/src/test/java/org/glassfish/jersey/microprofile/restclient/InterfaceUtilTest.java
+++ b/ext/microprofile/mp-rest-client/src/test/java/org/glassfish/jersey/microprofile/restclient/InterfaceUtilTest.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,11 +16,13 @@
package org.glassfish.jersey.microprofile.restclient;
-import org.junit.Test;
+
+import org.junit.jupiter.api.Test;
import java.util.Arrays;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
public class InterfaceUtilTest {
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 685e53a..bd4bf9c 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 @@
@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/mvc-freemarker/pom.xml b/ext/mvc-freemarker/pom.xml
index f2355c8..ac75f0c 100644
--- a/ext/mvc-freemarker/pom.xml
+++ b/ext/mvc-freemarker/pom.xml
@@ -58,12 +58,6 @@
<dependencies>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>4.0.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${servlet5.version}</version>
diff --git a/ext/pom.xml b/ext/pom.xml
index 93e409d..c8d6a3f 100644
--- a/ext/pom.xml
+++ b/ext/pom.xml
@@ -63,8 +63,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
diff --git a/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/RequestParametersTest.java b/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/RequestParametersTest.java
index aee925e..9ade669 100644
--- a/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/RequestParametersTest.java
+++ b/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/RequestParametersTest.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,7 +30,7 @@
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.beans.IntrospectionException;
import java.lang.annotation.Annotation;
@@ -42,7 +42,8 @@
import java.util.List;
import java.util.Map;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* @author Richard Obersheimer
diff --git a/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/WebResourceFactoryBeanParamTest.java b/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/WebResourceFactoryBeanParamTest.java
index 27b1fd8..dc24861 100644
--- a/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/WebResourceFactoryBeanParamTest.java
+++ b/ext/proxy-client/src/test/java/org/glassfish/jersey/client/proxy/WebResourceFactoryBeanParamTest.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,12 +20,13 @@
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 java.util.Arrays;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Richard Obersheimer
@@ -41,6 +42,7 @@
}
@Override
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
resourceWithBeanParam = WebResourceFactory.newResource(MyResourceWithBeanParamIfc.class, target());
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 68e81c7..89927e9 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, 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
@@ -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 @@
return new ResourceConfig(MyResource.class);
}
+ @BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
@@ -161,7 +162,7 @@
}
@Test
- @Ignore("See issue JERSEY-2441")
+ @Disabled("See issue JERSEY-2441")
public void testHeaderCookieAsList() {
final List<String> list = new ArrayList<>();
list.add("a");
@@ -172,7 +173,7 @@
}
@Test
- @Ignore("See issue JERSEY-2441")
+ @Disabled("See issue JERSEY-2441")
public void testHeaderCookieAsSet() {
final Set<String> set = new HashSet<>();
set.add("a");
@@ -184,7 +185,7 @@
}
@Test
- @Ignore("See issue JERSEY-2441")
+ @Disabled("See issue JERSEY-2441")
public void testHeaderCookieAsSortedSet() {
final SortedSet<String> set = new TreeSet<>();
set.add("a");
@@ -200,7 +201,7 @@
* 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<String> list = new ArrayList<>();
list.add("a");
@@ -211,7 +212,7 @@
}
@Test
- @Ignore("See issue JERSEY-2263")
+ @Disabled("See issue JERSEY-2263")
public void testHeaderParamsAsSet() {
final Set<String> set = new HashSet<>();
set.add("a");
@@ -223,7 +224,7 @@
}
@Test
- @Ignore("See issue JERSEY-2263")
+ @Disabled("See issue JERSEY-2263")
public void testHeaderParamsAsSortedSet() {
final SortedSet<String> set = new TreeSet<>();
set.add("a");
@@ -267,10 +268,10 @@
}
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 @@
@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 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 1a4de9a..468c5d8 100644
--- a/ext/rx/pom.xml
+++ b/ext/rx/pom.xml
@@ -44,8 +44,8 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 92032f1..e12fa9a 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, 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
@@ -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 @@
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 @@
.build());
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
executor.shutdown();
client = null;
@@ -72,49 +73,51 @@
testInvoker(invoker, 404, false);
}
- @Test(expected = NotFoundException.class)
+ @Test
public void testNotFoundReadEntityViaClass() throws Throwable {
- client.register(RxListenableFutureInvokerProvider.class);
+ 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) {
+ 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
- // jakarta.ws.rs.NotFoundException
- .getCause();
- }
+ // java.util.concurrent.ExecutionException
+ throw expected
+ // jakarta.ws.rs.NotFoundException
+ .getCause();
+ }
+ });
}
-
- @Test(expected = NotFoundException.class)
+ @Test
public void testNotFoundReadEntityViaGenericType() throws Throwable {
- client.register(RxListenableFutureInvokerProvider.class);
+ 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<String>() {
- })
- .get();
- } catch (final Exception expected) {
+ try {
+ client.target("http://jersey.java.net")
+ .request()
+ .header("Response-Status", 404)
+ .rx(RxListenableFutureInvoker.class)
+ .get(new GenericType<String>() {
+ })
+ .get();
+ } catch (final Exception expected) {
- expected.printStackTrace();
+ expected.printStackTrace();
- // java.util.concurrent.ExecutionException
- throw expected
- // jakarta.ws.rs.NotFoundException
- .getCause();
- }
+ // java.util.concurrent.ExecutionException
+ throw expected
+ // jakarta.ws.rs.NotFoundException
+ .getCause();
+ }
+ });
}
-
@Test
public void testReadEntityViaClass() throws Throwable {
client.register(RxListenableFutureInvokerProvider.class);
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 d06977c..1e2ec1c 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, 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
@@ -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 @@
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 @@
clientWithExecutor.register(RxObservableInvokerProvider.class);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
executor.shutdown();
@@ -91,47 +92,52 @@
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
- // jakarta.ws.rs.ProcessingException
- // .getCause()
- // jakarta.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
+ // jakarta.ws.rs.ProcessingException
+ // .getCause()
+ // jakarta.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<String>() { })
- .toBlocking()
- .toFuture()
- .get();
- } catch (final Exception expected) {
+ assertThrows(NotFoundException.class, () -> {
+ try {
+ client.target("http://jersey.java.net")
+ .request()
+ .header("Response-Status", 404)
+ .rx(RxObservableInvoker.class)
+ .get(new GenericType<String>() {
+ })
+ .toBlocking()
+ .toFuture()
+ .get();
+ } catch (final Exception expected) {
- expected.printStackTrace();
+ expected.printStackTrace();
- // java.util.concurrent.ExecutionException
- throw expected
- // jakarta.ws.rs.NotFoundException
- .getCause();
- }
+ // java.util.concurrent.ExecutionException
+ throw expected
+ // jakarta.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 8788bad..1a0bf4e 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, 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
@@ -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 @@
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 @@
clientWithExecutor.register(RxFlowableInvokerProvider.class);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
executor.shutdown();
@@ -90,33 +91,37 @@
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<String>() {
- })
- .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<String>() {
+ })
+ .blockingFirst();
+ } catch (final Exception expected) {
+ throw expected;
+ }
+ });
}
@Test
diff --git a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java
index d360115..be03c73 100644
--- a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java
+++ b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/aspect4j/Aspect4JTest.java
@@ -19,11 +19,11 @@
import jakarta.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 @@
private TestAspect testAspect;
- @Before
+ @BeforeEach
public void before() {
testAspect.reset();
}
diff --git a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java
index c06d2db..cdb8667 100644
--- a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java
+++ b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/fieldinjection/SpringFieldInjectionTest.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java
index 925ae46..37457b8 100644
--- a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java
+++ b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/filter/FilterTest.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java
index 0b087ce..29f75a9 100644
--- a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java
+++ b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/methodinjection/SpringMethodInjectionTest.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java
index 8a1bfb5..da438bc 100644
--- a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java
+++ b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/parameterinjection/SpringParameterInjectionTest.java
@@ -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 jakarta.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/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java
index 559d3dd..1297544 100644
--- a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java
+++ b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDefaultProfileResourceTest.java
@@ -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 @@
@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/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java
index 0fe73d3..1dfa1f1 100644
--- a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java
+++ b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringDevProfileResourceTest.java
@@ -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 @@
@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/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java
index 72fe2b1..e871afb 100644
--- a/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java
+++ b/ext/spring6/src/test/java/org/glassfish/jersey/server/spring/profiles/SpringProfilesTest.java
@@ -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 ccfb4cd..4bbcd4c 100644
--- a/incubator/cdi-inject-weld/pom.xml
+++ b/incubator/cdi-inject-weld/pom.xml
@@ -81,8 +81,13 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 5f5538c..85bfe56 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 jakarta.enterprise.inject.InjectionException;
import jakarta.ws.rs.MatrixParam;
+import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.PathParam;
import jakarta.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 @@
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 cc83fb2..5b45ea4 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 aa85e82..afb04b8 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 @@
});
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 @@
});
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 @@
});
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 3fd6a2d..ee96847 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 @@
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 a5da3cd..7be66d9 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 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 9459dac..42aadeb 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 @@
// });
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 8bc075b..7db2804 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 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 1b749c1..3f67389 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 @@
injectionManager = Injections.createInjectionManager();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (container != null && container.isRunning()) {
container.close();
@@ -275,48 +276,54 @@
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 843a03b..9c247a9 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 @@
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 8522462..e3013fe 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 jakarta.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 17f4307..144c333 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 @@
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 df798a3..2e28b8f 100644
--- a/incubator/declarative-linking/pom.xml
+++ b/incubator/declarative-linking/pom.xml
@@ -63,8 +63,8 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
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 657d607..8f41d7b 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, 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
@@ -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 020a4d6..bbac5b1 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, 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
@@ -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 87c610e..34e0ff1 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, 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
@@ -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 a494f02..9284181 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, 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
@@ -19,9 +19,9 @@
import jakarta.el.ExpressionFactory;
import jakarta.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 5a38261..f86c757 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, 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
@@ -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 f6ceb9c..35dddd8 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, 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
@@ -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 2ad845b..0dae312 100644
--- a/incubator/html-json/pom.xml
+++ b/incubator/html-json/pom.xml
@@ -70,8 +70,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 513f174..c687717 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, 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
@@ -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 @@
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 cc5faef..a3db7de 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, 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
@@ -23,8 +23,8 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.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 a16bfd5..8742447 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, 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
@@ -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 @@
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 @@
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 52c3181..280006f 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, 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
@@ -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 @@
GenericType<List<MyBean>> ge = new GenericType<List<MyBean>>() {};
List<MyBean> 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 05de2fe..a359260 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, 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
@@ -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 @@
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 860aeb2..e9369cd 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, 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
@@ -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 jakarta.ws.rs.client.Entity;
import jakarta.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 af84146..de0e76a 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 7994cab..e1efa42 100644
--- a/incubator/open-tracing/pom.xml
+++ b/incubator/open-tracing/pom.xml
@@ -60,8 +60,8 @@
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
diff --git a/inject/cdi2-se/pom.xml b/inject/cdi2-se/pom.xml
index 77e2270..362ca4b 100644
--- a/inject/cdi2-se/pom.xml
+++ b/inject/cdi2-se/pom.xml
@@ -45,8 +45,13 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 13dc124..6bade9b 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, 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
@@ -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 @@
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 379c3e7..0bddf41 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, 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
@@ -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 ccaf38f..813eb05 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, 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
@@ -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 @@
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 8033cd2..7a7b8db 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, 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
@@ -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 @@
private InjectionManager injectionManager;
- @Before
+ @BeforeEach
public void setup() {
injectionManager = BindingTestHelper.createInjectionManager();
}
- @After
+ @AfterEach
public void teardown() {
injectionManager.shutdown();
}
@@ -195,33 +196,39 @@
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 4c4d965..602ed80 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, 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
@@ -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 @@
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 4176c93..cf377c1 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, 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
@@ -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 33c66ab..cc9e78a 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, 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
@@ -27,8 +27,9 @@
import jakarta.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 @@
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 fbb716d..da6526d 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, 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
@@ -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 c3c8b94..c800fda 100644
--- a/inject/hk2/pom.xml
+++ b/inject/hk2/pom.xml
@@ -65,8 +65,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 96a58df..89d2db3 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, 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
@@ -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 @@
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 02be49f..57a5d49 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 @@
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 @@
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 5612ba2..20ec589 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, 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
@@ -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 @@
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 e048cb5..74afa37 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, 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
@@ -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 @@
private InjectionManager injectionManager;
- @Before
+ @BeforeEach
public void setup() {
injectionManager = BindingTestHelper.createInjectionManager();
}
- @After
+ @AfterEach
public void teardown() {
injectionManager.shutdown();
}
@@ -194,33 +195,39 @@
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 8cbc8b4..2431ce6 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, 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,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 @@
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 2604d27..79e9c9f 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 @@
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 4856007..632e164 100644
--- a/media/jaxb/pom.xml
+++ b/media/jaxb/pom.xml
@@ -149,8 +149,13 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 232c9d7..8be1403 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 b7c543c..5079201 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 ee40609..a0b4c26 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 1aaee2a..be7cc9a 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 @@
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 81e9cfe..9f4fa5b 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 f09590f..f5c6664 100644
--- a/media/json-binding/pom.xml
+++ b/media/json-binding/pom.xml
@@ -98,8 +98,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 3323864..6ad437f 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 jakarta.ws.rs.ext.MessageBodyWriter;
import jakarta.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<Foo> mbr = (MessageBodyReader) new JsonBindingProvider(providers);
+ assertThrows(NoContentException.class, () -> {
+ // given
+ final Providers providers = new EmptyProviders();
+ final MessageBodyReader<Foo> 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]));
+ // when
+ mbr.readFrom(Foo.class, Foo.class, new Annotation[0], APPLICATION_JSON_TYPE,
+ new MultivaluedHashMap<>(), new ByteArrayInputStream(new byte[0]));
- // then
- // should throw NoContentException
+ // then
+ // should throw NoContentException
+ });
}
private static final class Foo {
diff --git a/media/json-gson/pom.xml b/media/json-gson/pom.xml
index eaa7d25..023455d 100644
--- a/media/json-gson/pom.xml
+++ b/media/json-gson/pom.xml
@@ -73,8 +73,8 @@
<artifactId>gson</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 7aa403e..98b8248 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 jakarta.ws.rs.ext.MessageBodyWriter;
import jakarta.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<Foo> 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<Foo> 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 a0eb3bd..5f23d65 100644
--- a/media/json-jackson/pom.xml
+++ b/media/json-jackson/pom.xml
@@ -95,6 +95,12 @@
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
@@ -161,14 +167,8 @@
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.test-framework</groupId>
- <artifactId>jersey-test-framework-core</artifactId>
- <version>${project.version}</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 71ea96f..9488a16 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 jakarta.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 947d599..59d19c1 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 jakarta.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 a9a86e6..dc68332 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 jakarta.annotation.PostConstruct;
import jakarta.inject.Inject;
@@ -31,8 +31,8 @@
import jakarta.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 b1d5e9d..eaf293d 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 jakarta.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-jackson/src/test/java/org/glassfish/jersey/jackson/internal/JacksonJaxb2JsonProviderTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/JacksonJaxb2JsonProviderTest.java
index 09a3c8b..4a85090 100644
--- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/JacksonJaxb2JsonProviderTest.java
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/JacksonJaxb2JsonProviderTest.java
@@ -20,9 +20,9 @@
import org.glassfish.jersey.jackson.internal.model.Jaxb2ServiceTest;
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;
public final class JacksonJaxb2JsonProviderTest extends JerseyTest {
diff --git a/media/json-jettison/pom.xml b/media/json-jettison/pom.xml
index 0efb107..21e1973 100644
--- a/media/json-jettison/pom.xml
+++ b/media/json-jettison/pom.xml
@@ -88,8 +88,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/media/json-processing/pom.xml b/media/json-processing/pom.xml
index 9f884ee..ea5d446 100644
--- a/media/json-processing/pom.xml
+++ b/media/json-processing/pom.xml
@@ -89,8 +89,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 d9a26f6..2b57034 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, 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
@@ -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 ae83d83..1fad557 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, 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
@@ -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 d1db2b3..136540b 100644
--- a/media/moxy/pom.xml
+++ b/media/moxy/pom.xml
@@ -117,8 +117,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/media/multipart/pom.xml b/media/multipart/pom.xml
index 945e5d8..5948fca 100644
--- a/media/multipart/pom.xml
+++ b/media/multipart/pom.xml
@@ -94,8 +94,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
</dependency>
</dependencies>
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 5a1af1a..f6a4a9c 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, 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
@@ -22,13 +22,13 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.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 cd87a26..354e1f7 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, 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
@@ -18,14 +18,14 @@
import jakarta.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 7cf196a..1c48a39 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 9f8cffd..6cb4376 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, 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
@@ -18,9 +18,9 @@
import jakarta.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 d2102f7..ee6cefa 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, 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
@@ -18,11 +18,11 @@
import jakarta.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 @@
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 5e36625..180bd85 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, 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
@@ -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 dee6da0..647100c 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 @@
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 40eaeef..3968368 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 d2acefb..c35f468 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, 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
@@ -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 ac6d035..c2e8e90 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, 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
@@ -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 @@
private StreamDataBodyPart cut;
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
cut = new StreamDataBodyPart();
@@ -60,7 +60,7 @@
}
@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 5e49273..1fa6744 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, 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
@@ -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 f48f467..92599dd 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, 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
@@ -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 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 dd0c7e2..06222b9 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, 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
@@ -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<? extends ConnectorProvider> connectorProviderClass,
- boolean messageLogged)
- throws InstantiationException, IllegalAccessException {
- this.connectorProvider = connectorProviderClass.newInstance();
- this.messageLogged = messageLogged;
- }
-
- @Parameterized.Parameters(name = "{index}: {0} / {1}")
public static List<Object[]> 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<Class<?>> getResourceClasses() {
- final HashSet<Class<?>> classes = new HashSet<Class<?>>();
- classes.add(MultiPartResource.class);
- return classes;
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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;
}
- }
- private LogRecord findLogRecord(String messageContains) {
- for (final LogRecord record : getLoggedRecords()) {
- if (record.getMessage().contains(messageContains)) {
- return record;
+ @Override
+ protected Set<Class<?>> getResourceClasses() {
+ final HashSet<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(MultiPartResource.class);
+ return classes;
+ }
+
+ @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 f4437fe..36c6ebd 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, 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
@@ -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 @@
private static Path TMP_DIRECTORY;
private static String ORIGINAL_TMP_DIRECTORY;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
@@ -59,7 +60,7 @@
System.setProperty("java.io.tmpdir", TMP_DIRECTORY.toString());
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
@@ -201,14 +202,15 @@
/**
* 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 @@
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 812e7a6..2a76b3d 100644
--- a/media/sse/pom.xml
+++ b/media/sse/pom.xml
@@ -45,8 +45,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 bebfaf8..85fd7d4 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, 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
@@ -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 24717e3..3cadf8e 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, 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
@@ -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 d895e83..5be6d00 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, 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
@@ -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 9845a18..307e770 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, 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
@@ -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 @@
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 1ad77af..e984f2b 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, 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
@@ -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 0341895..92803df 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, 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
@@ -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 @@
}
// ... 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 @@
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 c14d3cc..fee3e9b 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, 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
@@ -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 6b7da0d..98fbfff 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 742c57a..4321adc 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, 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,10 +23,8 @@
import jakarta.ws.rs.sse.OutboundSseEvent;
import jakarta.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 jakarta.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 @@
});
broadcaster.broadcast(new JerseySse().newEvent("ping"));
- Assert.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS));
+ Assertions.assertTrue(latch.await(2000, TimeUnit.MILLISECONDS));
}
}
@@ -124,7 +121,7 @@
});
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 cc48ffb..09f5406 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) 2020 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 jakarta.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 d73ec69..c3473a1 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}
</argLine>
<skipTests>${skip.tests}</skipTests>
+ <properties>
+ <configurationParameters>
+ junit.jupiter.execution.parallel.enabled=true
+ junit.jupiter.execution.parallel.mode.classes.default=same_thread
+ junit.jupiter.execution.parallel.mode.default=same_thread
+ </configurationParameters>
+ </properties>
+ <threadCount>124</threadCount>
</configuration>
<dependencies>
<dependency>
@@ -1984,12 +1992,28 @@
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
+
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.1</version>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${jetty.plugin.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ <version>${jetty.plugin.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>servlet-api-2.5</artifactId>
+ <version>${jetty.servlet.api.25.version}</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
@@ -2005,7 +2029,7 @@
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
- <version>6.9.6</version>
+ <version>6.9.13.6</version>
<scope>test</scope>
</dependency>
@@ -2028,8 +2052,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-core</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
@@ -2150,7 +2174,7 @@
<enforcer.version>3.1.0</enforcer.version>
<!--versions, extracted here due to maven-enforcer-plugin -->
- <slf4j.version>2.0.0-alpha6</slf4j.version>
+ <slf4j.version>2.0.3</slf4j.version>
<commons.codec.version>1.15</commons.codec.version>
<reactive.streams.version>1.0.3</reactive.streams.version>
<com.uber.jaeger.version>0.27.0</com.uber.jaeger.version>
@@ -2168,7 +2192,7 @@
<guava.version>31.1-jre</guava.version>
<hamcrest.version>2.2</hamcrest.version>
<!--<helidon.version>1.0.3</helidon.version>-->
- <xmlunit.version>1.6</xmlunit.version>
+ <xmlunit.version>2.9.0</xmlunit.version>
<hk2.osgi.version>org.glassfish.hk2.*;version="[2.5,4)"</hk2.osgi.version>
<hk2.jvnet.osgi.version>org.jvnet.hk2.*;version="[2.5,4)"</hk2.jvnet.osgi.version>
<httpclient.version>4.5.13</httpclient.version>
@@ -2180,10 +2204,12 @@
<jersey1.last.final.version>${jersey1.version}</jersey1.last.final.version>
<jettison.version>1.3.7</jettison.version> <!-- TODO: 1.3.8 doesn't work; AbstractJsonTest complexBeanWithAttributes -->
<jmh.version>1.10.2</jmh.version>
- <jmockit.version>1.44</jmockit.version>
- <junit5.version>5.6.0</junit5.version>
+ <jmockit.version>1.49</jmockit.version>
+ <junit4.version>4.13.2</junit4.version>
+ <junit5.version>5.9.1</junit5.version>
+ <junit-platform-suite.version>1.9.1</junit-platform-suite.version>
<kryo.version>4.0.2</kryo.version>
- <mockito.version>3.9.0</mockito.version> <!-- CQ 17673 -->
+ <mockito.version>3.12.4</mockito.version> <!-- CQ 17673 -->
<mustache.version>0.8.17</mustache.version>
<netty.version>4.1.75.Final</netty.version>
<nexus-staging.mvn.plugin.version>1.6.7</nexus-staging.mvn.plugin.version>
@@ -2202,7 +2228,7 @@
<simple.version>6.0.1</simple.version>
<skip.e2e>false</skip.e2e>
<spring6.version>6.0.0-M3</spring6.version>
- <surefire.version>3.0.0-M6</surefire.version>
+ <surefire.version>3.0.0-M7</surefire.version>
<validation.impl.version>6.2.0.Final</validation.impl.version>
<gson.version>2.9.0</gson.version>
@@ -2247,8 +2273,9 @@
<jaxrs.api.spec.version>3.0</jaxrs.api.spec.version>
<jaxrs.api.impl.version>3.0.0</jaxrs.api.impl.version>
<jetty.osgi.version>org.eclipse.jetty.*;version="[11,15)"</jetty.osgi.version>
- <jetty.version>11.0.9</jetty.version>
- <jetty.plugin.version>11.0.9</jetty.plugin.version>
+ <jetty.version>11.0.12</jetty.version>
+ <jetty9.version>9.4.49.v20220914</jetty9.version>
+ <jetty.plugin.version>11.0.12</jetty.plugin.version>
<jetty.servlet.api.25.version>6.1.14</jetty.servlet.api.25.version>
<jsonb.api.version>2.0.0</jsonb.api.version>
<jsonp.ri.version>1.0.0</jsonp.ri.version>
diff --git a/security/oauth1-client/pom.xml b/security/oauth1-client/pom.xml
index bf765dc..93dbc1e 100644
--- a/security/oauth1-client/pom.xml
+++ b/security/oauth1-client/pom.xml
@@ -67,8 +67,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
diff --git a/security/oauth1-server/pom.xml b/security/oauth1-server/pom.xml
index 86b1409..5887a46 100644
--- a/security/oauth1-server/pom.xml
+++ b/security/oauth1-server/pom.xml
@@ -46,8 +46,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 25069ea..7d40786 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 f21e895..ac3e0da 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, 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
@@ -19,9 +19,9 @@
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.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 b1daa8b..231964a 100644
--- a/security/oauth1-signature/pom.xml
+++ b/security/oauth1-signature/pom.xml
@@ -53,8 +53,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 21a052a..b390aa5 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, 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
@@ -24,8 +24,8 @@
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.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 f72b023..3f0cb79 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 @@
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 a433015..058975a 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 <pbryan@sun.com>
diff --git a/security/oauth2-client/pom.xml b/security/oauth2-client/pom.xml
index 920e17f..1f1370d 100644
--- a/security/oauth2-client/pom.xml
+++ b/security/oauth2-client/pom.xml
@@ -63,6 +63,12 @@
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!--<dependency>-->
diff --git a/test-framework/core/pom.xml b/test-framework/core/pom.xml
index 36b2633..2cc71a0 100644
--- a/test-framework/core/pom.xml
+++ b/test-framework/core/pom.xml
@@ -70,8 +70,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter</artifactId>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
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 fec3b79..243466c 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
@@ -16,6 +16,7 @@
package org.glassfish.jersey.test;
+import java.lang.annotation.Annotation;
import java.net.URI;
import java.security.AccessController;
import java.util.ArrayList;
@@ -28,6 +29,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,11 +54,11 @@
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;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInstance;
/**
* Parent class for testing JAX-RS and Jersey-based applications using Jersey test framework.
@@ -122,7 +124,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 +170,7 @@
private JerseyTestLogHandler logHandler;
private final Map<Logger, Level> logLevelMap = new IdentityHashMap<>();
+ private final AtomicInteger activeThreadCount = new AtomicInteger(0);
/**
* Initialize JerseyTest instance.
@@ -187,7 +189,6 @@
// not be set soon enough
this.context = configureDeployment();
this.testContainerFactory = getTestContainerFactory();
- registerLogHandlerIfEnabled();
}
/**
@@ -209,7 +210,6 @@
// not be set soon enough
this.context = configureDeployment();
this.testContainerFactory = testContainerFactory;
- registerLogHandlerIfEnabled();
}
/**
@@ -234,7 +234,6 @@
public JerseyTest(final Application jaxrsApplication) {
this.context = DeploymentContext.newInstance(jaxrsApplication);
this.testContainerFactory = getTestContainerFactory();
- registerLogHandlerIfEnabled();
}
/**
@@ -618,14 +617,37 @@
@Before
@BeforeEach
public void setUp() throws Exception {
- final TestContainer testContainer = createTestContainer(context);
+ synchronized (this) {
+ if (!isConcurrent() || 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()));
+ }
+ }
+ }
+
+ /**
+ * Do not setup multiple containers for concurrent junit 5 environment not to hit Address already in use exception
+ * @return true when TestInstance.Lifecycle.PER_CLASS annotation is used and the test run in concurrent
+ */
+ private boolean isConcurrent() {
+ Annotation[] annotations = this.getClass().getAnnotations();
+ for (Annotation annotation : annotations) {
+ // check the name first for JUnit 4 only environment
+ if (annotation.annotationType().getName().equals("org.junit.jupiter.api.TestInstance")) {
+ TestInstance testInstance = (TestInstance) annotation;
+ if (testInstance != null && testInstance.value() == TestInstance.Lifecycle.PER_CLASS) {
+ return true;
+ }
+ }
+ }
+ return false;
}
/**
@@ -639,17 +661,21 @@
@After
@AfterEach
public void tearDown() throws Exception {
- if (isLogRecordingEnabled()) {
- unregisterLogHandler();
- }
+ synchronized (this) {
+ if (!isConcurrent() || 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 60b8105..1d2457d 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);
* }
* }
* </pre>
@@ -86,7 +86,7 @@
* WebTarget t = target("root");
*
* String s = t.request().get(String.class);
- * Assert.assertEquals("GET", s);
+ * Assertions.assertEquals("GET", s);
* }
* }
* </pre>
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 23809f6..0aabca5 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 @@
*/
private TestHelper() {
}
+
+ public static DynamicContainer toTestContainer(Object test, String displayName) {
+ Class<?> klass = test.getClass();
+ List<Method> testMethods = ReflectionUtils.findMethods(klass,
+ method -> method.isAnnotationPresent(org.junit.jupiter.api.Test.class)
+ && !method.isAnnotationPresent(org.junit.jupiter.api.Disabled.class));
+ List<Method> beforeEachMethods = ReflectionUtils.findMethods(klass,
+ method -> method.isAnnotationPresent(org.junit.jupiter.api.BeforeEach.class));
+ List<Method> afterEachMethods = ReflectionUtils.findMethods(klass,
+ method -> method.isAnnotationPresent(org.junit.jupiter.api.AfterEach.class));
+ Collection<DynamicTest> 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 ee43895..d3adbb4 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, 2020 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 32d86a4..f279c64 100644
--- a/test-framework/maven/container-runner-maven-plugin/pom.xml
+++ b/test-framework/maven/container-runner-maven-plugin/pom.xml
@@ -39,8 +39,8 @@
<groovy.version>3.0.2</groovy.version>
<groovy-eclipse-compiler.version>3.6.0-03</groovy-eclipse-compiler.version>
<groovy-eclipse-batch.version>3.0.2-02</groovy-eclipse-batch.version>
- <maven.version>3.6.0</maven.version>
- <maven-plugin.version>3.6.0</maven-plugin.version>
+ <maven.version>3.8.6</maven.version>
+ <maven-plugin.version>3.6.4</maven-plugin.version>
</properties>
<dependencies>
@@ -49,6 +49,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
+ <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
@@ -76,11 +77,13 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>${maven.version}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>${maven.version}</version>
+ <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
@@ -99,6 +102,7 @@
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>${maven.version}</version>
+ <scope>provided</scope>
</dependency>
<!-- dependencies to annotations -->
@@ -147,6 +151,14 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
</dependency>
<dependency>
diff --git a/test-framework/maven/custom-enforcer-rules/pom.xml b/test-framework/maven/custom-enforcer-rules/pom.xml
index c690eef..b99519e 100644
--- a/test-framework/maven/custom-enforcer-rules/pom.xml
+++ b/test-framework/maven/custom-enforcer-rules/pom.xml
@@ -60,6 +60,26 @@
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-classworlds</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.aether</groupId>
+ <artifactId>aether-util</artifactId>
+ </exclusion>
</exclusions>
</dependency>
@@ -70,8 +90,8 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>compile</scope>
</dependency>
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 301369a..0c2d91a 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 1897a2b..681106a 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 a9b8f3d..d39a745 100644
--- a/test-framework/memleak-test-common/pom.xml
+++ b/test-framework/memleak-test-common/pom.xml
@@ -37,8 +37,13 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
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 149405f..0388c39 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 faede81..d1879ba 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 @@
*
* @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 200b10a..3398707 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<Void> invocation, ReflectiveInvocationContext<Method> 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 eadee50..7a929e6 100644
--- a/test-framework/pom.xml
+++ b/test-framework/pom.xml
@@ -42,8 +42,13 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
diff --git a/test-framework/providers/bundle/pom.xml b/test-framework/providers/bundle/pom.xml
index adc29af..72fbc27 100644
--- a/test-framework/providers/bundle/pom.xml
+++ b/test-framework/providers/bundle/pom.xml
@@ -62,6 +62,12 @@
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-netty</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.servlet</groupId>
+ <artifactId>jakarta.servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
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 f276547..90ef96a 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, 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
@@ -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 2ee0125..ebd2d01 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, 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,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 @@
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 @@
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 c7bc78e..5b8ce9d 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, 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
@@ -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 87eb00f..99fed28 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, 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
@@ -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 d7c0464..5ebb70d 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, 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
@@ -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 @@
// 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 012357e..cebf5bc 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, 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
@@ -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 e959498..4c76035 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, 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
@@ -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 76d46c3..a767cb2 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, 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
@@ -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 @@
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 9f9ea38..8f6a0ac 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, 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
@@ -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 @@
WebTarget target = target("root");
String s = target.request().get(String.class);
- Assert.assertEquals("GET", s);
+ Assertions.assertEquals("GET", s);
}
@Test
@@ -77,6 +77,6 @@
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 92498c9..e4a3f74 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, 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
@@ -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 0d39d60..8b12d6a 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, 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
@@ -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 @@
private SSLContext serverSslContext;
private SSLParameters serverSslParameters;
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
@Override
protected TestContainerFactory getTestContainerFactory() {
return new GrizzlyTestContainerFactory();
@@ -112,33 +107,33 @@
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);
+ Assertions.assertThrows(ProcessingException.class, () -> {
+ SSLContext clientSslContext = SslUtils.createClientSslContext(false, false);
- Client client = ClientBuilder.newBuilder()
- .sslContext(clientSslContext)
- .build();
+ Client client = ClientBuilder.newBuilder()
+ .sslContext(clientSslContext)
+ .build();
- WebTarget target = client.target(getBaseUri()).path("secure");
+ WebTarget target = client.target(getBaseUri()).path("secure");
- exception.expect(ProcessingException.class);
-
- target.request().get(String.class);
+ target.request().get(String.class);
+ });
}
@Test
public void testGetFailsWhenClientExecutesRequestWithoutHavingSslConfigured() {
- Client client = ClientBuilder.newClient();
+ Assertions.assertThrows(ProcessingException.class, () -> {
+ Client client = ClientBuilder.newClient();
- WebTarget target = client.target(getBaseUri()).path("secure");
+ WebTarget target = client.target(getBaseUri()).path("secure");
- exception.expect(ProcessingException.class);
-
- 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 53bb930..3d97974 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, 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
@@ -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 @@
private SSLContext serverSslContext;
private SSLParameters serverSslParameters;
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
@Override
protected TestContainerFactory getTestContainerFactory() {
return new GrizzlyTestContainerFactory();
@@ -113,48 +108,48 @@
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");
+ WebTarget target = client.target(getBaseUri()).path("more-secure");
- exception.expect(ProcessingException.class);
-
- 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();
+ Client client = ClientBuilder.newBuilder()
+ .sslContext(clientSslContext)
+ .build();
- WebTarget target = client.target(getBaseUri()).path("more-secure");
+ WebTarget target = client.target(getBaseUri()).path("more-secure");
- exception.expect(ProcessingException.class);
-
- target.request().get(String.class);
+ target.request().get(String.class);
+ });
}
@Test
public void testGetFailsWhenClientExecutesRequestWithoutHavingSslConfigured() {
- Client client = ClientBuilder.newClient();
+ Assertions.assertThrows(ProcessingException.class, () -> {
+ Client client = ClientBuilder.newClient();
- WebTarget target = client.target(getBaseUri()).path("more-secure");
+ WebTarget target = client.target(getBaseUri()).path("more-secure");
- exception.expect(ProcessingException.class);
-
- 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 7942b6f..455bcf2 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, 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
@@ -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 faff77e..1e1ec76 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, 2020 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 2e412fc..98b5e21 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, 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
@@ -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 4452a45..9139190 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, 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
@@ -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 371c76a..2655fc3 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, 2020 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 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 af5069c..4f278e3 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, 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
@@ -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 31193c2..7481e8d 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, 2020 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 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 @@
} 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 3e1348c..5e3ab0b 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, 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
@@ -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 9f2c352..4b869cf 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, 2020 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 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 569ab3e..c36359f 100644
--- a/test-framework/util/pom.xml
+++ b/test-framework/util/pom.xml
@@ -43,5 +43,32 @@
<artifactId>jersey-client</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <dependencies>
+ <!-- JUnit vintage engine to run JUnit 4 tests -->
+ <dependency>
+ <groupId>org.junit.vintage</groupId>
+ <artifactId>junit-vintage-engine</artifactId>
+ <version>${junit5.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
</project>
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 a62a586..3813380 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
+ * <a href="https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution">executions tools</a>.
*/
@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 f4f4d5f..9540560 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
+ * <a href="https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution">executions tools</a>.
*/
@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 9dee038..49a474f 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
+ * <a href="https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution">executions tools</a>.
*/
@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 67f6287..431f1d7 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, 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
@@ -28,12 +28,13 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.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 @@
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 @@
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 @@
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/test-framework/util/src/test/java/org/glassfish/jersey/test/util/runner/ConcurrentRunnerTest.java b/test-framework/util/src/test/java/org/glassfish/jersey/test/util/runner/ConcurrentRunnerTest.java
index 41f0ac5..391ab4f 100644
--- a/test-framework/util/src/test/java/org/glassfish/jersey/test/util/runner/ConcurrentRunnerTest.java
+++ b/test-framework/util/src/test/java/org/glassfish/jersey/test/util/runner/ConcurrentRunnerTest.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,6 +30,7 @@
*
* @author Jakub Podlesak
*/
+@SuppressWarnings({"unchecked", "deprecation"})
@RunWith(ConcurrentRunner.class)
public class ConcurrentRunnerTest extends TestCase {
diff --git a/tests/e2e-client/pom.xml b/tests/e2e-client/pom.xml
index 10c79d4..8dae6fa 100644
--- a/tests/e2e-client/pom.xml
+++ b/tests/e2e-client/pom.xml
@@ -178,8 +178,9 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-suite</artifactId>
+ <version>${junit-platform-suite.version}</version>
<scope>test</scope>
</dependency>
<dependency>
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 97cd2fe..868a7d3 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, 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
@@ -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 @@
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 479d9dd..b51312c 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, 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
@@ -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 jakarta.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 74f6bf1..ed122f3 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 @@
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 @@
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 1895c84..c27459a 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, 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
@@ -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 3298e5d..58e6033 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
@@ -51,12 +51,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;
/**
* Reproducer for JERSEY-2705. Client side entity InputStream exception
@@ -160,15 +160,14 @@
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));
+ assertEquals(200, testResponse.getStatus(), "Unexpected response status code.");
+ assertEquals("16", testResponse.readEntity(String.class), "Unexpected response entity.");
- 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));
+ 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.");
}
/**
@@ -191,24 +190,23 @@
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");
@@ -216,16 +214,15 @@
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 785bc0d..0e971dc 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, 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
@@ -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 @@
* fix length streaming on {@code HttpURLConnection}.
*/
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testDisableBufferingWithFixedLengthViaProperty() {
postLatch = new CountDownLatch(1);
@@ -107,9 +108,9 @@
= 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 @@
* fix length streaming on {@code HttpURLConnection}.
*/
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testDisableBufferingWithFixedLengthViaMethod() {
postLatch = new CountDownLatch(1);
@@ -136,9 +138,9 @@
= 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.");
}
/**
@@ -147,12 +149,13 @@
* Content-length request attribute. This cause problems for large entities.
* <p>
* In Jersey 1.x chunk encoding with {@code HttpURLConnection} was causing bugs
- * which occurred from time to time. This looks to be a case also in Jersey 3.x. This test
+ * which occurred from time to time. This looks to be a case also in Jersey 2.x. This test
* has failed unpredictably on some machines. Therefore it is disabled now.
* </p>
*/
@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 @@
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 @@
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 7e32a17..1d50cb3 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 @@
private static final Map<String, Boolean> destroyed = new HashMap<>();
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
destroyed.clear();
destroyed.put("filter", false);
@@ -228,22 +228,22 @@
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 c6c80df..ace326f 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, 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
@@ -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 @@
Entity<String> 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 @@
@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 a8cb9b7..9797387 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, 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
@@ -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 @@
* 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 @@
.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 88dea4b..adc7446 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, 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
@@ -43,9 +43,8 @@
import org.glassfish.jersey.spi.ExecutorServiceProvider;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Before;
-import org.junit.Ignore;
-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;
@@ -74,7 +73,7 @@
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 9f82be8..c9d76e4 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, 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
@@ -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 c2b9c9b..2b6c33e 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, 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
@@ -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.
@@ -53,8 +53,7 @@
Response response = client().target("http://localhost:" + getPort() + "/test/{beginBy}")
.resolveTemplate("beginBy", "abc")
- .request(MediaType.TEXT_PLAIN_TYPE)
- .get();
+ .request(MediaType.TEXT_PLAIN_TYPE).get();
assertEquals(200, response.getStatus());
assertEquals("test-get,abc", response.readEntity(String.class));
}
@@ -64,8 +63,7 @@
*/
@Test
public void pathConcatenationTest1() {
- Response response = client().target("http://localhost:" + getPort()).path("path")
- .request(MediaType.TEXT_PLAIN_TYPE)
+ Response response = client().target("http://localhost:" + getPort()).path("path").request(MediaType.TEXT_PLAIN_TYPE)
.get();
assertEquals(200, response.getStatus());
assertEquals("test-path", response.readEntity(String.class));
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 7e917c2..5d49aa4 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, 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
@@ -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 @@
}
}
- @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 e7d8e96..b7e4769 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, 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
@@ -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 @@
@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 1ad6c53..ee33037 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, 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
@@ -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 e0beea0..2b9a2f3 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 38655f9..24197b5 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, 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
@@ -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 @@
}
@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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testBasicNonPreemptiveWithEmptyPassword() {
final WebTarget target = target().path("resource")
.register(HttpAuthenticationFeature.basicBuilder().nonPreemptive().build());
@@ -279,7 +282,7 @@
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 @@
}
@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 @@
* insensitve.
*/
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testUniversalBasicCaseSensitivity() {
Response response;
@@ -330,6 +335,7 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testDigest() {
Response response = target().path("resource").path("digest")
.register(HttpAuthenticationFeature.digest("homer", "Homer"))
@@ -386,6 +395,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testDigestWithPasswords() {
final WebTarget target = target().path("resource").path("digest")
.register(HttpAuthenticationFeature.digest("homer", "Homer"));
@@ -393,6 +403,7 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testDigestWithEmptyDefaultPassword() {
final WebTarget target = target().path("resource")
.register(HttpAuthenticationFeature.digest());
@@ -427,6 +439,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testDigestUniversalWithEmptyDefaultPassword() {
final WebTarget target = target().path("resource")
.register(HttpAuthenticationFeature.universalBuilder().build());
@@ -452,7 +465,7 @@
.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 @@
}
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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testDigestUniversalSimple3() {
Response response = target().path("resource").path("digest")
.register(HttpAuthenticationFeature.universalBuilder()
@@ -500,6 +516,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testDigestUniversalSimple4() {
Response response = target().path("resource").path("digest")
.register(HttpAuthenticationFeature.universal("homer", "Homer"))
@@ -508,6 +525,7 @@
}
@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 9f506b0..74bc3ca 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
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 fe3813c..a0d90fb 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, 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
@@ -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 jakarta.ws.rs.Consumes;
import jakarta.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 f5587aa..0428b59 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 9e21b10..39c31c1 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, 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
@@ -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 @@
/**
* 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 @@
/**
* 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 573be80..7cf59c2 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, 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
@@ -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 3d768f2..6ec8640 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, 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
@@ -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 15096e7..6e7aea6 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
@@ -46,7 +46,7 @@
private static final String ECHO = "ECHO";
private CountDownLatch latch;
- @Before
+ @BeforeEach
public void beforeEach() {
latch = new CountDownLatch(1);
}
@@ -95,8 +95,8 @@
.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 @@
.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 @@
.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 @@
.method("POST", Entity.entity(ECHO, MediaType.TEXT_PLAIN), new GenericType<Response>(){});
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 c00b360..a231a95 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, 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
@@ -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 655104f..8baf262 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, 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
@@ -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 @@
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 @@
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 b5ff140..d53685e 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, 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,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 fe04e6d..13f8a3b 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, 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
@@ -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 fd16afb..8b54346 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, 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,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 @@
// 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 @@
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 @@
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 5a0b830..e0538a3 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, 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
@@ -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,16 +39,15 @@
import org.glassfish.jersey.jetty.connector.JettyConnectorProvider;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-
-import org.glassfish.jersey.tests.e2e.client.connector.ProviderFiltering;
-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
@@ -58,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<ConnectorProvider> connectionProviders() {
+ return Arrays.asList(
+ new GrizzlyConnectorProvider(),
+ new JettyConnectorProvider(),
+ new ApacheConnectorProvider(),
+ new HttpUrlConnectorProvider()
+ );
}
-
- @Parameterized.Parameters
- public static List<ConnectorProvider[]> connectionProviders() {
- return Arrays.asList(ProviderFiltering.filterProviders(new ConnectorProvider[][] {
- {new GrizzlyConnectorProvider()},
- {new JettyConnectorProvider()},
- {new ApacheConnectorProvider()},
- {new HttpUrlConnectorProvider()}
- }));
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ connectionProviders().forEach(connectionProvider -> {
+ ShutdownHookMemoryLeakTemplateTest test = new ShutdownHookMemoryLeakTemplateTest(connectionProvider) {};
+ tests.add(TestHelper.toTestContainer(test, connectionProvider.getClass().getSimpleName()));
+ });
+ return tests;
}
@Path(PATH)
@@ -90,63 +91,72 @@
}
}
- @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());
+ @Override
+ protected Application configure() {
+ return new ResourceConfig(TestResource.class);
+ }
- assertThat(String.format(
- "%s: number of initialized listeners should be the same as number of total request count",
- connectorProvider.getClass()),
- listenersInitialized.get(), is(ITERATIONS));
+ @Override
+ protected void configureClient(ClientConfig config) {
+ config.connectorProvider(connectorProvider);
+ }
-// 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()));
+ @Test
+ @Disabled("Unstable, ignored for now")
+ public void testClientDoesNotLeakResources() throws Exception {
- client().close(); // clean up the rest
+ final AtomicInteger listenersInitialized = new AtomicInteger(0);
+ final AtomicInteger listenersClosed = new AtomicInteger(0);
- 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));
- }
+ for (int i = 0; i < ITERATIONS; i++) {
+ final Response response = target(PATH).property("another", "runtime").register(new ClientLifecycleListener() {
+ @Override
+ public void onInit() {
+ listenersInitialized.incrementAndGet();
+ }
- private Collection getShutdownHooks(jakarta.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);
+ @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(jakarta.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 8ea22b0..dc8300f 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, 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
@@ -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 4a4fabe..051be02 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,12 +16,15 @@
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;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.stream.Stream;
import jakarta.ws.rs.PATCH;
import jakarta.ws.rs.Path;
@@ -33,8 +36,10 @@
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.HttpUrlConnectorProvider;
import org.glassfish.jersey.client.spi.ConnectorProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
+import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.jdk.connector.JdkConnectorProvider;
import org.glassfish.jersey.jetty.connector.JettyConnectorProvider;
import org.glassfish.jersey.logging.LoggingFeature;
@@ -42,121 +47,135 @@
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<Object[]> testData() {
- return Arrays.asList(ProviderFiltering.filterProviders(new Object[][]{
- // {HttpUrlConnectorProvider.class}, // cannot process PATCH without additional configuration
- {GrizzlyConnectorProvider.class},
- {JettyConnectorProvider.class}, // unstable.
- {ApacheConnectorProvider.class},
- {Apache5ConnectorProvider.class},
- {NettyConnectorProvider.class},
- {JdkConnectorProvider.class},
- }));
+ public static List<ConnectorProvider> testData() {
+ int size = JdkVersion.getJdkVersion().getMajor() < 11 ? 5 : 6;
+ final ConnectorProvider[] providers = new ConnectorProvider[size];
+ providers[0] = new JdkConnectorProvider();
+ providers[1] = new GrizzlyConnectorProvider();
+ providers[2] = new ApacheConnectorProvider();
+ providers[3] = new Apache5ConnectorProvider();
+ providers[4] = new NettyConnectorProvider();
+ if (size == 6) {
+ providers[5] = new JettyConnectorProvider();
+ }
+ return Arrays.asList(providers);
}
- private final ConnectorProvider connectorProvider;
-
- public HttpPatchTest(Class<? extends ConnectorProvider> connectorProviderClass)
- throws IllegalAccessException, InstantiationException {
- this.connectorProvider = connectorProviderClass.newInstance();
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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<String>() {
- });
+ @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> 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<String>() {
+ });
- assertEquals(200, response.get().getStatus());
- assertEquals("patch", response.get().readEntity(String.class));
- }
+ assertEquals("patch", response);
+ }
- @Test
- public void testAsyncPatchEntity() throws Exception {
- Future<String> response = target().request().async().method("PATCH", Entity.text("patch"), String.class);
+ @Test
+ public void testAsyncPatchResponse() throws Exception {
+ Future<Response> 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<String> response = target().request().async().method("PATCH", Entity.text("patch"), new GenericType<String>() {
- });
+ @Test
+ public void testAsyncPatchEntity() throws Exception {
+ Future<String> 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> response = target().request().rx().method("PATCH", Entity.text("patch"));
+ @Test
+ public void testAsyncPatchGenericType() throws Exception {
+ Future<String> response = target().request().async().method("PATCH", Entity.text("patch"), new GenericType<String>() {
+ });
- 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<String> response = target().request().rx().method("PATCH", Entity.text("patch"), String.class);
+ @Test
+ public void testRxPatchResponse() throws Exception {
+ CompletionStage<Response> 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 testRxPatchGenericType() throws Exception {
- CompletionStage<String> response = target().request().rx()
- .method("PATCH", Entity.text("patch"), new GenericType<String>() {
- });
+ @Test
+ public void testRxPatchEntity() throws Exception {
+ CompletionStage<String> response = target().request().rx().method("PATCH", Entity.text("patch"), String.class);
- assertEquals("patch", response.toCompletableFuture().get());
+ assertEquals("patch", response.toCompletableFuture().get());
+ }
+
+ @Test
+ public void testRxPatchGenericType() throws Exception {
+ CompletionStage<String> response = target().request().rx()
+ .method("PATCH", Entity.text("patch"), new GenericType<String>() {
+ });
+
+ 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 d955ff3..551d72c 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;
@@ -56,29 +58,30 @@
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.client.spi.ConnectorProvider;
+import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
import org.glassfish.jersey.jetty.connector.JettyConnectorProvider;
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 +100,121 @@
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<Object[]> testData() {
- return Arrays.asList(ProviderFiltering.filterProviders(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
- }));
+ return Arrays.asList(new Object[][] {
+ {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<? extends ConnectorProvider> connectorProviderClass,
- boolean modificationSupported, boolean addHeader)
- throws IllegalAccessException, InstantiationException {
- this.connectorProvider = connectorProviderClass.newInstance();
- this.modificationSupported = modificationSupported;
- this.addHeader = addHeader;
- }
-
- @Override
- protected Application configure() {
- set(TestProperties.RECORD_LOG_LEVEL, Level.WARNING.intValue());
-
- enable(TestProperties.LOG_TRAFFIC);
- if (DUMP_ENTITY) {
- enable(TestProperties.DUMP_ENTITY);
- }
- 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);
- }
-
- @Test
- public void testWarningLogged() throws Exception {
- Response response = requestBuilder().post(requestEntity());
- assertResponse(response);
- }
-
- @Test
- public void testWarningLoggedAsync() throws Exception {
- AsyncInvoker asyncInvoker = requestBuilder().async();
- Future<Response> responseFuture = asyncInvoker.post(requestEntity());
- Response response = responseFuture.get();
- assertResponse(response);
- }
-
- 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");
- }
-
- private Entity<MyEntity> 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("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);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ testData().forEach(arr -> {
+ if (JdkVersion.getJdkVersion().getMajor() < 11
+ && arr[0].getClass().getName().contains("Jetty")) {
+ return;
}
- }
-
- assertEquals(200, response.getStatus());
- assertEquals(ANSWER, response.readEntity(String.class));
+ 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;
}
- private LogRecord findLogRecord(String messageContains) {
- for (final LogRecord record : getLoggedRecords()) {
- if (record.getMessage().contains(messageContains)) {
- return record;
- }
+ public abstract static class RequestHeaderModificationsTemplateTest extends JerseyTest {
+ private final ConnectorProvider connectorProvider;
+ private final boolean modificationSupported; // remove when JERSEY-2341 fixed
+ private final boolean addHeader;
+
+ public RequestHeaderModificationsTemplateTest(ConnectorProvider connectorProvider,
+ boolean modificationSupported, boolean addHeader) {
+ this.connectorProvider = connectorProvider;
+ this.modificationSupported = modificationSupported;
+ this.addHeader = addHeader;
}
- return null;
+
+ @Override
+ protected Application configure() {
+ set(TestProperties.RECORD_LOG_LEVEL, Level.WARNING.intValue());
+
+ enable(TestProperties.LOG_TRAFFIC);
+ if (DUMP_ENTITY) {
+ enable(TestProperties.DUMP_ENTITY);
+ }
+ 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);
+ }
+
+ @Test
+ public void testWarningLogged() throws Exception {
+ Response response = requestBuilder().post(requestEntity());
+ assertResponse(response);
+ }
+
+ @Test
+ public void testWarningLoggedAsync() throws Exception {
+ AsyncInvoker asyncInvoker = requestBuilder().async();
+ Future<Response> responseFuture = asyncInvoker.post(requestEntity());
+ Response response = responseFuture.get();
+ assertResponse(response);
+ }
+
+ 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");
+ }
+
+ private Entity<MyEntity> 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;
+ }
+ }
+ 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 91ea1b1..8c3bdc4 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 jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -42,40 +36,20 @@
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> 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<? extends ConnectorProvider> 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 @@
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 @@
System.setProperty("http.proxyPort", "9997");
}
- @AfterClass
+ @AfterAll
public static void tearDownProxy() {
try {
server.stop();
@@ -122,7 +96,7 @@
}
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 f3006e2..efaf2ce 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,13 @@
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 org.junit.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -47,19 +47,25 @@
import jakarta.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)
+@Suite
+@SelectClasses({
+ ProxyTest.ApacheConnectorProviderProxyTest.class,
+ ProxyTest.Apache5ConnectorProviderProxyTest.class,
+ ProxyTest.GrizzlyConnectorProviderProxyTest.class,
+ ProxyTest.JettyConnectorProviderProxyTest.class,
+ ProxyTest.NettyConnectorProviderProxyTest.class,
+ ProxyTest.HttpUrlConnectorProviderProxyTest.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 +73,133 @@
private static final String PROXY_PASSWORD = "proxy-password";
private static final String NO_PASS = "no-pass";
- @Parameterized.Parameters(name = "{index}: {0}")
- public static List<Object[]> testData() {
- return Arrays.asList(new Object[][]{
- {ApacheConnectorProvider.class},
- {Apache5ConnectorProvider.class},
- {GrizzlyConnectorProvider.class},
- {JettyConnectorProvider.class},
- {NettyConnectorProvider.class},
- {HttpUrlConnectorProvider.class},
- });
- }
-
- private final ConnectorProvider connectorProvider;
-
- public ProxyTest(Class<? extends ConnectorProvider> connectorProviderClass)
- throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
- this.connectorProvider = connectorProviderClass.getConstructor().newInstance();
- }
-
- protected void configureClient(ClientConfig config) {
- config.connectorProvider(connectorProvider);
- }
-
- @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 ApacheConnectorProviderProxyTest extends ProxyTemplateTest {
+ public ApacheConnectorProviderProxyTest()
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ super(ApacheConnectorProvider.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 Apache5ConnectorProviderProxyTest extends ProxyTemplateTest {
+ public Apache5ConnectorProviderProxyTest()
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ super(Apache5ConnectorProvider.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());
- }
-
- private static Server server;
- @BeforeClass
- public static void startFakeProxy() {
- server = new Server(9997);
- server.setHandler(new ProxyHandler());
- try {
- server.start();
- } catch (Exception e) {
-
+ public static class GrizzlyConnectorProviderProxyTest extends ProxyTemplateTest {
+ public GrizzlyConnectorProviderProxyTest()
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ super(GrizzlyConnectorProvider.class);
}
}
- @AfterClass
- public static void tearDownProxy() {
- try {
- server.stop();
- } catch (Exception e) {
-
+ public static class JettyConnectorProviderProxyTest extends ProxyTemplateTest {
+ public JettyConnectorProviderProxyTest()
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ super(JettyConnectorProvider.class);
}
}
- private static Client client;
- @Before
- public void beforeEach() {
- ClientConfig config = new ClientConfig();
- this.configureClient(config);
- client = ClientBuilder.newClient(config);
+ public static class NettyConnectorProviderProxyTest extends ProxyTemplateTest {
+ public NettyConnectorProviderProxyTest()
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ super(NettyConnectorProvider.class);
+ }
}
- private Client client() {
- return client;
+ public static class HttpUrlConnectorProviderProxyTest extends ProxyTemplateTest {
+ public HttpUrlConnectorProviderProxyTest()
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException,
+ IllegalAccessException {
+ super(HttpUrlConnectorProvider.class);
+ }
}
- private WebTarget target(String path) {
- return client().target("http://localhost:9998").path(path);
+ public abstract static class ProxyTemplateTest {
+ private final ConnectorProvider connectorProvider;
+
+ public ProxyTemplateTest(Class<? extends ConnectorProvider> connectorProviderClass)
+ throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
+ this.connectorProvider = connectorProviderClass.getConstructor().newInstance();
+ }
+
+
+ protected void configureClient(ClientConfig config) {
+ config.connectorProvider(connectorProvider);
+ }
+
+ @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());
+ }
+ }
+
+ @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 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 7976f4d..a458eb9 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;
@@ -28,13 +29,11 @@
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.glassfish.jersey.client.spi.ConnectorProvider;
import org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider;
+import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.jetty.connector.JettyConnectorProvider;
-import org.glassfish.jersey.tests.e2e.client.connector.ProviderFiltering;
-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 org.apache.commons.io.IOUtils;
@@ -43,7 +42,6 @@
*
* @author Petr Bouda
*/
-@RunWith(Parameterized.class)
public abstract class AbstractConnectorServerTest {
// Default truststore and keystore
@@ -56,24 +54,23 @@
*
* @return test parameters.
*/
- @Parameterized.Parameters(name = "{index}: {0}")
- public static Iterable<Object[]> testData() {
- return Arrays.asList(ProviderFiltering.filterProviders(new Object[][] {
- {new HttpUrlConnectorProvider()},
- {new GrizzlyConnectorProvider()},
- {new JettyConnectorProvider()},
- {new ApacheConnectorProvider()},
- {new Apache5ConnectorProvider()}
- }));
+ public static Stream<ConnectorProvider> testData() {
+ int size = JdkVersion.getJdkVersion().getMajor() < 11 ? 4 : 5;
+ final ConnectorProvider[] providers = new ConnectorProvider[size];
+ providers[0] = new HttpUrlConnectorProvider();
+ providers[1] = new GrizzlyConnectorProvider();
+ providers[2] = new ApacheConnectorProvider();
+ providers[3] = new Apache5ConnectorProvider();
+ if (size == 5) {
+ providers[4] = new JettyConnectorProvider();
+ }
+ return Stream.of(providers);
}
- @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) {
@@ -84,7 +81,7 @@
}
}
- @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 801d28c..2b07d63 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 @@
*
* @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 @@
*
* @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 @@
*
* @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 @@
/**
* 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 1e21173..364c214 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, 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
@@ -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 @@
*
* @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 @@
}
}
- private boolean isExcluded(List<Class<? extends ConnectorProvider>> excluded) {
+ private boolean isExcluded(List<Class<? extends ConnectorProvider>> 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 f687407..d958151 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 @@
*
* @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 @@
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<Exception> 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 cb1a3e4..7434408 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, 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,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 @@
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 c003db9..c4ea5e3 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, 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
@@ -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 @@
}
@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 176e4d3..f057572 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 jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
@@ -33,7 +33,7 @@
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.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 @@
@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 @@
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 @@
.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 @@
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 @@
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 @@
.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 @@
.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 0c97c1f..d4e8113 100644
--- a/tests/e2e-core-common/pom.xml
+++ b/tests/e2e-core-common/pom.xml
@@ -39,8 +39,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 5a506a2..491f42b 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, 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
@@ -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 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 14c7360..27f009e 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, 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
@@ -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 ServiceFinderBinderTest() {
}
- @BeforeClass
+ @BeforeAll
public static void setUpClass() throws Exception {
AbstractBinder binder = new AbstractBinder() {
@Override
@@ -60,7 +60,7 @@
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 c18203f..bd07da2 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, 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
@@ -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 @@
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 cf7128e..29f460b 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, 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
@@ -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 @@
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 @@
final ExceptionMapper<RuntimeException> 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 @@
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 7226d8d..85f1ea6 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, 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
@@ -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 22c679f..e056964 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 @@
@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 335f5be..331a893 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, 2020 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 0855b45..961af30 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, 2020 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 2faf424..740549a 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<Object[]> getParameters() {
+ public static Stream<Arguments> getParameters() {
final Map<String, String> emptyParams = new HashMap<String, String>();
final Map<String, String> params = new HashMap<String, String>();
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 32718d6..5bcb606 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, 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
@@ -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 jakarta.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<Object[]> 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<Arguments> 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 78da593..54771a9 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, 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
@@ -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 @@
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 767b644..ad4b91a 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, 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
@@ -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 6859bfc..f252906 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 e11c1e8..91c325e 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, 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
@@ -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 2ea67da..1c11687 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, 2020 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 @@
}
}
- @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 3faed55..d999e91 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, 2020 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 42eec6c..3bcd66a 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, 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
@@ -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 c4870e5..502356b 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, 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
@@ -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 @@
@Test
public void testConvertToString() {
final List<MediaType> 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 b230615..392701c 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, 2020 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 21c45ca..c001cd9 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
}
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 2da0916..8456fd7 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, 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
@@ -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 d9e4ee3..e15c0ff 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, 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
@@ -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 jakarta.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<Object[]> 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<Arguments> 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 e6d18a0..d1b4d38 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, 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
@@ -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 jakarta.ws.rs.core.Configuration}.
@@ -77,7 +77,7 @@
private CommonConfig config;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
config = new CommonConfig(null, ComponentBag.INCLUDE_ALL);
}
@@ -442,9 +442,9 @@
final ContractProvider contractProvider = config.getComponentBag().getModel(ComplexEmptyProvider.class);
final Set<Class<?>> 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 @@
final ContractProvider contractProvider = config.getComponentBag().getModel(ComplexEmptyProvider.class);
final Set<Class<?>> 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 @@
throws Exception {
// Not null.
- assertNotNull(testName + " - returned collection is null.", collection);
+ assertNotNull(collection, testName + " - returned collection is null.");
// Immutability.
try {
@@ -965,7 +965,7 @@
@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 @@
}
@Test
- @Ignore
+ @Disabled
public void testFeatureInjectionsBindInFeature() throws Exception {
config.register(new BindInjectMeInFeature());
config.register(InjectIntoFeatureClass.class);
@@ -1078,9 +1078,9 @@
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 @@
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 d72bdaa..040aeb2 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, 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
@@ -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 @@
/**
* Set-up the tests.
*/
- @Before
+ @BeforeEach
public void setup() {
injectionManager = Injections.createInjectionManager(this);
ExecutorProviders.registerExecutorBindings(injectionManager);
@@ -262,8 +262,8 @@
}
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 36a23e9..7582894 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 755b805..88c1496 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 @@
}
@Test
- @Ignore
+ @Disabled
public void failingTests() {
testUri("a://#fragment"); // fails in JerseyUriBuilder
testUri("a://?query");
@@ -413,107 +413,107 @@
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 @@
final List<PathSegment> ps = UriComponent.decodePath(uri, true);
final MultivaluedMap<String, String> mps = ps.get(2).getMatrixParameters();
final List<String> 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<String> 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 @@
final List<PathSegment> ps = UriComponent.decodePath(uri, true);
final MultivaluedMap<String, String> mps = ps.get(2).getMatrixParameters();
final List<String> 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<String> 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 @@
final List<PathSegment> ps = UriComponent.decodePath(uri, true);
final MultivaluedMap<String, String> mps = ps.get(2).getMatrixParameters();
final List<String> 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<String> 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<String> 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 @@
MultivaluedMap<String, String> mps = ps.get(0).getMatrixParameters();
List<String> 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<String> 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<String> 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<String> 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 @@
final List<PathSegment> ps = UriComponent.decodePath(uri, true);
final MultivaluedMap<String, String> mps = ps.get(2).getMatrixParameters();
final List<String> 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 @@
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 @@
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 @@
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 @@
final MultivaluedMap<String, String> qps = UriComponent.decodeQuery(uri, true);
final List<String> 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<String> 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<String> 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 @@
final MultivaluedMap<String, String> qps = UriComponent.decodeQuery(uri, true);
final List<String> 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<String> 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<String> 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 @@
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 @@
caught = true;
}
- Assert.assertTrue(caught);
+ Assertions.assertTrue(caught);
}
}
@@ -724,12 +724,12 @@
final MultivaluedMap<String, String> qps = UriComponent.decodeQuery(uri, true);
final List<String> 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<String> 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
@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 @@
@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 @@
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 @@
@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 @@
@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 @@
@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<T, U> {
@@ -1081,20 +1081,20 @@
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<String, Object> m = new HashMap<String, Object>();
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 @@
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<String, Object> m = new HashMap<String, Object>();
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 @@
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 @@
caught = true;
}
- Assert.assertTrue(caught);
+ Assertions.assertTrue(caught);
}
@Test
@@ -1173,29 +1173,29 @@
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<String, Object> m = new HashMap<String, Object>();
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<String, Object> m = new HashMap<String, Object>();
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 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<String, Object> m = new HashMap<String, Object>();
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<String, Object> m = new HashMap<String, Object>();
m.put("foo", "x");
@@ -1227,7 +1227,7 @@
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 @@
.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<String, Object> m = new HashMap<String, Object>();
m.put("foo", "x");
@@ -1244,34 +1244,34 @@
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<String, Object> m = new HashMap<String, Object>();
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<String, Object> m = new HashMap<String, Object>();
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 @@
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 @@
} catch (final IllegalArgumentException e) {
caught = true;
}
- Assert.assertTrue(caught);
+ Assertions.assertTrue(caught);
caught = false;
try {
@@ -1300,7 +1300,7 @@
} catch (final IllegalArgumentException e) {
caught = true;
}
- Assert.assertTrue(caught);
+ Assertions.assertTrue(caught);
caught = false;
try {
@@ -1308,7 +1308,7 @@
} catch (final IllegalArgumentException e) {
caught = true;
}
- Assert.assertTrue(caught);
+ Assertions.assertTrue(caught);
}
@Test
@@ -1334,7 +1334,7 @@
} catch (final IllegalArgumentException e) {
caught = true;
}
- Assert.assertTrue(caught);
+ Assertions.assertTrue(caught);
}
@Test
@@ -1345,7 +1345,7 @@
} catch (final IllegalArgumentException e) {
caught = true;
}
- Assert.assertTrue(caught);
+ Assertions.assertTrue(caught);
}
@Test
@@ -1353,16 +1353,16 @@
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 @@
} 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 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
uriBuilder.resolveTemplatesFromEncoded(resolveMap);
final Map<String, Object> buildMap = new HashMap<String, Object>();
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 @@
uriBuilder.resolveTemplates(resolveMap);
final Map<String, Object> buildMap = new HashMap<String, Object>();
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 @@
uriBuilder.resolveTemplates(resolveMap, false);
final Map<String, Object> buildMap = new HashMap<String, Object>();
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 @@
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 @@
.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 @@
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 @@
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 @@
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 @@
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 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 @@
.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 3c654b5..7e0c7db 100644
--- a/tests/e2e-entity/pom.xml
+++ b/tests/e2e-entity/pom.xml
@@ -164,7 +164,12 @@
<artifactId>jersey-test-framework-util</artifactId>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-suite</artifactId>
+ <version>${junit-platform-suite.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
@@ -184,8 +189,9 @@
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-core</artifactId>
+ <version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
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 da19ee8..5c089d5 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, 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
@@ -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 @@
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 4fac5d3..1daf862 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, 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
@@ -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 f286519..491f01b 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, 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
@@ -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 aadab80..f7cfe15 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, 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
@@ -33,22 +33,30 @@
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 org.junit.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Paul Sandoz
* @author Martin Matula
*/
-@RunWith(Enclosed.class)
+@Suite
+@SelectClasses({
+ ContextResolverMediaTypeTest.ProduceTest.class,
+ ContextResolverMediaTypeTest.ProducesSeparateTest.class,
+ ContextResolverMediaTypeTest.ProducesTest.class,
+ ContextResolverMediaTypeTest.ProducesXXXTest.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<String> {
public String getContext(Class<?> objectType) {
@@ -58,7 +66,7 @@
@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<String> {
public String getContext(Class<?> objectType) {
@@ -68,7 +76,7 @@
@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<String> {
public String getContext(Class<?> objectType) {
@@ -78,7 +86,7 @@
@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<String> {
public String getContext(Class<?> objectType) {
@@ -89,7 +97,7 @@
@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<String> {
public String getContext(Class<?> objectType) {
@@ -99,7 +107,7 @@
}
@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 +133,7 @@
}
}
+ @Nested
public static class ProduceTest extends JerseyTest {
@Override
@@ -151,6 +160,7 @@
}
}
+ @Nested
public static class ProducesTest extends JerseyTest {
@Override
@@ -177,6 +187,7 @@
}
}
+ @Nested
public static class ProducesSeparateTest extends JerseyTest {
@Override
@@ -204,6 +215,7 @@
}
}
+ @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 d0e14b5..34c84a8 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, 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
@@ -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 717d053..c07e598 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, 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
@@ -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 @@
@DELETE
public void delete(Map<String, String> 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 0611daa..74e4613 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, 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
@@ -39,22 +39,29 @@
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 org.junit.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Paul Sandoz
* @author Martin Matula
*/
-@RunWith(Enclosed.class)
+@Suite
+@SelectClasses({
+ EmptyRequestWithJaxbTest.EmptyRequestTest.class,
+ EmptyRequestWithJaxbTest.BadgerFishCRTest.class,
+ EmptyRequestWithJaxbTest.MappedJettisonCRTest.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 +95,7 @@
}
+ @Nested
public static class EmptyRequestTest extends JerseyTest {
@Override
@@ -129,7 +137,7 @@
}
}
- @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<JAXBContext> {
private final JAXBContext context;
@@ -153,6 +161,7 @@
}
}
+ @Nested
public static class MappedJettisonCRTest extends JerseyTest {
@Override
@@ -178,6 +187,7 @@
}
}
+ @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 875bbc2..77a74a6 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, 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
@@ -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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testInputStream() {
final ByteArrayInputStream in = new ByteArrayInputStream("CONTENT".getBytes());
_test(in, InputStreamResource.class);
@@ -120,6 +122,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testString() {
_test("CONTENT", StringResource.class);
}
@@ -133,6 +136,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testByteArrayRepresentation() {
_test("CONTENT".getBytes(), ByteArrayResource.class);
}
@@ -144,6 +148,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanRepresentation() {
_test(new JaxbBean("CONTENT"), JaxbBeanResource.class, MediaType.APPLICATION_XML_TYPE);
}
@@ -155,11 +160,13 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanTextRepresentation() {
_test(new JaxbBean("CONTENT"), JaxbBeanTextResource.class, MediaType.TEXT_XML_TYPE);
}
@@ -186,6 +194,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentation() {
_test(new JaxbBean("CONTENT"), JAXBElementBeanResource.class, MediaType.APPLICATION_XML_TYPE);
}
@@ -201,6 +210,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementListXMLRepresentation() {
_testListOrArray(true, MediaType.APPLICATION_XML_TYPE);
}
@@ -218,14 +228,15 @@
.asList((JAXBElement<String>[]) in);
final List<JAXBElement<String>> outList = isList ? ((List<JAXBElement<String>>) out) : Arrays
.asList((JAXBElement<String>[]) 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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentationMediaType() {
_test(new JaxbBean("CONTENT"), JAXBElementBeanResourceMediaType.class, MediaType.valueOf("application/foo+xml"));
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentationError() {
final WebTarget target = target("JAXBElementBeanResource");
@@ -280,6 +295,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanTextRepresentation() {
_test(new JaxbBean("CONTENT"), JAXBElementBeanTextResource.class, MediaType.TEXT_XML_TYPE);
}
@@ -291,6 +307,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanRepresentationMediaTypeAtom() {
_test(new JaxbBean("CONTENT"), JaxbBeanResourceAtom.class, MediaType.valueOf("application/atom+xml"));
}
@@ -318,6 +335,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBTypeRepresentation() {
final WebTarget target = target("JAXBTypeResource");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -332,6 +350,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBTypeRepresentationMediaType() {
final WebTarget target = target("JAXBTypeResourceMediaType");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -365,6 +384,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBObjectRepresentation() {
final WebTarget target = target("JAXBObjectResource");
final Object in = new JaxbBean("CONTENT");
@@ -379,6 +399,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBObjectRepresentationMediaType() {
final WebTarget target = target("JAXBObjectResourceMediaType");
final Object in = new JaxbBean("CONTENT");
@@ -387,6 +408,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBObjectRepresentationError() {
final WebTarget target = target("JAXBObjectResource");
@@ -400,6 +422,7 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testFormRepresentation() {
final Form fp = new Form();
fp.param("Email", "johndoe@gmail.com");
@@ -442,6 +466,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJSONObjectRepresentation() throws Exception {
final JSONObject object = new JSONObject();
object.put("userid", 1234)
@@ -459,6 +484,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJSONObjectRepresentationGeneralMediaTyp() throws Exception {
final JSONObject object = new JSONObject();
object.put("userid", 1234)
@@ -476,6 +502,7 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJSONArrayRepresentationGeneralMediaType() throws Exception {
final JSONArray array = new JSONArray();
array.put("One").put("Two").put("Three").put(1).put(2.0);
@@ -528,6 +556,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testReaderRepresentation() throws Exception {
_test(new StringReader("CONTENT"), ReaderResource.class);
}
@@ -539,6 +568,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testStreamSourceRepresentation() throws Exception {
final StreamSource ss = new StreamSource(
new ByteArrayInputStream(XML_DOCUMENT.getBytes()));
@@ -550,6 +580,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testSAXSourceRepresentation() throws Exception {
final StreamSource ss = new StreamSource(
new ByteArrayInputStream(XML_DOCUMENT.getBytes()));
@@ -561,6 +592,7 @@
}
@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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testFormMultivaluedMapRepresentation() {
final MultivaluedMap<String, String> fp = new MultivaluedStringMap();
fp.add("Email", "johndoe@gmail.com");
@@ -620,6 +654,7 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanJSONRepresentation() {
final WebTarget target = target("JAXBElementBeanJSONResource");
@@ -643,10 +679,10 @@
final byte[] inBytes = getRequestEntity();
final byte[] outBytes = getEntityAsByteArray(rib);
- assertEquals(new String(outBytes), inBytes.length, outBytes.length);
+ assertEquals(inBytes.length, outBytes.length, new String(outBytes));
for (int i = 0; i < inBytes.length; i++) {
if (inBytes[i] != outBytes[i]) {
- assertEquals("Index: " + i, inBytes[i], outBytes[i]);
+ assertEquals(inBytes[i], outBytes[i], "Index: " + i);
}
}
}
@@ -658,6 +694,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanRepresentationJSON() {
final WebTarget target = target("JaxbBeanResourceJSON");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -672,6 +709,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanRepresentationJSONMediaType() {
final WebTarget target = target("JaxbBeanResourceJSONMediaType");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -686,6 +724,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentationJSON() {
final WebTarget target = target("JAXBElementBeanResourceJSON");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -700,6 +739,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentationJSONMediaType() {
final WebTarget target = target("JAXBElementBeanResourceJSONMediaType");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -719,6 +759,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBTypeRepresentationJSON() {
final WebTarget target = target("JAXBTypeResourceJSON");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -738,6 +779,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBTypeRepresentationJSONMediaType() {
final WebTarget target = target("JAXBTypeResourceJSONMediaType");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -752,7 +794,8 @@
}
@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 @@
}
@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 testJAXBElementBeanRepresentationFastInfoset() {
final WebTarget target = target("JAXBElementBeanResourceFastInfoset");
@@ -789,7 +833,8 @@
}
@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 testJAXBTypeRepresentationFastInfoset() {
final WebTarget target = target("JAXBTypeResourceFastInfoset");
@@ -883,6 +928,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBArrayRepresentation() {
final WebTarget target = target("JAXBArrayResource");
@@ -907,6 +953,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationMediaType() {
final WebTarget target = target("JAXBListResourceMediaType");
@@ -964,6 +1011,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationError() {
final WebTarget target = target("JAXBListResource");
@@ -982,7 +1030,8 @@
* TODO, the unmarshalling fails.
*/
@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 testJAXBListRepresentationFastInfoset() {
final WebTarget target = target("JAXBListResourceFastInfoset");
@@ -1046,6 +1095,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationJSON() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
@@ -1118,6 +1168,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationJSONMediaType() throws Exception {
final WebTarget target = target("JAXBListResourceJSONMediaType");
@@ -1158,6 +1209,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testNoContentTypeJaxbEntity() throws IOException {
assertThat(target("NoContentTypeJAXBResource").request("application/xml").post(Entity.xml(new JaxbBean("foo")))
.getMediaType(),
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EnumEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EnumEntityTest.java
index abc66cd..11a2817 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EnumEntityTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/EnumEntityTest.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,10 +18,11 @@
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;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
@@ -31,7 +32,7 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
-@RunWith(ConcurrentRunner.class)
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class EnumEntityTest extends JerseyTest {
public enum SimpleEnum {
@@ -91,41 +92,45 @@
// Server side tests
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testSimpleEnumServerReader() {
for (SimpleEnum value : SimpleEnum.values()) {
try (Response r = target("simple").request(MediaType.TEXT_PLAIN_TYPE)
.post(Entity.entity(value.name(), MediaType.TEXT_PLAIN_TYPE))) {
- Assert.assertEquals(value.name(), r.readEntity(String.class));
+ Assertions.assertEquals(value.name(), r.readEntity(String.class));
}
}
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testValueEnumServerReader() {
for (ValueEnum value : ValueEnum.values()) {
try (Response r = target("value").request(MediaType.TEXT_PLAIN_TYPE)
.post(Entity.entity(value.name(), MediaType.TEXT_PLAIN_TYPE))) {
- Assert.assertEquals(value.name(), r.readEntity(String.class));
+ Assertions.assertEquals(value.name(), r.readEntity(String.class));
}
}
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testSimpleEnumServerWriter() {
for (SimpleEnum value : SimpleEnum.values()) {
try (Response r = target("simple").request(MediaType.TEXT_PLAIN_TYPE)
.put(Entity.entity(value.name(), MediaType.TEXT_PLAIN_TYPE))) {
- Assert.assertEquals(value.name(), r.readEntity(String.class));
+ Assertions.assertEquals(value.name(), r.readEntity(String.class));
}
}
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testValueEnumServerWriter() {
for (ValueEnum value : ValueEnum.values()) {
try (Response r = target("value").request(MediaType.TEXT_PLAIN_TYPE)
.put(Entity.entity(value.name(), MediaType.TEXT_PLAIN_TYPE))) {
- Assert.assertEquals(value.name(), r.readEntity(String.class));
+ Assertions.assertEquals(value.name(), r.readEntity(String.class));
}
}
}
@@ -133,41 +138,45 @@
// Client side tests
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testSimpleEnumClientReader() {
for (SimpleEnum value : SimpleEnum.values()) {
try (Response r = target("simple").request(MediaType.TEXT_PLAIN_TYPE)
.post(Entity.entity(value.name(), MediaType.TEXT_PLAIN_TYPE))) {
- Assert.assertEquals(value, r.readEntity(SimpleEnum.class));
+ Assertions.assertEquals(value, r.readEntity(SimpleEnum.class));
}
}
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testValueEnumClientReader() {
for (ValueEnum value : ValueEnum.values()) {
try (Response r = target("value").request(MediaType.TEXT_PLAIN_TYPE)
.post(Entity.entity(value.name(), MediaType.TEXT_PLAIN_TYPE))) {
- Assert.assertEquals(value, r.readEntity(ValueEnum.class));
+ Assertions.assertEquals(value, r.readEntity(ValueEnum.class));
}
}
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testSimpleEnumClientWriter() {
for (SimpleEnum value : SimpleEnum.values()) {
try (Response r = target("echo").request(MediaType.TEXT_PLAIN_TYPE)
.post(Entity.entity(value, MediaType.TEXT_PLAIN_TYPE))) {
- Assert.assertEquals(value.name(), r.readEntity(String.class));
+ Assertions.assertEquals(value.name(), r.readEntity(String.class));
}
}
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testValueEnumClientWriter() {
for (ValueEnum value : ValueEnum.values()) {
try (Response r = target("echo").request(MediaType.TEXT_PLAIN_TYPE)
.post(Entity.entity(value, MediaType.TEXT_PLAIN_TYPE))) {
- Assert.assertEquals(value.name(), r.readEntity(String.class));
+ Assertions.assertEquals(value.name(), r.readEntity(String.class));
}
}
}
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/GenericTypeAndEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/GenericTypeAndEntityTest.java
index c030349..e59f464 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/GenericTypeAndEntityTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/GenericTypeAndEntityTest.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
@@ -49,10 +49,11 @@
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.glassfish.jersey.message.internal.ReaderWriter;
-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-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InjectedProviderTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InjectedProviderTest.java
index 733a815..ce37307 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InjectedProviderTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InjectedProviderTest.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
@@ -39,8 +39,8 @@
import org.glassfish.jersey.client.ClientConfig;
-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-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InterceptedStreamCloseTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InterceptedStreamCloseTest.java
index 483f6b4..0abcb35 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InterceptedStreamCloseTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InterceptedStreamCloseTest.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
@@ -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;
/**
* Reproducer for JERSEY-1845.
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InvalidEntityTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InvalidEntityTest.java
index 52a1d4c..6ede29f 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InvalidEntityTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InvalidEntityTest.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
@@ -21,8 +21,8 @@
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.client.ResponseProcessingException;
-import org.junit.Test;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* @author Martin Matula
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InvalidFormTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InvalidFormTest.java
index 5ea50b8..c7f254d 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InvalidFormTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/InvalidFormTest.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
@@ -24,8 +24,8 @@
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.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;
/**
*
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JAXBContextResolverTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JAXBContextResolverTest.java
index 426e767..e56763f 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JAXBContextResolverTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/JAXBContextResolverTest.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
@@ -35,23 +35,37 @@
import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.runners.Enclosed;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Nested;
+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.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 Paul Sandoz
* @author Martin Matula
*/
-@RunWith(Enclosed.class)
+@Suite
+@SelectClasses({
+ JAXBContextResolverTest.JAXBContextTest.class,
+ JAXBContextResolverTest.JAXBContextAllTest.class,
+ JAXBContextResolverTest.JAXBContextAppTest.class,
+ JAXBContextResolverTest.JAXBContextAllWithOtherJaxbBeanTest.class,
+ JAXBContextResolverTest.JAXBContextTextTest.class,
+ JAXBContextResolverTest.UnmarshallerAllTest.class,
+ JAXBContextResolverTest.UnmarshallerAppTest.class,
+ JAXBContextResolverTest.UnmarshallerFooTest.class,
+ JAXBContextResolverTest.UnmarshallerTest.class,
+ JAXBContextResolverTest.UnmarshallerTextTest.class
+})
public class JAXBContextResolverTest {
@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 JAXBContextResolver implements ContextResolver<JAXBContext> {
private JAXBContext context;
@@ -80,7 +94,7 @@
}
@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<Marshaller> {
private JAXBContext context;
@@ -113,7 +127,7 @@
}
@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<Unmarshaller> {
private JAXBContext context;
@@ -146,7 +160,7 @@
}
@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 +190,7 @@
}
}
+ @Nested
public static class UnmarshallerTest extends AbstractTypeTester {
private JAXBContextResolver cr;
@@ -205,29 +220,30 @@
@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 +265,7 @@
}
}
+ @Nested
public static class UnmarshallerAppTest extends AbstractTypeTester {
private JAXBContextResolver cr;
@@ -289,29 +306,30 @@
@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 +350,7 @@
}
}
+ @Nested
public static class UnmarshallerTextTest extends AbstractTypeTester {
private JAXBContextResolver cr;
@@ -363,23 +382,24 @@
@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 +439,7 @@
}
@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 +464,7 @@
}
}
+ @Nested
public static class JAXBContextAllTest extends AbstractTypeTester {
private JAXBContextResolver cr;
@@ -479,6 +500,7 @@
}
}
+ @Nested
public static class UnmarshallerAllTest extends AbstractTypeTester {
private JAXBContextResolver cr;
@@ -546,7 +568,7 @@
}
@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 +590,7 @@
}
@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 +615,7 @@
}
}
+ @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 491afdd..c972472 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, 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
@@ -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 @@
isList ? ((List<JAXBElement<String>>) in) : Arrays.asList((JAXBElement<String>[]) in);
final List<JAXBElement<String>> outList = isList ? ((List<JAXBElement<String>>) out) : Arrays
.asList((JAXBElement<String>[]) 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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementArrayJSONRepresentation() {
_testListOrArray(false, MediaType.APPLICATION_JSON_TYPE);
}
@@ -152,6 +156,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanJSONRepresentation() {
final WebTarget target = target("JAXBElementBeanJSONResource");
@@ -167,10 +172,10 @@
final byte[] inBytes = getRequestEntity();
final byte[] outBytes = getEntityAsByteArray(rib);
- assertEquals(new String(outBytes), inBytes.length, outBytes.length);
+ assertEquals(inBytes.length, outBytes.length, new String(outBytes));
for (int i = 0; i < inBytes.length; i++) {
if (inBytes[i] != outBytes[i]) {
- assertEquals("Index: " + i, inBytes[i], outBytes[i]);
+ assertEquals(inBytes[i], outBytes[i], "Index: " + i);
}
}
}
@@ -182,6 +187,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanRepresentationJSON() {
final WebTarget target = target("JaxbBeanResourceJSON");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -196,6 +202,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanRepresentationJSONMediaType() {
final WebTarget target = target("JaxbBeanResourceJSONMediaType");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -210,6 +217,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentationJSON() {
final WebTarget target = target("JAXBElementBeanResourceJSON");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -224,6 +232,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentationJSONMediaType() {
final WebTarget target = target("JAXBElementBeanResourceJSONMediaType");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -243,6 +252,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBTypeRepresentationJSON() {
final WebTarget target = target("JAXBTypeResourceJSON");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -262,6 +272,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBTypeRepresentationJSONMediaType() {
final WebTarget target = target("JAXBTypeResourceJSONMediaType");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -336,6 +347,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationJSONCollection() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
@@ -355,6 +367,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationJSONLinkedList() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
@@ -371,6 +384,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationJSONSet() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
@@ -397,6 +411,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationJSONStack() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
@@ -414,7 +429,8 @@
}
@Test
- @Ignore("Until JERSEY-2825 is fixed.")
+ @Execution(ExecutionMode.CONCURRENT)
+ @Disabled("Until JERSEY-2825 is fixed.")
public void testJAXBListRepresentationJSONArrayList() throws Exception {
final WebTarget target = target("JAXBListResourceJSON");
@@ -435,6 +451,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationJSONMediaType() throws Exception {
final WebTarget target = target("JAXBListResourceJSONMediaType");
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MediaTypeSelectionTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MediaTypeSelectionTest.java
index 3ab546e..4bfdb90 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MediaTypeSelectionTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MediaTypeSelectionTest.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
@@ -29,9 +29,9 @@
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
-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;
/**
* @author Martin Matula
@@ -171,7 +171,7 @@
}
@Test
- @Ignore("JSONB breaks this test.")
+ @Disabled("JSONB breaks this test.")
public void testApplicationWildCard() {
Response r = target("wildcard").request("application/*").post(Entity.text("test"));
assertEquals(MediaType.APPLICATION_OCTET_STREAM_TYPE, r.getMediaType());
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MessageBodyProviderAnnotationsTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MessageBodyProviderAnnotationsTest.java
index 071d421..2638d62 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MessageBodyProviderAnnotationsTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MessageBodyProviderAnnotationsTest.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
@@ -42,8 +42,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 annotations passed to message body provider.
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MultipartTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MultipartTest.java
index 682f1a8..1e7e353 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MultipartTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/MultipartTest.java
@@ -21,8 +21,11 @@
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.stream.Stream;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
@@ -51,9 +54,11 @@
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.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 static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
@@ -62,21 +67,10 @@
/**
* @author Martin Matula
*/
-@RunWith(Parameterized.class)
-public class MultipartTest extends JerseyTest {
+public class MultipartTest {
private static Class<? extends Feature> featureClass;
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][]{{MoxyJsonFeature.class}, {JacksonFeature.class}, {JsonBindingFeature.class}});
- }
-
- public MultipartTest(Class<? extends Feature> featureProvider) {
- super(configure(featureProvider));
- }
-
- @SuppressWarnings("UnusedDeclaration")
public static class MyObject {
private String value;
@@ -172,6 +166,9 @@
}
}
+ private static final List<Class<? extends Feature>> providers =
+ Arrays.asList(MoxyJsonFeature.class, JacksonFeature.class, JsonBindingFeature.class);
+
protected static Application configure(Class<? extends Feature> featureClass) {
MultipartTest.featureClass = featureClass;
return new ResourceConfig(MultipartResource.class, MessageBodyProvider.class)
@@ -180,87 +177,105 @@
// .register(JacksonFeature.class);
// .register(JsonBindingFeature.class);
}
-
- @Override
- protected void configureClient(final ClientConfig config) {
- config.register(MultiPartFeature.class);
- config.register(featureClass);
- //config.register(JacksonFeature.class);
- //config.register(JsonBindingFeature.class);
+ public static Stream<Class<? extends Feature>> parameters() {
+ return providers.stream();
}
- @Test
- public void testFileNameInternetExplorer() throws Exception {
- final InputStream entity = getClass().getResourceAsStream("multipart-testcase.txt");
- final Response response = target("filename")
- .request()
- .header("User-Agent", "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)")
- .post(Entity.entity(entity, "multipart/form-data; boundary=---------------------------7dc941520888"));
-
- assertThat(response.readEntity(String.class), equalTo("bhhklbpom.xml"));
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ final Collection<DynamicContainer> tests = new ArrayList<>();
+ MultipartTest.parameters().forEach(feature -> {
+ final MultipartTest.MultipartTemplateTest test =
+ new MultipartTemplateTest(feature) {};
+ tests.add(TestHelper.toTestContainer(test, feature.getClass().getSimpleName()));
+ });
+ return tests;
}
+ public abstract class MultipartTemplateTest extends JerseyTest {
- @Test
- public void testFileName() throws Exception {
- final InputStream entity = getClass().getResourceAsStream("multipart-testcase.txt");
- final Response response = target("filename")
- .request()
- .post(Entity.entity(entity, "multipart/form-data; boundary=---------------------------7dc941520888"));
-
- assertThat(response.readEntity(String.class), equalTo("bhhklbC:javaprojectsmultipart-testcasepom.xml"));
- }
-
- @Test
- public void testMbrExceptionServer() throws Exception {
- final InputStream entity = getClass().getResourceAsStream("multipart-testcase.txt");
- final Response response = target("mbr")
- .request()
- .post(Entity.entity(entity, "multipart/form-data; boundary=---------------------------7dc941520888"));
-
- assertThat(response.getStatus(), equalTo(500));
- }
-
- /**
- * Test that injection of a list (specific type) works.
- */
- @Test
- public void testSpecificListAsParameter() throws Exception {
- if (featureClass == MoxyJsonFeature.class) {
- // No available MessageBodyWriter for class "class java.util.Arrays$ArrayList" and media type "application/json"
- return;
+ public MultipartTemplateTest(Class<? extends Feature> featureProvider) {
+ super(MultipartTest.configure(featureProvider));
}
- final MyObject object = new MyObject("object");
- final List<MyObject> list = Arrays.asList(new MyObject("list1"), new MyObject("list2"));
+ @Override
+ protected void configureClient(final ClientConfig config) {
+ config.register(MultiPartFeature.class);
+ config.register(featureClass);
+ //config.register(JacksonFeature.class);
+ //config.register(JsonBindingFeature.class);
+ }
- final FormDataMultiPart mp = new FormDataMultiPart();
- mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("object").fileName("object").build(),
- object, MediaType.APPLICATION_JSON_TYPE));
- mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("list").fileName("list").build(),
- list, MediaType.APPLICATION_JSON_TYPE));
+ @Test
+ public void testFileNameInternetExplorer() throws Exception {
+ final InputStream entity = getClass().getResourceAsStream("multipart-testcase.txt");
+ final Response response = target("filename")
+ .request()
+ .header("User-Agent", "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)")
+ .post(Entity.entity(entity, "multipart/form-data; boundary=---------------------------7dc941520888"));
- final Response response = target("listAsParameter")
- .request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE));
+ assertThat(response.readEntity(String.class), equalTo("bhhklbpom.xml"));
+ }
- assertThat(response.readEntity(String.class), is("object_list1_list2"));
+ @Test
+ public void testFileName() throws Exception {
+ final InputStream entity = getClass().getResourceAsStream("multipart-testcase.txt");
+ final Response response = target("filename")
+ .request()
+ .post(Entity.entity(entity, "multipart/form-data; boundary=---------------------------7dc941520888"));
+
+ assertThat(response.readEntity(String.class), equalTo("bhhklbC:javaprojectsmultipart-testcasepom.xml"));
+ }
+
+ @Test
+ public void testMbrExceptionServer() throws Exception {
+ final InputStream entity = getClass().getResourceAsStream("multipart-testcase.txt");
+ final Response response = target("mbr")
+ .request()
+ .post(Entity.entity(entity, "multipart/form-data; boundary=---------------------------7dc941520888"));
+
+ assertThat(response.getStatus(), equalTo(500));
+ }
+
+ /**
+ * Test that injection of a list (specific type) works.
+ */
+ @Test
+ public void testSpecificListAsParameter() throws Exception {
+ if (featureClass == MoxyJsonFeature.class) {
+ // No available MessageBodyWriter for class "class java.util.Arrays$ArrayList" and media type "application/json"
+ return;
+ }
+ final MyObject object = new MyObject("object");
+ final List<MyObject> list = Arrays.asList(new MyObject("list1"), new MyObject("list2"));
+
+ final FormDataMultiPart mp = new FormDataMultiPart();
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("object").fileName("object").build(),
+ object, MediaType.APPLICATION_JSON_TYPE));
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("list").fileName("list").build(),
+ list, MediaType.APPLICATION_JSON_TYPE));
+
+ final Response response = target("listAsParameter")
+ .request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE));
+
+ assertThat(response.readEntity(String.class), is("object_list1_list2"));
+ }
+
+ @Test
+ public void testEmptyEntity() throws Exception {
+ final Response response = target("filename")
+ .request()
+ .post(Entity.entity(null, MediaType.MULTIPART_FORM_DATA_TYPE));
+
+ assertThat(response.getStatus(), is(400));
+ }
+
+ @Test
+ public void testEmptyEntityWithoutContentType() throws Exception {
+ final Response response = target("filename")
+ .request()
+ .header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_TYPE)
+ .post(null);
+
+ assertThat(response.getStatus(), is(400));
+ }
}
-
- @Test
- public void testEmptyEntity() throws Exception {
- final Response response = target("filename")
- .request()
- .post(Entity.entity(null, MediaType.MULTIPART_FORM_DATA_TYPE));
-
- assertThat(response.getStatus(), is(400));
- }
-
- @Test
- public void testEmptyEntityWithoutContentType() throws Exception {
- final Response response = target("filename")
- .request()
- .header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_TYPE)
- .post(null);
-
- assertThat(response.getStatus(), is(400));
- }
-
}
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/NoMessageBodyWorkerTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/NoMessageBodyWorkerTest.java
index 3aed5a7..61880c2 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/NoMessageBodyWorkerTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/NoMessageBodyWorkerTest.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,8 +26,8 @@
import org.glassfish.jersey.CommonProperties;
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 Paul Sandoz
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentOrderTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentOrderTest.java
index ef7bba6..41890e4 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentOrderTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentOrderTest.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 org.glassfish.jersey.server.ResourceConfig;
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;
/**
* Tests the correct order of providers.
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentResourceReaderWriterOrderTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentResourceReaderWriterOrderTest.java
index 58aa798..fe1725c 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentResourceReaderWriterOrderTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentResourceReaderWriterOrderTest.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 org.glassfish.jersey.server.ResourceConfig;
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;
/**
* Tests the correct order of providers.
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentReversedOrderTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentReversedOrderTest.java
index 8fc826b..82183d9 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentReversedOrderTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/ParameterTypeArgumentReversedOrderTest.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 org.glassfish.jersey.server.ResourceConfig;
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;
/**
* Tests the correct order of providers.
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/RenderedImageTypeTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/RenderedImageTypeTest.java
index e4bdeb5..fcc3b79 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/RenderedImageTypeTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/RenderedImageTypeTest.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
@@ -31,10 +31,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.notNullValue;
import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author Michal Gajdos
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/StreamingOutputTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/StreamingOutputTest.java
index 89ab71d..1f7d017 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/StreamingOutputTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/StreamingOutputTest.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
@@ -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;
/**
* @author Martin Matula
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/SubResourceDynamicProxyTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/SubResourceDynamicProxyTest.java
index 8ca5650..7f223a0 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/SubResourceDynamicProxyTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/SubResourceDynamicProxyTest.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
@@ -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;
/**
* Reproducer for JERSEY-2541.
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XXETest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XXETest.java
index 93e95cb..bc3eba7 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XXETest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XXETest.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
@@ -39,12 +39,12 @@
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 org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests xml security.
@@ -170,7 +170,7 @@
assertEquals("", s);
}
- @Ignore // TODO
+ @Disabled // TODO
@Test
public void testJAXBListSecure() {
final String s = target().path("jaxb/list").request("application/xml").post(Entity.entity(getListDocument(),
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlJaxBElementProviderTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlJaxBElementProviderTest.java
index d87fccf..d1a24a4 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlJaxBElementProviderTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlJaxBElementProviderTest.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
@@ -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 Miroslav Fuksa
diff --git a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlMoxyTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlMoxyTest.java
index de5b32e..a71fac0 100644
--- a/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlMoxyTest.java
+++ b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/entity/XmlMoxyTest.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
@@ -52,20 +52,22 @@
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.moxy.xml.MoxyXmlFeature;
import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.test.util.runner.ConcurrentRunner;
-import org.junit.Test;
+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.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import org.junit.runner.RunWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Pavel Bucek
*/
-@RunWith(ConcurrentRunner.class)
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class XmlMoxyTest extends AbstractTypeTester {
@Path("JaxbBeanResource")
@@ -75,6 +77,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanRepresentation() {
_test(new JaxbBean("CONTENT"), JaxbBeanResource.class, MediaType.APPLICATION_XML_TYPE);
}
@@ -86,11 +89,13 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJaxbBeanTextRepresentation() {
_test(new JaxbBean("CONTENT"), JaxbBeanTextResource.class, MediaType.TEXT_XML_TYPE);
}
@@ -117,6 +123,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentation() {
_test(new JaxbBean("CONTENT"), JAXBElementBeanResource.class, MediaType.APPLICATION_XML_TYPE);
}
@@ -132,6 +139,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementListXMLRepresentation() {
_testListOrArray(true, MediaType.APPLICATION_XML_TYPE);
}
@@ -150,10 +158,10 @@
isList ? ((List<JAXBElement<String>>) in) : Arrays.asList((JAXBElement<String>[]) in);
final List<JAXBElement<String>> outList = isList ? ((List<JAXBElement<String>>) out) : Arrays
.asList((JAXBElement<String>[]) 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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementArrayXMLRepresentation() {
_testListOrArray(false, MediaType.APPLICATION_XML_TYPE);
}
@@ -183,11 +192,13 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentationMediaType() {
_test(new JaxbBean("CONTENT"), JAXBElementBeanResourceMediaType.class, MediaType.valueOf("application/foo+xml"));
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanRepresentationError() {
final WebTarget target = target("JAXBElementBeanResource");
@@ -203,6 +214,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBElementBeanTextRepresentation() {
_test(new JaxbBean("CONTENT"), JAXBElementBeanTextResource.class, MediaType.TEXT_XML_TYPE);
}
@@ -230,6 +242,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBTypeRepresentation() {
final WebTarget target = target("JAXBTypeResource");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -244,6 +257,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBTypeRepresentationMediaType() {
final WebTarget target = target("JAXBTypeResourceMediaType");
final JaxbBean in = new JaxbBean("CONTENT");
@@ -278,6 +292,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBObjectRepresentation() {
final WebTarget target = target("JAXBObjectResource");
final Object in = new JaxbBean("CONTENT");
@@ -292,6 +307,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBObjectRepresentationMediaType() {
final WebTarget target = target("JAXBObjectResourceMediaType");
final Object in = new JaxbBean("CONTENT");
@@ -300,6 +316,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBObjectRepresentationError() {
final WebTarget target = target("JAXBObjectResource");
@@ -393,6 +410,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBArrayRepresentation() {
final WebTarget target = target("JAXBArrayResource");
@@ -417,6 +435,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationMediaType() {
final WebTarget target = target("JAXBListResourceMediaType");
@@ -472,6 +491,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testJAXBListRepresentationError() {
final WebTarget target = target("JAXBListResource");
@@ -535,6 +555,7 @@
}
@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 225d2df..0b7a435 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, 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
@@ -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 6318dc8..d8627f5 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, 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
@@ -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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testEntityAnnotationsDefaultView() throws Exception {
final String fields = target()
.request()
@@ -107,6 +111,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testEntityAnnotationsInvalidView() throws Exception {
final String fields = target()
.request()
@@ -120,17 +125,20 @@
}
@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 @@
}
@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 @@
}
@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 09f16e4..939c37e 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, 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,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 b0abf9c..32a1f1c 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, 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,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 8478a26..b452886 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, 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
@@ -27,7 +27,9 @@
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;
/**
* @author Michal Gajdos
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 f8d8e2e..704771c 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, 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
@@ -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 98aaa73..0b08d78 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, 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
@@ -16,8 +16,6 @@
package org.glassfish.jersey.tests.e2e.entity.filtering.json;
-import java.util.Arrays;
-
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -33,30 +31,40 @@
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;
import com.fasterxml.jackson.databind.SerializationFeature;
+import org.junit.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
/**
* Use-cases to check whether empty class causes problems (JERSEY-2824 reproducer).
*
* @author Michal Gajdos
*/
-@RunWith(Parameterized.class)
-public class JsonEmptyEntityTest extends JerseyTest {
+@Suite
+@SelectClasses({
+ JsonEmptyEntityTest.JacksonFeatureJsonEmptyEntityTest.class,
+ JsonEmptyEntityTest.MoxyJsonFeatureJsonEmptyEntityTest.class
+})
+public class JsonEmptyEntityTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}});
+ public static class MoxyJsonFeatureJsonEmptyEntityTest extends JsonEmptyEntityTemplateTest {
+ public MoxyJsonFeatureJsonEmptyEntityTest() {
+ super(MoxyJsonFeature.class);
+ }
+ }
+
+ public static class JacksonFeatureJsonEmptyEntityTest extends JsonEmptyEntityTemplateTest {
+ public JacksonFeatureJsonEmptyEntityTest() {
+ super(JacksonFeature.class);
+ }
}
@Path("/")
@@ -77,32 +85,35 @@
}
}
- public JsonEmptyEntityTest(final Class<Feature> filteringProvider) {
- super(new ResourceConfig(Resource.class, EntityFilteringFeature.class)
- .register(filteringProvider)
- .register(new ContextResolver<ObjectMapper>() {
- @Override
- public ObjectMapper getContext(final Class<?> type) {
- return new ObjectMapper()
- .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
- .setSerializationInclusion(JsonInclude.Include.NON_NULL);
- }
- }));
+ public abstract static class JsonEmptyEntityTemplateTest extends JerseyTest {
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.LOG_TRAFFIC);
- }
+ public JsonEmptyEntityTemplateTest(final Class<? extends Feature> filteringProvider) {
+ super(new ResourceConfig(Resource.class, EntityFilteringFeature.class)
+ .register(filteringProvider)
+ .register(new ContextResolver<ObjectMapper>() {
+ @Override
+ public ObjectMapper getContext(final Class<?> type) {
+ return new ObjectMapper()
+ .configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
+ .setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ }
+ }));
- @Test
- public void testNonEmptyEntity() throws Exception {
- final NonEmptyEntity entity = target("nonEmptyEntity").request().get(NonEmptyEntity.class);
+ enable(TestProperties.DUMP_ENTITY);
+ enable(TestProperties.LOG_TRAFFIC);
+ }
- assertThat(entity.getValue(), is("foo"));
- assertThat(entity.getEmptyEntity(), nullValue());
- }
+ @Test
+ public void testNonEmptyEntity() throws Exception {
+ final NonEmptyEntity entity = target("nonEmptyEntity").request().get(NonEmptyEntity.class);
- @Test
- public void testEmptyEntity() throws Exception {
- assertThat(target("emptyEntity").request().get(String.class), is("{}"));
+ assertThat(entity.getValue(), is("foo"));
+ assertThat(entity.getEmptyEntity(), nullValue());
+ }
+
+ @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 d95c0c3..f8d1e7e 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, 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
@@ -17,7 +17,6 @@
package org.glassfish.jersey.tests.e2e.entity.filtering.json;
import java.lang.annotation.Annotation;
-import java.util.Arrays;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
@@ -46,42 +45,240 @@
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.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.Parameterized;
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 {
+@Suite
+@SelectClasses({
+ JsonEntityFilteringClientTest.JacksonFeatureJsonEntityFilteringClientTest.class,
+ JsonEntityFilteringClientTest.JsonEntityFilteringClientTemplateTest.class,
+ JsonEntityFilteringClientTest.MoxyJsonFeatureJsonEntityFilteringClientTest.class
+})
+public class JsonEntityFilteringClientTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> 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<Feature> filteringProvider;
-
- @Override
- protected Application configure() {
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.LOG_TRAFFIC);
-
- return new ResourceConfig()
- // Resources.
- .register(Resource.class);
+ public static class JacksonFeatureJsonEntityFilteringClientTest extends JsonEntityFilteringClientTemplateTest {
+ public JacksonFeatureJsonEntityFilteringClientTest() {
+ super(JacksonFeature.class);
+ }
}
- @Override
- protected void configureClient(final ClientConfig config) {
- config.register(EntityFilteringFeature.class).register(filteringProvider);
+ public abstract static class JsonEntityFilteringClientTemplateTest extends JerseyTest {
+ private Class<? extends Feature> filteringProvider;
+
+ public JsonEntityFilteringClientTemplateTest(Class<? extends Feature> filteringProvider) {
+ this.filteringProvider = filteringProvider;
+ }
+
+ @Override
+ protected Application configure() {
+ enable(TestProperties.DUMP_ENTITY);
+ enable(TestProperties.LOG_TRAFFIC);
+
+ return new ResourceConfig()
+ // Resources.
+ .register(Resource.class);
+ }
+
+ @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 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 testConfigurationPrimaryView() throws Exception {
+ _testPrimaryViewEntity(retrieveEntity(PrimaryDetailedView.Factory.get()));
+ }
+
+ @Test
+ public void testConfigurationDefaultView() throws Exception {
+ _testEmptyEntity(retrieveEntity(new DefaultFilteringScope()));
+ }
+
+ @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);
+
+ 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);
+
+ final OneFilteringOnClassEntity entity =
+ ClientBuilder.newClient(config)
+ .target(getBaseUri())
+ .request()
+ .post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE),
+ OneFilteringOnClassEntity.class);
+
+ _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());
+ }
+
+ 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());
+
+ // DefaultFilteringSubEntity
+ assertThat(entity.getDefaultEntities(), 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"));
+ }
}
@Path("/")
@@ -94,184 +291,4 @@
return value;
}
}
-
- @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 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 testConfigurationDefaultView() throws Exception {
- _testEmptyEntity(retrieveEntity(new DefaultFilteringScope()));
- }
-
- @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);
-
- 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);
-
- final OneFilteringOnClassEntity entity =
- ClientBuilder.newClient(config)
- .target(getBaseUri())
- .request()
- .post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE),
- OneFilteringOnClassEntity.class);
-
- _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());
- }
-
- 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());
-
- // DefaultFilteringSubEntity
- assertThat(entity.getDefaultEntities(), 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"));
- }
}
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 5c18c6c..ee29bce 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, 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
@@ -17,7 +17,6 @@
package org.glassfish.jersey.tests.e2e.entity.filtering.json;
import java.lang.annotation.Annotation;
-import java.util.Arrays;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
@@ -42,33 +41,277 @@
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.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.Parameterized;
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 {
+@Suite
+@SelectClasses({
+ JsonEntityFilteringOnClassTest.JacksonFeatureJsonEntityFilteringOnClassTest.class,
+ JsonEntityFilteringOnClassTest.JsonEntityFilteringOnClassTemplateTest.class,
+ JsonEntityFilteringOnClassTest.MoxyJsonFeatureJsonEntityFilteringOnClassTest.class
+})
+public class JsonEntityFilteringOnClassTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}});
+ public static class MoxyJsonFeatureJsonEntityFilteringOnClassTest extends JsonEntityFilteringOnClassTemplateTest {
+ public MoxyJsonFeatureJsonEntityFilteringOnClassTest() {
+ super(MoxyJsonFeature.class);
+ }
}
- public JsonEntityFilteringOnClassTest(final Class<Feature> filteringProvider) {
- super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider));
+ public static class JacksonFeatureJsonEntityFilteringOnClassTest extends JsonEntityFilteringOnClassTemplateTest {
+ public JacksonFeatureJsonEntityFilteringOnClassTest() {
+ super(JacksonFeature.class);
+ }
+ }
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.LOG_TRAFFIC);
+ public abstract static class JsonEntityFilteringOnClassTemplateTest extends JerseyTest {
+ public JsonEntityFilteringOnClassTemplateTest(final Class<? extends Feature> 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());
+
+ // 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 +373,4 @@
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 979483f..25ead7f 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, 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
@@ -17,7 +17,6 @@
package org.glassfish.jersey.tests.e2e.entity.filtering.json;
import java.lang.annotation.Annotation;
-import java.util.Arrays;
import jakarta.ws.rs.Consumes;
import jakarta.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.OneFilteringOnPropertiesEntity;
import org.glassfish.jersey.tests.e2e.entity.filtering.domain.OneFilteringSubEntity;
+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.Parameterized;
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 {
+@Suite
+@SelectClasses({
+ JsonEntityFilteringOnPropertiesTest.JacksonFeatureJsonEntityFilteringOnPropertiesTest.class,
+ JsonEntityFilteringOnPropertiesTest.JsonEntityFilteringOnPropertiesTemplateTest.class,
+ JsonEntityFilteringOnPropertiesTest.MoxyJsonFeatureJsonEntityFilteringOnPropertiesTest.class
+})
+public class JsonEntityFilteringOnPropertiesTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}});
+ public static class MoxyJsonFeatureJsonEntityFilteringOnPropertiesTest extends JsonEntityFilteringOnPropertiesTemplateTest {
+ public MoxyJsonFeatureJsonEntityFilteringOnPropertiesTest() {
+ super(MoxyJsonFeature.class);
+ }
}
- public JsonEntityFilteringOnPropertiesTest(final Class<Feature> filteringProvider) {
- super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider));
+ public static class JacksonFeatureJsonEntityFilteringOnPropertiesTest extends JsonEntityFilteringOnPropertiesTemplateTest {
+ public JacksonFeatureJsonEntityFilteringOnPropertiesTest() {
+ super(JacksonFeature.class);
+ }
+ }
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.LOG_TRAFFIC);
+ public abstract static class JsonEntityFilteringOnPropertiesTemplateTest extends JerseyTest {
+ public JsonEntityFilteringOnPropertiesTemplateTest(final Class<? extends Feature> 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());
+
+ // 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 +364,4 @@
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 88e70f1..92a1516 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, 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
@@ -16,8 +16,6 @@
package org.glassfish.jersey.tests.e2e.entity.filtering.json;
-import java.util.Arrays;
-
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -34,31 +32,68 @@
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.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.Parameterized;
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 {
+@Suite
+@SelectClasses({
+ JsonEntityFilteringScopesTest.JacksonFeatureJsonEntityFilteringScopesTest.class,
+ JsonEntityFilteringScopesTest.MoxyJsonFeatureJsonEntityFilteringScopesTest.class
+})
+public class JsonEntityFilteringScopesTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> 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<Feature> filteringProvider) {
- super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider));
+ public static class JacksonFeatureJsonEntityFilteringScopesTest extends JsonEntityFilteringScopesTemplateTest {
+ public JacksonFeatureJsonEntityFilteringScopesTest() {
+ super(JacksonFeature.class);
+ }
+ }
- enable(TestProperties.DUMP_ENTITY);
- enable(TestProperties.LOG_TRAFFIC);
+ public abstract static class JsonEntityFilteringScopesTemplateTest extends JerseyTest {
+ public JsonEntityFilteringScopesTemplateTest(Class<? extends Feature> 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);
+
+ // 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 +107,4 @@
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 3e7e6d8..0354980 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.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 @@
}
}
- @RunWith(Parameterized.class)
- public static class ConfigurationServerTest extends JerseyTest {
+ public static Iterable<Class<? extends Feature>> providers() {
+ return Arrays.asList(MoxyJsonFeature.class, JacksonFeature.class);
+ }
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}});
- }
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ providers().forEach(filteringProvider -> {
+ ConfigurationServerTest test1 = new ConfigurationServerTest(filteringProvider) {};
+ tests.add(TestHelper.toTestContainer(test1,
+ ConfigurationServerTest.class.getSimpleName() + " (" + filteringProvider.getSimpleName() + ")"));
- public ConfigurationServerTest(final Class<Feature> filteringProvider) {
+ 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 abstract static class ConfigurationServerTest extends JerseyTest {
+
+ public ConfigurationServerTest(Class<? extends Feature> filteringProvider) {
super(new ResourceConfig(Resource.class, EntityFilteringFeature.class)
.register(filteringProvider)
.property(EntityFilteringFeature.ENTITY_FILTERING_SCOPE, PrimaryDetailedView.Factory.get()));
@@ -145,15 +162,9 @@
}
}
- @RunWith(Parameterized.class)
- public static class ConfigurationDefaultViewServerTest extends JerseyTest {
+ public abstract static class ConfigurationDefaultViewServerTest extends JerseyTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}});
- }
-
- public ConfigurationDefaultViewServerTest(final Class<Feature> filteringProvider) {
+ public ConfigurationDefaultViewServerTest(final Class<? extends Feature> filteringProvider) {
super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider));
enable(TestProperties.DUMP_ENTITY);
@@ -184,15 +195,9 @@
}
}
- @RunWith(Parameterized.class)
- public static class AnnotationsServerTest extends JerseyTest {
+ public abstract static class AnnotationsServerTest extends JerseyTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}});
- }
-
- public AnnotationsServerTest(final Class<Feature> filteringProvider) {
+ public AnnotationsServerTest(final Class<? extends Feature> filteringProvider) {
super(new ResourceConfig(Resource.class, EntityFilteringFeature.class).register(filteringProvider));
enable(TestProperties.DUMP_ENTITY);
@@ -210,15 +215,9 @@
}
}
- @RunWith(Parameterized.class)
- public static class AnnotationsOverConfigurationServerTest extends JerseyTest {
+ public abstract static class AnnotationsOverConfigurationServerTest extends JerseyTest {
- @Parameterized.Parameters(name = "Provider: {0}")
- public static Iterable<Class[]> providers() {
- return Arrays.asList(new Class[][] {{MoxyJsonFeature.class}, {JacksonFeature.class}});
- }
-
- public AnnotationsOverConfigurationServerTest(final Class<Feature> filteringProvider) {
+ public AnnotationsOverConfigurationServerTest(final Class<? extends Feature> 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 4219db4..ffad6ad 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, 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
@@ -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 71cc2ca..bc1058a 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 jakarta.ws.rs.GET;
import jakarta.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 @@
found++;
}
}
- Assert.assertEquals(2, found);
+ Assertions.assertEquals(2, found);
}
@Test
@@ -203,7 +203,7 @@
};
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 @@
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<String, String> map, String expectedValue) {
for (Map.Entry<String, List<String>> 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 2c95738..f7f43a5 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, 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,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 jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;
@@ -39,11 +39,11 @@
@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 @@
@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 @@
.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 @@
.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 2a7dcac..0a89aca 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, 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,10 +16,11 @@
package org.glassfish.jersey.tests.e2e.header;
+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 jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;
@@ -36,11 +37,11 @@
@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)
);
@@ -50,7 +51,7 @@
@Test
public void testContainerResponseFilter() {
try (Response response = target("/simple").request().get()) {
- Assert.assertEquals(
+ Assertions.assertEquals(
HeaderDelegateProviderTest.BeanForHeaderDelegateProviderTest.getValue(),
response.getHeaderString(HEADER_NAME)
);
@@ -61,7 +62,7 @@
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())
);
@@ -73,7 +74,7 @@
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 5f7f5b9..2deec5f 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<JsonTestSetup[]> generateTestCases() throws Exception {
- final List<JsonTestSetup[]> jsonTestSetups = new LinkedList<JsonTestSetup[]>();
+ @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 881d15d..27a1ede 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<JsonTestSetup[]> generateTestCases() throws Exception {
- final List<JsonTestSetup[]> jsonTestSetups = new LinkedList<JsonTestSetup[]>();
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() throws Exception {
+ List<DynamicContainer> 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/JacksonJsonViewTest.java b/tests/e2e-entity/src/test/java/org/glassfish/jersey/tests/e2e/json/JacksonJsonViewTest.java
index 197f882..1816294 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, 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
@@ -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 7733e23..49e4703 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 @@
UserTable.class
};
- public JaxbTest(final JsonTestSetup jsonTestSetup) throws Exception {
- super(jsonTestSetup);
- }
-
/**
* checks provided string to be a number
*
@@ -130,18 +126,21 @@
return true;
}
- @Parameterized.Parameters()
- public static Collection<JsonTestSetup[]> getJsonProviders() throws Exception {
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() throws Exception {
+ List<DynamicContainer> tests = new ArrayList<>();
final Class<?>[]
filteredClasses = (isJavaVersionSupported()) ? CLASSES : ArrayUtils.remove(CLASSES, EncodedContentBean.class);
- final List<JsonTestSetup[]> 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 70fcfda..b0dfc4d 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, 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
@@ -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 jakarta.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<JsonTestSetup[]> generateTestCases() throws Exception {
- final List<JsonTestSetup[]> jsonTestSetups = new LinkedList<>();
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() throws Exception {
+ List<DynamicContainer> 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 fa291d5..881a362 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 {
+public class Jersey1835Test {
- @Parameterized.Parameters()
- public static Collection<JsonTestSetup[]> generateTestCases() throws Exception {
- final List<JsonTestSetup[]> result = new LinkedList<JsonTestSetup[]>();
- result.add(new JsonTestSetup[] {new JsonTestSetup(new Class<?>[] {SingleItemListWrapperBean.class},
- new JsonTestProvider.JettisonMappedJsonTestProvider())});
- return result;
- }
-
- 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 7ed8e08..082b5af 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, 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
@@ -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 8bf8ebd..dd480ff 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, 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
@@ -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 e73684f..bf34953 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, 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
@@ -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 @@
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 @@
// 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 bc79f2c..c429786 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
@@ -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 1a35164..39f7bc5 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.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,33 +115,153 @@
}
}
- @Parameterized.Parameters(name = "{0}")
- public static Collection<JsonTestProvider[]> getJsonProviders() throws Exception {
- final List<JsonTestProvider[]> testProviders = new LinkedList<>();
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ JsonTestProvider.JAXB_PROVIDERS.forEach(jsonProvider -> {
+ JsonWithPaddingTemplateTest test = new JsonWithPaddingTemplateTest(jsonProvider) {};
+ tests.add(TestHelper.toTestContainer(test, jsonProvider.getClass().getSimpleName()));
+ });
+ return tests;
+ }
- for (final JsonTestProvider jsonProvider : JsonTestProvider.JAXB_PROVIDERS) {
- testProviders.add(new JsonTestProvider[] {jsonProvider});
+ public abstract static class JsonWithPaddingTemplateTest extends JerseyTest {
+ private final JsonTestProvider jsonTestProvider;
+ private final String errorMessage;
+
+ 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());
}
- return testProviders;
- }
+ @Override
+ protected void configureClient(final ClientConfig config) {
+ config.register(jsonTestProvider.getFeature());
+ }
- private final JsonTestProvider jsonTestProvider;
- private final String errorMessage;
+ @Test
+ public void testJson() throws Exception {
+ final Response response = target("jsonp").path("PureJson").request("application/json").get();
- public JsonWithPaddingTest(final JsonTestProvider jsonTestProvider) throws Exception {
- super(configureJaxrsApplication(jsonTestProvider));
- enable(TestProperties.LOG_TRAFFIC);
- enable(TestProperties.DUMP_ENTITY);
+ assertThat(response.getStatus(), equalTo(200));
+ assertThat(response.getMediaType().toString(), equalTo("application/json"));
- this.jsonTestProvider = jsonTestProvider;
- this.errorMessage = String.format("%s: Received JSON entity content does not match expected JSON entity content.",
- jsonTestProvider.getClass().getSimpleName());
- }
+ final String entity = response.readEntity(String.class);
- @Override
- protected void configureClient(final ClientConfig config) {
- config.register(jsonTestProvider.getFeature());
+ assertThat(errorMessage, entity, allOf(not(startsWith("callback(")), not(endsWith(")"))));
+ }
+
+ @Test
+ public void testJsonWithJavaScriptMediaType() throws Exception {
+ final Response response = target("jsonp").path("PureJson").request("application/x-javascript").get();
+
+ // 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 testJsonWithPaddingDefault() throws Exception {
+ test("JsonWithPaddingDefault", "callback");
+ }
+
+ @Test
+ public void testJsonWithPaddingQueryCallbackParam() throws Exception {
+ test("JsonWithPaddingQueryCallbackParam", "eval", "parse");
+ }
+
+ @Test
+ public void testJsonWithPaddingQueryCallbackParamDefaultQueryParam() throws Exception {
+ test("JsonWithPaddingQueryCallbackParam", "callback", "parse", "callback");
+ }
+
+ @Test
+ public void testJsonWithPaddingQueryCallbackParamDefaultCallback() throws Exception {
+ test("JsonWithPaddingQueryCallbackParam", null, "callback");
+ }
+
+ @Test
+ public void testJsonWithPaddingQueryCallbackParamNegative() throws Exception {
+ test("JsonWithPaddingQueryCallbackParam", "call", "parse", true);
+ }
+
+ @Test
+ public void testJsonWithPaddingCallbackAndQueryCallbackParam() throws Exception {
+ test("JsonWithPaddingCallbackAndQueryCallbackParam", "eval", "run");
+ }
+
+ @Test
+ public void testJsonWithPaddingCallbackAndQueryCallbackParamNegative() throws Exception {
+ test("JsonWithPaddingCallbackAndQueryCallbackParam", "eval", "run", "parse", true);
+ }
+
+ @Test
+ public void testJsonWithPaddingCallbackAndQueryCallbackParamDefault() throws Exception {
+ test("JsonWithPaddingCallbackAndQueryCallbackParam", "evalx", "parse");
+ }
+
+ @Test
+ public void testJsonWithPaddingCallbackAndQueryCallbackParamDefaultNegative() throws Exception {
+ test("JsonWithPaddingCallbackAndQueryCallbackParam", "evalx", "xlave", "eval", true);
+ }
+
+ @Test
+ public void testJsonWithPaddingCallback() throws Exception {
+ test("JsonWithPaddingCallback", "eval", "eval");
+ }
+
+ @Test
+ public void testJsonWithPaddingCallbackNegative() throws Exception {
+ test("JsonWithPaddingCallback", "eval", "lave", true);
+ }
+
+ 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 callback) {
+ test(path, queryParamName, callback, callback, false);
+ }
+
+ 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 queryParamName, final String queryParamValue, final String callback) {
+ test(path, queryParamName, queryParamValue, callback, false);
+ }
+
+ private void test(final String path, final String queryParamName, final String queryParamValue, final String callback,
+ final boolean isNegative) {
+
+ WebTarget tempTarget = target("jsonp").path(path);
+ if (queryParamName != null) {
+ tempTarget = tempTarget.queryParam(queryParamName, queryParamValue);
+ }
+
+ final Response response = tempTarget.request("application/x-javascript").get();
+
+ assertThat(response.getStatus(), equalTo(200));
+ assertThat(response.getMediaType().toString(), equalTo("application/x-javascript"));
+
+ final String entity = response.readEntity(String.class);
+
+ // Check the entity.
+ final Matcher<String> startsWith = startsWith(callback + "(");
+ final Matcher<String> endsWith = endsWith(")");
+
+ final Matcher<String> callbackMatcher = isNegative ? not(startsWith) : startsWith;
+
+ assertThat(errorMessage, entity, allOf(callbackMatcher, endsWith));
+ }
}
private static Application configureJaxrsApplication(final JsonTestProvider jsonTestProvider) {
@@ -159,123 +276,4 @@
return resourceConfig;
}
- @Test
- public void testJson() throws Exception {
- final Response response = target("jsonp").path("PureJson").request("application/json").get();
-
- assertThat(response.getStatus(), equalTo(200));
- assertThat(response.getMediaType().toString(), equalTo("application/json"));
-
- final String entity = response.readEntity(String.class);
-
- assertThat(errorMessage, entity, allOf(not(startsWith("callback(")), not(endsWith(")"))));
- }
-
- @Test
- public void testJsonWithJavaScriptMediaType() throws Exception {
- final Response response = target("jsonp").path("PureJson").request("application/x-javascript").get();
-
- // 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 testJsonWithPaddingDefault() throws Exception {
- test("JsonWithPaddingDefault", "callback");
- }
-
- @Test
- public void testJsonWithPaddingQueryCallbackParam() throws Exception {
- test("JsonWithPaddingQueryCallbackParam", "eval", "parse");
- }
-
- @Test
- public void testJsonWithPaddingQueryCallbackParamDefaultQueryParam() throws Exception {
- test("JsonWithPaddingQueryCallbackParam", "callback", "parse", "callback");
- }
-
- @Test
- public void testJsonWithPaddingQueryCallbackParamDefaultCallback() throws Exception {
- test("JsonWithPaddingQueryCallbackParam", null, "callback");
- }
-
- @Test
- public void testJsonWithPaddingQueryCallbackParamNegative() throws Exception {
- test("JsonWithPaddingQueryCallbackParam", "call", "parse", true);
- }
-
- @Test
- public void testJsonWithPaddingCallbackAndQueryCallbackParam() throws Exception {
- test("JsonWithPaddingCallbackAndQueryCallbackParam", "eval", "run");
- }
-
- @Test
- public void testJsonWithPaddingCallbackAndQueryCallbackParamNegative() throws Exception {
- test("JsonWithPaddingCallbackAndQueryCallbackParam", "eval", "run", "parse", true);
- }
-
- @Test
- public void testJsonWithPaddingCallbackAndQueryCallbackParamDefault() throws Exception {
- test("JsonWithPaddingCallbackAndQueryCallbackParam", "evalx", "parse");
- }
-
- @Test
- public void testJsonWithPaddingCallbackAndQueryCallbackParamDefaultNegative() throws Exception {
- test("JsonWithPaddingCallbackAndQueryCallbackParam", "evalx", "xlave", "eval", true);
- }
-
- @Test
- public void testJsonWithPaddingCallback() throws Exception {
- test("JsonWithPaddingCallback", "eval", "eval");
- }
-
- @Test
- public void testJsonWithPaddingCallbackNegative() throws Exception {
- test("JsonWithPaddingCallback", "eval", "lave", true);
- }
-
- 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 callback) {
- test(path, queryParamName, callback, callback, false);
- }
-
- 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 queryParamName, final String queryParamValue, final String callback) {
- test(path, queryParamName, queryParamValue, callback, false);
- }
-
- private void test(final String path, final String queryParamName, final String queryParamValue, final String callback,
- final boolean isNegative) {
-
- WebTarget tempTarget = target("jsonp").path(path);
- if (queryParamName != null) {
- tempTarget = tempTarget.queryParam(queryParamName, queryParamValue);
- }
-
- final Response response = tempTarget.request("application/x-javascript").get();
-
- assertThat(response.getStatus(), equalTo(200));
- assertThat(response.getMediaType().toString(), equalTo("application/x-javascript"));
-
- final String entity = response.readEntity(String.class);
-
- // Check the entity.
- final Matcher<String> startsWith = startsWith(callback + "(");
- final Matcher<String> endsWith = endsWith(")");
-
- final Matcher<String> callbackMatcher = isNegative ? not(startsWith) : startsWith;
-
- assertThat(errorMessage, entity, allOf(callbackMatcher, endsWith));
- }
-
}
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 fe50dcd..6821046 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, 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,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 jakarta.annotation.Priority;
import jakarta.ws.rs.client.Entity;
@@ -64,7 +64,7 @@
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 26475b4..84fb2ce 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<JsonTestSetup[]> generateTestCases() throws Exception {
- final List<JsonTestSetup[]> jsonTestSetups = new LinkedList<>();
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() throws Exception {
+ List<DynamicContainer> 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;
+ return tests;
}
-
- public PojoTest(final JsonTestSetup jsonTestSetup) throws Exception {
- super(jsonTestSetup);
- }
-
}
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 f3a2514..bb7b8fc 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, 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
@@ -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 @@
.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 @@
.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 c0b803c..5b3d957 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, 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
@@ -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 @@
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 216d9fb..7f691a9 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, 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
@@ -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 jakarta.inject.Singleton;
import jakarta.ws.rs.GET;
@@ -166,8 +166,8 @@
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 @@
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 1dad526..0d63c5c 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, 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
@@ -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 @@
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 @@
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 71e453f..7280b84 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, 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
@@ -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 @@
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 @@
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 8657747..d0c22f6 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, 2020 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 jakarta.inject.Singleton;
import jakarta.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 @@
}
- @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 b69230a..e9c90be 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, 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
@@ -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 @@
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 @@
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 141e042..a2a055a 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, 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
@@ -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 @@
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 @@
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 @@
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 37f6c76..a20f4c9 100644
--- a/tests/e2e-inject/cdi-inject-weld/pom.xml
+++ b/tests/e2e-inject/cdi-inject-weld/pom.xml
@@ -79,8 +79,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 3c402fe..c93a71d 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 @@
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 @@
}
}
+ @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 d52cac2..f789edc 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 @@
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 @@
}
}
+ @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 9f7522b..f88b1e2 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 @@
private Weld weld;
+ @BeforeEach
@Override
public void setUp() throws Exception {
weld = new Weld();
@@ -38,6 +41,7 @@
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 a26cb29..58d2e5b 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 @@
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 578e6e9..69e5862 100644
--- a/tests/e2e-inject/cdi2-se/pom.xml
+++ b/tests/e2e-inject/cdi2-se/pom.xml
@@ -59,8 +59,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 f76134e..a1d688c 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,9 +23,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;
/**
* Tests that the resource can fire an event.
@@ -52,7 +52,7 @@
}
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
try {
super.setUp();
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 a8433f7..dae02fc 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, 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
@@ -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 96be176..baeb657 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 c431a65..3545f4c 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 45247b0..6cc37d0 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, 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
@@ -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 jakarta.inject.Singleton;
import jakarta.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 f605631..0826456 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 jakarta.inject.Inject;
import jakarta.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 d652d8c..2d9e794 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, 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
@@ -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 jakarta.inject.Singleton;
import jakarta.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 242001b..7c776a4 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, 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
@@ -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 jakarta.inject.Singleton;
import jakarta.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 04d221a..90d29e5 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, 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,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 jakarta.inject.Singleton;
import jakarta.ws.rs.core.Application;
diff --git a/tests/e2e-server/pom.xml b/tests/e2e-server/pom.xml
index b82ce78..a3760af 100644
--- a/tests/e2e-server/pom.xml
+++ b/tests/e2e-server/pom.xml
@@ -183,6 +183,12 @@
<artifactId>jersey-test-framework-util</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-suite</artifactId>
+ <version>${junit-platform-suite.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.hamcrest</groupId>
@@ -191,8 +197,8 @@
</dependency>
<dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
+ <groupId>org.xmlunit</groupId>
+ <artifactId>xmlunit-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 687fc04..b3a17f3 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, 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
@@ -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 @@
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<UselessMessage> 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 1831b36..a15cde8 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, 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
@@ -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 422fc31..97673a9 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, 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
@@ -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 15f8968..65d18b4 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, 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
@@ -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 abb9721..f04ea41 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, 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
@@ -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 da3670c..41d5b6e 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 1d26958..f001b1e 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, 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
@@ -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 @@
@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 @@
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 5d129ae..19db63b 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, 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
@@ -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 ef4e519..36dc947 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, 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
@@ -19,7 +19,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import jakarta.json.bind.annotation.JsonbProperty;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -33,15 +32,15 @@
import jakarta.ws.rs.ext.ParamConverterProvider;
import jakarta.ws.rs.ext.Provider;
-// import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
+import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import org.glassfish.jersey.server.ParamException;
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;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Tests the ability to catch WebApplicationException thrown in ParamConverter
@@ -58,8 +57,8 @@
return new ResourceConfig(
BeanParamController.class,
ModelObjectParamConverter.class,
- QueryParamErrorMapper.class/*,
- JacksonJaxbJsonProvider.class*/);
+ QueryParamErrorMapper.class,
+ JacksonJaxbJsonProvider.class);
}
@Path("/")
@@ -199,14 +198,12 @@
this.status = status;
}
- // @JsonProperty
- @JsonbProperty
+ @JsonProperty
public String getMessage() {
return message;
}
- // @JsonProperty
- @JsonbProperty
+ @JsonProperty
public int getStatus() {
return status;
}
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 38bce22..24f7e13 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, 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
@@ -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 @@
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 @@
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 @@
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 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 bf848ec..d5be593 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, 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
@@ -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 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 13efb61..64c0422 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, 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,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 @@
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 @@
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 @@
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 f0d4e58..957e9ad 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, 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
@@ -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 2462148..2e10424 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, 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
@@ -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 50573cb..0355f04 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
@@ -45,14 +45,13 @@
import jakarta.ws.rs.ext.MessageBodyWriter;
import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.server.ServerProperties;
import org.glassfish.jersey.test.JerseyTest;
+import org.junit.jupiter.api.Test;
-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.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 955422a..12fe161 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, 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
@@ -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 4386342..f229965 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, 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
@@ -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 @@
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 @@
//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 @@
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 8e4ff15..74d05f1 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, 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
@@ -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 @@
}
}
- @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 cbe891c..3c94e70 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, 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
@@ -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 7bd7ae6..8d59c82 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, 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
@@ -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 0b8abd8..39bd709 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, 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
@@ -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 a265479..792c131 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, 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
@@ -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 8f8a405..15bfb06 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, 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,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 @@
}
}
- @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 @@
+ "<testBean><input>&lol3;</input></testBean>";
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 @@
String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
+ "<testBean str=\"aaa\" str2=\"bbb\" str3=\"ccc\"><input>test</input></testBean>";
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 6b50666..8629f03 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, 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
@@ -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 217bb5d..b8a4e08 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, 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
@@ -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 4aad777..a7ecf95 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, 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
@@ -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 @@
// 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 6e0389f..f7f4f68 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, 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
@@ -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 1d840e3..6934443 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, 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
@@ -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 @@
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 febfeae..09f51f7 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, 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
@@ -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 ac7ccf7..76195b4 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, 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
@@ -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 2935eeb..a3a115b 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, 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
@@ -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 @@
@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 ddfc4b6..07a5770 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, 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
@@ -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 cae8929..c598ae8 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, 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
@@ -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 a967dc7..993139d 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 0d0dad5..e22bb09 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 jakarta.ws.rs.Consumes;
import jakarta.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 33acc33..a1abb1a 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 54e9316..1257830 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, 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
@@ -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 2608401..eebfc8c 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, 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
@@ -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 8fca0aa..e248404 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, 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
@@ -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 @@
* 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 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 93849fc..e7e99a9 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, 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
@@ -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 7c87c28..09088db 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, 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
@@ -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 0e28366..767e42a 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, 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
@@ -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 ebe9bf7..1223c0b 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 jakarta.ws.rs.GET;
import jakarta.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 ea406a8..43d18e0 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, 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
@@ -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 @@
@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 dda65f7..a3194ba 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, 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
@@ -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 9fefcce..6446ff2 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, 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,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 2e30267..a517ff4 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 c2d1bbd..0a12b97 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, 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
@@ -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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testResourceAGet() {
Response response = target("/a").request().get();
assertEquals(200, response.getStatus());
@@ -237,6 +239,7 @@
}
@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 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testResourceAChildGet() {
Response response = target("/a/child").request().get();
assertEquals(200, response.getStatus());
@@ -261,6 +266,7 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testResourceALocatorGet() {
Response response = target("/a/locator").request().get();
assertEquals(200, response.getStatus());
@@ -269,6 +275,7 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testResourceBGet() {
Response response = target("/b").request().get();
assertEquals(200, response.getStatus());
@@ -285,6 +293,7 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testResourceBLocatorGet() {
Response response = target("/b/locator").request().get();
assertEquals(200, response.getStatus());
@@ -301,6 +311,7 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testResourceAMyResource() {
Response response = target("/a/my-resource").request().get();
assertEquals(200, response.getStatus());
@@ -317,6 +329,7 @@
}
@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 @@
}
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void testResourceBMyResource() {
Response response = target("/b/my-resource").request().get();
assertEquals(200, response.getStatus());
@@ -333,6 +347,7 @@
}
@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 3c24bfe..e872163 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, 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
@@ -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 @@
final Set<Class<?>> 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 @@
}
@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 @@
* invoked for each resource method (globally).
*/
@Test
+ @Execution(ExecutionMode.CONCURRENT)
public void preMatchingNameBinding() {
final Response response = _getResponse("resource/preMatchingNameBinding");
@@ -209,11 +213,13 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 16ec403..63a5d37 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 f0e5b08..444475b 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 628b548..a22b546 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, 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
@@ -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 0fd62a3..a167116 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, 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,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 @@
}
@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 1f91051..e92d035 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, 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
@@ -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 4f3cfcc..a6f9baf 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, 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
@@ -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 95b1b6d..c20ca5a 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, 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
@@ -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 @@
}
}
- @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 aff8bc7..43cd32a 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, 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
@@ -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 @@
}
@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 @@
}
@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 @@
}
@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 @@
@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 @@
}
@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 @@
}
@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 @@
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
@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 @@
}
@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 @@
}
@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 @@
}
@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 @@
}
@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 aafdb99..82214a7 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, 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
@@ -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 4933a82..4c5ec0d 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, 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,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 @@
}
}
- @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 6ded31f..67d8451 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, 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
@@ -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 @@
}
@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 75c9281..73ef456 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, 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
@@ -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 @@
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 a31d1aa..58b4dcc 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, 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
@@ -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 @@
@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 f0d513a..60c402b 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, 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
@@ -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 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 @@
}
@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 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 d360a6b..aca077d 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, 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
@@ -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 1cc76a0..ece386b 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 fea9d8d..5e2a9e0 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, 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
@@ -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 @@
@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 @@
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 @@
// 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 4621256..3e20517 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, 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
@@ -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 @@
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 deed0f1..c0b49d5 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, 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
@@ -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 455c5b9..284b274 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, 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
@@ -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 @@
@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 d66f831..911d733 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, 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
@@ -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 54bc087..beabf58 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, 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
@@ -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 @@
@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 062e5c5..a6e088a 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, 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
@@ -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 @@
@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 @@
@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 @@
@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 @@
@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 1eeef2b..8274194 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, 2020 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 e10da1b..9ab321d 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, 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
@@ -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 @@
}
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testResolveTemplate() {
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("a", "xyz");
- map.put(null, "path");
- UriBuilder builder = UriBuilder.fromPath("").path("{a}/{b}");
- builder.resolveTemplates(map);
+ assertThrows(IllegalArgumentException.class, () -> {
+ Map<String, Object> map = new HashMap<String, Object>();
+ 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 a5eecfe..88679d5 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, 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
@@ -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 1c0195f..c7054e4 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, 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
@@ -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 2206885..d220a21 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, 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
@@ -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 f2979c6..849f87c 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, 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
@@ -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 8245ecc..e977f1a 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, 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
@@ -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 7bcacd8..48df1b9 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, 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
@@ -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 d3269bf..8873587 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, 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
@@ -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 6296887..24e952a 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, 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
@@ -18,6 +18,8 @@
import java.util.Arrays;
import java.util.List;
+import java.util.Collection;
+import java.util.ArrayList;
import jakarta.ws.rs.ConstrainedTo;
import jakarta.ws.rs.GET;
@@ -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<Object[]> 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> 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;
+ @TestFactory
+ public Collection<DynamicContainer> generatedTests() {
+ Collection<DynamicContainer> 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 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;
+ 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 @@
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 913a667..f10661a 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, 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
@@ -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 @@
}
break;
case FINISHED:
- Assert.assertNotNull(event.getContainerResponse());
+ Assertions.assertNotNull(event.getContainerResponse());
this.appEventListener.finishedCalled.countDown();
break;
}
@@ -383,7 +383,7 @@
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 @@
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 6dd9e4f..609febc 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, 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
@@ -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 @@
}
@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 @@
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 @@
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 a550d46..cfa4df6 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, 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,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 17c7986..690777a 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, 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
@@ -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 @@
public static class ParentTest extends JerseyTest {
+ @BeforeEach
@Override
public void setUp() throws Exception {
super.setUp();
@@ -343,7 +346,7 @@
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 @@
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 ded54ab..f47330b 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, 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
@@ -16,6 +16,9 @@
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 jakarta.ws.rs.GET;
@@ -39,21 +42,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 +71,7 @@
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
super.tearDown();
assertTrue(StatisticsListener.ON_SHUTDOWN_CALLED);
@@ -90,7 +90,7 @@
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 +119,9 @@
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 b9914b1..20a98a5 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, 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
@@ -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 @@
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 d822592..8cf12dd 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, 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
@@ -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 3a16ce5..68d81a4 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, 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
@@ -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 @@
}
}
- @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 08bf95a..4709bda 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 @@
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 e87cc8e..cfacf8e 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, 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
@@ -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 1ffcc67..a3e73cb 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, 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
@@ -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 0364c95..83a417f 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, 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
@@ -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 0c40b15..e1008e2 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, 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,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 c229983..ac1e023 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, 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
@@ -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 6355545..582ff46 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, 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
@@ -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 15441ab..2f38f45 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, 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
@@ -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 c8a7621..66e030f 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, 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
@@ -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 df455e8..b19cbbf 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, 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
@@ -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 af33a63..febeeb1 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, 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
@@ -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<Object[]> data() {
return Arrays.asList(new Object[][]{
{new FreemarkerMvcFeature(), "freemarker", "FreemarkerResource.ftl", "UTF-8"},
@@ -67,85 +66,105 @@
});
}
- 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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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<String, String> map = new HashMap<String, String>();
- 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<String, String> map = new HashMap<String, String>();
- 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
+ public Viewable get() {
+ final Map<String, String> map = new HashMap<String, String>();
+ map.put("user", MESSAGE);
+
+ return new Viewable("/org/glassfish/jersey/tests/e2e/server/mvc/MvcEncodingTest/" + templateName, map);
+ }
+
+ @GET
+ @Path("textplain")
+ @Produces("text/plain")
+ public Viewable getTextPlain() {
+ final Map<String, String> map = new HashMap<String, String>();
+ 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<String, String> map = new HashMap<String, String>();
+ 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<String, String> map = new HashMap<String, String>();
- 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();
+ 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 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 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 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 testTextPlain406() {
+ final Response response = target().path("resource/textplain").request("text/html").get();
+ Assertions.assertEquals(406, response.getStatus());
+ }
- @Test
- public void testTextPlain406() {
- final Response response = target().path("resource/textplain").request("text/html").get();
- Assert.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 dfd6ee5..dfc1ef7 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, 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,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 8d929c0..6db289e 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, 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
@@ -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 7800222..2f2c712 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, 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
@@ -16,6 +16,9 @@
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;
@@ -40,18 +43,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 5696a83..ddd35e0 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, 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
@@ -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 ec1f728..bbd5ffa 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.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 512a2a5..2a75b9d 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, 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
@@ -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 2ff2e33..ee04238 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, 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
@@ -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 af5bf68..8dc5a5b 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, 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
@@ -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 77cd62a..ed9c7b6 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, 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
@@ -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 a051f66..17613a8 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, 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
@@ -18,12 +18,11 @@
import java.io.Serializable;
+import jakarta.validation.constraints.Email;
+import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.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 f1929f8..5f17f73 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, 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
@@ -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 606cb99..faba33c 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, 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
@@ -25,6 +25,7 @@
import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
+import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.glassfish.jersey.client.ClientConfig;
@@ -33,8 +34,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 d3c633e..a5e0c98 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, 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
@@ -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 b3f1a0c..d1e8106 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, 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
@@ -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 d93f2cd..759a147 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, 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
@@ -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 730144f..f8b2c9f 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, 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
@@ -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.
@@ -180,7 +180,8 @@
private void assertApply(int responseStatus, ResourceConfig resourceConfig, URI uri)
throws InterruptedException, ExecutionException {
final ApplicationHandler applicationHandler = new ApplicationHandler(resourceConfig);
- final ContainerRequest requestContext = new ContainerRequest(uri, uri, "POST", null, new MapPropertiesDelegate());
+ final ContainerRequest requestContext =
+ new ContainerRequest(uri, uri, "POST", null, new MapPropertiesDelegate(), resourceConfig);
final ContainerResponse containerResponse = applicationHandler.apply(requestContext).get();
assertEquals(responseStatus, containerResponse.getStatus());
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 fa65eae..2d88b34 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, 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
@@ -18,6 +18,8 @@
import java.io.Serializable;
+import jakarta.validation.constraints.Email;
+import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.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 bb89e99..d9a95e5 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, 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,12 @@
import jakarta.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 @@
}
@Test
- @RunSeparately
public void testOnTypeValidateResultFailValidateExecutableMatch() throws Exception {
_testOnType("match", -15, 500);
}
@@ -167,7 +168,6 @@
}
@Test
- @RunSeparately
public void testOnTypeValidateResultPassBiggerValidateExecutableMiss() throws Exception {
_testOnType("miss", -15, 200);
}
@@ -178,7 +178,6 @@
}
@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 3c3c946..995a6fb 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, 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
@@ -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 @@
}
@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 3a95283..0a8a46b 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, 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
@@ -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 14587b9..e2045c7 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, 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
@@ -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 b0983d9..e2830bd 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, 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
@@ -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 jakarta.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 6376c31..e147df7 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, 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
@@ -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 6d822ee..5c78ad1 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, 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
@@ -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 9dc66d9..8790628 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
@@ -51,15 +51,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;
/**
@@ -76,35 +76,6 @@
*/
public class WadlBeanParamTest extends JerseyTest {
- private final ElementNameAndTextQualifier elementQualifier = new ElementNameAndTextQualifier() {
-
- /**
- * For {@code <param ??? />} 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,
@@ -158,18 +129,28 @@
final SimpleNamespaceResolver nsContext = new SimpleNamespaceResolver("wadl", "http://wadl.dev.java.net/2009/02");
xp.setNamespaceContext(nsContext);
- final Diff diff = XMLUnit.compareXML(
- nodeAsString(
- xp.evaluate("//wadl:resource[@path='wadlBeanParamReference']/wadl:resource", d,
- XPathConstants.NODE)),
- nodeAsString(
- xp.evaluate("//wadl:resource[@path='" + resource + "']/wadl:resource", d,
- XPathConstants.NODE))
- );
- XMLUnit.setXpathNamespaceContext(
- new SimpleNamespaceContext(Collections.singletonMap("wadl", "http://wadl.dev.java.net/2009/02")));
- diff.overrideElementQualifier(elementQualifier);
- XMLAssert.assertXMLEqual(diff, true);
+ final Diff diff = DiffBuilder.compare(
+ nodeAsString(
+ xp.evaluate("//wadl:resource[@path='wadlBeanParamReference']/wadl:resource", d,
+ XPathConstants.NODE)))
+ .withTest(
+ nodeAsString(
+ xp.evaluate("//wadl:resource[@path='" + resource + "']/wadl:resource", d,
+ XPathConstants.NODE))
+ ).withNamespaceContext(Collections.singletonMap("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 f38a5a8..91ac445 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, 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
@@ -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 42e549e..6c4907f 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
@@ -91,27 +91,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.sun.research.ws.wadl.Method;
import com.sun.research.ws.wadl.Param;
@@ -128,8 +126,8 @@
* @author Libor Kramolis
* @author Marek Potociar
*/
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
+@Suite
+@SelectClasses({
WadlResourceTest.Wadl1Test.class,
WadlResourceTest.Wadl2Test.class,
WadlResourceTest.Wadl3Test.class,
@@ -1056,7 +1054,7 @@
}
@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 {
@@ -1073,7 +1071,7 @@
}
@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 {
@@ -1269,19 +1267,16 @@
final SimpleNamespaceResolver nsContext = new SimpleNamespaceResolver("wadl", "http://wadl.dev.java.net/2009/02");
xp.setNamespaceContext(nsContext);
- final Diff diff = XMLUnit.compareXML(
- nodeAsString(
- xp.evaluate("//wadl:resource[@path='annotated']/wadl:resource", document,
- XPathConstants.NODE)),
- nodeAsString(
- xp.evaluate("//wadl:resource[@path='not-annotated']/wadl:resource", document,
- XPathConstants.NODE))
- );
- XMLUnit.setXpathNamespaceContext(
- new SimpleNamespaceContext(Collections.singletonMap("wadl", "http://wadl.dev.java.net/2009/02")));
- final ElementQualifier elementQualifier = new RecursiveElementNameAndTextQualifier();
- diff.overrideElementQualifier(elementQualifier);
- XMLAssert.assertXMLEqual(diff, true);
+ final Diff diff = DiffBuilder.compare(
+ nodeAsString(
+ xp.evaluate("//wadl:resource[@path='annotated']/wadl:resource", document,
+ XPathConstants.NODE)))
+ .withTest(
+ nodeAsString(
+ xp.evaluate("//wadl:resource[@path='not-annotated']/wadl:resource", document,
+ XPathConstants.NODE))
+ ).withNamespaceContext(Collections.singletonMap("wadl", "http://wadl.dev.java.net/2009/02")).build();
+ Assertions.assertFalse(diff.hasDifferences());
}
diff --git a/tests/e2e-testng/pom.xml b/tests/e2e-testng/pom.xml
index 8e137ee..98fad18 100644
--- a/tests/e2e-testng/pom.xml
+++ b/tests/e2e-testng/pom.xml
@@ -52,7 +52,7 @@
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
- <version>2.17</version>
+ <version>${surefire.version}</version>
</dependency>
</dependencies>
</plugin>
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 8ba02b6..c5b5529 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
@@ -24,6 +24,7 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
+
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
diff --git a/tests/e2e/pom.xml b/tests/e2e/pom.xml
index da8b8d8..87271b6 100644
--- a/tests/e2e/pom.xml
+++ b/tests/e2e/pom.xml
@@ -169,6 +169,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-suite</artifactId>
+ <version>${junit-platform-suite.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
@@ -181,12 +187,6 @@
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<profiles>
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 30afa35..35566f8 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, 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
@@ -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 @@
* 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 @@
/**
* 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 32b3242..8193805 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, 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
@@ -21,10 +21,10 @@
import jakarta.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 02337f9..1e43485 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.MediaType;
import jakarta.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 @@
@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 @@
@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 @@
@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 @@
@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 c98d227..e9f7ef6 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 jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -81,8 +81,8 @@
@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 c05cb21..5ac388d 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, 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
@@ -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 f7cda82..163efda 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, 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
@@ -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 2cbd3fe..4332468 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, 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
@@ -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 @@
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 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 6d4a26c..f3acf78 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, 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
@@ -22,9 +22,9 @@
import jakarta.ws.rs.Produces;
import jakarta.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 8cbdcc1..f54685f 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 1d8c7de..1068272 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 cb397c6..de7a91e 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, 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
@@ -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 dbabadc..b5d7e6f 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, 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
@@ -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 @@
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 9d74547..c931809 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 38c7daa..63305db 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, 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
@@ -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 9bce717..6539e35 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 9a84b2c..874b0d0 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, 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
@@ -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 @@
* 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 @@
* 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 @@
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 @@
/**
* 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<Response> 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 7f9a4c1..7d8bc6a 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, 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
@@ -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 @@
* 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 @@
* 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 @@
* 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 @@
}
@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 7b94730..498c968 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.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 @@
* 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 @@
@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 @@
@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 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 fdc287e..8a1d4fa 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, 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
@@ -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 23d25f4..67f438e 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, 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
@@ -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 c858f35..ad1bbda 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, 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
@@ -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 48375f0..9076cae 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, 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
@@ -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 14da63a..661cb46 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, 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
@@ -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 21ee879..e5f5b10 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, 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
@@ -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 456f0a7..81dab3b 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, 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.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 53716eb..59356ad 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, 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
@@ -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 3e06e1a..6403bb7 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, 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
@@ -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 @@
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 @@
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 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 @@
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 @@
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 ece9740..906984a 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, 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
@@ -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 9bfbc4d..bf8c847 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, 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
@@ -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 c5f6db9..9a386cf 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, 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
@@ -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 @@
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 @@
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 7275a1d..4462c04 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, 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
@@ -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 @@
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 @@
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 4784924..62d71ca 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, 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
@@ -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 @@
}
@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 da6587d..52d7828 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, 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
@@ -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 ccb44fd..f8307a3 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, 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
@@ -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 @@
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 @@
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 73b0b68..86e071b 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, 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
@@ -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 @@
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<Response> fr = client.target(getBaseUri()).path("resource").request().async().get();
response = fr.get();
@@ -289,18 +289,16 @@
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 @@
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 @@
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 @@
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 966fe7f..452b344 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, 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
@@ -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 ecc1a89..a2d4a66 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, 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
@@ -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 2d3ca33..73d7fd6 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, 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
@@ -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 1f87a27..b77a6eb 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 jakarta.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 463d509..11d637e 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, 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
@@ -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 jakarta.ws.rs.POST;
@@ -43,10 +41,10 @@
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.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -55,8 +53,10 @@
*
* @author Jakub Podlesak
*/
-@RunWith(Parameterized.class)
-public class HugeEntityTest extends JerseyTest {
+@Suite
+@SelectClasses({HugeEntityTest.GrizzlyConnectorProviderHugeEntityTest.class,
+ HugeEntityTest.JdkConnectorProviderHugeEntityTest.class})
+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 +98,72 @@
}
}
- 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<? extends ConnectorProvider> 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;
- @Override
- protected void configureClient(ClientConfig config) {
- config.register(TestEntityWriter.class);
- config.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.CHUNKED);
- config.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!"));
+ }
+
+ /**
+ * 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> 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 +212,4 @@
}
}
}
-
- /**
- * 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> 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 f965998..e23f058 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, 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
@@ -16,9 +16,6 @@
package org.glassfish.jersey.tests.e2e.client.connector;
-import java.util.Arrays;
-import java.util.List;
-
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
@@ -35,19 +32,21 @@
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.platform.suite.api.SelectClasses;
+import org.junit.platform.suite.api.Suite;
-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 {
+@Suite
+@SelectClasses({MethodTest.JdkConnectorProviderMethodTest.class,
+ MethodTest.GrizzlyConnectorProviderMethodTest.class})
+public class MethodTest {
private static final String PATH = "test";
@@ -75,48 +74,57 @@
}
}
- 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<? extends ConnectorProvider> 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 c3ea342..3dea887 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, 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
@@ -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 b891b23..dc608cf 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, 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
@@ -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 @@
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 a884157..2050c8f 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, 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
@@ -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 a9fbb0c..8b00695 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, 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
@@ -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 9911171..521efa1 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, 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
@@ -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 31a00b4..31add12 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, 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
@@ -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 f3d849e..faa32a8 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 jakarta.ws.rs.ConstrainedTo;
import jakarta.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 cc56114..3550a1f 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, 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
@@ -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 c5e3db7..fd2721a 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, 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
@@ -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 3d4735d..fa3283d 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, 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
@@ -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 @@
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 843613d..bcdfbc4 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, 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
@@ -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 f005095..9958cd9 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 @@
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<String> headerValues) {
@@ -762,10 +762,5 @@
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 8775ec2..a4e95a6 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, 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
@@ -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 e5bc65a..8ecbed9 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, 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
@@ -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 8f51649..0bc6524 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, 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
@@ -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 d7a7693..996c68e 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, 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
@@ -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 @@
* 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 487e070..8be6c33 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
break;
}
}
- assertTrue("Expected log record was not found.", found);
+ assertTrue(found, "Expected log record was not found.");
}
}
@@ -377,9 +380,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
break;
}
}
- assertTrue("Expected log record was not found.", found);
+ assertTrue(found, "Expected log record was not found.");
}
}
@@ -525,7 +533,7 @@
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 ff079ac..ee9f4aa 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, 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,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 @@
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 0d4ea22..7cab7f8 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, 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
@@ -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 @@
.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 @@
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 cad67da..507cea3 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, 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
@@ -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 @@
@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 fd65f7a..ec76630 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, 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
@@ -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 6318bfe..fa64b62 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, 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
@@ -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 51a2894..44d9bac 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, 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
@@ -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 @@
WebTarget target = target("test");
Response response = target.path("1").request(MediaType.APPLICATION_JSON).get();
Set<Link> 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 @@
WebTarget target = target("test");
Response response = target.path("2").request(MediaType.APPLICATION_JSON).get();
Set<Link> 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 cdf03cc..2a2c4cf 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, 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
@@ -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 @@
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/ApplicationPathTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ApplicationPathTest.java
index 6239551..87ea906 100644
--- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ApplicationPathTest.java
+++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ApplicationPathTest.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,23 +22,28 @@
import jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;
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.jetty.JettyTestContainerFactory;
import org.glassfish.jersey.test.netty.NettyTestContainerFactory;
+import org.glassfish.jersey.test.simple.SimpleTestContainerFactory;
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.DynamicContainer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestFactory;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
+import java.util.stream.Stream;
-@RunWith(Parameterized.class)
-public class ApplicationPathTest extends JerseyContainerTest {
+import static org.glassfish.jersey.tests.e2e.container.JerseyContainerTest.listContainerFactories;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+public class ApplicationPathTest {
private static final List<TestContainerFactory> FACTORIES = listContainerFactories(
new GrizzlyTestContainerFactory(),
@@ -46,9 +51,8 @@
new NettyTestContainerFactory()
);
- @Parameterized.Parameters(name = "{0}")
- public static Collection<TestContainerFactory[]> parameters() throws Exception {
- return FACTORIES.stream().map(input -> new TestContainerFactory[]{input}).collect(Collectors.toList());
+ public static Stream<TestContainerFactory> parameters() {
+ return FACTORIES.stream();
}
@ApplicationPath("applicationpath")
@@ -67,21 +71,38 @@
}
}
- @Override
- protected Application configure() {
- return new ApplicationPathTestApplication();
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ final Collection<DynamicContainer> tests = new ArrayList<>();
+ ApplicationPathTest.parameters().forEach(testContainerFactory -> {
+ final ApplicationPathTest.ApplicationPathTemplateTest test =
+ new ApplicationPathTest.ApplicationPathTemplateTest(testContainerFactory) {};
+ tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName()));
+ });
+ return tests;
}
- @Test
- public void testApplicationPath() {
- try (Response response = target("applicationpath").path("resource").request().get()) {
- Assert.assertEquals(200, response.getStatus());
- Assert.assertEquals(new ApplicationPathResourceTest().hello(), response.readEntity(String.class));
+ public abstract class ApplicationPathTemplateTest extends JerseyContainerTest {
+ public ApplicationPathTemplateTest(TestContainerFactory testContainerFactory) {
+ super(testContainerFactory);
}
- try (Response response = target("").path("resource").request().get()) {
- Assert.assertEquals(404, response.getStatus());
+ @Override
+ protected Application configure() {
+ return new ApplicationPathTestApplication();
+ }
+
+
+ @Test
+ public void testApplicationPath() {
+ try (Response response = target("applicationpath").path("resource").request().get()) {
+ assertEquals(200, response.getStatus());
+ assertEquals(new ApplicationPathResourceTest().hello(), response.readEntity(String.class));
+ }
+
+ try (Response response = target("").path("resource").request().get()) {
+ assertEquals(404, response.getStatus());
+ }
}
}
-
}
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 9b91773..ae22360 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, 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,16 +23,24 @@
import jakarta.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 @@
private final String context;
- @SuppressWarnings("UnusedDeclaration")
public EscapedUriResource() {
this("");
}
@@ -69,18 +76,35 @@
}
}
- @Override
- protected Application configure() {
- return new ResourceConfig(EscapedUriResource.class, NonEscapedUriResource.class);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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 {
- @Test
- public void testNonEscaped() {
- assertThat(target("non/x y").request().get(String.class), is(RESPONSE));
+ public EscapedUriTesmplateTest(TestContainerFactory testContainerFactory) {
+ super(testContainerFactory);
+ }
+
+ @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 0cbf05c..e0ba263 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, 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,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 b18b952..e282d39 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, 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
@@ -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 jakarta.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 @@
}
}
- @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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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);
+ }
- @Test
- public void testPost() {
- final Response response = target().request()
- .header(HttpHeaders.ACCEPT_ENCODING, "gzip")
- .post(Entity.text("POST"));
+ @Override
+ protected Application configure() {
+ return new ResourceConfig(Resource.class, EncodingFilter.class, GZipEncoder.class);
+ }
- assertThat(response.readEntity(String.class), is("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"));
+ }
}
}
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 0e14b3d..08f4bfd 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, 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
@@ -18,9 +18,11 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -30,35 +32,32 @@
import jakarta.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<TestContainerFactory> FACTORIES = listContainerFactories(
+ private static final List<TestContainerFactory> FACTORIES = Arrays.asList(
new GrizzlyTestContainerFactory(),
new InMemoryTestContainerFactory(),
new SimpleTestContainerFactory(),
- new JettyTestContainerFactory()
- );
+ new JettyTestContainerFactory());
- @Parameterized.Parameters(name = "{0}")
- public static Collection<TestContainerFactory[]> parameters() throws Exception {
- return FACTORIES.stream().map(input -> new TestContainerFactory[]{input}).collect(Collectors.toList());
+ public static Stream<TestContainerFactory> parameters() throws Exception {
+ return FACTORIES.stream();
}
@Path("/")
@@ -88,18 +87,21 @@
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 5f8fde8..d0893ea 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, 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,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 @@
}
@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 63679c2..f67d538 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, 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
@@ -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 3c1bd96..7f9bd49 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, 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
@@ -16,10 +16,9 @@
package org.glassfish.jersey.tests.e2e.container;
-import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
-import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.test.JerseyTest;
@@ -29,15 +28,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<TestContainerFactory> FACTORIES = listContainerFactories(
@@ -49,18 +44,12 @@
new NettyTestContainerFactory()
);
- @Parameterized.Parameters(name = "{0}")
- public static Collection<TestContainerFactory[]> parameters() throws Exception {
- return FACTORIES.stream().map(input -> new TestContainerFactory[]{input}).collect(Collectors.toList());
+ public static Stream<TestContainerFactory> parameters() {
+ return FACTORIES.stream();
}
-
- @Parameterized.Parameter(0)
- public TestContainerFactory factory;
-
- @Override
- protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
- return factory;
+ public JerseyContainerTest(TestContainerFactory testContainerFactory) {
+ super(testContainerFactory);
}
protected static List<TestContainerFactory> listContainerFactories(TestContainerFactory...factories) {
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 81843b4..d2a1aed 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, 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
@@ -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 19ce489..b8aaaa6 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
@@ -17,6 +17,8 @@
package org.glassfish.jersey.tests.e2e.container;
import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
import jakarta.ws.rs.Encoded;
import jakarta.ws.rs.GET;
@@ -30,12 +32,15 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
-
import org.glassfish.jersey.test.jetty.JettyTestContainerFactory;
-import org.junit.Test;
-import static org.junit.Assert.assertNotEquals;
+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 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.
@@ -45,20 +50,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 {
@@ -102,63 +97,87 @@
}
}
- @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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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() {
- if (JettyTestContainerFactory.class.isInstance(factory)) {
- return; // since Jetty 11.0.5
- }
- Response result = call("///test");
- assertEquals("-", result.readEntity(String.class));
- }
-
- @Test
- public void testSlashesWithBeginningEmptyPathParamWithQueryParams() {
- if (JettyTestContainerFactory.class.isInstance(factory)) {
- return; // since Jetty 11.0.5
+ public LeadingSlashesTemplateTest(TestContainerFactory testContainerFactory) {
+ super(testContainerFactory);
}
- 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));
- }
-
- @Test
- public void testEncodedQueryParams() {
- if (JettyTestContainerFactory.class.isInstance(factory)) {
- return; // Jetty 11.0.5
+ resourceConfig.property(ServerProperties.REDUCE_CONTEXT_PATH_SLASHES_ENABLED, true);
+ return resourceConfig;
}
- 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));
+ @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));
+ }
+
+ @Test
+ public void testSlashesWithBeginningEmpty() {
+ Response result = call("/test");
+ assertEquals(CONTAINER_RESPONSE, result.readEntity(String.class));
+ }
+
+ @Test
+ public void testSlashesWithBeginningEmptyPathParam() {
+ if (JettyTestContainerFactory.class.isInstance(getTestContainerFactory())) {
+ return; // since Jetty 11.0.5
+ }
+ Response result = call("///test");
+ assertEquals("-", result.readEntity(String.class));
+ }
+
+ @Test
+ public void testSlashesWithBeginningEmptyPathParamWithQueryParams() {
+ if (JettyTestContainerFactory.class.isInstance(getTestContainerFactory())) {
+ return; // since Jetty 11.0.5
+ }
+ 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() {
+ if (JettyTestContainerFactory.class.isInstance(getTestContainerFactory())) {
+ return; // since Jetty 11.0.5
+ }
+ 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();
+ }
}
-
-
- 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 b74e5a4..18336a2 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, 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
@@ -22,15 +22,22 @@
import jakarta.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 @@
}
}
- @Override
- protected Application configure() {
- return new ResourceConfig(Resource.class);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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 bdae2a1..7f613f9 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, 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
@@ -22,15 +22,22 @@
import jakarta.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 @@
}
}
- @Override
- protected Application configure() {
- return new ResourceConfig(Resource.class);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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/ResourceConfigApplicationPathTest.java b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResourceConfigApplicationPathTest.java
index 9ad95a7..3c0d510 100644
--- a/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResourceConfigApplicationPathTest.java
+++ b/tests/e2e/src/test/java/org/glassfish/jersey/tests/e2e/container/ResourceConfigApplicationPathTest.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,8 +19,13 @@
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.test.spi.TestContainerFactory;
-public class ResourceConfigApplicationPathTest extends ApplicationPathTest {
+public class ResourceConfigApplicationPathTest extends JerseyContainerTest {
+ public ResourceConfigApplicationPathTest(TestContainerFactory testContainerFactory) {
+ super(testContainerFactory);
+ }
+
@Override
protected Application configure() {
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 a6b0907..c4d166a 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@@ -34,11 +36,15 @@
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.Test;
+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 +52,7 @@
/**
* @author Michal Gajdos
*/
-public class ResponseWriterMetadataTest extends JerseyContainerTest {
+public class ResponseWriterMetadataTest {
public static class ValueHolder {
@@ -101,23 +107,42 @@
}
}
- @Override
- protected Application configure() {
- return new ResourceConfig(Resource.class, ValueHolderWriter.class)
- .property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 1);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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);
+ }
- assertThat(response.readEntity(String.class), is("one"));
- assertThat(response.getHeaderString("X-BEFORE-WRITE"), is("foo"));
+ @Override
+ protected Application configure() {
+ return new ResourceConfig(Resource.class, ValueHolderWriter.class)
+ .property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 1);
+ }
- if (factory instanceof InMemoryTestContainerFactory) {
- assertThat(response.getHeaderString("X-AFTER-WRITE"), is("bar"));
- } else {
- assertThat(response.getHeaderString("X-AFTER-WRITE"), nullValue());
+ @Test
+ @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"));
+
+ 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 1a981bc..6fa9ba1 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, 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
@@ -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 jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
@@ -32,20 +36,22 @@
import jakarta.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 @@
}
}
- @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 testPost() throws InterruptedException, ExecutionException {
- final CountDownLatch controlLatch = new CountDownLatch(1);
- final Invocation invocation = target().request().buildPost(Entity.text(CHECK_STRING));
- final Future<Response> resp = invocation.submit(new InvocationCallback<Response>() {
- @Override
- public void completed(Response response) {
- controlLatch.countDown();
- }
-
- @Override
- public void failed(Throwable throwable) {
- controlLatch.countDown();
-
- }
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> tests = new ArrayList<>();
+ JerseyContainerTest.parameters().forEach(testContainerFactory -> {
+ ResponseWriterOutputStreamTemplateTest test = new ResponseWriterOutputStreamTemplateTest(testContainerFactory) {};
+ tests.add(TestHelper.toTestContainer(test, testContainerFactory.getClass().getSimpleName()));
});
- controlLatch.await();
- final String response = resp.get().readEntity(String.class);
- assertThat(response, is(CHECK_STRING));
+ return tests;
}
- @Test
- public void testAll() throws InterruptedException, ExecutionException {
- testGet();
- testPost();
+ public abstract static class ResponseWriterOutputStreamTemplateTest extends JerseyContainerTest {
+
+ 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 testPost() throws InterruptedException, ExecutionException {
+ final CountDownLatch controlLatch = new CountDownLatch(1);
+ final Invocation invocation = target().request().buildPost(Entity.text(CHECK_STRING));
+ final Future<Response> resp = invocation.submit(new InvocationCallback<Response>() {
+ @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 1626b2c..2ba8ba3 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, 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
@@ -22,15 +22,22 @@
import jakarta.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 @@
}
}
- @Override
- protected Application configure() {
- return new ResourceConfig(Resource.class);
+ @TestFactory
+ public Collection<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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 a203858..8028cb9 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, 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
@@ -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 26138fc..f99fea4 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, 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
@@ -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 0021cdb..f81e219 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, 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
@@ -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 7caff6d..47e973c 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, 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,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 0a32f1b..1c37e76 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, 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
@@ -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 1c66fda..22594db 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, 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
@@ -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 dfaa771..70ee14d 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 jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
@@ -41,13 +41,13 @@
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);
}
@@ -68,13 +68,14 @@
@Test
public void testOptionsNoWadl() {
// Make sure the test does not have JAX-B on a classpath
- Assert.assertFalse(ServiceFinder.find("jakarta.xml.bind.JAXBContext").iterator().hasNext());
+ Assertions.assertFalse(ServiceFinder.find("jakarta.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.assertTrue(readableStream.toString().contains(LocalizationMessages.WADL_FEATURE_DISABLED()));
+ Assertions.assertTrue(
+ 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 832db1e..c27dfd3 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 @@
@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 72e7945..72e48a4 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, 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.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 31000df..98e5af9 100644
--- a/tests/integration/asm/pom.xml
+++ b/tests/integration/asm/pom.xml
@@ -43,8 +43,8 @@
<artifactId>jersey-server</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 74570b7..92fc8b0 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 @@
.println(" not implemented by AnnotationAcceptingListener.AnnotatedClassVisitor");
}
}
- Assert.assertThat(containsAllMethods, Matchers.is(true));
+ MatcherAssert.assertThat(containsAllMethods, Matchers.is(true));
}
@Test
@@ -100,10 +101,8 @@
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 @@
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 @@
}
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 df3a0e7..e0ff357 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, 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
@@ -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 @@
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 6a2430c..7bd2d55 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, 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
@@ -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 @@
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 @@
// [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 @@
// [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 bcda6a2..0a1141c 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, 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,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 eb8d095..2b04f74 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, 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
@@ -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 @@
Client client;
WebTarget cdiTarget, hk2Target;
- @Before
+ @BeforeEach
public void before() throws IOException {
if (isDefaultTestContainerFactorySet && Hk2InjectionManagerFactory.isImmediateStrategy()) {
initializeWeld();
@@ -78,12 +77,12 @@
}
}
- @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 @@
@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 d2fa52a..dfb2340 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, 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,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 @@
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 @@
}
}
+ @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 f7aa170..1998e9a 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, 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
@@ -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 6d513ff..f25ee90 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 jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
@@ -65,7 +68,7 @@
@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 1548a91..fb9e615 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, 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
@@ -18,9 +18,9 @@
import jakarta.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 @@
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 @@
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 5db044f..f687f16 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, 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
@@ -18,9 +18,9 @@
import jakarta.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 dfbfff5..1320121 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, 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
@@ -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 8c4d62e..202f052 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, 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
@@ -25,9 +25,9 @@
import jakarta.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 4c5bb7b..e2de3ea 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, 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
@@ -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 jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
@@ -84,7 +87,7 @@
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 ed9759f..29e4d77 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, 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
@@ -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 jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
weld.shutdown();
@@ -63,7 +66,7 @@
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 dd9c11b..9d0039f 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, 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
@@ -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 jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
weld.shutdown();
@@ -63,7 +66,7 @@
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 634fcf6..7e677bc 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, 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
@@ -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 f42b813..2068931 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, 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
@@ -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 @@
_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 21dce34..983debe 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, 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
@@ -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 jakarta.ws.rs.client.Entity;
import jakarta.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<Object[]> 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<String> testData() {
+ return Stream.of("No matter what", "You should never", "ever", "just give up");
}
@Override
@@ -84,8 +69,9 @@
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 5f0772c..1f846f3 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 jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;
@@ -37,11 +38,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()) {
@@ -51,6 +53,7 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
@@ -79,7 +82,7 @@
@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/pom.xml b/tests/integration/cdi-integration/cdi-singleton/pom.xml
index ad33e45..853ef02 100644
--- a/tests/integration/cdi-integration/cdi-singleton/pom.xml
+++ b/tests/integration/cdi-integration/cdi-singleton/pom.xml
@@ -67,10 +67,6 @@
<artifactId>jersey-weld2-se</artifactId>
<exclusions>
<exclusion>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- </exclusion>
- <exclusion>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
</exclusion>
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 5fe5070..8e39986 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 jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
weld.shutdown();
@@ -62,11 +65,11 @@
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 12193c1..8fdd9be 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 jakarta.enterprise.inject.Vetoed;
import jakarta.enterprise.inject.spi.BeanManager;
@@ -30,11 +32,12 @@
import jakarta.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 @@
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 485d49e..d4523ad 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, 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
@@ -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 @@
Weld weld;
+ @BeforeEach
@Override
public void setUp() throws Exception {
weld = new Weld();
@@ -46,6 +49,7 @@
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 7e46592..fe0edde 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 jakarta.ws.rs.client.WebTarget;
import jakarta.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 524f335..392d639 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, 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
@@ -18,10 +18,10 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.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 @@
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 c772ad3..b00475c 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, 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
@@ -19,11 +19,11 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.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 6c33cd3..3d577f4 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, 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
@@ -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 @@
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 @@
}
}
- @After
+ @AfterEach
public void after() {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
if (isDefaultTestContainerFactorySet) {
@@ -94,7 +93,7 @@
@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 6fb1456..6865a66 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, 2020 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 jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"alpha"},
- {"AAA"},
- {"$%^"},
- {"a b"}
- });
+ public static Stream<String> 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 @@
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 @@
List<Object> 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 70c1568..4954859 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, 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
@@ -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 jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"alpha"},
- {"AAA"},
- {"$%^"},
- {"a b"}
- });
+ public static Stream<String> 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 4b2dc3b..ed9dc7e 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, 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
@@ -18,9 +18,9 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.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 030f721..04570fb 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, 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
@@ -19,9 +19,9 @@
import jakarta.inject.Qualifier;
import jakarta.ws.rs.client.Entity;
import jakarta.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 ff44b6f..4f57650 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, 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
@@ -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 jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"alpha", "ahpla"},
- {"gogol", "logog"},
- {"elcaro", "oracle"}
- });
+ public static Stream<Arguments> 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 3bcc9b3..7d33b41 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, 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
@@ -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 @@
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 d8d6e78..045d742 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, 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
@@ -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 jakarta.ws.rs.client.Entity;
import jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"alpha", "beta"},
- {"1", "2"}
- });
+ public static Stream<Arguments> 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 @@
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 @@
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 79e8657..19a7033 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, 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
@@ -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 jakarta.ws.rs.client.Entity;
import jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"alpha", "beta"},
- {"1", "2"}
- });
+ public static Stream<Arguments> 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 @@
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 @@
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 b8655a6..ba2d1fd 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<Object[]> 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<Arguments> 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 c1bd844..fa7dcb2 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, 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,10 @@
import java.util.logging.Logger;
import jakarta.ws.rs.client.WebTarget;
import jakarta.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 @@
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 9cd84c4..48b3204 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, 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
@@ -18,51 +18,35 @@
import java.util.Arrays;
import java.util.List;
+import java.util.stream.Stream;
import jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> 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<String> 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 @@
* 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 9248f05..2c027f6 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, 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
@@ -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 jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> 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<String> 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 524aed0..a4e063f 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, 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
@@ -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 jakarta.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<Object[]> 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<String> testData() {
+ return Stream.of("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected");
}
/**
@@ -61,8 +41,9 @@
*
* @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 93370c5..5c90a3d 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<Object[]> 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<Arguments> 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 f238790..426ed9d 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, 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
@@ -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 d28af64..11a1e9f 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, 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
@@ -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 jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"app-field-injected"},
- {"app-ctor-injected"},
- {"request-field-injected"},
- {"request-ctor-injected"},
- });
+ public static List<String> 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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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;
- /**
- * 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"));
+ 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(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 70d81f9..a5c23fb 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, 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
@@ -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 jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"app-field-injected"},
- {"app-ctor-injected"},
- {"request-field-injected"},
- {"request-ctor-injected"}
- });
+ public static Collection<String> 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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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 524aed0..7de2ba6 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, 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
@@ -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 jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"app-field-injected"},
- {"app-ctor-injected"},
- {"request-field-injected"},
- {"request-ctor-injected"}
- });
+ public static Collection<String> 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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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 93370c5..d8f18df 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<Object[]> 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<String[]> 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<DynamicContainer> generateTests() {
+ Collection<DynamicContainer> 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;
- @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)));
+ 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)));
+ }
}
}
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 9ce26f9..51dd698 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, 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
@@ -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 jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> 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<String> 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 36a2ba8..556f343 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, 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
@@ -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 jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> 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<String> 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 b3b3697..6271fa3 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, 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
@@ -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 jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"app-field-injected"},
- {"app-ctor-injected"},
- {"request-field-injected"},
- {"request-ctor-injected"}
- });
+ public static Stream<String> testData() {
+ return Stream.of("app-field-injected", "app-ctor-injected", "request-field-injected", "request-ctor-injected");
}
final String resource;
@@ -61,8 +52,9 @@
*
* @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 930eb37..1ac7e2a 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<Object[]> 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<Arguments> 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 60c7a1c..2b25463 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 jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
@@ -80,7 +83,7 @@
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 @@
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 5fc2af1..c1339f5 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 jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
@@ -81,7 +84,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 bc7eef7..9c2f15d 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 jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
@@ -80,7 +83,7 @@
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 @@
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 660335f..85ebed0 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 jakarta.ws.rs.core.Application;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
@@ -80,7 +83,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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/ServletTest.java b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ServletTest.java
index 73e8e72..d847ac1 100644
--- a/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ServletTest.java
+++ b/tests/integration/cdi-integration/context-inject-on-server/src/test/java/org/glassfish/jersey/tests/cdi/inject/ServletTest.java
@@ -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 jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;
@@ -36,12 +37,13 @@
public class ServletTest extends JerseyTest {
private Weld weld;
- @Before
+ @BeforeEach
public void setup() {
- Assume.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy());
+ Assumptions.assumeTrue(Hk2InjectionManagerFactory.isImmediateStrategy());
}
@Override
+ @BeforeEach
public void setUp() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
weld = new Weld();
@@ -51,6 +53,7 @@
}
@Override
+ @AfterEach
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
weld.shutdown();
@@ -81,7 +84,7 @@
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
System.out.println(response.readEntity(String.class));
}
- Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ Assertions.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
}
}
@@ -92,7 +95,7 @@
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
System.out.println(response.readEntity(String.class));
}
- Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ Assertions.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
}
}
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 b4cadfc..6fc8952 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 jakarta.ws.rs.client.Entity;
import jakarta.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 @@
}
}
+ @AfterEach
@Override
public void tearDown() throws Exception {
if (Hk2InjectionManagerFactory.isImmediateStrategy()) {
@@ -112,19 +115,19 @@
});
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 7228461..b140f4a 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 @@
<glassfish.home>${project.build.directory}/glassfish6</glassfish.home>
<modules.dir>${glassfish.home}/glassfish/modules</modules.dir>
<glassfish.container.version>${gf.impl.version}</glassfish.container.version>
- <junit.jupiter.version>${junit5.version}</junit.jupiter.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
- <version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
@@ -73,7 +71,7 @@
<dependency>
<groupId>org.jboss.arquillian.junit5</groupId>
<artifactId>arquillian-junit5-container</artifactId>
- <version>1.7.0.Alpha10</version>
+ <version>1.7.0.Alpha12</version>
<scope>test</scope>
</dependency>
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 a380a5b..71ccc04 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, 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
@@ -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 47abf80..04b2299 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, 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,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 771f816..2de0066 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, 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
@@ -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 c235759..8eab7cb 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, 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
@@ -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 18710f3..3bac844 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, 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
@@ -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 91ff812..e8edf8b 100644
--- a/tests/integration/externalproperties/pom.xml
+++ b/tests/integration/externalproperties/pom.xml
@@ -33,8 +33,8 @@
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 7e79571..cdca445 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
@@ -25,9 +25,9 @@
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.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@@ -57,7 +57,7 @@
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);
@@ -81,7 +81,7 @@
Response response = target("resource").request().get();
- Assert.assertEquals(407, response.getStatus());
+ Assertions.assertEquals(407, response.getStatus());
}
@Test
@@ -90,9 +90,9 @@
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 f812f12..dc5f276 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, 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
@@ -22,12 +22,11 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-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
@@ -36,12 +35,12 @@
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 50811f9..f7f7c68 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, 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,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 fa724d5..fac1637 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, 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,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 99d842e..6090f3a 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, 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
@@ -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 b4f44cf..873915f 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, 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
@@ -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 jakarta.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 cb0fc11..7e5fa30 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, 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
@@ -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 6ea3471..a198102 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 f99fbdf..b5f5644 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, 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
@@ -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 d26be8c..f6697c1 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, 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
@@ -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 ee701d6..48ea38d 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, 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
@@ -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 @@
@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 88022d3..5f25ab9 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, 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
@@ -26,10 +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.Ignore;
-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;
@@ -38,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 0a9a007..ded21d7 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, 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
@@ -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 d61cd31..a524196 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, 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
@@ -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 3c474ae..1f058d9 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, 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
@@ -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 @@
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 7e4f384..fd7ba8f 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, 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
@@ -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 71620ad..479b743 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, 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
@@ -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 @@
// 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 2929612..5a1a631 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, 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
@@ -26,9 +26,9 @@
import jakarta.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;
/**
@@ -51,7 +51,7 @@
}
/**
- * Test all {@jakarta.transaction.Transactional}
+ * Test all {@javax.transaction.Transactional}
* annotated CDI beans. The test scenario is as follows.
* Set two accounts via the CDI bean that avoids rollback.
* Should any rollback happen there, we would not be able
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 a67071a..7f4abf0 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, 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
@@ -26,9 +26,9 @@
import jakarta.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 85b9c71..460779b 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, 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
@@ -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 a1c21b1..cd7d2c6 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, 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
@@ -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 7075bf2..6012155 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, 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
@@ -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 @@
// 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 e661322..8c23d5b 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, 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
@@ -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 @@
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 @@
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 0e31b3d..bd5fd1f 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, 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
@@ -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 7763394..5c88a45 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, 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
@@ -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 78d24d3..ab1e434 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, 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
@@ -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 bde18f9..0eb8599 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, 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
@@ -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 57272ef..f557c88 100644
--- a/tests/integration/jersey-2421/pom.xml
+++ b/tests/integration/jersey-2421/pom.xml
@@ -43,8 +43,14 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
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 e4ea1d7..bae7758 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, 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
@@ -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 @@
/**
* 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 f509fea..b50f8a5 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, 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,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 4caa766..32b37d6 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, 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,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 75de572..d215f29 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, 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
@@ -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 ac5bf4b..48d884e 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, 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
@@ -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 jakarta.ws.rs.client.Entity;
import jakarta.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 jakarta.ws.rs.FormParam}.
*/
-@RunWith(Parameterized.class)
public class Jersey2637EnabledITCase extends JerseyTest {
- @Parameterized.Parameters(name = "path = {0}")
- public static Collection<Object[]> paths() {
- return Arrays.asList(new Object[][]{{"defaut"}, {"enabled"}});
+ public static Stream<String> paths() {
+ return Stream.of("defaut", "enabled");
}
- @Parameterized.Parameter
- public String path;
-
@Override
protected Application configure() {
return new Jersey2637();
@@ -59,8 +52,9 @@
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 @@
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 @@
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 @@
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 @@
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 cc74267..a6ae409 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, 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
@@ -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 564e01d..d1aa7fb 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, 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
@@ -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 f91c907..e0fb780 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, 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
@@ -33,9 +33,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 8606449..7ab7186 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, 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
@@ -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 @@
*/
@Test
public void testCorrectInjection() throws IOException {
- Assert.assertEquals(200, test(HappyService.class));
+ Assertions.assertEquals(200, test(HappyService.class));
}
/**
@@ -93,6 +93,6 @@
*/
@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 67124de..b432102 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, 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
@@ -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 366a24e..80eca2d 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, 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
@@ -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 f51190c..4286aef 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, 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
@@ -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 9fb4467..3f9e10f 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, 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
@@ -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 c85716f..89ce16d 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, 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.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 @@
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 @@
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 @@
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 ed7425b..76fbd4b 100644
--- a/tests/integration/jersey-3662/pom.xml
+++ b/tests/integration/jersey-3662/pom.xml
@@ -40,8 +40,8 @@
<version>${project.version}</version>
<exclusions>
<exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
</exclusion>
</exclusions>
</dependency>
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 a4253e8..b2198a8 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, 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
@@ -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 jakarta.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 1094968..7a63311 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, 2020 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 jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.MediaType;
@@ -48,14 +48,14 @@
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 afa5d08..a20d5d0 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 jakarta.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 @@
Weld weld;
+ @BeforeEach
@Override
public void setUp() throws Exception {
weld = new Weld();
@@ -45,6 +48,7 @@
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 4fdde3a..0d32a08 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, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 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
@@ -19,8 +19,8 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.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 059e450..394995c 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
@@ -21,9 +21,9 @@
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;
@@ -54,7 +54,7 @@
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 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 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 putEntityAndGenericTypeTypeFailure() {
try {
client.target(DUMMY_URL).request().put(bodyEntity, new GenericType<String>(){});
- 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 @@
try {
Future<Response> 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 @@
try {
Future<String> 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 @@
try {
Future<String> future = client.target(DUMMY_URL).request().async().put(bodyEntity, new GenericType<String>(){});
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 @@
client.target(DUMMY_URL).request().async().put(bodyEntity, new InvocationCallback<Response>() {
@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 @@
}
});
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 @@
try {
CompletionStage<Response> 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 @@
.put(bodyEntity, new InvocationCallback<Response>() {
@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 @@
}
});
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 3d9ca2e..25e1899 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 @@
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 0fbec13..c3f2993 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, 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
@@ -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 jakarta.inject.Singleton;
import jakarta.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 401ee75..f3f78e7 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 jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Application;
@@ -99,8 +100,8 @@
}
});
- 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 @@
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 @@
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 9dd9797..eb61641 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 @@
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 @@
}
}
+ @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 15eef57..2cd56a2 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 @@
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 35d413b..fef3ef5 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 jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.HttpHeaders;
@@ -52,7 +52,7 @@
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 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 740f952..fad2de5 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 @@
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 32cd5ac..fa9761a 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, 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
@@ -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 @@
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/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 64c225b..79dcd7e 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, 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
@@ -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 jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.MediaType;
@@ -44,6 +44,6 @@
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/config/webapp/pom.xml b/tests/integration/microprofile/config/webapp/pom.xml
index ef82e1e..a71696a 100644
--- a/tests/integration/microprofile/config/webapp/pom.xml
+++ b/tests/integration/microprofile/config/webapp/pom.xml
@@ -33,6 +33,12 @@
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.bundles</groupId>
diff --git a/tests/integration/microprofile/rest-client-tck/pom.xml b/tests/integration/microprofile/rest-client-tck/pom.xml
index 9e477b8..947348b 100644
--- a/tests/integration/microprofile/rest-client-tck/pom.xml
+++ b/tests/integration/microprofile/rest-client-tck/pom.xml
@@ -60,12 +60,6 @@
<artifactId>smallrye-config</artifactId>
<version>${smallrye.config.version}</version>
<scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.rest.client</groupId>
@@ -180,6 +174,11 @@
<artifactId>jersey-weld2-se</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
+ </dependency>
</dependencies>
<profiles>
@@ -242,7 +241,7 @@
<properties>
<surefire.security.argline>-Djava.security.manager -Djava.security.policy=${project.build.directory}/test-classes/server.policy</surefire.security.argline>
- <jetty.version>9.4.27.v20200227</jetty.version>
+ <jetty.version>${jetty9.version}</jetty.version>
</properties>
diff --git a/tests/integration/microprofile/rest-client/pom.xml b/tests/integration/microprofile/rest-client/pom.xml
index 20e6087..469e2d7 100644
--- a/tests/integration/microprofile/rest-client/pom.xml
+++ b/tests/integration/microprofile/rest-client/pom.xml
@@ -51,12 +51,6 @@
<artifactId>smallrye-config</artifactId>
<version>${smallrye.config.version}</version>
<scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
diff --git a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/ConnectorTest.java b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/ConnectorTest.java
index 26de896..ddacaa0 100644
--- a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/ConnectorTest.java
+++ b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/ConnectorTest.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
@@ -29,9 +29,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-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/ConsumesAndProducesTest.java b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/ConsumesAndProducesTest.java
index 5f998b5..bdd024b 100644
--- a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/ConsumesAndProducesTest.java
+++ b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/ConsumesAndProducesTest.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
@@ -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.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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Created by David Kral.
@@ -98,7 +99,7 @@
.baseUri(new URI("http://localhost:9998"))
.build(ApplicationResource.class);
- assertEquals(app.regex("bar"), "bar");
+ assertEquals("bar", app.regex("bar"));
}
@Test
@@ -110,13 +111,15 @@
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/test/microprofile/restclient/InboundHeadersProviderTest.java b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/InboundHeadersProviderTest.java
index 5d5c7f2..082e949 100644
--- a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/InboundHeadersProviderTest.java
+++ b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/InboundHeadersProviderTest.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
@@ -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 @@
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/test/microprofile/restclient/RestClientModelTest.java b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/RestClientModelTest.java
index ab54993..24c0308 100644
--- a/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/RestClientModelTest.java
+++ b/tests/integration/microprofile/rest-client/src/test/java/org/glassfish/jersey/test/microprofile/restclient/RestClientModelTest.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
@@ -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/property-check/pom.xml b/tests/integration/property-check/pom.xml
index 1d1ca19..d4ee4ad 100644
--- a/tests/integration/property-check/pom.xml
+++ b/tests/integration/property-check/pom.xml
@@ -58,9 +58,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.1</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 f943686..2a07280 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 @@
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 9eba3fa..6b5eb3d 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 b6031de..7e1d7f1 100644
--- a/tests/integration/reactive-streams/sse/pom.xml
+++ b/tests/integration/reactive-streams/sse/pom.xml
@@ -40,8 +40,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
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 ef2ce16..948a210 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 jakarta.ws.rs.core.MediaType;
import jakarta.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 ab35cbe..c676b03 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, 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
@@ -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 @@
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 @@
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 @@
.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 @@
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 @@
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 @@
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 @@
.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 85acbf3..9f8a6b9 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, 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
@@ -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 1acce03..a8cd5bd 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, 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
@@ -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 ad56ab1..a3eed41 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, 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,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 ddf5bc1..a695d9a 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, 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
@@ -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 f53a5c7..c44f34a 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, 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
@@ -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 @@
@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 @@
@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 a5b6281..586118a 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, 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
@@ -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 b87c539..3a63913 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 1efb844..ea791df 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 510faa0..c0bf8aa 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, 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
@@ -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 @@
@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 a8d2c8c..3d8e2b7 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 c40a8cf..ba4570b 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 418e5fa..9b50ba7 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 1f3b9b6..c38b08d 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, 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
@@ -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 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 @@
}
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 5ff37a5..f390bf8 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, 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,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 @@
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 97be49f..37cc2fd 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, 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
@@ -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 void assertHtmlResponse(String response) {
- assertNotNull("No text returned!", response);
+ assertNotNull(response, "No text returned!");
assertResponseContains(response, "<html>");
assertResponseContains(response, "</html>");
}
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 dcf7b96..b1b8433 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, 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,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 @@
}
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 6491c37..0960e47 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, 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,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 @@
}
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 b7a8aee..17faca8 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, 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,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 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 645690a..3db77e3 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 jakarta.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,6 +52,7 @@
}
@Test
+ @Disabled("Jetty 9 is ignoring the charset")
public void testResourceAsHtmlIso88592() throws Exception {
final Response response = item1resource().path("iso").request().get();
response.bufferEntity();
@@ -59,13 +60,13 @@
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"));
}
@@ -75,8 +76,8 @@
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 776cf1e..f6643eb 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, 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
@@ -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 void assertHtmlResponse(final String response) {
- assertNotNull("No text returned!", response);
+ assertNotNull(response, "No text returned!");
assertResponseContains(response, "<html>");
assertResponseContains(response, "</html>");
}
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 bc57a0e..cf9931f 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 @@
}
@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 87b1e65..ccf1ac3 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, 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.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 @@
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 @@
assertEquals(MAX_MESSAGES, getResponses.size());
for (Map.Entry<Integer, ResponseRecord> 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 @@
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 @@
assertEquals(MAX_MESSAGES, postResponses.size());
for (Map.Entry<Integer, String> 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<Integer> 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 a5adda3..0a77d0c 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, 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
@@ -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 jakarta.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 db8b1d9..8c7926e 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, 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
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 3df288f..ab2be8c 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, 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,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 9d58272..78eac87 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, 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
@@ -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 jakarta.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 44edc76..929d4d3 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, 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
@@ -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 jakarta.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 05d55a5..1bc5a3a 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, 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,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 @@
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 @@
assertEquals(MAX_MESSAGES, getResponses.size());
for (final Map.Entry<Integer, ResponseRecord> 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 @@
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 @@
assertEquals(MAX_MESSAGES, postResponses.size());
for (final Map.Entry<Integer, String> 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<Integer> 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 443530c..477785e 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, 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
@@ -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 f1a5759..d7d70bf 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, 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
@@ -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 @@
@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 66bbfaa..df6b76a 100644
--- a/tests/integration/servlet-3-init-2/pom.xml
+++ b/tests/integration/servlet-3-init-2/pom.xml
@@ -41,8 +41,9 @@
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <scope>compile</scope>
</dependency>
<dependency>
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 190eb17..9bfeeef 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, 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
@@ -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 1db7596..030ce75 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, 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
@@ -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 74d97c6..e2d2d23 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, 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
@@ -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 0eaa27d..d5a6e54 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 979d450..79afcc1 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, 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
@@ -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 4955e48..d85bb33 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 8bf54a4..cb0e4b6 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, 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
@@ -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 jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> 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<Arguments> 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 @@
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 dc1c987..5638aad 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, 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
@@ -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 jakarta.ws.rs.client.WebTarget;
import jakarta.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<Object[]> 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<Arguments> 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 @@
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 de329a1..c36f22a 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 8bc960d..1d522b5 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, 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
@@ -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 jakarta.ws.rs.NotFoundException;
@@ -51,15 +51,15 @@
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 b5efef9..7c1f150 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, 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
@@ -18,8 +18,8 @@
import jakarta.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 @@
@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 @@
}
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 bcb4419..6164e6a 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, 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
@@ -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 jakarta.ws.rs.client.WebTarget;
@@ -37,7 +37,7 @@
@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 b736798..c5da8e9 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, 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
@@ -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 jakarta.ws.rs.core.Response;
@@ -37,7 +37,7 @@
@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 ab50349..9a423ce 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 @@
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 ec22022..e86e4de 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, 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
@@ -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 a255d86..1d59cae 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, 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
@@ -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 @@
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 @@
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<Integer> 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 @@
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 @@
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 @@
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 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 45256ef..0144064 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 jakarta.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 c3579a8..27271a1 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 void assertHtmlResponse(final String response) {
- assertNotNull("No text returned!", response);
+ assertNotNull(response, "No text returned!");
assertResponseContains(response, "<html>");
assertResponseContains(response, "</html>");
}
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 9756521..d81deb5 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 29cda9d..f21144f 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 01f49d2..44b42aa 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, 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
@@ -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 26db4aa..0e61272 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, 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
@@ -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 @@
.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 2e3f85b..2d26ae8 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, 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
@@ -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 @@
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 9ab8e71..cd4d5ff 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, 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
@@ -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 64c8e64..c11db43 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, 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
@@ -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 9fac671..3cddbb3 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, 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
@@ -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 db67e95..94289f2 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 eee9463..c204c86 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, 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.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 df68c192..f2b2931 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, 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
@@ -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 c6e4d34..a089b99 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, 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
@@ -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 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/spring6/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java
index a17f3ee..d785c78 100644
--- a/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java
+++ b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceITCase.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java
index 301e155..e71b58e 100644
--- a/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java
+++ b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/AccountResourceTestBase.java
@@ -22,10 +22,10 @@
import jakarta.ws.rs.client.WebTarget;
import jakarta.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/spring6/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java
index 241f450..1064726 100644
--- a/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java
+++ b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/JerseyManagedITCase.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java
index f2847ff..2dfb755 100644
--- a/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java
+++ b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedControllerITCase.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java
index 5a316ec..3fce661 100644
--- a/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java
+++ b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedEndpointITCase.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java
index 8046675..1d05f52 100644
--- a/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java
+++ b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedITCase.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java
index 0fa4a22..a745e7d 100644
--- a/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java
+++ b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedRepositoryITCase.java
@@ -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/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java
index 36a602c..9b03b5b 100644
--- a/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java
+++ b/tests/integration/spring6/src/test/java/org/glassfish/jersey/server/spring/test/SpringManagedServiceITCase.java
@@ -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 79b4301..6dbf62d 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, 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
@@ -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 jakarta.ws.rs.client.Entity;
import jakarta.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<Object[]> testData() {
- return Arrays.asList(new Object[][] {
- {"/root"},
- {"/async"},
- });
+ public static Stream<String> testData() {
+ return Stream.of("/root", "/async");
}
//
@@ -88,16 +75,18 @@
// 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
}
}
}
- 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 d097bef..922b23a 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, 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
@@ -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 b23e24e..75afd57 100644
--- a/tests/jmockit/pom.xml
+++ b/tests/jmockit/pom.xml
@@ -54,11 +54,13 @@
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
+ <version>1.44</version> <!-- do not upgrade for Junit 4 -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -86,6 +88,13 @@
</argLine>
<skipTests>${skip.tests}</skipTests>
</configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
</plugins>
</build>
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 0de72ac..a2665e0 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, 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
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 046ee3d..d6305f9 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, 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
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 b90d72d..24c685e 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, 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
@@ -145,7 +145,7 @@
new Verifications() {{
stream.close();
- minTimes = 3;
+ times = 3;
}};
}
diff --git a/tests/mem-leaks/test-cases/bean-param-leak/src/main/webapp/WEB-INF/weblogic.xml b/tests/mem-leaks/test-cases/bean-param-leak/src/main/webapp/WEB-INF/weblogic.xml
index 9db2915..c43daf4 100644
--- a/tests/mem-leaks/test-cases/bean-param-leak/src/main/webapp/WEB-INF/weblogic.xml
+++ b/tests/mem-leaks/test-cases/bean-param-leak/src/main/webapp/WEB-INF/weblogic.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- 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
@@ -42,7 +42,7 @@
</wls:prefer-application-packages>
<wls:prefer-application-resources>
- <wls:resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</wls:resource-name>
+ <wls:resource-name>META-INF/services/jakarta.servlet.ServletContainerInitializer</wls:resource-name>
<wls:resource-name>META-INF/services/jakarta.ws.rs.ext.RuntimeDelegate</wls:resource-name>
<!-- jersey -->
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 c698396..87b87c3 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, 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
@@ -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 @@
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 9ba72ce..37fc649 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, 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
@@ -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 @@
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 c965fd4..1618b5b 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, 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,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 @@
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 852d868..d87b230 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, 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
@@ -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 @@
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 1b99666..d5d4740 100644
--- a/tests/osgi/functional/pom.xml
+++ b/tests/osgi/functional/pom.xml
@@ -80,6 +80,13 @@
</goals>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit47</artifactId>
+ <version>${surefire.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
<!-- use pax exam maven plugin -->
<plugin>
@@ -363,6 +370,12 @@
<artifactId>jakarta.xml.bind-api</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit4.version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- logging -->
<dependency>
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 8df2eb3..55f4c91 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, 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
@@ -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/pom.xml b/tests/performance/benchmarks/pom.xml
index de3d43d..565c998 100644
--- a/tests/performance/benchmarks/pom.xml
+++ b/tests/performance/benchmarks/pom.xml
@@ -41,6 +41,12 @@
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>jakarta.activation-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
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 0daad9c..a4136ed 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, 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,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 cb21882..099bf1f 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, 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,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 7a1fa59..440135a 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, 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,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 ea43dc2..d964ed6 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, 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,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 669253f..b1c3f99 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, 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,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 d9bcbf9..cfeb650 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, 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,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 439c3f7..2ca0b5a 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, 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,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 8de5bea..bdfa1d2 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, 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,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 f6da870..7beca21 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, 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
@@ -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 6ba0c45..62384a7 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, 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
@@ -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 038f8e1..ce8983d 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, 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
@@ -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 97d22be..7e02949 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, 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
@@ -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 06bbb91..d0f0a71 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, 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,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 625417b..9ffcd1c 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, 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,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 355cbb3..261cbd1 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, 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
@@ -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 0a54762..c4076c2 100644
--- a/tests/performance/test-cases/monitoring/pom.xml
+++ b/tests/performance/test-cases/monitoring/pom.xml
@@ -41,9 +41,9 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.1</version>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <version>5.9.1</version>
<scope>test</scope>
</dependency>
diff --git a/tests/performance/test-cases/param-srl/src/test/java/org/glassfish/jersey/tests/performance/param/srl/SrlSrmTest.java b/tests/performance/test-cases/param-srl/src/test/java/org/glassfish/jersey/tests/performance/param/srl/SrlSrmTest.java
index 2f22348..ec692f0 100644
--- a/tests/performance/test-cases/param-srl/src/test/java/org/glassfish/jersey/tests/performance/param/srl/SrlSrmTest.java
+++ b/tests/performance/test-cases/param-srl/src/test/java/org/glassfish/jersey/tests/performance/param/srl/SrlSrmTest.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
@@ -20,8 +20,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 for SRL/SRM resource.
diff --git a/tests/performance/test-cases/proxy-injection/src/test/java/org/glassfish/jersey/tests/performance/proxy/injection/InjectedResourcesTest.java b/tests/performance/test-cases/proxy-injection/src/test/java/org/glassfish/jersey/tests/performance/proxy/injection/InjectedResourcesTest.java
index 9ba20eb..949c561 100644
--- a/tests/performance/test-cases/proxy-injection/src/test/java/org/glassfish/jersey/tests/performance/proxy/injection/InjectedResourcesTest.java
+++ b/tests/performance/test-cases/proxy-injection/src/test/java/org/glassfish/jersey/tests/performance/proxy/injection/InjectedResourcesTest.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
@@ -20,8 +20,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 for field/method injected resource.
diff --git a/tests/stress/src/test/java/org/glassfish/jersey/server/internal/monitoring/MultiThreadingAggregatedReservoirTest.java b/tests/stress/src/test/java/org/glassfish/jersey/server/internal/monitoring/MultiThreadingAggregatedReservoirTest.java
index eed30f7..56df223 100644
--- a/tests/stress/src/test/java/org/glassfish/jersey/server/internal/monitoring/MultiThreadingAggregatedReservoirTest.java
+++ b/tests/stress/src/test/java/org/glassfish/jersey/server/internal/monitoring/MultiThreadingAggregatedReservoirTest.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
@@ -31,10 +31,10 @@
import org.glassfish.jersey.server.internal.monitoring.core.TimeReservoir;
import org.glassfish.jersey.server.internal.monitoring.core.UniformTimeSnapshot;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+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;
/**
* Multi Threading concurrency test of Jersey monitoring internals.
@@ -148,10 +148,10 @@
doShutdown = true;
producerExecutorService.shutdown();
consumerExecutorService.shutdown();
- Assert.assertTrue("Consumer tasks didn't terminated peacefully, aborting this test.",
- consumerExecutorService.awaitTermination(SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS));
- Assert.assertTrue("Producer tasks didn't terminated peacefully, aborting this test.",
- producerExecutorService.awaitTermination(SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS));
+ Assertions.assertTrue(consumerExecutorService.awaitTermination(SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS),
+ "Consumer tasks didn't terminated peacefully, aborting this test.");
+ Assertions.assertTrue(producerExecutorService.awaitTermination(SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS),
+ "Producer tasks didn't terminated peacefully, aborting this test.");
final long snapshotTime = System.nanoTime();
final long sum = (long) incrementer.get() * (incrementer.get() + 1) / 2;
@@ -173,7 +173,7 @@
/**
* Shutdown the producer executor service.
*/
- @After
+ @AfterEach
public void shutdownProducers() {
producerExecutorService.shutdownNow();
}
@@ -181,7 +181,7 @@
/**
* Shutdown the consumer executor service.
*/
- @After
+ @AfterEach
public void shutdownConsumers() {
consumerExecutorService.shutdownNow();
}
@@ -205,10 +205,10 @@
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/tools/jersey-release-notes-maven-plugin/pom.xml b/tools/jersey-release-notes-maven-plugin/pom.xml
index a9c74ec..3ede899 100644
--- a/tools/jersey-release-notes-maven-plugin/pom.xml
+++ b/tools/jersey-release-notes-maven-plugin/pom.xml
@@ -85,7 +85,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.12</version>
+ <version>4.13.2</version>
<scope>test</scope>
</dependency>