public void testFormatFooter() { JSONRowFormatter fmtr = new JSONRowFormatter(); Date now = Calendar.getInstance().getTime(); DateFormat dateFormatter = new SimpleDateFormat("yyyy.MM.dd HH:mm::ss"); String executionTime = dateFormatter.format(now); String expected = "],\"executionTime\":\"" + executionTime + "\",\"wasSuccessful\":true,\"error\":null,\"statusCode\":200}"; assertEquals(expected, fmtr.formatFooter(null, 200)); expected = "],\"executionTime\":\"" + executionTime + "\",\"wasSuccessful\":false,\"error\":\"Not feeling like it\"," + "\"statusCode\":400}"; assertEquals(expected, fmtr.formatFooter("Not feeling like it", 400)); expected += ");"; attributes.put(JSONRowFormatter.KEY_CALLBACK, "should_not_appear_in_footer"); fmtr.formatHeader(attributes); // needs to be called to set the callback parameter assertEquals(expected, fmtr.formatFooter("Not feeling like it", 400)); }