JUnit tests actualized: 4 -> 5
diff --git a/media/jaxb/pom.xml b/media/jaxb/pom.xml
index 61fae82..b2d691d 100644
--- a/media/jaxb/pom.xml
+++ b/media/jaxb/pom.xml
@@ -144,8 +144,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>
</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 bc28e3a..74148fe 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 d906232..38793d8 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 5a79737..67e6e55 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 899e682..b83373c 100644
--- a/media/json-binding/pom.xml
+++ b/media/json-binding/pom.xml
@@ -113,8 +113,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 1a8cf00..b373b2e 100644
--- a/media/json-binding/src/test/java/org/glassfish/jersey/jsonb/internal/JsonBindingProviderTest.java
+++ b/media/json-binding/src/test/java/org/glassfish/jersey/jsonb/internal/JsonBindingProviderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Markus KARG
+ * Copyright (c) 2020, 2022 Markus KARG
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -38,7 +38,8 @@
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Providers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Unit Test for {@link JsonBindingProvider}.
@@ -47,18 +48,20 @@
*/
public final class JsonBindingProviderTest {
- @Test(expected = NoContentException.class)
+ @Test
public final void shouldThrowNoContentException() throws IOException {
- // given
- final Providers providers = new EmptyProviders();
- final MessageBodyReader<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 157e84f..374f13d 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 c7884d6..db765f2 100644
--- a/media/json-gson/src/test/java/org/glassfish/jersey/gson/internal/JsonGsonProviderTest.java
+++ b/media/json-gson/src/test/java/org/glassfish/jersey/gson/internal/JsonGsonProviderTest.java
@@ -32,16 +32,19 @@
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Providers;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class JsonGsonProviderTest {
- @Test(expected = NoContentException.class)
+ @Test
public void shouldThrowNoContentException() throws IOException {
- Providers providers = new EmptyProviders();
- MessageBodyReader<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 d99b900..d51aa86 100644
--- a/media/json-jackson/pom.xml
+++ b/media/json-jackson/pom.xml
@@ -135,8 +135,8 @@
</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/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 281d4c4..388ca2a 100644
--- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProviderTest.java
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProviderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -19,11 +19,11 @@
import org.glassfish.jersey.jackson.internal.model.ServiceTest;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.ws.rs.core.Application;
-import static junit.framework.TestCase.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public final class DefaultJacksonJaxbJsonProviderTest extends JerseyTest {
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java
index d8d43c0..9d86b84 100644
--- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForBothModulesTest.java
@@ -19,11 +19,11 @@
import org.glassfish.jersey.jackson.internal.model.ServiceTest;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.ws.rs.core.Application;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class DefaultJsonJacksonProviderForBothModulesTest extends JerseyTest {
@Override
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java
index 3a1bbe6..8d8075c 100644
--- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForDisabledModulesTest.java
@@ -23,7 +23,7 @@
import org.glassfish.jersey.jackson.internal.model.ServiceTest;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
@@ -31,8 +31,8 @@
import javax.ws.rs.core.Configuration;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class DefaultJsonJacksonProviderForDisabledModulesTest extends JerseyTest {
@Override
diff --git a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java
index 76b7dd9..77092f6 100644
--- a/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java
+++ b/media/json-jackson/src/test/java/org/glassfish/jersey/jackson/internal/DefaultJsonJacksonProviderForEnabledModulesTest.java
@@ -19,11 +19,11 @@
import org.glassfish.jersey.jackson.internal.model.ServiceTest;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import javax.ws.rs.core.Application;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class DefaultJsonJacksonProviderForEnabledModulesTest extends JerseyTest {
@Override
diff --git a/media/json-jackson1/pom.xml b/media/json-jackson1/pom.xml
index ada3eae..571a162 100644
--- a/media/json-jackson1/pom.xml
+++ b/media/json-jackson1/pom.xml
@@ -86,8 +86,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-jettison/pom.xml b/media/json-jettison/pom.xml
index 2436a5e..c475ffd 100644
--- a/media/json-jettison/pom.xml
+++ b/media/json-jettison/pom.xml
@@ -83,8 +83,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 f98abe3..3e62429 100644
--- a/media/json-processing/pom.xml
+++ b/media/json-processing/pom.xml
@@ -86,8 +86,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 ffcde89..e309e5a 100644
--- a/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableClientTest.java
+++ b/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableClientTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -29,8 +29,8 @@
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Michal Gajdos
diff --git a/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableServerTest.java b/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableServerTest.java
index 58da0e1..5806b6b 100644
--- a/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableServerTest.java
+++ b/media/json-processing/src/test/java/org/glassfish/jersey/jsonp/JsonProcessingAutoDiscoverableServerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -35,8 +35,8 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Michal Gajdos
diff --git a/media/moxy/pom.xml b/media/moxy/pom.xml
index 64ee029..9f6599e 100644
--- a/media/moxy/pom.xml
+++ b/media/moxy/pom.xml
@@ -120,8 +120,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 9d6113c..d101439 100644
--- a/media/multipart/pom.xml
+++ b/media/multipart/pom.xml
@@ -100,8 +100,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 509d297..f5e721a 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/BodyPartTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/BodyPartTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,13 +22,13 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for {@link BodyPart}.
@@ -40,12 +40,12 @@
*/
public class BodyPartTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
bodyPart = new BodyPart();
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
bodyPart = null;
}
diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataBodyPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataBodyPartTest.java
index 40932f9..79a222c 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataBodyPartTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataBodyPartTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,14 +18,14 @@
import javax.ws.rs.core.MediaType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test case for {@link FormDataBodyPart}.
@@ -38,14 +38,14 @@
public class FormDataBodyPartTest extends BodyPartTest {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
bodyPart = new FormDataBodyPart();
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
bodyPart = null;
super.tearDown();
diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataMultiPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/FormDataMultiPartTest.java
index 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 7b5d3a9..41b759c 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartMediaTypesTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartMediaTypesTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,9 +18,9 @@
import javax.ws.rs.core.MediaType;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for {@link MultiPartMediaTypes}.
diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartTest.java
index 91cf08d..fbfa600 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultiPartTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,11 +18,11 @@
import javax.ws.rs.core.MediaType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test case for {@link MultiPart}.
@@ -34,12 +34,12 @@
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 5867494..30748b8 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultipartMixedWithApacheClientTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/MultipartMixedWithApacheClientTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -35,8 +35,8 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
*
diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/ParameterizedHeadersMapTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/ParameterizedHeadersMapTest.java
index 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 9d55e7d..3721193 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/FileDataBodyPartTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/FileDataBodyPartTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,12 +22,12 @@
import org.glassfish.jersey.media.multipart.BodyPartTest;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case for {@link FileDataBodyPart}.
@@ -39,14 +39,14 @@
public class FileDataBodyPartTest extends BodyPartTest {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
super.setUp();
bodyPart = new FileDataBodyPart();
}
@Override
- @After
+ @AfterEach
public void tearDown() throws Exception {
bodyPart = null;
super.tearDown();
diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/StreamDataBodyPartTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/StreamDataBodyPartTest.java
index 7da702b..2b0d72b 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/StreamDataBodyPartTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/file/StreamDataBodyPartTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,13 +24,13 @@
import org.glassfish.jersey.media.multipart.BodyPartTest;
import org.glassfish.jersey.media.multipart.ContentDisposition;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests for the {@link StreamDataBodyPart} class which checks the class' main
@@ -50,7 +50,7 @@
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 2eb6b14..7222690 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartBufferTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartBufferTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -37,10 +37,10 @@
import org.glassfish.jersey.server.ContainerRequest;
import org.glassfish.jersey.server.ResourceConfig;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test cases for inspecting an {@code FormDataMultiPart} entity in a {@code RequestFilter} and following injection of this
diff --git a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartReaderWriterTest.java b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartReaderWriterTest.java
index 693007e..9dcddf1 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartReaderWriterTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/FormDataMultiPartReaderWriterTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -57,17 +57,15 @@
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.glassfish.jersey.media.multipart.MultiPart;
-import org.junit.Test;
-import org.jvnet.mimepull.MIMEMessage;
-import org.jvnet.mimepull.MIMEParsingException;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Tests for multipart {@code MessageBodyReader} and {@code MessageBodyWriter} as well as {@code FormDataMultiPart} and {@code
@@ -754,7 +752,7 @@
}
private void 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 e8cb04a..c37065b 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartHeaderModificationTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartHeaderModificationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,7 +16,9 @@
package org.glassfish.jersey.media.multipart.internal;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -37,16 +39,17 @@
import org.glassfish.jersey.jetty.connector.JettyConnectorProvider;
import org.glassfish.jersey.media.multipart.MultiPart;
import org.glassfish.jersey.test.TestProperties;
+import org.glassfish.jersey.test.spi.TestHelper;
+import org.junit.jupiter.api.DynamicContainer;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestFactory;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* JERSEY-2123 reproducer.
@@ -55,81 +58,88 @@
*
* @author Libor Kramolis
*/
-@RunWith(Parameterized.class)
-public class MultiPartHeaderModificationTest extends MultiPartJerseyTest {
+public class MultiPartHeaderModificationTest {
- private final ConnectorProvider connectorProvider;
- private final boolean messageLogged;
-
- public MultiPartHeaderModificationTest(Class<? 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 32b02f3..a718780 100644
--- a/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartReaderWriterTest.java
+++ b/media/multipart/src/test/java/org/glassfish/jersey/media/multipart/internal/MultiPartReaderWriterTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -34,11 +34,12 @@
import org.glassfish.jersey.media.multipart.BodyPartEntity;
import org.glassfish.jersey.media.multipart.MultiPart;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Unit tests for {@link org.glassfish.jersey.media.multipart.internal.MultiPartReaderClientSide} (in the client) and
@@ -49,7 +50,7 @@
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 ce434af..57f6b62 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 996d32e..ebd0792 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/ClientCloseTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/ClientCloseTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -33,10 +33,10 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.TestCase.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Petr Janouch
diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/EmptyEventsTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/EmptyEventsTest.java
index c405777..2c99079 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/EmptyEventsTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/EmptyEventsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -33,8 +33,8 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests handling of empty SSE events.
diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/EventSourceTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/EventSourceTest.java
index 842ae17..d544746 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/EventSourceTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/EventSourceTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -34,10 +34,10 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.TestCase.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Pavel Bucek
diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/InboundEventReaderTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/InboundEventReaderTest.java
index ae522ae..bc9f057 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/InboundEventReaderTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/InboundEventReaderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -37,9 +37,9 @@
import org.glassfish.jersey.model.internal.CommonConfig;
import org.glassfish.jersey.model.internal.ComponentBag;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author Petr Bouda
@@ -56,7 +56,7 @@
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 c5af425..001d123 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/OutboundEventTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/OutboundEventTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -24,11 +24,11 @@
import org.glassfish.jersey.internal.util.ReflectionHelper;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Basic set of unit tests for OutboundEvent creation.
diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkCloseTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkCloseTest.java
index f6afa45..5706eb5 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkCloseTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkCloseTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -39,9 +39,9 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test, that {@code SseEventSink} and the connection is closed eventually after closing {@code SseEventSource} on client side.
@@ -99,9 +99,9 @@
}
// ... 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 b6059ff..7721105 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/SseEventSinkTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -34,8 +34,8 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
-import org.junit.Test;
-import static org.junit.Assert.assertTrue;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* @author Pavel Bucek
diff --git a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseyEventSinkTest.java b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseyEventSinkTest.java
index 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 0e5c635..5fdeac2 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseBroadcasterTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseBroadcasterTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -23,10 +23,8 @@
import javax.ws.rs.sse.OutboundSseEvent;
import javax.ws.rs.sse.SseEventSink;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
* {@link javax.ws.rs.sse.SseBroadcaster} test.
@@ -35,27 +33,26 @@
*/
public class JerseySseBroadcasterTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
private static final String TEST_EXCEPTION_MSG = "testException";
@Test
public void testOnErrorNull() {
- try (JerseySseBroadcaster broadcaster = new JerseySseBroadcaster()) {
+ Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ try (JerseySseBroadcaster broadcaster = new JerseySseBroadcaster()) {
- thrown.expect(IllegalArgumentException.class);
- broadcaster.onError(null);
- }
+ broadcaster.onError(null);
+ }
+ });
}
@Test
public void testOnCloseNull() {
- try (JerseySseBroadcaster jerseySseBroadcaster = new JerseySseBroadcaster()) {
+ Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ try (JerseySseBroadcaster jerseySseBroadcaster = new JerseySseBroadcaster()) {
- thrown.expect(IllegalArgumentException.class);
- jerseySseBroadcaster.onClose(null);
- }
+ jerseySseBroadcaster.onClose(null);
+ }
+ });
}
@Test
@@ -89,7 +86,7 @@
});
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 238ba82..5509d7e 100644
--- a/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseEventSourceTest.java
+++ b/media/sse/src/test/java/org/glassfish/jersey/media/sse/internal/JerseySseEventSourceTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,20 +16,15 @@
package org.glassfish.jersey.media.sse.internal;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import javax.ws.rs.sse.SseEventSource;
public class JerseySseEventSourceTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void testNPEOnNull() {
- thrown.expect(NullPointerException.class);
- SseEventSource.target(null);
+ Assertions.assertThrows(NullPointerException.class, () -> SseEventSource.target(null));
}
}