1
- package com .fasterxml .jackson .databind ;
1
+ package com .fasterxml .jackson .databind . testutil ;
2
2
3
- import com .fasterxml .jackson .databind .json .JsonMapper ;
4
3
import java .io .IOException ;
4
+ import java .nio .charset .StandardCharsets ;
5
5
import java .util .LinkedHashMap ;
6
6
import java .util .Map ;
7
7
8
+ import com .fasterxml .jackson .databind .*;
9
+ import com .fasterxml .jackson .databind .json .JsonMapper ;
10
+
8
11
/**
9
12
* Class containing test utility methods.
10
13
* The methods are migrated from {@link BaseMapTest} and {@link BaseTest},
14
17
*/
15
18
public class DatabindTestUtil
16
19
{
20
+ /*
21
+ /**********************************************************
22
+ /* Mapper construction helpers
23
+ /**********************************************************
24
+ */
25
+
26
+ public static ObjectMapper newJsonMapper () {
27
+ return new JsonMapper ();
28
+ }
29
+
30
+ public static JsonMapper .Builder jsonMapperBuilder () {
31
+ return JsonMapper .builder ();
32
+ }
17
33
18
34
/*
19
35
/**********************************************************
@@ -31,25 +47,19 @@ public static Map<String,Object> writeAndMap(ObjectMapper m, Object value)
31
47
32
48
/*
33
49
/**********************************************************
34
- /* Construction
50
+ /* Encoding or String representations
35
51
/**********************************************************
36
52
*/
37
53
38
- public static ObjectMapper newJsonMapper ( ) {
39
- return new JsonMapper ( );
54
+ public static String a2q ( String json ) {
55
+ return json . replace ( "'" , " \" " );
40
56
}
41
57
42
- public static JsonMapper . Builder jsonMapperBuilder ( ) {
43
- return JsonMapper . builder () ;
58
+ public static String q ( String str ) {
59
+ return '"' + str + '"' ;
44
60
}
45
61
46
- /*
47
- /**********************************************************
48
- /* Encoding or String representations
49
- /**********************************************************
50
- */
51
-
52
- public static String a2q (String json ) {
53
- return json .replace ("'" , "\" " );
62
+ public static byte [] utf8Bytes (String str ) {
63
+ return str .getBytes (StandardCharsets .UTF_8 );
54
64
}
55
65
}
0 commit comments