ConfigurationHandler { public static Object read(String value) throws IOException { try (UnsyncStringReader unsyncStringReader = new UnsyncStringReader( value); PushbackReader pushbackReader = new PushbackReader( unsyncStringReader, 1)) { return _readValue(pushbackReader); } }  static Object read(String value); static String write(Object value);  }
@Test public void testReadArray() throws IOException { Assert.assertArrayEquals( new String[] {"test1", "test2"}, (String[])ConfigurationHandler.read( "[ \\\r\n \"test1\", \\\r\n \"test2\", \\\r\n ]")); }
@Test public void testReadArrayNoLineBreaks() throws IOException { Assert.assertArrayEquals( new String[] {"test1", "test2"}, (String[])ConfigurationHandler.read("[\"test1\", \"test2\"]")); }
@Test public void testReadBoolean() throws IOException { Assert.assertEquals(true, ConfigurationHandler.read("B\"true\"")); Assert.assertEquals(true, ConfigurationHandler.read("b\"true\"")); }
@Test public void testReadByte() throws IOException { Assert.assertEquals((byte)1, ConfigurationHandler.read("X\"1\"")); Assert.assertEquals((byte)1, ConfigurationHandler.read("x\"1\"")); }
@Test public void testReadChar() throws IOException { Assert.assertEquals('A', ConfigurationHandler.read("C\"A\"")); Assert.assertEquals('A', ConfigurationHandler.read("c\"A\"")); }
@Test public void testReadCollection() throws IOException { Assert.assertEquals( new ArrayList<String>() { { add("test1"); add("test2"); } }, ConfigurationHandler.read( "( \\\r\n \"test1\", \\\r\n \"test2\", \\\r\n)")); }
@Test public void testReadCollectionNoLineBreaks() throws IOException { Assert.assertEquals( new ArrayList<String>() { { add("test1"); add("test2"); } }, ConfigurationHandler.read("(\"test1\", \"test2\",)")); }
@Test public void testReadDouble() throws IOException { Assert.assertEquals(12.2D, ConfigurationHandler.read("D\"12.2\"")); Assert.assertEquals(12.2D, ConfigurationHandler.read("d\"12.2\"")); Assert.assertEquals( 12.2D, ConfigurationHandler.read("D\"4623057607486498406\"")); }
@Test public void testReadEmptyCollection() throws IOException { Assert.assertEquals( new ArrayList<String>(), ConfigurationHandler.read("( \\\r\n)")); }
@Test public void testReadFloat() throws IOException { Assert.assertEquals(12.2F, ConfigurationHandler.read("F\"12.2\"")); Assert.assertEquals(12.2F, ConfigurationHandler.read("f\"12.2\"")); Assert.assertEquals( 12.2F, ConfigurationHandler.read("F\"1094923059\"")); }
@Test public void testReadInteger() throws IOException { Assert.assertEquals(20, ConfigurationHandler.read("I\"20\"")); Assert.assertEquals(20, ConfigurationHandler.read("i\"20\"")); }
@Test public void testReadInvalidCollection() throws IOException { Assert.assertEquals(null, ConfigurationHandler.read("(test)")); }
@Test public void testReadInvalidType() throws IOException { Assert.assertEquals(null, ConfigurationHandler.read("Z\"test\"")); }
@Test public void testReadLong() throws IOException { Assert.assertEquals(30L, ConfigurationHandler.read("L\"30\"")); Assert.assertEquals(30L, ConfigurationHandler.read("l\"30\"")); }
@Test public void testReadShort() throws IOException { Assert.assertEquals((short)2, ConfigurationHandler.read("S\"2\"")); Assert.assertEquals((short)2, ConfigurationHandler.read("s\"2\"")); }
@Test public void testReadSimpleString() throws IOException { Assert.assertEquals("test", ConfigurationHandler.read("\"test\"")); }
@Test public void testReadSpecial() throws IOException { Assert.assertEquals( "\b\t\n\f\r+a", ConfigurationHandler.read("\"\\b\\t\\n\\f\\r\\u002B\\a\"")); }
@Test public void testReadString() throws IOException { Assert.assertEquals("test", ConfigurationHandler.read("T\"test\"")); }
@Test public void testReadStringWithWhitespace() throws IOException { Assert.assertEquals( "test", ConfigurationHandler.read(" \r\n\r\"test\"")); }
@Test public void testReadTypedArray() throws IOException { Assert.assertArrayEquals( new Integer[] {1, 2}, (Integer[])ConfigurationHandler.read( "I[ \\\r\n \"1\", \\\r\n \"2\", \\\r\n ]")); }
@Test public void testReadTypedCollection() throws IOException { Assert.assertEquals( new ArrayList<Integer>() { { add(1); add(2); } }, ConfigurationHandler.read( "I( \\\r\n \"1\", \\\r\n \"2\", \\\r\n)")); }