BoundWriter extends ElementWriter { public void process(Bound bound) { if (legacyBound) { processLegacy(bound); } else { processRegular(bound); } } BoundWriter(String elementName, int indentLevel, boolean legacyBound); void process(Bound bound);  }
@Test public final void testProcess1() { BoundWriter bw = new BoundWriter("bound", 2, true); bw.setWriter(testBufferedWriter); bw.process(new Bound(20.123456, -21.987654, 22.555555, -23.234567, "originstring")); try { testBufferedWriter.flush(); } catch (IOException e) { e.printStackTrace(); fail("IOException"); } String regexMatch = "^\\s*<bound\\s*" + "box=['\"]-23.23457,-21.98765,22.55556,20.12346['\"]\\s*" + "origin=['\"]originstring['\"]/>\\s*$"; assertTrue(testWriter.toString().matches(regexMatch)); }
@Test public final void testProcess2() { BoundWriter bw = new BoundWriter("bound", 2, true); bw.setWriter(testBufferedWriter); bw.process(new Bound(20.123456, -21.987654, 22.555555, -23.234567, "")); try { testBufferedWriter.flush(); } catch (IOException e) { e.printStackTrace(); fail("IOException"); } assertTrue(testWriter.toString().equals("")); }