Skip to content

Commit badad56

Browse files
committed
Minor rewrite of test from #4012, to easy merge to master
1 parent 644a742 commit badad56

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed
Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,26 @@
11
package com.fasterxml.jackson.databind.deser.jdk;
22

3-
import static org.junit.jupiter.api.Assertions.assertThrows;
4-
import com.fasterxml.jackson.core.JsonProcessingException;
5-
import com.fasterxml.jackson.databind.BaseMapTest;
6-
import com.fasterxml.jackson.databind.DeserializationFeature;
7-
import com.fasterxml.jackson.databind.ObjectMapper;
8-
import com.fasterxml.jackson.databind.ObjectReader;
93
import java.util.Locale;
104

5+
import com.fasterxml.jackson.databind.*;
6+
117
// [databind#4009] Locale "" is deserialised as NULL if ACCEPT_EMPTY_STRING_AS_NULL_OBJECT is true
128
public class LocaleDeser4009Test extends BaseMapTest
139
{
14-
15-
static class MyPojo {
16-
public String field;
17-
}
18-
final ObjectMapper mapper = newJsonMapper();
19-
20-
final ObjectReader DISABLED_READER = mapper.reader()
21-
.without(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
22-
23-
final ObjectReader ENABLED_READER = mapper.reader()
24-
.with(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
25-
26-
public void testPOJOWithFeatureDisabled()
27-
{
28-
assertThrows(JsonProcessingException.class, () -> {
29-
DISABLED_READER.readValue("\"\"", MyPojo.class);
30-
});
31-
}
32-
33-
public void testPOJOWithFeatureEnabled() throws Exception
34-
{
35-
assertNull(ENABLED_READER.readValue("\"\"", MyPojo.class));
36-
}
10+
private final ObjectMapper MAPPER = newJsonMapper();
3711

3812
public void testLocaleWithFeatureDisabled() throws Exception
3913
{
40-
assertEquals(Locale.ROOT, DISABLED_READER.readValue("\"\"", Locale.class));
14+
assertEquals(Locale.ROOT,
15+
MAPPER.readerFor(Locale.class)
16+
.without(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)
17+
.readValue("\"\""));
4118
}
4219

4320
public void testLocaleWithFeatureEnabled() throws Exception
4421
{
45-
assertNull(ENABLED_READER.readValue("\"\"", Locale.class));
22+
assertNull(MAPPER.readerFor(Locale.class)
23+
.with(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)
24+
.readValue("\"\""));
4625
}
4726
}

0 commit comments

Comments
 (0)