From 9335323dae9d106702291d4e310e7d1c2a008417 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Tue, 9 Jun 2020 16:53:03 -0700 Subject: [PATCH] Minor test rearrangement; also test (now) obsolete initial tests for #2066 --- .../EmptyArrayAsNullTest.java | 2 +- .../failing/JDKStringLikeTypes2066Test.java | 98 ------------------- 2 files changed, 1 insertion(+), 99 deletions(-) rename src/test/java/com/fasterxml/jackson/databind/{struct => convert}/EmptyArrayAsNullTest.java (99%) delete mode 100644 src/test/java/com/fasterxml/jackson/failing/JDKStringLikeTypes2066Test.java diff --git a/src/test/java/com/fasterxml/jackson/databind/struct/EmptyArrayAsNullTest.java b/src/test/java/com/fasterxml/jackson/databind/convert/EmptyArrayAsNullTest.java similarity index 99% rename from src/test/java/com/fasterxml/jackson/databind/struct/EmptyArrayAsNullTest.java rename to src/test/java/com/fasterxml/jackson/databind/convert/EmptyArrayAsNullTest.java index 3bad7f9350..ad42a985f8 100644 --- a/src/test/java/com/fasterxml/jackson/databind/struct/EmptyArrayAsNullTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/convert/EmptyArrayAsNullTest.java @@ -1,4 +1,4 @@ -package com.fasterxml.jackson.databind.struct; +package com.fasterxml.jackson.databind.convert; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/src/test/java/com/fasterxml/jackson/failing/JDKStringLikeTypes2066Test.java b/src/test/java/com/fasterxml/jackson/failing/JDKStringLikeTypes2066Test.java deleted file mode 100644 index 2b44e8299e..0000000000 --- a/src/test/java/com/fasterxml/jackson/failing/JDKStringLikeTypes2066Test.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.fasterxml.jackson.failing; - -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.OptBoolean; - -import com.fasterxml.jackson.databind.BaseMapTest; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class JDKStringLikeTypes2066Test extends BaseMapTest -{ - static class UUIDWrapper { - public UUID value; - } - - static class StrictUUIDWrapper { - @JsonFormat(lenient=OptBoolean.FALSE) - public UUID value; - } - - /* - /********************************************************** - /* Test methods - /********************************************************** - */ - - // [databind#2066] - public void testUUIDLeniencyDefault() throws Exception - { - final ObjectMapper MAPPER = objectMapper(); - - // By default, empty String OK - assertNull(MAPPER.readValue(quote(""), UUID.class)); - - UUIDWrapper w = MAPPER.readValue("{\"value\":\"\"}", UUIDWrapper.class); - assertNull(w.value); - } - - // [databind#2066] - public void testUUIDLeniencyGlobal() throws Exception - { - final ObjectMapper STRICT_MAPPER = jsonMapperBuilder() - .defaultLeniency(Boolean.FALSE) - .build(); - try { - STRICT_MAPPER.readValue(quote(""), UUID.class); - fail("Should not pass"); - } catch (Exception e) { - _verifyBadUUID(e); - } - - try { - STRICT_MAPPER.readValue("{\"value\":\"\"}", UUIDWrapper.class); - fail("Should not pass"); - } catch (Exception e) { - _verifyBadUUID(e); - } - } - - // [databind#2066] - public void testUUIDLeniencyByType() throws Exception - { - final ObjectMapper STRICT_MAPPER = jsonMapperBuilder().build(); - STRICT_MAPPER.configOverride(UUID.class) - .setFormat(JsonFormat.Value.forLeniency(false)); - - try { - STRICT_MAPPER.readValue(quote(""), UUID.class); - fail("Should not pass"); - } catch (Exception e) { - _verifyBadUUID(e); - } - - try { - STRICT_MAPPER.readValue("{\"value\":\"\"}", UUIDWrapper.class); - fail("Should not pass"); - } catch (Exception e) { - _verifyBadUUID(e); - } - } - - // [databind#2066] - public void testUUIDLeniencyByProperty() throws Exception - { - final ObjectMapper MAPPER = objectMapper(); - try { - MAPPER.readValue("{\"value\":\"\"}", StrictUUIDWrapper.class); - fail("Should not pass"); - } catch (Exception e) { - _verifyBadUUID(e); - } - } - - private void _verifyBadUUID(Exception e) { - verifyException(e, "foobar"); // TODO: real exception message we want - } -}