source: PerfectFit/Dialog/src/test/java/movingdialog/JsonSpecialCharsTest.java

Last change on this file was 7, checked in by Wouter Pasman, 9 months ago

#124 release PerfectFit sources

File size: 1005 bytes
Line 
1package movingdialog;
2
3import static org.junit.Assert.assertEquals;
4
5import java.util.Arrays;
6import java.util.Collection;
7
8import org.junit.Test;
9import org.junit.runner.RunWith;
10import org.junit.runners.Parameterized;
11import org.junit.runners.Parameterized.Parameters;
12
13import com.fasterxml.jackson.core.JsonProcessingException;
14import com.fasterxml.jackson.databind.ObjectMapper;
15
16@RunWith(Parameterized.class)
17public 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.