|
4 | 4 |
|
5 | 5 | import com.fasterxml.jackson.annotation.JsonProperty;
|
6 | 6 | import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
| 7 | + |
7 | 8 | import com.fasterxml.jackson.databind.ObjectMapper;
|
| 9 | + |
8 | 10 | import com.fasterxml.jackson.module.afterburner.AfterburnerTestBase;
|
9 | 11 |
|
10 |
| -public class TestSimpleDeserialize extends AfterburnerTestBase |
| 12 | +public class BasicDeserializeTest extends AfterburnerTestBase |
11 | 13 | {
|
12 | 14 | public enum MyEnum {
|
13 | 15 | A, B, C;
|
@@ -143,6 +145,23 @@ static class Issue60Pojo {
|
143 | 145 | public List<Object> foos;
|
144 | 146 | }
|
145 | 147 |
|
| 148 | + // [modules-base#123]: fluent method(s) |
| 149 | + public static class Model123 { |
| 150 | + int value = 10; |
| 151 | + |
| 152 | + protected Model123() { } |
| 153 | + public Model123(int v) { value = v; } |
| 154 | + |
| 155 | + public int getValue() { |
| 156 | + return value; |
| 157 | + } |
| 158 | + |
| 159 | + public Model123 setValue(int value) { |
| 160 | + this.value = value; |
| 161 | + return this; |
| 162 | + } |
| 163 | + } |
| 164 | + |
146 | 165 | /*
|
147 | 166 | /**********************************************************************
|
148 | 167 | /* Test methods, method access
|
@@ -325,38 +344,13 @@ public void testProblemWithIndentation() throws Exception {
|
325 | 344 | assertEquals(0, pojo.foos.size());
|
326 | 345 | }
|
327 | 346 |
|
328 |
| - // 28-Sep-2019, tatu: I do not fully understand what this method tried to do; |
329 |
| - // it seemed to be a contribution from July 2016. But I noticed that it breaks |
330 |
| - // with JDK 12 and unlikely to be allowed so let's comment it out. |
331 |
| - /* |
| 347 | + // [modules-base#123] |
| 348 | + public void testFluentMethod() throws Exception |
| 349 | + { |
| 350 | + String json = MAPPER.writeValueAsString(new Model123(28)); |
332 | 351 |
|
333 |
| - static class CheckGeneratedDeserializerName { |
334 |
| - public String stringField; |
335 |
| - } |
336 |
| - |
337 |
| - @SuppressWarnings("unchecked") |
338 |
| - public void testGeneratedDeserializerName() throws Exception { |
339 |
| - MAPPER.readValue("{\"stringField\":\"foo\"}", CheckGeneratedDeserializerName.class); |
340 |
| - ClassLoader cl = getClass().getClassLoader(); |
341 |
| - Field declaredField = ClassLoader.class.getDeclaredField("classes"); |
342 |
| - declaredField.setAccessible(true); |
343 |
| - // 06-Sep-2017, tatu: Hmmh. Whatever this code does... is not very robust. |
344 |
| - // But has to do for now. OpenJDK 7 had issues with size, increased: |
345 |
| - Class<?>[] os = new Class[8192]; |
346 |
| - ((Vector<Class<?>>) declaredField.get(cl)).copyInto(os); |
347 |
| -
|
348 |
| - String expectedClassName = TestSimpleDeserialize.class.getCanonicalName() |
349 |
| - + "$CheckGeneratedDeserializerName$Access4JacksonDeserializer"; |
350 |
| - for (Class<?> clz : os) { |
351 |
| - if (clz == null) { |
352 |
| - break; |
353 |
| - } |
354 |
| - if (clz.getCanonicalName() != null |
355 |
| - && clz.getCanonicalName().startsWith(expectedClassName)) { |
356 |
| - return; |
357 |
| - } |
358 |
| - } |
359 |
| - fail("Expected class not found:" + expectedClassName); |
| 352 | + Model123 result = MAPPER.readValue(json, Model123.class); |
| 353 | + assertNotNull(result); |
| 354 | + assertEquals(28, result.value); |
360 | 355 | }
|
361 |
| - */ |
362 | 356 | }
|
0 commit comments