### Question:
Launcher { protected void parse(String[] args) throws ParameterException { JCommander jc = new JCommander(this); jc.parse(args); if (this.help || args.length < 1) { jc.usage(); } }  static void main(String[] args);  }### Answer:
@Test public void testParseFile() { try { String[] args = new String[]{ "-c", "file.xml" }; Launcher l = new Launcher(); l.parse(args); assertEquals(new File("file.xml"), l.config); } catch(Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testParseDouble() { try { String[] args = new String[]{ "-e", "8.33" }; Launcher l = new Launcher(); l.parse(args); assertEquals(8.33, l.extent, 0.0000001); } catch(Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testParseCoordinate() { try { String[] args = new String[]{ "-ce", "48.5,11.5" }; Launcher l = new Launcher(); l.parse(args); assertEquals(new Coordinate(48.5, 11.5), l.center); } catch(Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
@Test public void testParseFileFail() { try { String[] args = new String[]{ "-c", "file:?.xml" }; Launcher l = new Launcher(); l.parse(args); } catch(ParameterException e) { } catch(Exception e) { fail(e.getMessage()); } }
@Test public void testParseDoubleFail() { try { String[] args = new String[]{ "-e", "eight.33" }; Launcher l = new Launcher(); l.parse(args); fail("Should have thrown Exception!"); } catch(ParameterException e) { } catch(Exception e) { fail(e.getMessage()); } }
@Test public void testParseCoordinateFail() { try { String[] args = new String[]{ "-ce", "48.5,", "11.5" }; Launcher l = new Launcher(); l.parse(args); fail("Should have thrown Exception!"); } catch(ParameterException e) { } catch(Exception e) { fail(e.getMessage()); } }