diff --git a/src/test/java/com/fasterxml/jackson/databind/BaseTest.java b/src/test/java/com/fasterxml/jackson/databind/BaseTest.java index c3e8d534c9..bd234fd05e 100644 --- a/src/test/java/com/fasterxml/jackson/databind/BaseTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/BaseTest.java @@ -7,8 +7,6 @@ import com.fasterxml.jackson.core.*; -//import static org.junit.Assert.*; - public abstract class BaseTest extends TestCase { @@ -45,89 +43,6 @@ public abstract class BaseTest +"}" ; - /* - /********************************************************** - /* 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; - } - } - /* /********************************************************** /* High-level helpers @@ -316,7 +231,7 @@ protected JsonParser createParserUsingStream(JsonFactory f, /********************************************************** */ - protected final static byte[] jdkSerialize(Object o) + protected static byte[] jdkSerialize(Object o) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(2000); try (ObjectOutputStream obOut = new ObjectOutputStream(bytes)) { @@ -329,7 +244,7 @@ protected final static byte[] jdkSerialize(Object o) } @SuppressWarnings("unchecked") - protected final static T jdkDeserialize(byte[] raw) + protected static T jdkDeserialize(byte[] raw) { try (ObjectInputStream objIn = new ObjectInputStream(new ByteArrayInputStream(raw))) { return (T) objIn.readObject(); @@ -386,7 +301,7 @@ public static void verifyException(Throwable e, String... anyMatches) String lmsg = (msg == null) ? "" : msg.toLowerCase(); for (String match : anyMatches) { String lmatch = match.toLowerCase(); - if (lmsg.indexOf(lmatch) >= 0) { + if (lmsg.contains(lmatch)) { return; } } @@ -442,18 +357,9 @@ public static String q(String str) { return '"'+str+'"'; } - @Deprecated // use q - public String quote(String str) { - return q(str); - } - // `public` since 2.16, was only `protected` before then. public static String a2q(String json) { return json.replace("'", "\""); } - @Deprecated // use a2q - protected static String aposToQuotes(String json) { - return a2q(json); - } } diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/merge/PropertyMergeTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/merge/PropertyMergeTest.java index ce09d7e91b..8d74a1d9b8 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/merge/PropertyMergeTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/merge/PropertyMergeTest.java @@ -1,5 +1,6 @@ package com.fasterxml.jackson.databind.deser.merge; +import com.fasterxml.jackson.databind.testutil.FiveMinuteUser; import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.annotation.*; @@ -71,15 +72,6 @@ static class MergedReference public StringReference value = new StringReference("default"); } - static class MergedX - { - @JsonMerge - public T value; - - public MergedX(T v) { value = v; } - protected MergedX() { } - } - // // // Classes with invalid merge definition(s) static class CantMergeInts { diff --git a/src/test/java/com/fasterxml/jackson/databind/testutil/FiveMinuteUser.java b/src/test/java/com/fasterxml/jackson/databind/testutil/FiveMinuteUser.java new file mode 100644 index 0000000000..57ae609d07 --- /dev/null +++ b/src/test/java/com/fasterxml/jackson/databind/testutil/FiveMinuteUser.java @@ -0,0 +1,80 @@ +package com.fasterxml.jackson.databind.testutil; + +/** + * Sample class from Jackson tutorial ("JacksonInFiveMinutes") + */ +public 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; + } +} +