### Question:
Main { public static void main(String... args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { if (args.length < 1) { throw new IllegalArgumentException("Usage: Main <subcommand>"); } Class<?> cls = Class.forName(Main.class.getPackage().getName() + "." + args[0]); Method mm = cls.getMethod("main", String[].class); String[] subArgs = Arrays.copyOfRange(args, 1, args.length); mm.invoke(null, (Object) subArgs); }  static void main(String... args);  }### Answer:
@Test(expected = ClassNotFoundException.class) public void unknownClassesAreNotFound() throws Exception { Main.main("UnknownClass"); }
@Test public void knownClassIsFound() throws Exception { Main.main("TestMain"); }
@Test(expected = IOException.class) public void correctArgumentsArePassedToMainMethod() throws Throwable { try { Main.main("TestMain", "arg1", "arg2"); fail(); } catch (InvocationTargetException ite) { throw ite.getCause(); } }
@Test(expected = IllegalArgumentException.class) public void exceptionWhenNoClassIsProvided() throws Exception { Main.main(); }