13
13
14
14
public class WriteSimpleTest extends TestBase
15
15
{
16
- final static class POJO {
16
+ static class POJO {
17
17
public int value = 3 ;
18
18
19
19
public POJO () { }
@@ -22,12 +22,20 @@ public POJO() { }
22
22
23
23
enum ABC { A , B , C ; }
24
24
25
- final static class Address {
25
+ static class Address {
26
26
public String name ;
27
27
28
28
public Address (String n ) { name = n ; }
29
29
}
30
-
30
+
31
+ static class PathWrapper {
32
+ public Path path ;
33
+
34
+ public PathWrapper (Path p ) {
35
+ path = p ;
36
+ }
37
+ }
38
+
31
39
/*
32
40
/**********************************************************************
33
41
/* Test methdods
@@ -102,18 +110,30 @@ public void testNest() throws Exception
102
110
JSON .std .asString (stuff ));
103
111
}
104
112
105
- public void testKnownSimpleTypes () throws Exception
113
+ public void testKnownSimpleTypeURI () throws Exception
106
114
{
107
115
final String URL_STR = "http://fasterxml.com" ;
108
116
final URI uri = new URI (URL_STR );
109
117
assertEquals (q (URL_STR ), JSON .std .asString (uri ));
118
+ }
119
+
120
+ public void testKnownSimpleTypeFile () throws Exception
121
+ {
110
122
final String PATH = "/foo/bar.txt" ;
111
123
assertEquals (q (PATH ),
112
124
JSON .std .asString (new File (PATH )));
125
+ }
113
126
127
+ public void testKnownSimpleTypePath () throws Exception
128
+ {
114
129
Path p = Paths .get (new URI ("file:///foo/bar.txt" ));
115
130
assertEquals (q ("file:///foo/bar.txt" ), JSON .std .asString (p ));
116
131
132
+ assertEquals (a2q ("{'path':'file:///foo/bar.txt'}" ), JSON .std .asString (new PathWrapper (p )));
133
+ }
134
+
135
+ public void testSimpleEnumTypes () throws Exception
136
+ {
117
137
assertEquals (q ("B" ), JSON .std .asString (ABC .B ));
118
138
assertEquals ("1" , JSON .std .with (Feature .WRITE_ENUMS_USING_INDEX ).asString (ABC .B ));
119
139
}
0 commit comments