diff --git a/pom.xml b/pom.xml
index 68ff2df148..1be7655a76 100644
--- a/pom.xml
+++ b/pom.xml
@@ -297,13 +297,13 @@ com.fasterxml.jackson.core.*;version=${project.version}
- org.junit.vintage
- junit-vintage-engine
+ org.junit.jupiter
+ junit-jupiter
test
org.junit.jupiter
- junit-jupiter
+ junit-jupiter-api
test
diff --git a/src/test/java/com/fasterxml/jackson/core/BaseTest.java b/src/test/java/com/fasterxml/jackson/core/BaseTest.java
deleted file mode 100644
index 33204ffea6..0000000000
--- a/src/test/java/com/fasterxml/jackson/core/BaseTest.java
+++ /dev/null
@@ -1,538 +0,0 @@
-package com.fasterxml.jackson.core;
-
-import java.io.*;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-
-import com.fasterxml.jackson.core.io.IOContext;
-import com.fasterxml.jackson.core.testsupport.MockDataInput;
-import com.fasterxml.jackson.core.testsupport.TestSupport;
-import com.fasterxml.jackson.core.testsupport.ThrottledInputStream;
-import com.fasterxml.jackson.core.testsupport.ThrottledReader;
-
-import junit.framework.TestCase;
-
-/**
- * Base class for JUnit 4 based tests. To be deprecated from
- * Jackson 2.18 or later.
- */
-@SuppressWarnings("resource")
-public abstract class BaseTest
- extends TestCase
-{
- protected final static String FIELD_BASENAME = "f";
-
- protected final static int MODE_INPUT_STREAM = 0;
- protected final static int MODE_INPUT_STREAM_THROTTLED = 1;
- protected final static int MODE_READER = 2;
- protected final static int MODE_READER_THROTTLED = 3;
- protected final static int MODE_DATA_INPUT = 4;
-
- protected final static int[] ALL_MODES = new int[] {
- MODE_INPUT_STREAM,
- MODE_INPUT_STREAM_THROTTLED,
- MODE_READER,
- MODE_READER_THROTTLED,
- MODE_DATA_INPUT
- };
-
- protected final static int[] ALL_BINARY_MODES = new int[] {
- MODE_INPUT_STREAM,
- MODE_INPUT_STREAM_THROTTLED,
- MODE_DATA_INPUT
- };
-
- protected final static int[] ALL_TEXT_MODES = new int[] {
- MODE_READER,
- MODE_READER_THROTTLED
- };
-
- // DataInput not streaming
- protected final static int[] ALL_STREAMING_MODES = new int[] {
- MODE_INPUT_STREAM,
- MODE_INPUT_STREAM_THROTTLED,
- MODE_READER,
- MODE_READER_THROTTLED
- };
-
- /*
- /**********************************************************
- /* Some sample documents:
- /**********************************************************
- */
-
- protected final static int SAMPLE_SPEC_VALUE_WIDTH = 800;
- protected final static int SAMPLE_SPEC_VALUE_HEIGHT = 600;
- protected final static String SAMPLE_SPEC_VALUE_TITLE = "View from 15th Floor";
- protected final static String SAMPLE_SPEC_VALUE_TN_URL = "http://www.example.com/image/481989943";
- protected final static int SAMPLE_SPEC_VALUE_TN_HEIGHT = 125;
- protected final static String SAMPLE_SPEC_VALUE_TN_WIDTH = "100";
- protected final static int SAMPLE_SPEC_VALUE_TN_ID1 = 116;
- protected final static int SAMPLE_SPEC_VALUE_TN_ID2 = 943;
- protected final static int SAMPLE_SPEC_VALUE_TN_ID3 = 234;
- protected final static int SAMPLE_SPEC_VALUE_TN_ID4 = 38793;
-
- protected final static String SAMPLE_DOC_JSON_SPEC =
- "{\n"
- +" \"Image\" : {\n"
- +" \"Width\" : "+SAMPLE_SPEC_VALUE_WIDTH+",\n"
- +" \"Height\" : "+SAMPLE_SPEC_VALUE_HEIGHT+","
- +"\"Title\" : \""+SAMPLE_SPEC_VALUE_TITLE+"\",\n"
- +" \"Thumbnail\" : {\n"
- +" \"Url\" : \""+SAMPLE_SPEC_VALUE_TN_URL+"\",\n"
- +"\"Height\" : "+SAMPLE_SPEC_VALUE_TN_HEIGHT+",\n"
- +" \"Width\" : \""+SAMPLE_SPEC_VALUE_TN_WIDTH+"\"\n"
- +" },\n"
- +" \"IDs\" : ["+SAMPLE_SPEC_VALUE_TN_ID1+","+SAMPLE_SPEC_VALUE_TN_ID2+","+SAMPLE_SPEC_VALUE_TN_ID3+","+SAMPLE_SPEC_VALUE_TN_ID4+"]\n"
- +" }"
- +"}"
- ;
-
- /*
- /**********************************************************
- /* Helper classes (beans)
- /**********************************************************
- */
-
- /**
- * Sample class from Jackson tutorial ("JacksonInFiveMinutes")
- */
- protected static class FiveMinuteUser {
- public enum Gender { MALE, FEMALE };
-
- public static class Name
- {
- private String _first, _last;
-
- public Name() { }
- public Name(String f, String l) {
- _first = f;
- _last = l;
- }
-
- public String getFirst() { return _first; }
- public String getLast() { return _last; }
-
- public void setFirst(String s) { _first = s; }
- public void setLast(String s) { _last = s; }
-
- @Override
- public boolean equals(Object o)
- {
- if (o == this) return true;
- if (o == null || o.getClass() != getClass()) return false;
- Name other = (Name) o;
- return _first.equals(other._first) && _last.equals(other._last);
- }
- }
-
- private Gender _gender;
- private Name _name;
- private boolean _isVerified;
- private byte[] _userImage;
-
- public FiveMinuteUser() { }
-
- public FiveMinuteUser(String first, String last, boolean verified, Gender g, byte[] data)
- {
- _name = new Name(first, last);
- _isVerified = verified;
- _gender = g;
- _userImage = data;
- }
-
- public Name getName() { return _name; }
- public boolean isVerified() { return _isVerified; }
- public Gender getGender() { return _gender; }
- public byte[] getUserImage() { return _userImage; }
-
- public void setName(Name n) { _name = n; }
- public void setVerified(boolean b) { _isVerified = b; }
- public void setGender(Gender g) { _gender = g; }
- public void setUserImage(byte[] b) { _userImage = b; }
-
- @Override
- public boolean equals(Object o)
- {
- if (o == this) return true;
- if (o == null || o.getClass() != getClass()) return false;
- FiveMinuteUser other = (FiveMinuteUser) o;
- if (_isVerified != other._isVerified) return false;
- if (_gender != other._gender) return false;
- if (!_name.equals(other._name)) return false;
- byte[] otherImage = other._userImage;
- if (otherImage.length != _userImage.length) return false;
- for (int i = 0, len = _userImage.length; i < len; ++i) {
- if (_userImage[i] != otherImage[i]) {
- return false;
- }
- }
- return true;
- }
- }
-
- protected final static JsonFactory JSON_FACTORY = new JsonFactory();
-
- /*
- /**********************************************************
- /* Parser construction
- /**********************************************************
- */
-
- protected JsonParser createParser(int mode, String doc) throws IOException {
- return createParser(JSON_FACTORY, mode, doc);
- }
-
- protected JsonParser createParser(int mode, byte[] doc) throws IOException {
- return createParser(JSON_FACTORY, mode, doc);
- }
-
- protected JsonParser createParser(TokenStreamFactory f, int mode, String doc) throws IOException
- {
- switch (mode) {
- case MODE_INPUT_STREAM:
- return createParserUsingStream(f, doc, "UTF-8");
- case MODE_INPUT_STREAM_THROTTLED:
- return f.createParser(new ThrottledInputStream(utf8Bytes(doc), 1));
- case MODE_READER:
- return createParserUsingReader(f, doc);
- case MODE_READER_THROTTLED:
- return f.createParser(new ThrottledReader(doc, 1));
- case MODE_DATA_INPUT:
- return createParserForDataInput(f, new MockDataInput(doc));
- default:
- }
- throw new RuntimeException("internal error");
- }
-
- protected JsonParser createParser(TokenStreamFactory f, int mode, byte[] doc) throws IOException
- {
- switch (mode) {
- case MODE_INPUT_STREAM:
- return f.createParser(new ByteArrayInputStream(doc));
- case MODE_INPUT_STREAM_THROTTLED:
- return f.createParser(new ThrottledInputStream(doc, 1));
- case MODE_READER:
- return f.createParser(new StringReader(new String(doc, "UTF-8")));
- case MODE_READER_THROTTLED:
- return f.createParser(new ThrottledReader(new String(doc, "UTF-8"), 1));
- case MODE_DATA_INPUT:
- return createParserForDataInput(f, new MockDataInput(doc));
- default:
- }
- throw new RuntimeException("internal error");
- }
-
- protected JsonParser createParserUsingReader(String input) throws IOException
- {
- return createParserUsingReader(new JsonFactory(), input);
- }
-
- protected JsonParser createParserUsingReader(TokenStreamFactory f, String input)
- throws IOException
- {
- return f.createParser(new StringReader(input));
- }
-
- protected JsonParser createParserUsingStream(String input, String encoding)
- throws IOException
- {
- return createParserUsingStream(new JsonFactory(), input, encoding);
- }
-
- protected JsonParser createParserUsingStream(TokenStreamFactory f,
- String input, String encoding)
- throws IOException
- {
-
- /* 23-Apr-2008, tatus: UTF-32 is not supported by JDK, have to
- * use our own codec too (which is not optimal since there's
- * a chance both encoder and decoder might have bugs, but ones
- * that cancel each other out or such)
- */
- byte[] data;
- if (encoding.equalsIgnoreCase("UTF-32")) {
- data = encodeInUTF32BE(input);
- } else {
- data = input.getBytes(encoding);
- }
- InputStream is = new ByteArrayInputStream(data);
- return f.createParser(is);
- }
-
- protected JsonParser createParserForDataInput(TokenStreamFactory f,
- DataInput input)
- throws IOException
- {
- return f.createParser(input);
- }
-
- /*
- /**********************************************************
- /* Generator construction
- /**********************************************************
- */
-
- public static JsonGenerator createGenerator(OutputStream out) throws IOException {
- return createGenerator(JSON_FACTORY, out);
- }
-
- public static JsonGenerator createGenerator(TokenStreamFactory f, OutputStream out) throws IOException {
- return f.createGenerator(out);
- }
-
- public static JsonGenerator createGenerator(Writer w) throws IOException {
- return createGenerator(JSON_FACTORY, w);
- }
-
- public static JsonGenerator createGenerator(TokenStreamFactory f, Writer w) throws IOException {
- return f.createGenerator(w);
- }
-
- /*
- /**********************************************************************
- /* Helper type construction
- /**********************************************************************
- */
-
- protected static IOContext testIOContext() {
- return TestSupport.testIOContext();
- }
-
- /*
- /**********************************************************
- /* Helper read/write methods
- /**********************************************************
- */
-
- protected void writeJsonDoc(JsonFactory f, String doc, Writer w) throws IOException
- {
- writeJsonDoc(f, doc, f.createGenerator(w));
- }
-
- protected void writeJsonDoc(JsonFactory f, String doc, JsonGenerator g) throws IOException
- {
- JsonParser p = f.createParser(a2q(doc));
-
- while (p.nextToken() != null) {
- g.copyCurrentStructure(p);
- }
- p.close();
- g.close();
- }
-
- protected String readAndWrite(JsonFactory f, JsonParser p) throws IOException
- {
- StringWriter sw = new StringWriter(100);
- JsonGenerator g = f.createGenerator(sw);
- g.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT);
- try {
- while (p.nextToken() != null) {
- g.copyCurrentEvent(p);
- }
- } catch (IOException e) {
- g.flush();
- throw new AssertionError(
- "Unexpected problem during `readAndWrite`. Output so far: '" +
- sw + "'; problem: " + e.getMessage(),
- e);
- }
- p.close();
- g.close();
- return sw.toString();
- }
-
- /*
- /**********************************************************
- /* Additional assertion methods
- /**********************************************************
- */
-
- public static void assertToken(JsonToken expToken, JsonToken actToken)
- {
- if (actToken != expToken) {
- fail("Expected token "+expToken+", current token "+actToken);
- }
- }
-
- public static void assertToken(JsonToken expToken, JsonParser p)
- {
- assertToken(expToken, p.currentToken());
- }
-
- public static void assertType(Object ob, Class> expType)
- {
- if (ob == null) {
- fail("Expected an object of type "+expType.getName()+", got null");
- }
- Class> cls = ob.getClass();
- if (!expType.isAssignableFrom(cls)) {
- fail("Expected type "+expType.getName()+", got "+cls.getName());
- }
- }
-
- /**
- * @param e Exception to check
- * @param anyMatches Array of Strings of which AT LEAST ONE ("any") has to be included
- * in {@code e.getMessage()} -- using case-INSENSITIVE comparison
- */
- public static void verifyException(Throwable e, String... anyMatches)
- {
- String msg = e.getMessage();
- String lmsg = (msg == null) ? "" : msg.toLowerCase();
- for (String match : anyMatches) {
- String lmatch = match.toLowerCase();
- if (lmsg.indexOf(lmatch) >= 0) {
- return;
- }
- }
- fail("Expected an exception with one of substrings ("+Arrays.asList(anyMatches)+"): got one with message \""+msg+"\"");
- }
-
- /**
- * Method that gets textual contents of the current token using
- * available methods, and ensures results are consistent, before
- * returning them
- */
- public static String getAndVerifyText(JsonParser p) throws IOException
- {
- // Ok, let's verify other accessors
- int actLen = p.getTextLength();
- char[] ch = p.getTextCharacters();
- String str2 = new String(ch, p.getTextOffset(), actLen);
- String str = p.getText();
-
- if (str.length() != actLen) {
- fail("Internal problem (p.token == "+p.currentToken()+"): p.getText().length() ['"+str+"'] == "+str.length()+"; p.getTextLength() == "+actLen);
- }
- assertEquals("String access via getText(), getTextXxx() must be the same", str, str2);
-
- return str;
- }
-
- /*
- /**********************************************************
- /* And other helpers
- /**********************************************************
- */
-
- public static String q(String str) {
- return '"'+str+'"';
- }
-
- public static String a2q(String json) {
- return json.replace('\'', '"');
- }
-
- public static byte[] encodeInUTF32BE(String input)
- {
- int len = input.length();
- byte[] result = new byte[len * 4];
- int ptr = 0;
- for (int i = 0; i < len; ++i, ptr += 4) {
- char c = input.charAt(i);
- result[ptr] = result[ptr+1] = (byte) 0;
- result[ptr+2] = (byte) (c >> 8);
- result[ptr+3] = (byte) c;
- }
- return result;
- }
-
- public static byte[] utf8Bytes(String str) {
- return str.getBytes(StandardCharsets.UTF_8);
- }
-
- public static String utf8String(ByteArrayOutputStream bytes) {
- return new String(bytes.toByteArray(), StandardCharsets.UTF_8);
- }
-
- public static String fieldNameFor(int index)
- {
- StringBuilder sb = new StringBuilder(16);
- fieldNameFor(sb, index);
- return sb.toString();
- }
-
- private static void fieldNameFor(StringBuilder sb, int index)
- {
- /* let's do something like "f1.1" to exercise different
- * field names (important for byte-based codec)
- * Other name shuffling done mostly just for fun... :)
- */
- sb.append(FIELD_BASENAME);
- sb.append(index);
- if (index > 50) {
- sb.append('.');
- if (index > 200) {
- sb.append(index);
- if (index > 4000) { // and some even longer symbols...
- sb.append(".").append(index);
- }
- } else {
- sb.append(index >> 3); // divide by 8
- }
- }
- }
-
- // @since 2.9.7
- public static JsonFactory sharedStreamFactory() {
- return JSON_FACTORY;
- }
-
- // @since 2.9.7
- public static JsonFactory newStreamFactory() {
- return new JsonFactory();
- }
-
- // @since 2.9.8
- public static JsonFactoryBuilder streamFactoryBuilder() {
- return (JsonFactoryBuilder) JsonFactory.builder();
- }
-
- protected int[] calcQuads(String word) {
- return calcQuads(utf8Bytes(word));
- }
-
- protected int[] calcQuads(byte[] wordBytes) {
- int blen = wordBytes.length;
- int[] result = new int[(blen + 3) / 4];
- for (int i = 0; i < blen; ++i) {
- int x = wordBytes[i] & 0xFF;
-
- if (++i < blen) {
- x = (x << 8) | (wordBytes[i] & 0xFF);
- if (++i < blen) {
- x = (x << 8) | (wordBytes[i] & 0xFF);
- if (++i < blen) {
- x = (x << 8) | (wordBytes[i] & 0xFF);
- }
- }
- }
- result[i >> 2] = x;
- }
- return result;
- }
-
- public static byte[] readResource(String ref)
- {
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- final byte[] buf = new byte[4000];
-
- InputStream in = BaseTest.class.getResourceAsStream(ref);
- if (in != null) {
- try {
- int len;
- while ((len = in.read(buf)) > 0) {
- bytes.write(buf, 0, len);
- }
- in.close();
- } catch (IOException e) {
- throw new RuntimeException("Failed to read resource '"+ref+"': "+e);
- }
- }
- if (bytes.size() == 0) {
- throw new IllegalArgumentException("Failed to read resource '"+ref+"': empty resource?");
- }
- return bytes.toByteArray();
- }
-}
diff --git a/src/test/java/com/fasterxml/jackson/core/ComponentVersionsTest.java b/src/test/java/com/fasterxml/jackson/core/ComponentVersionsTest.java
index cab50d1dae..5636153800 100644
--- a/src/test/java/com/fasterxml/jackson/core/ComponentVersionsTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/ComponentVersionsTest.java
@@ -7,16 +7,15 @@
import com.fasterxml.jackson.core.testsupport.TestSupport;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests to verify functioning of {@link Version} class.
*/
-public class ComponentVersionsTest
- extends JUnit5TestBase
+class ComponentVersionsTest
+ extends JUnit5TestBase
{
@Test
- public void testCoreVersions() throws Exception
+ void coreVersions() throws Exception
{
final JsonFactory f = new JsonFactory();
assertVersion(f.version());
@@ -30,11 +29,11 @@ public void testCoreVersions() throws Exception
}
@Test
- public void testEquality() {
+ void equality() {
Version unk = Version.unknownVersion();
assertEquals("0.0.0", unk.toString());
assertEquals("//0.0.0", unk.toFullString());
- assertTrue(unk.equals(unk));
+ assertEquals(unk, unk);
Version other = new Version(2, 8, 4, "",
"groupId", "artifactId");
@@ -47,7 +46,7 @@ public void testEquality() {
}
@Test
- public void testMisc() {
+ void misc() {
Version unk = Version.unknownVersion();
int hash = unk.hashCode();
// Happens to be 0 at this point (Jackson 2.16)
diff --git a/src/test/java/com/fasterxml/jackson/core/ErrorReportConfigurationTest.java b/src/test/java/com/fasterxml/jackson/core/ErrorReportConfigurationTest.java
index bfa244c354..ec60e1ee5b 100644
--- a/src/test/java/com/fasterxml/jackson/core/ErrorReportConfigurationTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/ErrorReportConfigurationTest.java
@@ -14,8 +14,8 @@
*
* @since 2.16
*/
-public class ErrorReportConfigurationTest
- extends JUnit5TestBase
+class ErrorReportConfigurationTest
+ extends JUnit5TestBase
{
/*
/**********************************************************
@@ -30,7 +30,7 @@ public class ErrorReportConfigurationTest
private final ErrorReportConfiguration DEFAULTS = ErrorReportConfiguration.defaults();
@Test
- public void testNormalBuild()
+ void normalBuild()
{
ErrorReportConfiguration config = ErrorReportConfiguration.builder()
.maxErrorTokenLength(1004)
@@ -42,7 +42,7 @@ public void testNormalBuild()
}
@Test
- public void testZeroLengths()
+ void zeroLengths()
{
// boundary tests, because we throw error on negative values
ErrorReportConfiguration config = ErrorReportConfiguration.builder()
@@ -55,7 +55,7 @@ public void testZeroLengths()
}
@Test
- public void testInvalidMaxErrorTokenLength()
+ void invalidMaxErrorTokenLength()
{
ErrorReportConfiguration.Builder builder = ErrorReportConfiguration.builder();
try {
@@ -75,7 +75,7 @@ public void testInvalidMaxErrorTokenLength()
}
@Test
- public void testDefaults()
+ void defaults()
{
// default value
assertEquals(DEFAULT_ERROR_LENGTH, DEFAULTS.getMaxErrorTokenLength());
@@ -86,7 +86,7 @@ public void testDefaults()
}
@Test
- public void testOverrideDefaultErrorReportConfiguration()
+ void overrideDefaultErrorReportConfiguration()
{
// (1) override with null, will be no change
ErrorReportConfiguration.overrideDefaultErrorReportConfiguration(null);
@@ -117,7 +117,7 @@ public void testOverrideDefaultErrorReportConfiguration()
}
@Test
- public void testRebuild()
+ void rebuild()
{
ErrorReportConfiguration config = ErrorReportConfiguration.builder().build();
ErrorReportConfiguration rebuiltConfig = config.rebuild().build();
@@ -127,7 +127,7 @@ public void testRebuild()
}
@Test
- public void testBuilderConstructorWithErrorReportConfiguration()
+ void builderConstructorWithErrorReportConfiguration()
{
ErrorReportConfiguration configA = ErrorReportConfiguration.builder()
.maxErrorTokenLength(1234)
@@ -141,7 +141,7 @@ public void testBuilderConstructorWithErrorReportConfiguration()
}
@Test
- public void testWithJsonLocation() throws Exception
+ void withJsonLocation() throws Exception
{
// Truncated result
_verifyJsonLocationToString("abc", 2, "\"ab\"[truncated 1 chars]");
@@ -152,7 +152,7 @@ public void testWithJsonLocation() throws Exception
}
@Test
- public void testWithJsonFactory() throws Exception
+ void withJsonFactory() throws Exception
{
// default
_verifyJsonProcessingExceptionSourceLength(500,
@@ -175,7 +175,7 @@ public void testWithJsonFactory() throws Exception
}
@Test
- public void testExpectedTokenLengthWithConfigurations()
+ void expectedTokenLengthWithConfigurations()
throws Exception
{
// default
@@ -217,7 +217,7 @@ public void testExpectedTokenLengthWithConfigurations()
}
@Test
- public void testNonPositiveErrorTokenConfig()
+ void nonPositiveErrorTokenConfig()
{
// Zero should be ok
ErrorReportConfiguration.builder().maxErrorTokenLength(0).build();
@@ -234,7 +234,7 @@ public void testNonPositiveErrorTokenConfig()
}
@Test
- public void testNullSetterThrowsException() {
+ void nullSetterThrowsException() {
try {
newStreamFactory().setErrorReportConfiguration(null);
fail();
diff --git a/src/test/java/com/fasterxml/jackson/core/ExceptionsTest.java b/src/test/java/com/fasterxml/jackson/core/ExceptionsTest.java
index f538b36c02..5cd9d89d59 100644
--- a/src/test/java/com/fasterxml/jackson/core/ExceptionsTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/ExceptionsTest.java
@@ -9,14 +9,14 @@
import static org.junit.jupiter.api.Assertions.*;
-public class ExceptionsTest
- extends JUnit5TestBase
+class ExceptionsTest
+ extends JUnit5TestBase
{
private final JsonFactory JSON_F = newStreamFactory();
// For [core#10]
@Test
- public void testOriginalMesssage()
+ void originalMesssage()
{
JsonProcessingException exc = new JsonParseException(null, "Foobar", JsonLocation.NA);
String msg = exc.getMessage();
@@ -41,7 +41,7 @@ public void testOriginalMesssage()
// [core#198]
@Test
- public void testAccessToParser() throws Exception
+ void accessToParser() throws Exception
{
JsonParser p = JSON_F.createParser("{}");
assertToken(JsonToken.START_OBJECT, p.nextToken());
@@ -57,7 +57,7 @@ public void testAccessToParser() throws Exception
// [core#198]
@Test
- public void testAccessToGenerator() throws Exception
+ void accessToGenerator() throws Exception
{
StringWriter w = new StringWriter();
JsonGenerator g = JSON_F.createGenerator(w);
@@ -70,13 +70,13 @@ public void testAccessToGenerator() throws Exception
// [core#281]: new eof exception
@Test
- public void testEofExceptionsBytes() throws Exception {
+ void eofExceptionsBytes() throws Exception {
_testEofExceptions(MODE_INPUT_STREAM);
}
// [core#281]: new eof exception
@Test
- public void testEofExceptionsChars() throws Exception {
+ void eofExceptionsChars() throws Exception {
_testEofExceptions(MODE_READER);
}
@@ -132,7 +132,7 @@ private void _testEofExceptions(int mode) throws Exception
}
@Test
- public void testContentSnippetWithOffset() throws Exception
+ void contentSnippetWithOffset() throws Exception
{
final JsonFactory jsonF = streamFactoryBuilder()
.enable(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION)
diff --git a/src/test/java/com/fasterxml/jackson/core/JDKSerializabilityTest.java b/src/test/java/com/fasterxml/jackson/core/JDKSerializabilityTest.java
index 4fa10a5425..4da19ea005 100644
--- a/src/test/java/com/fasterxml/jackson/core/JDKSerializabilityTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/JDKSerializabilityTest.java
@@ -14,8 +14,8 @@
/**
* Unit tests for [core#31] (https://github.com/FasterXML/jackson-core/issues/31)
*/
-public class JDKSerializabilityTest
- extends JUnit5TestBase
+class JDKSerializabilityTest
+ extends JUnit5TestBase
{
/*
/**********************************************************************
@@ -24,7 +24,7 @@ public class JDKSerializabilityTest
*/
@Test
- public void testJsonFactorySerializable() throws Exception
+ void jsonFactorySerializable() throws Exception
{
JsonFactory f = new JsonFactory();
String origJson = "{\"simple\":[1,true,{}]}";
@@ -47,7 +47,7 @@ public void testJsonFactorySerializable() throws Exception
*/
@Test
- public void testBase64Variant() throws Exception
+ void base64Variant() throws Exception
{
{
Base64Variant orig = Base64Variants.PEM;
@@ -65,8 +65,8 @@ public void testBase64Variant() throws Exception
Base64Variant mod = orig.withWritePadding(true);
assertTrue(mod.usesPadding());
assertNotSame(orig, mod);
- assertFalse(orig.equals(mod));
- assertFalse(mod.equals(orig));
+ assertNotEquals(orig, mod);
+ assertNotEquals(mod, orig);
final String exp = _encodeBase64(mod);
byte[] stuff = jdkSerialize(mod);
@@ -79,7 +79,7 @@ public void testBase64Variant() throws Exception
}
@Test
- public void testPrettyPrinter() throws Exception
+ void prettyPrinter() throws Exception
{
PrettyPrinter p = new DefaultPrettyPrinter();
byte[] stuff = jdkSerialize(p);
@@ -89,7 +89,7 @@ public void testPrettyPrinter() throws Exception
}
@Test
- public void testLocation() throws Exception
+ void location() throws Exception
{
JsonFactory jf = new JsonFactory();
JsonParser jp = jf.createParser(" { }");
@@ -106,7 +106,7 @@ public void testLocation() throws Exception
}
@Test
- public void testSourceReference() throws Exception
+ void sourceReference() throws Exception
{
ContentReference ref = ContentReference.construct(true, "text",
ErrorReportConfiguration.defaults());
@@ -124,7 +124,7 @@ public void testSourceReference() throws Exception
*/
@Test
- public void testRecyclerPools() throws Exception
+ void recyclerPools() throws Exception
{
// First: shared/global pools that will always remain/become globally
// shared instances
@@ -160,7 +160,7 @@ private > T _testRecyclerPoolNonShared(T pool) throws
assertNotSame(pool, result);
return result;
}
-
+
/*
/**********************************************************************
/* Exception types
@@ -168,7 +168,7 @@ private > T _testRecyclerPoolNonShared(T pool) throws
*/
@Test
- public void testParseException() throws Exception
+ void parseException() throws Exception
{
JsonFactory jf = new JsonFactory();
JsonParser p = jf.createParser(" { garbage! }");
@@ -187,7 +187,7 @@ public void testParseException() throws Exception
}
@Test
- public void testGenerationException() throws Exception
+ void generationException() throws Exception
{
JsonFactory jf = new JsonFactory();
JsonGenerator g = jf.createGenerator(new ByteArrayOutputStream());
@@ -212,7 +212,7 @@ public void testGenerationException() throws Exception
*/
@Test
- public void testPointerSerializationNonEmpty() throws Exception
+ void pointerSerializationNonEmpty() throws Exception
{
// First, see that we can write and read a general JsonPointer
final String INPUT = "/Image/15/name";
@@ -243,7 +243,7 @@ public void testPointerSerializationNonEmpty() throws Exception
}
@Test
- public void testPointerSerializationEmpty() throws Exception
+ void pointerSerializationEmpty() throws Exception
{
// and then verify that "empty" instance gets canonicalized
final JsonPointer emptyP = JsonPointer.empty();
diff --git a/src/test/java/com/fasterxml/jackson/core/JsonLocationTest.java b/src/test/java/com/fasterxml/jackson/core/JsonLocationTest.java
index aa13ab7de7..2844e889fe 100644
--- a/src/test/java/com/fasterxml/jackson/core/JsonLocationTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/JsonLocationTest.java
@@ -16,21 +16,21 @@
* Tests for verifying internal working of {@link JsonLocation} class itself,
* as opposed to accuracy of reported location information by parsers.
*/
-public class JsonLocationTest
- extends JUnit5TestBase
+class JsonLocationTest
+ extends JUnit5TestBase
{
static class Foobar { }
@Test
- public void testBasics()
+ void basics()
{
JsonLocation loc1 = new JsonLocation(_sourceRef("src"),
10L, 10L, 1, 2);
JsonLocation loc2 = new JsonLocation(null, 10L, 10L, 3, 2);
assertEquals(loc1, loc1);
- assertFalse(loc1.equals(null));
- assertFalse(loc1.equals(loc2));
- assertFalse(loc2.equals(loc1));
+ assertNotEquals(null, loc1);
+ assertNotEquals(loc1, loc2);
+ assertNotEquals(loc2, loc1);
// don't care about what it is; should not compute to 0 with data above
assertTrue(loc1.hashCode() != 0);
@@ -38,7 +38,7 @@ public void testBasics()
}
@Test
- public void testBasicToString() throws Exception
+ void basicToString() throws Exception
{
// no location; presumed to be Binary due to defaulting
assertEquals("[Source: UNKNOWN; line: 3, column: 2]",
@@ -73,7 +73,7 @@ public void testBasicToString() throws Exception
}
@Test
- public void testTruncatedSource() throws Exception
+ void truncatedSource() throws Exception
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < ErrorReportConfiguration.DEFAULT_MAX_RAW_CONTENT_LENGTH; ++i) {
@@ -93,7 +93,7 @@ public void testTruncatedSource() throws Exception
// for [jackson-core#658]
@Test
- public void testEscapeNonPrintable() throws Exception
+ void escapeNonPrintable() throws Exception
{
final String DOC = "[ \"tab:[\t]/null:[\0]\" ]";
JsonLocation loc = new JsonLocation(_sourceRef(DOC), 0L, 0L, -1, -1);
@@ -104,7 +104,7 @@ public void testEscapeNonPrintable() throws Exception
// for [jackson-core#356]
@Test
- public void testDisableSourceInclusion() throws Exception
+ void disableSourceInclusion() throws Exception
{
JsonFactory f = JsonFactory.builder()
.disable(StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION)
@@ -138,10 +138,10 @@ private void _verifyContentDisabled(JsonParseException e) {
assertNull(loc.contentReference().getRawContent());
assertThat(loc.sourceDescription()).startsWith("REDACTED");
}
-
+
// for [jackson-core#739]: try to support equality
@Test
- public void testLocationEquality() throws Exception
+ void locationEquality() throws Exception
{
// important: create separate but equal instances
File src1 = new File("/tmp/foo");
@@ -166,8 +166,8 @@ public void testLocationEquality() throws Exception
5L, 0L, 1, 2);
loc2 = new JsonLocation(_sourceRef(bogus, 1, 4),
5L, 0L, 1, 2);
- assertFalse(loc1.equals(loc2));
- assertFalse(loc2.equals(loc1));
+ assertNotEquals(loc1, loc2);
+ assertNotEquals(loc2, loc1);
}
private ContentReference _sourceRef(String rawSrc) {
diff --git a/src/test/java/com/fasterxml/jackson/core/JsonpCharacterEscapesTest.java b/src/test/java/com/fasterxml/jackson/core/JsonpCharacterEscapesTest.java
index bda30d97cf..cb5e095a31 100644
--- a/src/test/java/com/fasterxml/jackson/core/JsonpCharacterEscapesTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/JsonpCharacterEscapesTest.java
@@ -12,18 +12,18 @@
* @see JsonpCharacterEscapes
*
**/
-public class JsonpCharacterEscapesTest
- extends JUnit5TestBase
+class JsonpCharacterEscapesTest
+ extends JUnit5TestBase
{
@Test
- public void testGetEscapeSequenceOne() {
+ void getEscapeSequenceOne() {
JsonpCharacterEscapes jsonpCharacterEscapes = JsonpCharacterEscapes.instance();
assertEquals(new SerializedString("\\u2028"),jsonpCharacterEscapes.getEscapeSequence(0x2028));
}
@Test
- public void testGetEscapeSequenceTwo() {
+ void getEscapeSequenceTwo() {
JsonpCharacterEscapes jsonpCharacterEscapes = JsonpCharacterEscapes.instance();
assertEquals(new SerializedString("\\u2029"),jsonpCharacterEscapes.getEscapeSequence(0x2029));
diff --git a/src/test/java/com/fasterxml/jackson/core/ParserFeatureDefaultsTest.java b/src/test/java/com/fasterxml/jackson/core/ParserFeatureDefaultsTest.java
index 07e3a799ab..fb07650031 100644
--- a/src/test/java/com/fasterxml/jackson/core/ParserFeatureDefaultsTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/ParserFeatureDefaultsTest.java
@@ -9,8 +9,8 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
-public class ParserFeatureDefaultsTest
- extends JUnit5TestBase
+class ParserFeatureDefaultsTest
+ extends JUnit5TestBase
{
static class TestParser extends ParserMinimalBase
{
@@ -145,7 +145,7 @@ public BigDecimal getDecimalValue() {
}
@Test
- public void testParserFlagDefaults() throws Exception
+ void parserFlagDefaults() throws Exception
{
try (JsonParser p = new TestParser()) {
for (JsonParser.Feature feat : JsonParser.Feature.values()) {
diff --git a/src/test/java/com/fasterxml/jackson/core/VersionClassTest.java b/src/test/java/com/fasterxml/jackson/core/VersionClassTest.java
index 74e2fe7cb9..d0c72348e9 100644
--- a/src/test/java/com/fasterxml/jackson/core/VersionClassTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/VersionClassTest.java
@@ -8,11 +8,11 @@
/**
* Unit tests for class {@link Version}.
*/
-public class VersionClassTest
- extends JUnit5TestBase
+class VersionClassTest
+ extends JUnit5TestBase
{
@Test
- public void testEqualsAndHashCode() {
+ void equalsAndHashCode() {
Version version1 = new Version(1, 2, 3, "", "", "");
Version version2 = new Version(1, 2, 3, "", "", "");
@@ -22,8 +22,8 @@ public void testEqualsAndHashCode() {
assertEquals(version1.hashCode(), version2.hashCode());
}
- @Test
- public void testCompareToOne() {
+ @Test
+ void compareToOne() {
Version version = Version.unknownVersion();
Version versionTwo = new Version(0, (-263), (-1820), "",
"", "");
@@ -31,8 +31,8 @@ public void testCompareToOne() {
assertEquals(263, version.compareTo(versionTwo));
}
- @Test
- public void testCompareToReturningZero() {
+ @Test
+ void compareToReturningZero() {
Version version = Version.unknownVersion();
Version versionTwo = new Version(0, 0, 0, "",
"", "");
@@ -40,16 +40,16 @@ public void testCompareToReturningZero() {
assertEquals(0, version.compareTo(versionTwo));
}
- @Test
- public void testCreatesVersionTaking6ArgumentsAndCallsCompareTo() {
+ @Test
+ void createsVersionTaking6ArgumentsAndCallsCompareTo() {
Version version = new Version(0, 0, 0, null, null, "");
Version versionTwo = new Version(0, 0, 0, "", "", "//0.0.0");
assertTrue(version.compareTo(versionTwo) < 0);
}
- @Test
- public void testCompareToTwo() {
+ @Test
+ void compareToTwo() {
Version version = Version.unknownVersion();
Version versionTwo = new Version((-1), 0, 0, "0.0.0",
"", "");
@@ -57,24 +57,24 @@ public void testCompareToTwo() {
assertTrue(version.compareTo(versionTwo) > 0);
}
- @Test
- public void testCompareToAndCreatesVersionTaking6ArgumentsAndUnknownVersion() {
+ @Test
+ void compareToAndCreatesVersionTaking6ArgumentsAndUnknownVersion() {
Version version = Version.unknownVersion();
Version versionTwo = new Version(0, 0, 0, "//0.0.0", "//0.0.0", "");
assertTrue(version.compareTo(versionTwo) < 0);
}
- @Test
- public void testCompareToSnapshotSame() {
+ @Test
+ void compareToSnapshotSame() {
Version version = new Version(0, 0, 0, "alpha", "com.fasterxml", "bogus");
Version versionTwo = new Version(0, 0, 0, "alpha", "com.fasterxml", "bogus");
assertEquals(0, version.compareTo(versionTwo));
}
- @Test
- public void testCompareToSnapshotDifferent() {
+ @Test
+ void compareToSnapshotDifferent() {
Version version = new Version(0, 0, 0, "alpha", "com.fasterxml", "bogus");
Version versionTwo = new Version(0, 0, 0, "beta", "com.fasterxml", "bogus");
@@ -82,8 +82,8 @@ public void testCompareToSnapshotDifferent() {
assertTrue(versionTwo.compareTo(version) > 0);
}
- @Test
- public void testCompareWhenOnlyFirstHasSnapshot() {
+ @Test
+ void compareWhenOnlyFirstHasSnapshot() {
Version version = new Version(0, 0, 0, "beta", "com.fasterxml", "bogus");
Version versionTwo = new Version(0, 0, 0, null, "com.fasterxml", "bogus");
@@ -91,8 +91,8 @@ public void testCompareWhenOnlyFirstHasSnapshot() {
assertTrue(versionTwo.compareTo(version) > 0);
}
- @Test
- public void testCompareWhenOnlySecondHasSnapshot() {
+ @Test
+ void compareWhenOnlySecondHasSnapshot() {
Version version = new Version(0, 0, 0, "", "com.fasterxml", "bogus");
Version versionTwo = new Version(0, 0, 0, "beta", "com.fasterxml", "bogus");
diff --git a/src/test/java/com/fasterxml/jackson/core/json/BoundsChecksWithJsonFactoryTest.java b/src/test/java/com/fasterxml/jackson/core/json/BoundsChecksWithJsonFactoryTest.java
index 776609e51f..a834d45172 100644
--- a/src/test/java/com/fasterxml/jackson/core/json/BoundsChecksWithJsonFactoryTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/json/BoundsChecksWithJsonFactoryTest.java
@@ -3,7 +3,6 @@
import com.fasterxml.jackson.core.JUnit5TestBase;
import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.core.BaseTest;
import com.fasterxml.jackson.core.TokenStreamFactory;
import static org.junit.jupiter.api.Assertions.fail;
diff --git a/src/test/java/com/fasterxml/jackson/core/json/JsonReadContextTest.java b/src/test/java/com/fasterxml/jackson/core/json/JsonReadContextTest.java
index 431935f140..c6e049940b 100644
--- a/src/test/java/com/fasterxml/jackson/core/json/JsonReadContextTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/json/JsonReadContextTest.java
@@ -3,7 +3,6 @@
import com.fasterxml.jackson.core.JUnit5TestBase;
import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.core.BaseTest;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.io.ContentReference;
diff --git a/src/test/java/com/fasterxml/jackson/core/type/TypeReferenceTest.java b/src/test/java/com/fasterxml/jackson/core/type/TypeReferenceTest.java
index ad6815ad69..375196f153 100644
--- a/src/test/java/com/fasterxml/jackson/core/type/TypeReferenceTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/type/TypeReferenceTest.java
@@ -1,11 +1,14 @@
package com.fasterxml.jackson.core.type;
+import com.fasterxml.jackson.core.JUnit5TestBase;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
-import com.fasterxml.jackson.core.BaseTest;
+import static org.junit.jupiter.api.Assertions.*;
// Not much to test, but exercise to prevent code coverage tool from showing all red for package
-public class TypeReferenceTest extends BaseTest
+class TypeReferenceTest extends JUnit5TestBase
{
static class BogusResolvedType extends ResolvedType {
private final boolean _refType;
@@ -123,7 +126,8 @@ public String toCanonical() {
}
}
- public void testSimple()
+ @Test
+ void simple()
{
TypeReference> ref = new TypeReference>() { };
assertNotNull(ref);
@@ -131,7 +135,8 @@ public void testSimple()
}
@SuppressWarnings("rawtypes")
- public void testInvalid()
+ @Test
+ void invalid()
{
try {
Object ob = new TypeReference() { };
@@ -141,7 +146,8 @@ public void testInvalid()
}
}
- public void testResolvedType() {
+ @Test
+ void resolvedType() {
ResolvedType type1 = new BogusResolvedType(false);
assertFalse(type1.isReferenceType());
ResolvedType type2 = new BogusResolvedType(true);
diff --git a/src/test/java/com/fasterxml/jackson/core/util/ByteArrayBuilderTest.java b/src/test/java/com/fasterxml/jackson/core/util/ByteArrayBuilderTest.java
index 7fd883cf54..dad69d5457 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/ByteArrayBuilderTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/ByteArrayBuilderTest.java
@@ -2,19 +2,22 @@
import java.nio.charset.StandardCharsets;
-import org.junit.Assert;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.base.GeneratorBase;
import com.fasterxml.jackson.core.io.IOContext;
-public class ByteArrayBuilderTest extends com.fasterxml.jackson.core.BaseTest
+import static org.junit.jupiter.api.Assertions.*;
+
+class ByteArrayBuilderTest extends com.fasterxml.jackson.core.JUnit5TestBase
{
- public void testSimple() throws Exception
+ @Test
+ void simple() throws Exception
{
ByteArrayBuilder b = new ByteArrayBuilder(null, 20);
- Assert.assertArrayEquals(new byte[0], b.toByteArray());
+ assertArrayEquals(new byte[0], b.toByteArray());
b.write((byte) 0);
b.append(1);
@@ -36,7 +39,8 @@ public void testSimple() throws Exception
}
// [core#1195]: Try to verify that BufferRecycler instance is indeed reused
- public void testBufferRecyclerReuse() throws Exception
+ @Test
+ void bufferRecyclerReuse() throws Exception
{
JsonFactory f = new JsonFactory();
BufferRecycler br = new BufferRecycler()
diff --git a/src/test/java/com/fasterxml/jackson/core/util/JsonBufferRecyclersTest.java b/src/test/java/com/fasterxml/jackson/core/util/JsonBufferRecyclersTest.java
index be1556f57e..dcc11a0f24 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/JsonBufferRecyclersTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/JsonBufferRecyclersTest.java
@@ -4,31 +4,40 @@
import com.fasterxml.jackson.core.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
// Basic testing for [core#1064] wrt usage by `JsonParser` / `JsonGenerator`
// (wrt simple reads/writes working without issues)
-public class JsonBufferRecyclersTest extends BaseTest
+class JsonBufferRecyclersTest extends JUnit5TestBase
{
// // Parsers with RecyclerPools:
- public void testParserWithThreadLocalPool() throws Exception {
+ @Test
+ void parserWithThreadLocalPool() throws Exception {
_testParser(JsonRecyclerPools.threadLocalPool());
}
- public void testParserWithNopLocalPool() throws Exception {
+ @Test
+ void parserWithNopLocalPool() throws Exception {
_testParser(JsonRecyclerPools.nonRecyclingPool());
}
- public void testParserWithDequeuPool() throws Exception {
+ @Test
+ void parserWithDequeuPool() throws Exception {
_testParser(JsonRecyclerPools.newConcurrentDequePool());
_testParser(JsonRecyclerPools.sharedConcurrentDequePool());
}
- public void testParserWithLockFreePool() throws Exception {
+ @Test
+ void parserWithLockFreePool() throws Exception {
_testParser(JsonRecyclerPools.newLockFreePool());
_testParser(JsonRecyclerPools.sharedLockFreePool());
}
- public void testParserWithBoundedPool() throws Exception {
+ @Test
+ void parserWithBoundedPool() throws Exception {
_testParser(JsonRecyclerPools.newBoundedPool(5));
_testParser(JsonRecyclerPools.sharedBoundedPool());
}
@@ -57,25 +66,30 @@ private void _testParser(RecyclerPool pool) throws Exception
// // Generators with RecyclerPools:
- public void testGeneratorWithThreadLocalPool() throws Exception {
+ @Test
+ void generatorWithThreadLocalPool() throws Exception {
_testGenerator(JsonRecyclerPools.threadLocalPool());
}
- public void testGeneratorWithNopLocalPool() throws Exception {
+ @Test
+ void generatorWithNopLocalPool() throws Exception {
_testGenerator(JsonRecyclerPools.nonRecyclingPool());
}
- public void testGeneratorWithDequeuPool() throws Exception {
+ @Test
+ void generatorWithDequeuPool() throws Exception {
_testGenerator(JsonRecyclerPools.newConcurrentDequePool());
_testGenerator(JsonRecyclerPools.sharedConcurrentDequePool());
}
- public void testGeneratorWithLockFreePool() throws Exception {
+ @Test
+ void generatorWithLockFreePool() throws Exception {
_testGenerator(JsonRecyclerPools.newLockFreePool());
_testGenerator(JsonRecyclerPools.sharedLockFreePool());
}
- public void testGeneratorWithBoundedPool() throws Exception {
+ @Test
+ void generatorWithBoundedPool() throws Exception {
_testGenerator(JsonRecyclerPools.newBoundedPool(5));
_testGenerator(JsonRecyclerPools.sharedBoundedPool());
}
@@ -101,25 +115,30 @@ private void _testGenerator(RecyclerPool pool) throws Exception
// // Read-and-Write: Parser and Generator, overlapping usage
- public void testCopyWithThreadLocalPool() throws Exception {
+ @Test
+ void copyWithThreadLocalPool() throws Exception {
_testCopy(JsonRecyclerPools.threadLocalPool());
}
- public void testCopyWithNopLocalPool() throws Exception {
+ @Test
+ void copyWithNopLocalPool() throws Exception {
_testCopy(JsonRecyclerPools.nonRecyclingPool());
}
- public void testCopyWithDequeuPool() throws Exception {
+ @Test
+ void copyWithDequeuPool() throws Exception {
_testCopy(JsonRecyclerPools.newConcurrentDequePool());
_testCopy(JsonRecyclerPools.sharedConcurrentDequePool());
}
- public void testCopyWithLockFreePool() throws Exception {
+ @Test
+ void copyWithLockFreePool() throws Exception {
_testCopy(JsonRecyclerPools.newLockFreePool());
_testCopy(JsonRecyclerPools.sharedLockFreePool());
}
- public void testCopyWithBoundedPool() throws Exception {
+ @Test
+ void copyWithBoundedPool() throws Exception {
_testCopy(JsonRecyclerPools.newBoundedPool(5));
_testCopy(JsonRecyclerPools.sharedBoundedPool());
}
diff --git a/src/test/java/com/fasterxml/jackson/core/util/TestCharTypes.java b/src/test/java/com/fasterxml/jackson/core/util/TestCharTypes.java
index 5bded08f98..7d1da82c71 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/TestCharTypes.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/TestCharTypes.java
@@ -1,11 +1,16 @@
package com.fasterxml.jackson.core.util;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.io.CharTypes;
-public class TestCharTypes
- extends com.fasterxml.jackson.core.BaseTest
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class TestCharTypes
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
- public void testQuoting()
+ @Test
+ void quoting()
{
StringBuilder sb = new StringBuilder();
CharTypes.appendQuoted(sb, "\n");
diff --git a/src/test/java/com/fasterxml/jackson/core/util/TestDefaultPrettyPrinter.java b/src/test/java/com/fasterxml/jackson/core/util/TestDefaultPrettyPrinter.java
index a3a896fbd0..c1037a1231 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/TestDefaultPrettyPrinter.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/TestDefaultPrettyPrinter.java
@@ -7,13 +7,19 @@
import org.assertj.core.api.ThrowingConsumer;
import com.fasterxml.jackson.core.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.util.Separators.Spacing;
-public class TestDefaultPrettyPrinter extends BaseTest
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+class TestDefaultPrettyPrinter extends JUnit5TestBase
{
private final JsonFactory JSON_F = new JsonFactory();
- public void testSystemLinefeed() throws IOException
+ @Test
+ void systemLinefeed() throws IOException
{
PrettyPrinter pp = new DefaultPrettyPrinter();
String LF = System.getProperty("line.separator");
@@ -25,7 +31,8 @@ public void testSystemLinefeed() throws IOException
assertEquals(EXP, _printTestData(pp, true));
}
- public void testWithLineFeed() throws IOException
+ @Test
+ void withLineFeed() throws IOException
{
PrettyPrinter pp = new DefaultPrettyPrinter()
.withObjectIndenter(new DefaultIndenter().withLinefeed("\n"));
@@ -37,7 +44,8 @@ public void testWithLineFeed() throws IOException
assertEquals(EXP, _printTestData(pp, true));
}
- public void testWithIndent() throws IOException
+ @Test
+ void withIndent() throws IOException
{
PrettyPrinter pp = new DefaultPrettyPrinter()
.withObjectIndenter(new DefaultIndenter().withLinefeed("\n").withIndent(" "));
@@ -49,7 +57,8 @@ public void testWithIndent() throws IOException
assertEquals(EXP, _printTestData(pp, true));
}
- public void testUnixLinefeed() throws IOException
+ @Test
+ void unixLinefeed() throws IOException
{
PrettyPrinter pp = new DefaultPrettyPrinter()
.withObjectIndenter(new DefaultIndenter(" ", "\n"));
@@ -61,7 +70,8 @@ public void testUnixLinefeed() throws IOException
assertEquals(EXP, _printTestData(pp, true));
}
- public void testWindowsLinefeed() throws IOException
+ @Test
+ void windowsLinefeed() throws IOException
{
PrettyPrinter pp = new DefaultPrettyPrinter()
.withObjectIndenter(new DefaultIndenter(" ", "\r\n"));
@@ -73,7 +83,8 @@ public void testWindowsLinefeed() throws IOException
assertEquals(EXP, _printTestData(pp, true));
}
- public void testTabIndent() throws IOException
+ @Test
+ void tabIndent() throws IOException
{
PrettyPrinter pp = new DefaultPrettyPrinter()
.withObjectIndenter(new DefaultIndenter("\t", "\n"));
@@ -84,8 +95,9 @@ public void testTabIndent() throws IOException
assertEquals(EXP, _printTestData(pp, false));
assertEquals(EXP, _printTestData(pp, true));
}
-
- public void testObjectFieldValueSpacingAfter() throws IOException
+
+ @Test
+ void objectFieldValueSpacingAfter() throws IOException
{
Separators separators = new Separators()
.withObjectFieldValueSpacing(Spacing.AFTER);
@@ -99,8 +111,9 @@ public void testObjectFieldValueSpacingAfter() throws IOException
assertEquals(EXP, _printTestData(pp, false));
assertEquals(EXP, _printTestData(pp, true));
}
-
- public void testObjectFieldValueSpacingNone() throws IOException
+
+ @Test
+ void objectFieldValueSpacingNone() throws IOException
{
Separators separators = new Separators()
.withObjectFieldValueSpacing(Spacing.NONE);
@@ -114,8 +127,9 @@ public void testObjectFieldValueSpacingNone() throws IOException
assertEquals(EXP, _printTestData(pp, false));
assertEquals(EXP, _printTestData(pp, true));
}
-
- public void testCopyConfigOld() throws IOException
+
+ @Test
+ void copyConfigOld() throws IOException
{
Separators separators = new Separators()
.withObjectFieldValueSpacing(Spacing.AFTER)
@@ -132,8 +146,9 @@ public void testCopyConfigOld() throws IOException
assertEquals(expected, _printTestData(copy, false));
assertEquals(expected, _printTestData(copy, true));
}
-
- public void testCopyConfigNew() throws IOException
+
+ @Test
+ void copyConfigNew() throws IOException
{
Separators separators = new Separators()
.withObjectFieldValueSpacing(Spacing.AFTER)
@@ -150,7 +165,8 @@ public void testCopyConfigNew() throws IOException
assertEquals(expected, _printTestData(copy, true));
}
- public void testRootSeparatorOld() throws IOException
+ @Test
+ void rootSeparatorOld() throws IOException
{
@SuppressWarnings("deprecation") // Testing the old API
DefaultPrettyPrinter pp = new DefaultPrettyPrinter()
@@ -166,8 +182,9 @@ public void testRootSeparatorOld() throws IOException
assertEquals(EXP, _printTestData(pp, false, writeTestData));
assertEquals(EXP, _printTestData(pp, true, writeTestData));
}
-
- public void testRootSeparator() throws IOException
+
+ @Test
+ void rootSeparator() throws IOException
{
Separators separators = new Separators()
.withRootSeparator("|");
@@ -185,7 +202,8 @@ public void testRootSeparator() throws IOException
assertEquals(EXP, _printTestData(pp, true, writeTestData));
}
- public void testWithoutSeparatorsOld() throws IOException
+ @Test
+ void withoutSeparatorsOld() throws IOException
{
// Also: let's try removing separator altogether
@SuppressWarnings("deprecation") // Testing the old API
@@ -208,8 +226,9 @@ public void testWithoutSeparatorsOld() throws IOException
// no root separator, nor array, object
assertEquals("1[2]{\"a\":3}", _printTestData(pp, false, writeTestData));
}
-
- public void testWithoutSeparatorsNew() throws IOException
+
+ @Test
+ void withoutSeparatorsNew() throws IOException
{
Separators separators = new Separators()
.withRootSeparator(null)
@@ -233,7 +252,8 @@ public void testWithoutSeparatorsNew() throws IOException
assertEquals("1[2]{\"a\":3}", _printTestData(pp, false, writeTestData));
}
- public void testObjectEmptySeparatorDefault() throws IOException
+ @Test
+ void objectEmptySeparatorDefault() throws IOException
{
Separators separators = new Separators()
.withRootSeparator(null)
@@ -254,7 +274,8 @@ public void testObjectEmptySeparatorDefault() throws IOException
assertEquals("{\"objectEmptySeparatorDefault\":{ }}", _printTestData(pp, false, writeTestData));
}
- public void testObjectEmptySeparatorCustom() throws IOException
+ @Test
+ void objectEmptySeparatorCustom() throws IOException
{
Separators separators = new Separators()
.withRootSeparator(null)
@@ -276,7 +297,8 @@ public void testObjectEmptySeparatorCustom() throws IOException
assertEquals("{\"objectEmptySeparatorCustom\":{ }}", _printTestData(pp, false, writeTestData));
}
- public void testArrayEmptySeparatorDefault() throws IOException
+ @Test
+ void arrayEmptySeparatorDefault() throws IOException
{
Separators separators = new Separators()
.withRootSeparator(null)
@@ -297,7 +319,8 @@ public void testArrayEmptySeparatorDefault() throws IOException
assertEquals("{\"arrayEmptySeparatorDefault\":[ ]}", _printTestData(pp, false, writeTestData));
}
- public void testArrayEmptySeparatorCustom() throws IOException
+ @Test
+ void arrayEmptySeparatorCustom() throws IOException
{
Separators separators = new Separators()
.withRootSeparator(null)
@@ -357,7 +380,8 @@ private String _printTestData(PrettyPrinter pp, boolean useBytes, ThrowingConsum
}
// [core#502]: Force sub-classes to reimplement `createInstance`
- public void testInvalidSubClass() throws Exception
+ @Test
+ void invalidSubClass() throws Exception
{
DefaultPrettyPrinter pp = new MyPrettyPrinter();
try {
diff --git a/src/test/java/com/fasterxml/jackson/core/util/TestDelegates.java b/src/test/java/com/fasterxml/jackson/core/util/TestDelegates.java
index 03acb78aac..caf9808d6e 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/TestDelegates.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/TestDelegates.java
@@ -6,14 +6,16 @@
import java.util.Iterator;
import com.fasterxml.jackson.core.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.JsonParser.NumberType;
import com.fasterxml.jackson.core.JsonParser.NumberTypeFP;
import com.fasterxml.jackson.core.type.ResolvedType;
import com.fasterxml.jackson.core.type.TypeReference;
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.*;
-public class TestDelegates extends com.fasterxml.jackson.core.BaseTest
+class TestDelegates extends com.fasterxml.jackson.core.JUnit5TestBase
{
static class BogusSchema implements FormatSchema
{
@@ -197,7 +199,8 @@ public JsonParser traverse(ObjectCodec codec) {
/**
* Test default, non-overridden parser delegate.
*/
- public void testParserDelegate() throws IOException
+ @Test
+ void parserDelegate() throws IOException
{
final int MAX_NUMBER_LEN = 200;
final String TOKEN ="foo";
@@ -307,7 +310,8 @@ public void testParserDelegate() throws IOException
* Test default, non-overridden generator delegate.
*/
@SuppressWarnings("deprecation")
- public void testGeneratorDelegate() throws IOException
+ @Test
+ void generatorDelegate() throws IOException
{
final String TOKEN ="foo";
@@ -370,7 +374,8 @@ public void testGeneratorDelegate() throws IOException
g0.close();
}
- public void testGeneratorDelegateArrays() throws IOException
+ @Test
+ void generatorDelegateArrays() throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator g0 = JSON_F.createGenerator(sw);
@@ -391,7 +396,8 @@ public void testGeneratorDelegateArrays() throws IOException
g0.close();
}
- public void testGeneratorDelegateComments() throws IOException
+ @Test
+ void generatorDelegateComments() throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator g0 = JSON_F.createGenerator(sw);
@@ -415,7 +421,8 @@ public void testGeneratorDelegateComments() throws IOException
g0.close();
}
- public void testDelegateCopyMethods() throws IOException
+ @Test
+ void delegateCopyMethods() throws IOException
{
JsonParser p = JSON_F.createParser("[123,[true,false]]");
StringWriter sw = new StringWriter();
@@ -438,7 +445,8 @@ public void testDelegateCopyMethods() throws IOException
assertEquals("[123,false]", sw.toString());
}
- public void testNotDelegateCopyMethods() throws IOException
+ @Test
+ void notDelegateCopyMethods() throws IOException
{
JsonParser jp = JSON_F.createParser("[{\"a\":[1,2,{\"b\":3}],\"c\":\"d\"},{\"e\":false},null]");
StringWriter sw = new StringWriter();
@@ -459,7 +467,8 @@ public void writeFieldName(String name) throws IOException {
}
@SuppressWarnings("resource")
- public void testGeneratorWithCodec() throws IOException
+ @Test
+ void generatorWithCodec() throws IOException
{
BogusCodec codec = new BogusCodec();
StringWriter sw = new StringWriter();
diff --git a/src/test/java/com/fasterxml/jackson/core/util/TestNumberPrinting.java b/src/test/java/com/fasterxml/jackson/core/util/TestNumberPrinting.java
index 26bd962a7f..a11126f966 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/TestNumberPrinting.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/TestNumberPrinting.java
@@ -4,14 +4,19 @@
import com.fasterxml.jackson.core.io.NumberOutput;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Set of basic unit tests for verifying that the low-level number
* printing methods work as expected.
*/
-public class TestNumberPrinting
- extends com.fasterxml.jackson.core.BaseTest
+class TestNumberPrinting
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
- public void testIntPrinting() throws Exception
+ @Test
+ void intPrinting() throws Exception
{
assertIntPrint(0);
assertIntPrint(-3);
@@ -38,7 +43,8 @@ public void testIntPrinting() throws Exception
}
}
- public void testLongPrinting() throws Exception
+ @Test
+ void longPrinting() throws Exception
{
// First, let's just cover couple of edge cases
assertLongPrint(0L, 0);
@@ -69,11 +75,11 @@ private void assertIntPrint(int value)
String act = printToString(value);
if (!exp.equals(act)) {
- assertEquals("Expected conversion (exp '"+exp+"', len "+exp.length()+"; act len "+act.length()+")", exp, act);
+ assertEquals(exp, act, "Expected conversion (exp '"+exp+"', len "+exp.length()+"; act len "+act.length()+")");
}
String alt = NumberOutput.toString(value);
if (!exp.equals(alt)) {
- assertEquals("Expected conversion (exp '"+exp+"', len "+exp.length()+"; act len "+act.length()+")", exp, act);
+ assertEquals(exp, act, "Expected conversion (exp '"+exp+"', len "+exp.length()+"; act len "+act.length()+")");
}
}
@@ -83,11 +89,11 @@ private void assertLongPrint(long value, int index)
String act = printToString(value);
if (!exp.equals(act)) {
- assertEquals("Expected conversion (exp '"+exp+"', len "+exp.length()+"; act len "+act.length()+"; number index "+index+")", exp, act);
+ assertEquals(exp, act, "Expected conversion (exp '"+exp+"', len "+exp.length()+"; act len "+act.length()+"; number index "+index+")");
}
String alt = NumberOutput.toString(value);
if (!exp.equals(alt)) {
- assertEquals("Expected conversion (exp '"+exp+"', len "+exp.length()+"; act len "+act.length()+"; number index "+index+")", exp, act);
+ assertEquals(exp, act, "Expected conversion (exp '"+exp+"', len "+exp.length()+"; act len "+act.length()+"; number index "+index+")");
}
}
diff --git a/src/test/java/com/fasterxml/jackson/core/util/TestSerializedString.java b/src/test/java/com/fasterxml/jackson/core/util/TestSerializedString.java
index 33c0bddcb2..be7b6e4c30 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/TestSerializedString.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/TestSerializedString.java
@@ -5,16 +5,21 @@
import java.util.Arrays;
import com.fasterxml.jackson.core.SerializableString;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.io.SerializedString;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Simple unit tests to try to verify that the default
* {@link SerializableString} implementation works as expected.
*/
-public class TestSerializedString
- extends com.fasterxml.jackson.core.BaseTest
+class TestSerializedString
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
- public void testAppending() throws IOException
+ @Test
+ void appending() throws IOException
{
final String INPUT = "\"quo\\ted\"";
final String QUOTED = "\\\"quo\\\\ted\\\"";
@@ -39,7 +44,8 @@ public void testAppending() throws IOException
assertEquals(INPUT, new String(buffer, 5, INPUT.length()));
}
- public void testFailedAccess() throws IOException
+ @Test
+ void failedAccess() throws IOException
{
final String INPUT = "Bit longer text";
SerializableString sstr = new SerializedString(INPUT);
diff --git a/src/test/java/com/fasterxml/jackson/core/util/TestTextBuffer.java b/src/test/java/com/fasterxml/jackson/core/util/TestTextBuffer.java
index c031213d08..6daf5a2ffc 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/TestTextBuffer.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/TestTextBuffer.java
@@ -1,13 +1,18 @@
package com.fasterxml.jackson.core.util;
-public class TestTextBuffer
- extends com.fasterxml.jackson.core.BaseTest
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TestTextBuffer
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
/**
* Trivially simple basic test to ensure all basic append
* methods work
*/
- public void testSimple() throws Exception
+ @Test
+ void simple() throws Exception
{
TextBuffer tb = new TextBuffer(new BufferRecycler());
tb.append('a');
@@ -22,7 +27,8 @@ public void testSimple() throws Exception
assertNotNull(tb.expandCurrentSegment());
}
- public void testLonger() throws Exception
+ @Test
+ void longer() throws Exception
{
TextBuffer tb = new TextBuffer(null);
for (int i = 0; i < 2000; ++i) {
@@ -37,7 +43,8 @@ public void testLonger() throws Exception
assertTrue(tb.hasTextAsCharacters());
}
- public void testLongAppend() throws Exception
+ @Test
+ void longAppend() throws Exception
{
final int len = TextBuffer.MAX_SEGMENT_LEN * 3 / 2;
StringBuilder sb = new StringBuilder(len);
@@ -65,7 +72,8 @@ public void testLongAppend() throws Exception
}
// [core#152]
- public void testExpand() throws Exception
+ @Test
+ void expand() throws Exception
{
TextBuffer tb = new TextBuffer(new BufferRecycler());
char[] buf = tb.getCurrentSegment();
@@ -82,22 +90,25 @@ public void testExpand() throws Exception
}
// [core#182]
- public void testEmpty() throws Exception {
+ @Test
+ void empty() throws Exception {
TextBuffer tb = new TextBuffer(new BufferRecycler());
tb.resetWithEmpty();
- assertTrue(tb.getTextBuffer().length == 0);
+ assertEquals(0, tb.getTextBuffer().length);
tb.contentsAsString();
- assertTrue(tb.getTextBuffer().length == 0);
+ assertEquals(0, tb.getTextBuffer().length);
}
- public void testResetWithAndSetCurrentAndReturn() throws Exception {
+ @Test
+ void resetWithAndSetCurrentAndReturn() throws Exception {
TextBuffer textBuffer = new TextBuffer(null);
textBuffer.resetWith('l');
textBuffer.setCurrentAndReturn(349);
}
- public void testGetCurrentSegment() throws Exception {
+ @Test
+ void getCurrentSegment() throws Exception {
TextBuffer textBuffer = new TextBuffer(null);
textBuffer.emptyAndGetCurrentSegment();
// 26-Aug-2019, tatu: Value depends on "minimum segment size":
@@ -107,7 +118,8 @@ public void testGetCurrentSegment() throws Exception {
assertEquals(500, textBuffer.size());
}
- public void testAppendTakingTwoAndThreeInts() throws Exception {
+ @Test
+ void appendTakingTwoAndThreeInts() throws Exception {
BufferRecycler bufferRecycler = new BufferRecycler();
TextBuffer textBuffer = new TextBuffer(bufferRecycler);
textBuffer.ensureNotShared();
@@ -118,7 +130,8 @@ public void testAppendTakingTwoAndThreeInts() throws Exception {
assertEquals(3, textBuffer.getCurrentSegmentSize());
}
- public void testEnsureNotSharedAndResetWithString() throws Exception {
+ @Test
+ void ensureNotSharedAndResetWithString() throws Exception {
BufferRecycler bufferRecycler = new BufferRecycler();
TextBuffer textBuffer = new TextBuffer(bufferRecycler);
textBuffer.resetWithString("");
@@ -130,7 +143,8 @@ public void testEnsureNotSharedAndResetWithString() throws Exception {
assertEquals(0, textBuffer.getCurrentSegmentSize());
}
- public void testGetTextBufferAndEmptyAndGetCurrentSegmentAndFinishCurrentSegment() throws Exception {
+ @Test
+ void getTextBufferAndEmptyAndGetCurrentSegmentAndFinishCurrentSegment() throws Exception {
BufferRecycler bufferRecycler = new BufferRecycler();
TextBuffer textBuffer = new TextBuffer(bufferRecycler);
textBuffer.emptyAndGetCurrentSegment();
@@ -140,7 +154,8 @@ public void testGetTextBufferAndEmptyAndGetCurrentSegmentAndFinishCurrentSegment
assertEquals(200, textBuffer.size());
}
- public void testGetTextBufferAndAppendTakingCharAndContentsAsArray() throws Exception {
+ @Test
+ void getTextBufferAndAppendTakingCharAndContentsAsArray() throws Exception {
BufferRecycler bufferRecycler = new BufferRecycler();
TextBuffer textBuffer = new TextBuffer(bufferRecycler);
textBuffer.append('(');
@@ -150,7 +165,8 @@ public void testGetTextBufferAndAppendTakingCharAndContentsAsArray() throws Exce
assertEquals(1, textBuffer.getCurrentSegmentSize());
}
- public void testGetTextBufferAndResetWithString() throws Exception {
+ @Test
+ void getTextBufferAndResetWithString() throws Exception {
BufferRecycler bufferRecycler = new BufferRecycler();
TextBuffer textBuffer = new TextBuffer(bufferRecycler);
textBuffer.resetWithString("");
@@ -162,7 +178,8 @@ public void testGetTextBufferAndResetWithString() throws Exception {
assertTrue(textBuffer.hasTextAsCharacters());
}
- public void testResetWithString() throws Exception {
+ @Test
+ void resetWithString() throws Exception {
BufferRecycler bufferRecycler = new BufferRecycler();
TextBuffer textBuffer = new TextBuffer(bufferRecycler);
textBuffer.ensureNotShared();
@@ -175,7 +192,8 @@ public void testResetWithString() throws Exception {
assertEquals(0, textBuffer.getTextOffset());
}
- public void testGetCurrentSegmentSizeResetWith() {
+ @Test
+ void getCurrentSegmentSizeResetWith() {
TextBuffer textBuffer = new TextBuffer(null);
textBuffer.resetWith('.');
textBuffer.resetWith('q');
@@ -183,7 +201,8 @@ public void testGetCurrentSegmentSizeResetWith() {
assertEquals(1, textBuffer.getCurrentSegmentSize());
}
- public void testGetSizeFinishCurrentSegmentAndResetWith() throws Exception {
+ @Test
+ void getSizeFinishCurrentSegmentAndResetWith() throws Exception {
TextBuffer textBuffer = new TextBuffer(null);
textBuffer.resetWith('.');
textBuffer.finishCurrentSegment();
diff --git a/src/test/java/com/fasterxml/jackson/core/util/TestVersionUtil.java b/src/test/java/com/fasterxml/jackson/core/util/TestVersionUtil.java
index 9d2774e2ee..40da7bab82 100644
--- a/src/test/java/com/fasterxml/jackson/core/util/TestVersionUtil.java
+++ b/src/test/java/com/fasterxml/jackson/core/util/TestVersionUtil.java
@@ -1,36 +1,45 @@
package com.fasterxml.jackson.core.util;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.json.PackageVersion;
import com.fasterxml.jackson.core.json.UTF8JsonGenerator;
-public class TestVersionUtil extends com.fasterxml.jackson.core.BaseTest
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class TestVersionUtil extends com.fasterxml.jackson.core.JUnit5TestBase
{
- public void testVersionPartParsing()
+ @Test
+ void versionPartParsing()
{
assertEquals(13, VersionUtil.parseVersionPart("13"));
assertEquals(27, VersionUtil.parseVersionPart("27.8"));
assertEquals(0, VersionUtil.parseVersionPart("-3"));
}
- public void testVersionParsing()
+ @Test
+ void versionParsing()
{
assertEquals(new Version(1, 2, 15, "foo", "group", "artifact"),
VersionUtil.parseVersion("1.2.15-foo", "group", "artifact"));
}
@SuppressWarnings("deprecation")
- public void testMavenVersionParsing() {
+ @Test
+ void mavenVersionParsing() {
assertEquals(new Version(1, 2, 3, "SNAPSHOT", "foo.bar", "foo-bar"),
VersionUtil.mavenVersionFor(TestVersionUtil.class.getClassLoader(), "foo.bar", "foo-bar"));
}
- public void testPackageVersionMatches() {
+ @Test
+ void packageVersionMatches() {
assertEquals(PackageVersion.VERSION, VersionUtil.versionFor(UTF8JsonGenerator.class));
}
// [core#248]: make sure not to return `null` but `Version.unknownVersion()`
- public void testVersionForUnknownVersion() {
+ @Test
+ void versionForUnknownVersion() {
// expecting return version.unknownVersion() instead of null
assertEquals(Version.unknownVersion(), VersionUtil.versionFor(TestVersionUtil.class));
}
diff --git a/src/test/java/com/fasterxml/jackson/core/write/ArrayGenerationTest.java b/src/test/java/com/fasterxml/jackson/core/write/ArrayGenerationTest.java
index 4ef8acd756..4c7346a852 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/ArrayGenerationTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/ArrayGenerationTest.java
@@ -7,10 +7,15 @@
import com.fasterxml.jackson.core.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
/**
* Basic testing for scalar-array write methods added in 2.8.
*/
-public class ArrayGenerationTest extends BaseTest
+class ArrayGenerationTest extends JUnit5TestBase
{
private final JsonFactory FACTORY = new JsonFactory();
@@ -18,25 +23,29 @@ protected JsonFactory jsonFactory() {
return FACTORY;
}
- public void testIntArray() throws Exception
+ @Test
+ void intArray() throws Exception
{
_testIntArray(false);
_testIntArray(true);
}
- public void testLongArray() throws Exception
+ @Test
+ void longArray() throws Exception
{
_testLongArray(false);
_testLongArray(true);
}
- public void testDoubleArray() throws Exception
+ @Test
+ void doubleArray() throws Exception
{
_testDoubleArray(false);
_testDoubleArray(true);
}
- public void testStringArray() throws Exception
+ @Test
+ void stringArray() throws Exception
{
_testStringArray(false);
_testStringArray(true);
diff --git a/src/test/java/com/fasterxml/jackson/core/write/ArrayWriteTest.java b/src/test/java/com/fasterxml/jackson/core/write/ArrayWriteTest.java
index 72d1c44167..8a922e1086 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/ArrayWriteTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/ArrayWriteTest.java
@@ -4,15 +4,20 @@
import java.io.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
/**
* Set of basic unit tests for verifying that the Array write methods
* of {@link JsonGenerator} work as expected.
*/
-public class ArrayWriteTest
- extends com.fasterxml.jackson.core.BaseTest
+class ArrayWriteTest
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
- public void testEmptyArrayWrite()
- throws Exception
+ @Test
+ void emptyArrayWrite()
+ throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
@@ -36,7 +41,7 @@ public void testEmptyArrayWrite()
gen.writeEndArray();
ctxt = gen.getOutputContext();
- assertTrue("Should be in root, was "+ctxt.typeDesc(), ctxt.inRoot());
+ assertTrue(ctxt.inRoot(), "Should be in root, was "+ctxt.typeDesc());
assertFalse(ctxt.inArray());
assertFalse(ctxt.inObject());
assertEquals(1, ctxt.getEntryCount());
@@ -64,12 +69,13 @@ public void testEmptyArrayWrite()
assertEquals(JsonToken.START_ARRAY, jp.nextToken());
assertEquals(JsonToken.END_ARRAY, jp.nextToken());
assertEquals(JsonToken.END_ARRAY, jp.nextToken());
- assertEquals(null, jp.nextToken());
+ assertNull(jp.nextToken());
jp.close();
}
- public void testInvalidArrayWrite()
- throws Exception
+ @Test
+ void invalidArrayWrite()
+ throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
@@ -84,8 +90,9 @@ public void testInvalidArrayWrite()
gen.close();
}
- public void testSimpleArrayWrite()
- throws Exception
+ @Test
+ void simpleArrayWrite()
+ throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
@@ -104,7 +111,7 @@ public void testSimpleArrayWrite()
assertEquals(JsonToken.VALUE_STRING, jp.nextToken());
assertEquals("foobar", jp.getText());
assertEquals(JsonToken.END_ARRAY, jp.nextToken());
- assertEquals(null, jp.nextToken());
+ assertNull(jp.nextToken());
jp.close();
}
}
diff --git a/src/test/java/com/fasterxml/jackson/core/write/BoundsChecksWithGeneratorTest.java b/src/test/java/com/fasterxml/jackson/core/write/BoundsChecksWithGeneratorTest.java
index 35fe9cc45e..8258cd8037 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/BoundsChecksWithGeneratorTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/BoundsChecksWithGeneratorTest.java
@@ -3,10 +3,14 @@
import java.io.*;
import com.fasterxml.jackson.core.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.exc.StreamWriteException;
-public class BoundsChecksWithGeneratorTest
- extends com.fasterxml.jackson.core.BaseTest
+import static org.junit.jupiter.api.Assertions.fail;
+
+class BoundsChecksWithGeneratorTest
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
final static JsonFactory JSON_F = new JsonFactory();
@@ -69,11 +73,13 @@ public void call(JsonGenerator g, byte[] data, int offset, int len) throws Excep
}
};
- public void testBoundsWithByteArrayInputFromBytes() throws Exception {
+ @Test
+ void boundsWithByteArrayInputFromBytes() throws Exception {
_testBoundsWithByteArrayInput(BYTE_GENERATOR_CREATOR, true);
}
- public void testBoundsWithByteArrayInputFromChars() throws Exception {
+ @Test
+ void boundsWithByteArrayInputFromChars() throws Exception {
_testBoundsWithByteArrayInput(CHAR_GENERATOR_CREATOR, false);
}
@@ -151,11 +157,13 @@ public void call(JsonGenerator g, char[] data, int offset, int len) throws Excep
}
};
- public void testBoundsWithCharArrayInputFromBytes() throws Exception {
+ @Test
+ void boundsWithCharArrayInputFromBytes() throws Exception {
_testBoundsWithCharArrayInput(BYTE_GENERATOR_CREATOR);
}
- public void testBoundsWithCharArrayInputFromChars() throws Exception {
+ @Test
+ void boundsWithCharArrayInputFromChars() throws Exception {
_testBoundsWithCharArrayInput(CHAR_GENERATOR_CREATOR);
}
@@ -221,11 +229,13 @@ public void call(JsonGenerator g, String data, int offset, int len) throws Excep
}
};
- public void testBoundsWithStringInputFromBytes() throws Exception {
+ @Test
+ void boundsWithStringInputFromBytes() throws Exception {
_testBoundsWithStringInput(BYTE_GENERATOR_CREATOR);
}
- public void testBoundsWithStringInputFromChar() throws Exception {
+ @Test
+ void boundsWithStringInputFromChar() throws Exception {
_testBoundsWithStringInput(CHAR_GENERATOR_CREATOR);
}
diff --git a/src/test/java/com/fasterxml/jackson/core/write/GeneratorBasicTest.java b/src/test/java/com/fasterxml/jackson/core/write/GeneratorBasicTest.java
index 701c5adcfc..e9e3d80e3c 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/GeneratorBasicTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/GeneratorBasicTest.java
@@ -3,21 +3,27 @@
import com.fasterxml.jackson.core.*;
import java.io.*;
+
+import static org.junit.jupiter.api.Assertions.*;
+
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.junit.jupiter.api.Test;
+
/**
* Set of basic unit tests for verifying that the basic generator
* functionality works as expected.
*/
public class GeneratorBasicTest
- extends com.fasterxml.jackson.core.BaseTest
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
private final JsonFactory JSON_F = new JsonFactory();
// // // First, tests for primitive (non-structured) values
- public void testStringWrite() throws Exception
+ @Test
+ void stringWrite() throws Exception
{
String[] inputStrings = new String[] { "", "X", "1234567890" };
for (int useReader = 0; useReader < 2; ++useReader) {
@@ -45,17 +51,18 @@ public void testStringWrite() throws Exception
JsonParser jp = JSON_F.createParser(new ByteArrayInputStream(bout.toByteArray()));
JsonToken t = jp.nextToken();
- assertNotNull("Document \""+utf8String(bout)+"\" yielded no tokens", t);
+ assertNotNull(t, "Document \""+utf8String(bout)+"\" yielded no tokens");
assertEquals(JsonToken.VALUE_STRING, t);
assertEquals(input, jp.getText());
- assertEquals(null, jp.nextToken());
+ assertNull(jp.nextToken());
jp.close();
}
}
}
}
- public void testIntValueWrite() throws Exception
+ @Test
+ void intValueWrite() throws Exception
{
// char[]
doTestIntValueWrite(false, false);
@@ -65,7 +72,8 @@ public void testIntValueWrite() throws Exception
doTestIntValueWrite(true, true);
}
- public void testLongValueWrite() throws Exception
+ @Test
+ void longValueWrite() throws Exception
{
// char[]
doTestLongValueWrite(false, false);
@@ -75,7 +83,8 @@ public void testLongValueWrite() throws Exception
doTestLongValueWrite(true, true);
}
- public void testBooleanWrite() throws Exception
+ @Test
+ void booleanWrite() throws Exception
{
for (int i = 0; i < 4; ++i) {
boolean state = (i & 1) == 0;
@@ -95,13 +104,14 @@ public void testBooleanWrite() throws Exception
fail("Expected '"+exp+"', got '"+jp.getText());
}
assertEquals(state ? JsonToken.VALUE_TRUE : JsonToken.VALUE_FALSE, t);
- assertEquals(null, jp.nextToken());
+ assertNull(jp.nextToken());
jp.close();
}
}
- public void testNullWrite()
- throws Exception
+ @Test
+ void nullWrite()
+ throws Exception
{
for (int i = 0; i < 2; ++i) {
boolean pad = (i & 1) == 0;
@@ -120,14 +130,15 @@ public void testNullWrite()
fail("Expected '"+exp+"', got '"+jp.getText());
}
assertEquals(JsonToken.VALUE_NULL, t);
- assertEquals(null, jp.nextToken());
+ assertNull(jp.nextToken());
jp.close();
}
}
// // Then root-level output testing
- public void testRootIntsWrite() throws Exception {
+ @Test
+ void rootIntsWrite() throws Exception {
_testRootIntsWrite(false);
_testRootIntsWrite(true);
}
@@ -167,7 +178,8 @@ private void _testRootIntsWrite(boolean useBytes) throws Exception
// Convenience methods
- public void testFieldValueWrites() throws Exception {
+ @Test
+ void fieldValueWrites() throws Exception {
_testFieldValueWrites(false);
_testFieldValueWrites(true);
}
@@ -204,7 +216,8 @@ public void _testFieldValueWrites(boolean useBytes) throws Exception
/**
* Test to verify that output context actually contains useful information
*/
- public void testOutputContext() throws Exception
+ @Test
+ void outputContext() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = JSON_F.createGenerator(sw);
@@ -272,7 +285,8 @@ public void testOutputContext() throws Exception
gen.close();
}
- public void testGetOutputTarget() throws Exception
+ @Test
+ void getOutputTarget() throws Exception
{
OutputStream out = new ByteArrayOutputStream();
JsonGenerator gen = JSON_F.createGenerator(out);
@@ -286,7 +300,8 @@ public void testGetOutputTarget() throws Exception
}
// for [core#195]
- public void testGetOutputBufferd() throws Exception
+ @Test
+ void getOutputBufferd() throws Exception
{
OutputStream out = new ByteArrayOutputStream();
JsonGenerator gen = JSON_F.createGenerator(out);
@@ -361,7 +376,7 @@ private void doTestIntValueWrite(boolean pad, boolean useBytes) throws Exception
} catch (IOException e) {
fail("Problem with value "+VALUE+", document ["+docStr+"]: "+e.getMessage());
}
- assertNotNull("Document \""+docStr+"\" yielded no tokens", t);
+ assertNotNull(t, "Document \""+docStr+"\" yielded no tokens");
// Number are always available as lexical representation too
String exp = ""+VALUE;
if (!exp.equals(p.getText())) {
@@ -369,7 +384,7 @@ private void doTestIntValueWrite(boolean pad, boolean useBytes) throws Exception
}
assertEquals(JsonToken.VALUE_NUMBER_INT, t);
assertEquals(VALUE, p.getIntValue());
- assertEquals(null, p.nextToken());
+ assertNull(p.nextToken());
p.close();
}
}
@@ -417,14 +432,14 @@ private void doTestLongValueWrite(boolean pad, boolean useBytes) throws Exceptio
} catch (IOException e) {
fail("Problem with number "+VALUE+", document ["+docStr+"]: "+e.getMessage());
}
- assertNotNull("Document \""+docStr+"\" yielded no tokens", t);
+ assertNotNull(t, "Document \""+docStr+"\" yielded no tokens");
String exp = ""+VALUE;
if (!exp.equals(p.getText())) {
fail("Expected '"+exp+"', got '"+p.getText());
}
assertEquals(JsonToken.VALUE_NUMBER_INT, t);
assertEquals(VALUE, p.getLongValue());
- assertEquals(null, p.nextToken());
+ assertNull(p.nextToken());
p.close();
}
}
diff --git a/src/test/java/com/fasterxml/jackson/core/write/GeneratorCloseTest.java b/src/test/java/com/fasterxml/jackson/core/write/GeneratorCloseTest.java
index 50751c79d9..b700346a1a 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/GeneratorCloseTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/GeneratorCloseTest.java
@@ -6,6 +6,10 @@
import java.io.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+import org.junit.jupiter.api.Test;
+
/**
* Set of basic unit tests that verify aspect of closing a
* {@link JsonGenerator} instance. This includes both closing
@@ -18,7 +22,7 @@
* JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT
* are tested.
*/
-public class GeneratorCloseTest extends BaseTest
+class GeneratorCloseTest extends JUnit5TestBase
{
/*
/**********************************************************
@@ -31,7 +35,8 @@ public class GeneratorCloseTest extends BaseTest
* automatic closing should occur, nor explicit one unless specific
* forcing method is used.
*/
- public void testNoAutoCloseGenerator() throws Exception
+ @Test
+ void noAutoCloseGenerator() throws Exception
{
JsonFactory f = new JsonFactory();
@@ -52,7 +57,8 @@ public void testNoAutoCloseGenerator() throws Exception
assertFalse(output.isClosed());
}
- public void testCloseGenerator() throws Exception
+ @Test
+ void closeGenerator() throws Exception
{
JsonFactory f = new JsonFactory();
f.enable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
@@ -68,7 +74,8 @@ public void testCloseGenerator() throws Exception
assertTrue(output.isClosed());
}
- public void testNoAutoCloseOutputStream() throws Exception
+ @Test
+ void noAutoCloseOutputStream() throws Exception
{
JsonFactory f = new JsonFactory();
f.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
@@ -82,8 +89,9 @@ public void testNoAutoCloseOutputStream() throws Exception
assertFalse(output.isClosed());
}
- public void testAutoCloseArraysAndObjects()
- throws Exception
+ @Test
+ void autoCloseArraysAndObjects()
+ throws Exception
{
JsonFactory f = new JsonFactory();
// let's verify default setting, first:
@@ -104,8 +112,9 @@ public void testAutoCloseArraysAndObjects()
assertEquals("{}", sw.toString());
}
- public void testNoAutoCloseArraysAndObjects()
- throws Exception
+ @Test
+ void noAutoCloseArraysAndObjects()
+ throws Exception
{
JsonFactory f = JsonFactory.builder()
.disable(StreamWriteFeature.AUTO_CLOSE_CONTENT)
@@ -126,7 +135,8 @@ public void testNoAutoCloseArraysAndObjects()
}
@SuppressWarnings("resource")
- public void testAutoFlushOrNot() throws Exception
+ @Test
+ void autoFlushOrNot() throws Exception
{
JsonFactory f = new JsonFactory();
assertTrue(f.isEnabled(StreamWriteFeature.FLUSH_PASSED_TO_STREAM));
diff --git a/src/test/java/com/fasterxml/jackson/core/write/GeneratorCopyTest.java b/src/test/java/com/fasterxml/jackson/core/write/GeneratorCopyTest.java
index 0def93b985..bd3207c6d4 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/GeneratorCopyTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/GeneratorCopyTest.java
@@ -5,17 +5,22 @@
import java.io.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
/**
* Set of basic unit tests for verifying that copy-through methods
* of {@link JsonGenerator} work as expected.
*/
-public class GeneratorCopyTest
- extends BaseTest
+class GeneratorCopyTest
+ extends JUnit5TestBase
{
private final JsonFactory JSON_F = sharedStreamFactory();
- public void testCopyRootTokens()
- throws IOException
+ @Test
+ void copyRootTokens()
+ throws IOException
{
JsonFactory jf = JSON_F;
final String DOC = "\"text\\non two lines\" true false 2.0 null 1234567890123 ";
@@ -36,8 +41,9 @@ public void testCopyRootTokens()
assertEquals("\"text\\non two lines\" true false 2.0 null 1234567890123", sw.toString());
}
- public void testCopyArrayTokens()
- throws IOException
+ @Test
+ void copyArrayTokens()
+ throws IOException
{
JsonFactory jf = JSON_F;
final String DOC = "123 [ 1, null, [ false, 1234567890124 ] ]";
@@ -62,8 +68,9 @@ public void testCopyArrayTokens()
assertEquals("123 [1,null,[false,1234567890124]]", sw.toString());
}
- public void testCopyObjectTokens()
- throws IOException
+ @Test
+ void copyObjectTokens()
+ throws IOException
{
JsonFactory jf = JSON_F;
final String DOC = "{ \"a\":1, \"b\":[{ \"c\" : null, \"d\" : 0.25 }] }";
diff --git a/src/test/java/com/fasterxml/jackson/core/write/GeneratorDupHandlingTest.java b/src/test/java/com/fasterxml/jackson/core/write/GeneratorDupHandlingTest.java
index 560bae3869..da2995b3e6 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/GeneratorDupHandlingTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/GeneratorDupHandlingTest.java
@@ -4,25 +4,35 @@
import com.fasterxml.jackson.core.*;
-public class GeneratorDupHandlingTest
- extends com.fasterxml.jackson.core.BaseTest
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.fail;
+
+class GeneratorDupHandlingTest
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
- public void testSimpleDupsEagerlyBytes() throws Exception {
+ @Test
+ void simpleDupsEagerlyBytes() throws Exception {
_testSimpleDups(true, false, new JsonFactory());
}
- public void testSimpleDupsEagerlyChars() throws Exception {
+
+ @Test
+ void simpleDupsEagerlyChars() throws Exception {
_testSimpleDups(false, false, new JsonFactory());
}
// Testing ability to enable checking after construction of
// generator, not just via JsonFactory
- public void testSimpleDupsLazilyBytes() throws Exception {
+ @Test
+ void simpleDupsLazilyBytes() throws Exception {
final JsonFactory f = new JsonFactory();
assertFalse(f.isEnabled(JsonGenerator.Feature.STRICT_DUPLICATE_DETECTION));
_testSimpleDups(true, true, f);
}
- public void testSimpleDupsLazilyChars() throws Exception {
+ @Test
+ void simpleDupsLazilyChars() throws Exception {
final JsonFactory f = new JsonFactory();
_testSimpleDups(false, true, f);
}
diff --git a/src/test/java/com/fasterxml/jackson/core/write/GeneratorMiscTest.java b/src/test/java/com/fasterxml/jackson/core/write/GeneratorMiscTest.java
index 6971de434a..a4e92e7b4c 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/GeneratorMiscTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/GeneratorMiscTest.java
@@ -7,13 +7,17 @@
import com.fasterxml.jackson.core.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* Set of basic unit tests for verifying basic generator
* features.
*/
@SuppressWarnings("resource")
public class GeneratorMiscTest
- extends com.fasterxml.jackson.core.BaseTest
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
private final JsonFactory JSON_F = new JsonFactory();
@@ -23,7 +27,8 @@ public class GeneratorMiscTest
/**********************************************************
*/
- public void testIsClosed() throws IOException
+ @Test
+ void isClosed() throws IOException
{
for (int i = 0; i < 2; ++i) {
boolean stream = ((i & 1) == 0);
@@ -44,7 +49,8 @@ public void testIsClosed() throws IOException
}
// Also, "very simple" objects are supported even without Codec:
- public void testSimpleWriteObject() throws IOException
+ @Test
+ void simpleWriteObject() throws IOException
{
// note: NOT mapping factory, for this test
StringWriter sw = new StringWriter();
@@ -93,7 +99,8 @@ public void testSimpleWriteObject() throws IOException
/**********************************************************
*/
- public void testRaw() throws IOException
+ @Test
+ void raw() throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator gen = JSON_F.createGenerator(sw);
@@ -115,7 +122,8 @@ public void testRaw() throws IOException
jp.close();
}
- public void testRawValue() throws IOException
+ @Test
+ void rawValue() throws IOException
{
StringWriter sw = new StringWriter();
JsonGenerator gen = JSON_F.createGenerator(sw);
@@ -149,7 +157,8 @@ public void testRawValue() throws IOException
/**
* Unit test that tries to trigger buffer-boundary conditions
*/
- public void testLongerObjects() throws Exception
+ @Test
+ void longerObjects() throws Exception
{
_testLongerObjects(JSON_F, 0);
_testLongerObjects(JSON_F, 1);
@@ -234,7 +243,8 @@ public void _testLongerObjects(JsonFactory jf, int mode) throws Exception
*/
// NOTE: test for binary data under `base64/` tests
- public void testAsEmbedded() throws Exception
+ @Test
+ void asEmbedded() throws Exception
{
StringWriter sw = new StringWriter();
try (JsonGenerator g = JSON_F.createGenerator(sw)) {
diff --git a/src/test/java/com/fasterxml/jackson/core/write/ObjectWriteTest.java b/src/test/java/com/fasterxml/jackson/core/write/ObjectWriteTest.java
index 820b6f49db..56a28249aa 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/ObjectWriteTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/ObjectWriteTest.java
@@ -3,15 +3,20 @@
import com.fasterxml.jackson.core.*;
import java.io.*;
+
+import static org.junit.jupiter.api.Assertions.*;
+
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.junit.jupiter.api.Test;
+
/**
* Set of basic unit tests for verifying that the Object write methods
* of {@link JsonGenerator} work as expected.
*/
-public class ObjectWriteTest
- extends BaseTest
+class ObjectWriteTest
+ extends JUnit5TestBase
{
private final JsonFactory FACTORY = new JsonFactory();
@@ -19,8 +24,9 @@ protected JsonFactory jsonFactory() {
return FACTORY;
}
- public void testEmptyObjectWrite()
- throws Exception
+ @Test
+ void emptyObjectWrite()
+ throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = jsonFactory().createGenerator(sw);
@@ -57,12 +63,13 @@ public void testEmptyObjectWrite()
JsonParser jp = createParserUsingReader(docStr);
assertEquals(JsonToken.START_OBJECT, jp.nextToken());
assertEquals(JsonToken.END_OBJECT, jp.nextToken());
- assertEquals(null, jp.nextToken());
+ assertNull(jp.nextToken());
jp.close();
}
- public void testInvalidObjectWrite()
- throws Exception
+ @Test
+ void invalidObjectWrite()
+ throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = jsonFactory().createGenerator(sw);
@@ -77,8 +84,9 @@ public void testInvalidObjectWrite()
gen.close();
}
- public void testSimpleObjectWrite()
- throws Exception
+ @Test
+ void simpleObjectWrite()
+ throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = jsonFactory().createGenerator(sw);
@@ -106,15 +114,16 @@ public void testSimpleObjectWrite()
assertEquals(JsonToken.VALUE_STRING, jp.nextToken());
assertEquals("yee-haw", jp.getText());
assertEquals(JsonToken.END_OBJECT, jp.nextToken());
- assertEquals(null, jp.nextToken());
+ assertNull(jp.nextToken());
jp.close();
}
/**
* Methods to test functionality added for [JACKSON-26]
*/
- public void testConvenienceMethods()
- throws Exception
+ @Test
+ void convenienceMethods()
+ throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = jsonFactory().createGenerator(sw);
@@ -214,15 +223,16 @@ public void testConvenienceMethods()
assertEquals(JsonToken.END_ARRAY, jp.nextToken());
assertEquals(JsonToken.END_OBJECT, jp.nextToken());
- assertEquals(null, jp.nextToken());
+ assertNull(jp.nextToken());
jp.close();
}
/**
* Tests to cover [JACKSON-164]
*/
- public void testConvenienceMethodsWithNulls()
- throws Exception
+ @Test
+ void convenienceMethodsWithNulls()
+ throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = jsonFactory().createGenerator(sw);
diff --git a/src/test/java/com/fasterxml/jackson/core/write/PrettyPrinterTest.java b/src/test/java/com/fasterxml/jackson/core/write/PrettyPrinterTest.java
index 05c91a4bac..e1360882c4 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/PrettyPrinterTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/PrettyPrinterTest.java
@@ -10,13 +10,18 @@
import java.io.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
/**
* Set of basic unit tests for verifying that indenting
* option of generator works correctly
*/
@SuppressWarnings("serial")
-public class PrettyPrinterTest
- extends com.fasterxml.jackson.core.BaseTest
+class PrettyPrinterTest
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
static class CountPrinter extends MinimalPrettyPrinter
{
@@ -43,7 +48,8 @@ public void writeEndArray(JsonGenerator jg, int nrOfValues)
private final JsonFactory JSON_F = sharedStreamFactory();
- public void testObjectCount() throws Exception
+ @Test
+ void objectCount() throws Exception
{
final String EXP = "{\"x\":{\"a\":1,\"b\":2(2)}(1)}";
@@ -68,7 +74,8 @@ public void testObjectCount() throws Exception
}
}
- public void testArrayCount() throws Exception
+ @Test
+ void arrayCount() throws Exception
{
final String EXP = "[6,[1,2,9(3)](2)]";
@@ -94,7 +101,8 @@ public void testArrayCount() throws Exception
}
}
- public void testSimpleDocWithDefault() throws Exception
+ @Test
+ void simpleDocWithDefault() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = JSON_F.createGenerator(sw);
@@ -104,7 +112,8 @@ public void testSimpleDocWithDefault() throws Exception
}
@SuppressWarnings("resource")
- public void testSimpleDocWithMinimal() throws Exception
+ @Test
+ void simpleDocWithMinimal() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = JSON_F.createGenerator(sw);
@@ -132,28 +141,32 @@ public void beforeArrayValues(JsonGenerator jg) throws IOException, JsonGenerati
}
// [core#26]
- public void testRootSeparatorWithoutPP() throws Exception
+ @Test
+ void rootSeparatorWithoutPP() throws Exception
{
// no pretty-printing (will still separate root values with a space!)
assertEquals("{} {} []", _generateRoot(JSON_F, null));
}
-
+
// [core#26]
- public void testDefaultRootSeparatorWithPP() throws Exception
+ @Test
+ void defaultRootSeparatorWithPP() throws Exception
{
assertEquals("{ } { } [ ]", _generateRoot(JSON_F, new DefaultPrettyPrinter()));
}
-
+
// [core#26]
- public void testCustomRootSeparatorWithPPOld() throws Exception
+ @Test
+ void customRootSeparatorWithPPOld() throws Exception
{
@SuppressWarnings("deprecation")
DefaultPrettyPrinter pp = new DefaultPrettyPrinter("|");
assertEquals("{ }|{ }|[ ]", _generateRoot(JSON_F, pp));
}
-
+
// [core#26]
- public void testCustomRootSeparatorWithPPNew() throws Exception
+ @Test
+ void customRootSeparatorWithPPNew() throws Exception
{
Separators separators = Separators.createDefaultInstance()
.withRootSeparator("|");
@@ -162,7 +175,8 @@ public void testCustomRootSeparatorWithPPNew() throws Exception
}
// Alternative solution for [jackson-core#26]
- public void testCustomRootSeparatorWithFactory() throws Exception
+ @Test
+ void customRootSeparatorWithFactory() throws Exception
{
JsonFactory f = ((JsonFactoryBuilder)JsonFactory.builder())
.rootValueSeparator("##")
@@ -176,7 +190,8 @@ public void testCustomRootSeparatorWithFactory() throws Exception
assertEquals("13##false##null", sw.toString());
}
- public void testCustomSeparatorsWithMinimal() throws Exception
+ @Test
+ void customSeparatorsWithMinimal() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = JSON_F.createGenerator(sw);
@@ -204,7 +219,8 @@ public void testCustomSeparatorsWithMinimal() throws Exception
assertEquals("[3|\"abc\"|[true]|{\"f\"=null;\"f2\"=null}]", bytes.toString("UTF-8"));
}
- public void testCustomSeparatorsWithPP() throws Exception
+ @Test
+ void customSeparatorsWithPP() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
@@ -227,8 +243,9 @@ public void testCustomSeparatorsWithPP() throws Exception
" \"f\"=null;" + DefaultIndenter.SYS_LF +
" \"f2\"=null" + DefaultIndenter.SYS_LF +
"} ]";
-
- public void testCustomSeparatorsWithPPWithoutSpacesOld() throws Exception
+
+ @Test
+ void customSeparatorsWithPPWithoutSpacesOld() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
@@ -248,7 +265,8 @@ public void testCustomSeparatorsWithPPWithoutSpacesOld() throws Exception
assertEquals(EXPECTED_CUSTOM_SEPARATORS_WITH_PP_WITHOUT_SPACES, sw.toString());
}
- public void testCustomSeparatorsWithPPWithoutSpacesNew() throws Exception
+ @Test
+ void customSeparatorsWithPPWithoutSpacesNew() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = new JsonFactory().createGenerator(sw);
diff --git a/src/test/java/com/fasterxml/jackson/core/write/RawStringWriteTest.java b/src/test/java/com/fasterxml/jackson/core/write/RawStringWriteTest.java
index dc4828c904..46dec3fd3b 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/RawStringWriteTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/RawStringWriteTest.java
@@ -3,19 +3,23 @@
import java.io.*;
import java.util.*;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.io.SerializedString;
-public class RawStringWriteTest extends com.fasterxml.jackson.core.BaseTest
+class RawStringWriteTest extends com.fasterxml.jackson.core.JUnit5TestBase
{
private final JsonFactory JSON_F = sharedStreamFactory();
/**
* Unit test for "JsonGenerator.writeRawUTF8String()"
*/
- public void testUtf8RawStrings() throws Exception
+ @Test
+ void utf8RawStrings() throws Exception
{
// Let's create set of Strings to output; no ctrl chars as we do raw
List strings = generateStrings(new Random(28), 750000, false);
@@ -47,7 +51,8 @@ public void testUtf8RawStrings() throws Exception
* Unit test for "JsonGenerator.writeUTF8String()", which needs
* to handle escaping properly
*/
- public void testUtf8StringsWithEscaping() throws Exception
+ @Test
+ void utf8StringsWithEscaping() throws Exception
{
// Let's create set of Strings to output; do include control chars too:
List strings = generateStrings(new Random(28), 720000, true);
@@ -78,7 +83,8 @@ public void testUtf8StringsWithEscaping() throws Exception
jp.close();
}
- public void testWriteRawWithSerializable() throws Exception
+ @Test
+ void writeRawWithSerializable() throws Exception
{
_testWriteRawWithSerializable(JSON_F, true);
_testWriteRawWithSerializable(JSON_F, false);
diff --git a/src/test/java/com/fasterxml/jackson/core/write/SerializedStringWriteTest.java b/src/test/java/com/fasterxml/jackson/core/write/SerializedStringWriteTest.java
index cc1366d9a9..9fcd5838e1 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/SerializedStringWriteTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/SerializedStringWriteTest.java
@@ -4,10 +4,15 @@
import java.util.Random;
import com.fasterxml.jackson.core.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.io.SerializedString;
-public class SerializedStringWriteTest
- extends com.fasterxml.jackson.core.BaseTest
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class SerializedStringWriteTest
+ extends com.fasterxml.jackson.core.JUnit5TestBase
{
final static String NAME_WITH_QUOTES = "\"name\"";
final static String NAME_WITH_LATIN1 = "P\u00f6ll\u00f6";
@@ -20,7 +25,8 @@ public class SerializedStringWriteTest
private final SerializedString quotedName = new SerializedString(NAME_WITH_QUOTES);
private final SerializedString latin1Name = new SerializedString(NAME_WITH_LATIN1);
- public void testSimpleFieldNames() throws Exception
+ @Test
+ void simpleFieldNames() throws Exception
{
// First using char-backed generator
StringWriter sw = new StringWriter();
@@ -39,7 +45,8 @@ public void testSimpleFieldNames() throws Exception
_verifySimple(JSON_F.createParser(jsonB));
}
- public void testSimpleValues() throws Exception
+ @Test
+ void simpleValues() throws Exception
{
// First using char-backed generator
StringWriter sw = new StringWriter();
diff --git a/src/test/java/com/fasterxml/jackson/core/write/UTF8GeneratorTest.java b/src/test/java/com/fasterxml/jackson/core/write/UTF8GeneratorTest.java
index 5d63d1bd4d..775435af4c 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/UTF8GeneratorTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/UTF8GeneratorTest.java
@@ -3,6 +3,8 @@
import java.io.*;
import com.fasterxml.jackson.core.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
import com.fasterxml.jackson.core.filter.FilteringGeneratorDelegate;
import com.fasterxml.jackson.core.filter.JsonPointerBasedFilter;
@@ -10,15 +12,18 @@
import com.fasterxml.jackson.core.io.IOContext;
import com.fasterxml.jackson.core.json.UTF8JsonGenerator;
-public class UTF8GeneratorTest extends BaseTest
+import static org.junit.jupiter.api.Assertions.*;
+
+class UTF8GeneratorTest extends JUnit5TestBase
{
private final JsonFactory JSON_F = new JsonFactory();
private final JsonFactory JSON_MAX_NESTING_1 = JsonFactory.builder()
.streamWriteConstraints(StreamWriteConstraints.builder().maxNestingDepth(1).build())
.build();
-
- public void testUtf8Issue462() throws Exception
+
+ @Test
+ void utf8Issue462() throws Exception
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
IOContext ioc = testIOContext();
@@ -45,7 +50,8 @@ public void testUtf8Issue462() throws Exception
p.close();
}
- public void testNestingDepthWithSmallLimit() throws Exception
+ @Test
+ void nestingDepthWithSmallLimit() throws Exception
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
try (JsonGenerator gen = JSON_MAX_NESTING_1.createGenerator(bytes)) {
@@ -59,7 +65,8 @@ public void testNestingDepthWithSmallLimit() throws Exception
}
}
- public void testNestingDepthWithSmallLimitNestedObject() throws Exception
+ @Test
+ void nestingDepthWithSmallLimitNestedObject() throws Exception
{
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
try (JsonGenerator gen = JSON_MAX_NESTING_1.createGenerator(bytes)) {
@@ -74,7 +81,8 @@ public void testNestingDepthWithSmallLimitNestedObject() throws Exception
}
// for [core#115]
- public void testSurrogatesWithRaw() throws Exception
+ @Test
+ void surrogatesWithRaw() throws Exception
{
final String VALUE = q("\ud83d\ude0c");
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -97,7 +105,8 @@ public void testSurrogatesWithRaw() throws Exception
jp.close();
}
- public void testFilteringWithEscapedChars() throws Exception
+ @Test
+ void filteringWithEscapedChars() throws Exception
{
final String SAMPLE_WITH_QUOTES = "\b\t\f\n\r\"foo\"\u0000";
diff --git a/src/test/java/com/fasterxml/jackson/core/write/WriteTypeIdTest.java b/src/test/java/com/fasterxml/jackson/core/write/WriteTypeIdTest.java
index 6defe39bc2..826b379bdf 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/WriteTypeIdTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/WriteTypeIdTest.java
@@ -2,19 +2,20 @@
import java.io.StringWriter;
-import com.fasterxml.jackson.core.BaseTest;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.core.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.type.WritableTypeId;
-public class WriteTypeIdTest
- extends BaseTest
+import static org.junit.jupiter.api.Assertions.*;
+
+class WriteTypeIdTest
+ extends JUnit5TestBase
{
private final JsonFactory JSON_F = sharedStreamFactory();
- public void testNoNativeTypeIdForJson() throws Exception
+ @Test
+ void noNativeTypeIdForJson() throws Exception
{
StringWriter sw = new StringWriter();
JsonGenerator gen = JSON_F.createGenerator(sw);
@@ -28,7 +29,8 @@ public void testNoNativeTypeIdForJson() throws Exception
gen.close();
}
- public void testBasicTypeIdWriteForObject() throws Exception
+ @Test
+ void basicTypeIdWriteForObject() throws Exception
{
final Object data = new Object();
@@ -86,7 +88,8 @@ public void testBasicTypeIdWriteForObject() throws Exception
assertEquals("{\"value\":{\"number\":42},\"extId\":\"typeId\"}", sw.toString());
}
- public void testBasicTypeIdWriteForArray() throws Exception
+ @Test
+ void basicTypeIdWriteForArray() throws Exception
{
final Object data = new Object();
diff --git a/src/test/java/com/fasterxml/jackson/core/write/WriterBasedJsonGeneratorTest.java b/src/test/java/com/fasterxml/jackson/core/write/WriterBasedJsonGeneratorTest.java
index db73860493..bfd82722ca 100644
--- a/src/test/java/com/fasterxml/jackson/core/write/WriterBasedJsonGeneratorTest.java
+++ b/src/test/java/com/fasterxml/jackson/core/write/WriterBasedJsonGeneratorTest.java
@@ -2,19 +2,22 @@
import java.io.StringWriter;
-import com.fasterxml.jackson.core.BaseTest;
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.StreamWriteConstraints;
+import com.fasterxml.jackson.core.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
-public class WriterBasedJsonGeneratorTest extends BaseTest
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+class WriterBasedJsonGeneratorTest extends JUnit5TestBase
{
private final JsonFactory JSON_MAX_NESTING_1 = JsonFactory.builder()
.streamWriteConstraints(StreamWriteConstraints.builder().maxNestingDepth(1).build())
.build();
- public void testNestingDepthWithSmallLimit() throws Exception
+ @Test
+ void nestingDepthWithSmallLimit() throws Exception
{
StringWriter sw = new StringWriter();
try (JsonGenerator gen = JSON_MAX_NESTING_1.createGenerator(sw)) {
@@ -28,7 +31,8 @@ public void testNestingDepthWithSmallLimit() throws Exception
}
}
- public void testNestingDepthWithSmallLimitNestedObject() throws Exception
+ @Test
+ void nestingDepthWithSmallLimitNestedObject() throws Exception
{
StringWriter sw = new StringWriter();
try (JsonGenerator gen = JSON_MAX_NESTING_1.createGenerator(sw)) {