EnvelopeMain { public static void main(String[] args) throws Exception { if (args.length < 1) { throw new RuntimeException("Missing pipeline configuration file argument."); } else { Path p = Paths.get(args[0]); if (Files.notExists(p) || Files.isDirectory(p)) { throw new RuntimeException("Can't access pipeline configuration file '" + args[0] + "'."); } } LOG.info("Envelope application started"); Config config = ConfigUtils.configFromPath(args[0]); if (args.length == 2) { config = ConfigUtils.applySubstitutions(config, args[1]); } else if (args.length > 2) { LOG.error("Too many parameters to Envelope application"); } else { config = ConfigUtils.applySubstitutions(config); } LOG.info("Configuration loaded"); Runner runner = new Runner(); runner.run(config); }  static void main(String[] args);  }
@Test public void testMainNoConfig() throws Exception { thrown.expect(RuntimeException.class); thrown.expectMessage("Missing"); String[] empty = {}; EnvelopeMain.main(empty); }
@Test public void testMainBadConfig() throws Exception { thrown.expect(RuntimeException.class); thrown.expectMessage("Can't access"); String[] conf = { "xxx.conf" }; EnvelopeMain.main(conf); }
@Test public void testMainGoodConfig() throws Exception { Path p = Files.createTempFile("TestEnvelopeMain", null ) ; Files.write(p,"application {}\nsteps{}".getBytes()) ; p.toFile().deleteOnExit(); String[] conf = { p.toString() }; EnvelopeMain.main(conf); }