Line | |
---|
1 | package movingdialog;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertEquals;
|
---|
4 |
|
---|
5 | import java.util.Arrays;
|
---|
6 | import java.util.Collection;
|
---|
7 |
|
---|
8 | import org.junit.Test;
|
---|
9 | import org.junit.runner.RunWith;
|
---|
10 | import org.junit.runners.Parameterized;
|
---|
11 | import org.junit.runners.Parameterized.Parameters;
|
---|
12 |
|
---|
13 | import com.fasterxml.jackson.core.JsonProcessingException;
|
---|
14 | import com.fasterxml.jackson.databind.ObjectMapper;
|
---|
15 |
|
---|
16 | @RunWith(Parameterized.class)
|
---|
17 | public class JsonSpecialCharsTest {
|
---|
18 | private final ObjectMapper jackson = new ObjectMapper();
|
---|
19 | private Object testobj;
|
---|
20 |
|
---|
21 | @Parameters
|
---|
22 | public static Collection<Object> data() {
|
---|
23 | return Arrays.asList(
|
---|
24 | new Object[] { "'", "!@!!\"\n!$*(&)*(<!>@>", "Goodbye 👋" });
|
---|
25 | }
|
---|
26 |
|
---|
27 | public JsonSpecialCharsTest(Object testobj) {
|
---|
28 | this.testobj = testobj;
|
---|
29 | }
|
---|
30 |
|
---|
31 | @Test
|
---|
32 | public void testSpecialString() throws JsonProcessingException {
|
---|
33 | String str = jackson.writeValueAsString(testobj);
|
---|
34 | System.out.println("" + testobj + "->" + str);
|
---|
35 | assertEquals(testobj, jackson.readValue(str, String.class));
|
---|
36 | }
|
---|
37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.