JsonHandler extends HandlerBase { protected JsonArrayBuilder showArray(int[] iarray) { JsonArrayBuilder aBuilder = Json.createArrayBuilder(); for (int i : iarray) { aBuilder.add(i); } return aBuilder; } JsonHandler();  JsonHandler(String name, String release, int[] date, String note, String rights); @Override void show(); @Override void show(App app); @Override void show(OutputHandler handler); @Override void show(Module module); @Override void show(RepInfo info); @Override void showFooter(); @Override void showHeader();  }
@Test public void testShowArrayInt() throws IOException { final int[] iArrayTest = { 1, 2, 3 }; JsonArrayBuilder b = this.handler.showArray(iArrayTest); buildJson(b); handler.close(); String result = outString.toString(); LOGGER.info(FIND + result); final String expected = "{\"ARRAY\":[1,2,3]}"; assertEquals(expected, result); }
@Test public void testShowArrayDouble() throws IOException { final double[] dArrayTest = { -1.0, 0, 1.0 }; JsonArrayBuilder b = this.handler.showArray(dArrayTest); buildJson(b); handler.close(); String result = outString.toString(); LOGGER.info(FIND + result); final String expected = "{\"ARRAY\":[-1.0,0.0,1.0]}"; assertEquals(expected, result); }
@Test public void testShowArrayString() throws IOException { final String[] sArrayTest = { null, "", "DUMMY" }; JsonArrayBuilder b = this.handler.showArray(sArrayTest); buildJson(b); handler.close(); String result = outString.toString(); LOGGER.info(FIND + result); final String expected = "{\"ARRAY\":[null,\"\",\"DUMMY\"]}"; assertEquals(expected, result); }
@Test public void testShowArrayRational() throws IOException { final Rational[] rArrayTest = { new Rational(1L,1L), new Rational(-1, 2) }; JsonArrayBuilder b = this.handler.showArray(rArrayTest); buildJson(b); handler.close(); String result = outString.toString(); LOGGER.info(FIND + result); final String expected = "{\"ARRAY\":[[1,1],[-1,2]]}"; assertEquals(expected, result); }