JUnit tests actualized: 4 -> 5
diff --git a/core-common/pom.xml b/core-common/pom.xml
index 223109f..2f61b3b 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>
@@ -206,8 +229,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 0f025f1..33b9fb3 100644
--- a/core-common/src/test/java/org/glassfish/jersey/internal/TestRuntimeDelegate.java
+++ b/core-common/src/test/java/org/glassfish/jersey/internal/TestRuntimeDelegate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -27,7 +27,7 @@
import org.glassfish.jersey.message.internal.MessagingBinders;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
/**
* Test runtime delegate.
@@ -48,31 +48,31 @@
public 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 cccd36c..57b95d0 100644
--- a/core-common/src/test/java/org/glassfish/jersey/internal/config/DisabledProvidersTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/internal/config/DisabledProvidersTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,8 +21,8 @@
import org.glassfish.jersey.message.internal.MessagingBinders;
import org.glassfish.jersey.message.internal.RenderedImageProvider;
import org.glassfish.jersey.message.internal.SourceProvider;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import javax.ws.rs.RuntimeType;
import java.util.HashMap;
@@ -55,11 +55,11 @@
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 dc15766..2c80b35 100644
--- a/core-common/src/test/java/org/glassfish/jersey/internal/inject/ProvidersTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/internal/inject/ProvidersTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -28,8 +28,8 @@
import org.glassfish.jersey.spi.Contract;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests {@link Providers}.
diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/routing/CombinedMediaTypeTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/routing/CombinedMediaTypeTest.java
index f4414f5..c0c3112 100644
--- a/core-common/src/test/java/org/glassfish/jersey/internal/routing/CombinedMediaTypeTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/internal/routing/CombinedMediaTypeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,10 +24,10 @@
import javax.ws.rs.core.MediaType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* Combined media type tests.
diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/sonar/SonarJerseyCommonTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/sonar/SonarJerseyCommonTest.java
index 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 659f904..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, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -27,11 +27,11 @@
import org.glassfish.jersey.internal.jsr166.Flow;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test Jersey {@link Flow.Publisher} implementation, {@link JerseyPublisher}.
diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/OsgiRegistryTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/OsgiRegistryTest.java
index 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 1b319a8..68f6aac 100644
--- a/core-common/src/test/java/org/glassfish/jersey/internal/util/PropertiesHelperTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/internal/util/PropertiesHelperTest.java
@@ -21,9 +21,9 @@
import javax.ws.rs.RuntimeType;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* @author Miroslav Fuksa
diff --git a/core-common/src/test/java/org/glassfish/jersey/internal/util/ReflectionHelperTest.java b/core-common/src/test/java/org/glassfish/jersey/internal/util/ReflectionHelperTest.java
index 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 35459f9..e1886d4 100644
--- a/core-common/src/test/java/org/glassfish/jersey/logging/HasEntityTimeoutTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/logging/HasEntityTimeoutTest.java
@@ -24,7 +24,7 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.UriInfo;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
diff --git a/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java b/core-common/src/test/java/org/glassfish/jersey/logging/LoggingInterceptorTest.java
index 9034406..abd4d54 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 3d14861..dfeabe6 100644
--- a/core-common/src/test/java/org/glassfish/jersey/message/DeflateEncodingTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/message/DeflateEncodingTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -35,7 +35,7 @@
import javax.inject.Provider;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/**
* @author Martin Matula
diff --git a/core-common/src/test/java/org/glassfish/jersey/message/GZipEncodingTest.java b/core-common/src/test/java/org/glassfish/jersey/message/GZipEncodingTest.java
index 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 efbfa84..695fd4f 100644
--- a/core-common/src/test/java/org/glassfish/jersey/message/internal/FormMultivaluedMapProviderTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/FormMultivaluedMapProviderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -27,10 +27,10 @@
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* {@link FormProvider} unit tests
diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/FormProviderTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/FormProviderTest.java
index 79c5675..5dcc075 100644
--- a/core-common/src/test/java/org/glassfish/jersey/message/internal/FormProviderTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/FormProviderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -27,10 +27,10 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* {@link FormProvider} unit tests
diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/LanguageTagTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/LanguageTagTest.java
index 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 c6ff32c..5cc89dd 100644
--- a/core-common/src/test/java/org/glassfish/jersey/message/internal/MessageBodyFactoryTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/MessageBodyFactoryTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -27,10 +27,10 @@
import org.glassfish.jersey.message.WriterModel;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
import static org.glassfish.jersey.message.internal.MessageBodyFactory.WORKER_BY_TYPE_COMPARATOR;
@@ -46,9 +46,9 @@
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 ba7e6bd..d43c4f6 100644
--- a/core-common/src/test/java/org/glassfish/jersey/message/internal/ResponseTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/ResponseTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,10 +21,10 @@
import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.Response.StatusType;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
*
diff --git a/core-common/src/test/java/org/glassfish/jersey/message/internal/StringBuilderUtilsTest.java b/core-common/src/test/java/org/glassfish/jersey/message/internal/StringBuilderUtilsTest.java
index 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 06032e9..7fb708c 100644
--- a/core-common/src/test/java/org/glassfish/jersey/message/internal/VariantListBuilderTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/message/internal/VariantListBuilderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,9 +22,9 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Variant;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* TODO: javadoc.
diff --git a/core-common/src/test/java/org/glassfish/jersey/process/internal/RankedComparatorTest.java b/core-common/src/test/java/org/glassfish/jersey/process/internal/RankedComparatorTest.java
index 53cf7b6..78df231 100644
--- a/core-common/src/test/java/org/glassfish/jersey/process/internal/RankedComparatorTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/process/internal/RankedComparatorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -25,8 +25,8 @@
import org.glassfish.jersey.model.internal.RankedComparator;
import org.glassfish.jersey.model.internal.RankedProvider;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests {@link org.glassfish.jersey.model.internal.RankedComparator}.
diff --git a/core-common/src/test/java/org/glassfish/jersey/uri/PathPatternTest.java b/core-common/src/test/java/org/glassfish/jersey/uri/PathPatternTest.java
index 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 8e26e49..a98f8ae 100644
--- a/core-common/src/test/java/org/glassfish/jersey/uri/UriComponentTest.java
+++ b/core-common/src/test/java/org/glassfish/jersey/uri/UriComponentTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -21,9 +21,9 @@
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.PathSegment;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Unit test for {@link UriComponent} class.
diff --git a/core-common/src/test/java/org/glassfish/jersey/uri/UriTemplateTest.java b/core-common/src/test/java/org/glassfish/jersey/uri/UriTemplateTest.java
index 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";
+};