@Test public void testDecodeArray() { Assert.assertTrue(TempletonUtils.encodeArray((String[]) null) == null); String[] tmp = new String[3]; tmp[0] = "fred"; tmp[1] = null; tmp[2] = "peter,lisa,, barney"; String[] tmp2 = TempletonUtils.decodeArray(TempletonUtils.encodeArray(tmp)); try { for (int i = 0; i < tmp.length; i++) { Assert.assertEquals((String) tmp[i], (String) tmp2[i]); } } catch (Exception e) { Assert.fail("Arrays were not equal" + e.getMessage()); } }
@Test public void testEncodeArray() { Assert.assertEquals(null, TempletonUtils.encodeArray((String[]) null)); String[] tmp = new String[0]; Assert.assertTrue(TempletonUtils.encodeArray(new String[0]).length() == 0); tmp = new String[3]; tmp[0] = "fred"; tmp[1] = null; tmp[2] = "peter,lisa,, barney"; Assert.assertEquals( "fred,,peter" + StringUtils.ESCAPE_CHAR + ",lisa" + StringUtils.ESCAPE_CHAR + "," + StringUtils.ESCAPE_CHAR + ", barney", TempletonUtils.encodeArray(tmp)); }