ConfigurationHandler { public static String write(Object value) throws IOException { UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(); _writeValue(unsyncStringWriter, value); return unsyncStringWriter.toString(); }  static Object read(String value); static String write(Object value);  }
@Test public void testWriteArray() throws IOException { Assert.assertEquals( "[ \\\r\n \"test1\", \\\r\n \"test2\", \\\r\n ]", ConfigurationHandler.write(new String[] {"test1", "test2"})); }
@Test public void testWriteBlank() throws IOException { Assert.assertEquals( "\"\"", ConfigurationHandler.write(StringPool.BLANK)); }
@Test public void testWriteBoolean() throws IOException { Assert.assertEquals("B\"true\"", ConfigurationHandler.write(true)); }
@Test public void testWriteByte() throws IOException { Assert.assertEquals( "X\"1\"", ConfigurationHandler.write(Byte.valueOf("1"))); }
@Test public void testWriteChar() throws IOException { Assert.assertEquals("C\"A\"", ConfigurationHandler.write('A')); }
@Test public void testWriteCollection() throws IOException { Assert.assertEquals( "( \\\r\n \"test1\", \\\r\n \"test2\", \\\r\n)", ConfigurationHandler.write( new ArrayList<String>() { { add("test1"); add("test2"); } })); }
@Test public void testWriteDouble() throws IOException { Assert.assertEquals("D\"12.2\"", ConfigurationHandler.write(12.2D)); }
@Test public void testWriteEmptyArray() throws IOException { Assert.assertEquals( "[ \\\r\n ]", ConfigurationHandler.write(new String[0])); }
@Test public void testWriteEmptyCollection() throws IOException { Assert.assertEquals( "( \\\r\n)", ConfigurationHandler.write(new ArrayList())); }
@Test public void testWriteEscaped() throws IOException { Assert.assertEquals( "\"\\{\"", ConfigurationHandler.write(StringPool.OPEN_CURLY_BRACE)); Assert.assertEquals( "\"\\\\\"", ConfigurationHandler.write(StringPool.BACK_SLASH)); Assert.assertEquals( "\"\\=\"", ConfigurationHandler.write(StringPool.EQUAL)); Assert.assertEquals( "\"\\\"\"", ConfigurationHandler.write(StringPool.QUOTE)); Assert.assertEquals( "\"\\ \"", ConfigurationHandler.write(StringPool.SPACE)); Assert.assertEquals( "\"\\}\"", ConfigurationHandler.write(StringPool.CLOSE_CURLY_BRACE)); Assert.assertEquals("\"\\b\"", ConfigurationHandler.write("\b")); Assert.assertEquals( "\"\\t\"", ConfigurationHandler.write(StringPool.TAB)); Assert.assertEquals( "\"\\n\"", ConfigurationHandler.write(StringPool.NEW_LINE)); Assert.assertEquals("\"\\f\"", ConfigurationHandler.write("\f")); Assert.assertEquals( "\"\\r\"", ConfigurationHandler.write(StringPool.RETURN)); char c = CharPool.SPACE - 1; Assert.assertEquals("C\"\\u001f\"", ConfigurationHandler.write(c)); }
@Test public void testWriteFloat() throws IOException { Assert.assertEquals("F\"12.2\"", ConfigurationHandler.write(12.2F)); }
@Test public void testWriteInteger() throws IOException { Assert.assertEquals("I\"20\"", ConfigurationHandler.write(20)); }
@Test public void testWriteLong() throws IOException { Assert.assertEquals("L\"30\"", ConfigurationHandler.write(30L)); }
@Test public void testWriteObject() throws IOException { Assert.assertEquals( "\"testValue\"", ConfigurationHandler.write( new Object() { @Override public String toString() { return "testValue"; } })); }
@Test public void testWriteShort() throws IOException { Assert.assertEquals("S\"2\"", ConfigurationHandler.write((short)2)); }
@Test public void testWriteString() throws IOException { Assert.assertEquals("\"test\"", ConfigurationHandler.write("test")); }
@Test public void testWriteTypedArray() throws IOException { Assert.assertEquals( "B[ \\\r\n \"true\", \\\r\n ]", ConfigurationHandler.write(new Boolean[] {true})); }
@Test public void testWriteTypedCollection() throws IOException { Assert.assertEquals( "I( \\\r\n \"1\", \\\r\n \"2\", \\\r\n)", ConfigurationHandler.write( new ArrayList<Integer>() { { add(1); add(2); } })); }