-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathReflection4907Jackson3Test.java
More file actions
103 lines (85 loc) · 2.79 KB
/
Reflection4907Jackson3Test.java
File metadata and controls
103 lines (85 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package tools.jackson.databind.misc;
import org.junit.jupiter.api.Test;
import tools.jackson.databind.*;
import tools.jackson.databind.testutil.DatabindTestUtil;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.util.Arrays;
import java.util.List;
public class Reflection4907Jackson3Test extends DatabindTestUtil
{
static class SqlDatePojo {
public String name;
public java.sql.Date date;
public List<String> tags;
public SqlDatePojo() {
}
public SqlDatePojo(String name, java.sql.Date date, String... tags) {
this.name = name;
this.date = date;
this.tags = Arrays.asList(tags);
}
public SqlDatePojo(java.sql.Date date) {
this.date = date;
}
public java.sql.Date getDate() {
return date;
}
public void setDate(java.sql.Date date) {
this.date = date;
}
public List<String> getTags() {
return tags;
}
}
private final ObjectMapper MAPPER = newJsonMapper();
@Test
public void test4907ReadPojo() throws Exception {
System.err.println("<testReadPojo>");
SqlDatePojo pojo = MAPPER.readValue(a2q("{'date':'2000-01-01', 'name':'foo'}"),
SqlDatePojo.class);
System.err.println("</testReadPojo>");
assertNotNull(pojo);
}
@Test
public void test4907WritePojo() throws Exception {
System.err.println("<testWritePojo>");
String json = MAPPER.writeValueAsString(new SqlDatePojo("foobar",
java.sql.Date.valueOf("2000-01-01"), "abc", "def"));
System.err.println("</testWritePojo>");
assertNotNull(json);
}
/*
@Test
public void test4907ReadTags() throws Exception {
System.err.println("<testReadTags>");
List<?> tags = MAPPER.readValue(a2q("['abc', 'def']"),
List.class);
System.err.println("</testReadTags>");
assertNotNull(tags);
}
@Test
public void test4907WriteTags() throws Exception {
System.err.println("<testWriteTags>");
String json = MAPPER.writeValueAsString(Arrays.asList("abc", "def"));
System.err.println("</testWriteTags>");
assertNotNull(json);
}
*/
/*
@Test
public void test4907ReadDate() throws Exception {
System.err.println("<testReadDate>");
java.sql.Date date = MAPPER.readValue(a2q("'2000-01-01'"),
java.sql.Date.class);
System.err.println("</testReadDate>");
assertNotNull(date);
}
@Test
public void test4907WriteDate() throws Exception {
System.err.println("<testWriteDate>");
String json = MAPPER.writeValueAsString(java.sql.Date.valueOf("2000-01-01"));
System.err.println("</testWriteDate>");
assertNotNull(json);
}
*/
}