package movingdialog; import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(Parameterized.class) public class JsonSpecialCharsTest { private final ObjectMapper jackson = new ObjectMapper(); private Object testobj; @Parameters public static Collection data() { return Arrays.asList( new Object[] { "'", "!@!!\"\n!$*(&)*(@>", "Goodbye 👋" }); } public JsonSpecialCharsTest(Object testobj) { this.testobj = testobj; } @Test public void testSpecialString() throws JsonProcessingException { String str = jackson.writeValueAsString(testobj); System.out.println("" + testobj + "->" + str); assertEquals(testobj, jackson.readValue(str, String.class)); } }