@Test public void testParse() throws IOException { LOG.info("TEST parse"); ArgsParser parser = new ArgsParser(); Set<String> parameters = new HashSet<String>(); parameters.add("input1"); parameters.add("input3"); parser.setParameters(parameters); LOG.info("TEST good input"); String strCmdLine = "--input1=\"bla\" --input3=\"5\" < file.in > \"file with spaces.out\""; parser.parse(strCmdLine); Map<String, String> mapArgsExpected = new HashMap<String, String>(); mapArgsExpected.put("input1", "bla"); mapArgsExpected.put("input3", "5"); assertEquals(mapArgsExpected, parser.getArguments()); assertEquals("file.in", parser.getStdinFile() ); assertEquals("file with spaces.out", parser.getStdoutFile() ); LOG.info("TEST empty input"); strCmdLine = "--input1=\"bla\" --input3=\"\""; parser.parse(strCmdLine); mapArgsExpected = new HashMap<String, String>(); mapArgsExpected.put("input1", "bla"); mapArgsExpected.put("input3", ""); assertEquals(mapArgsExpected, parser.getArguments()); LOG.info("TEST input with quotes"); strCmdLine = "--input1=\"bla \\\"quoted\\\" bla\""; parser.parse(strCmdLine); mapArgsExpected = new HashMap<String, String>(); mapArgsExpected.put("input1", "bla \"quoted\" bla"); assertEquals(mapArgsExpected, parser.getArguments()); LOG.info("TEST bad input"); strCmdLine = "--input1=\"bla\" --input3 \""; parser.parse(strCmdLine); mapArgsExpected = new HashMap<String, String>(); mapArgsExpected.put("input1", "bla"); assertEquals(mapArgsExpected, parser.getArguments()); LOG.info("TEST other bad input"); strCmdLine = "-input1=\"bla\" --input3 \""; parser.parse(strCmdLine); mapArgsExpected = new HashMap<String, String>(); assertEquals(mapArgsExpected, parser.getArguments()); LOG.info("TEST other bad input concerning stdin"); strCmdLine = "< > file.out"; parser.parse(strCmdLine); assertEquals(null, parser.getStdinFile()); assertEquals(null, parser.getStdoutFile()); LOG.info("TEST other bad input concerning stdout"); strCmdLine = "< file.in >"; parser.parse(strCmdLine); assertEquals("file.in", parser.getStdinFile()); assertEquals(null, parser.getStdoutFile()); }
public void parse(String strCmdLine) throws IOException { mapArguments = new HashMap<String, String>(); strStdinFile = ""; strStdoutFile = ""; tokenizer = new StreamTokenizer( new StringReader(strCmdLine)); root(); }
ArgsParser { public void parse(String strCmdLine) throws IOException { mapArguments = new HashMap<String, String>(); strStdinFile = ""; strStdoutFile = ""; tokenizer = new StreamTokenizer( new StringReader(strCmdLine)); root(); } }
ArgsParser { public void parse(String strCmdLine) throws IOException { mapArguments = new HashMap<String, String>(); strStdinFile = ""; strStdoutFile = ""; tokenizer = new StreamTokenizer( new StringReader(strCmdLine)); root(); }  }
ArgsParser { public void parse(String strCmdLine) throws IOException { mapArguments = new HashMap<String, String>(); strStdinFile = ""; strStdoutFile = ""; tokenizer = new StreamTokenizer( new StringReader(strCmdLine)); root(); }  void parse(String strCmdLine); void setParameters(Set<String> parameters); Map<String, String> getArguments(); String getStdinFile(); String getStdoutFile(); }
ArgsParser { public void parse(String strCmdLine) throws IOException { mapArguments = new HashMap<String, String>(); strStdinFile = ""; strStdoutFile = ""; tokenizer = new StreamTokenizer( new StringReader(strCmdLine)); root(); }  void parse(String strCmdLine); void setParameters(Set<String> parameters); Map<String, String> getArguments(); String getStdinFile(); String getStdoutFile();  }