ArgumentParser { @SuppressWarnings({"unchecked"}) public static <T> String createUsage(Class<T> argProxyInterface) { return createUsage(new Class[]{argProxyInterface}); } private  ArgumentParser(); @SuppressWarnings({"unchecked"}) static String createUsage(Class<T> argProxyInterface); static String createUsage(Class<T>... argProxyInterfaces); @SuppressWarnings({"unchecked"}) static boolean validateArguments(String args[], Class<T> argProxyInterface); static boolean validateArguments(String args[], Class<T>... argProxyInterfaces); @SuppressWarnings({"unchecked"}) static String validateArgumentsLoudly(String args[], Class<T> argProxyInterface); static String validateArgumentsLoudly(String args[], Class<T>... argProxyInterfaces); @SuppressWarnings("unchecked") static T parse(String args[], Class<T> argProxyInterface); static String[] filter(String args[], Class<T> argProxyInterface);  }
@Test(expected = IllegalArgumentException.class) public void testZeroMethods() { ArgumentParser.createUsage(ZeroMethods.class); }
@Test(expected = IllegalArgumentException.class) public void testInvalidMethodName() { ArgumentParser.createUsage(InvalidMethodName.class); }
@Test(expected = IllegalArgumentException.class) public void testInvalidReturnType() { ArgumentParser.createUsage(InvalidReturnType.class); }
@Test public void testSimpleArgumentsUsage() { String arguments[] = new String[] {"-encoding charset", "[-iterations num]", "[-alphaNumOpt true|false]"}; String usage = ArgumentParser.createUsage(SimpleArguments.class); int expectedLength = 2; for (String arg : arguments) { assertTrue(usage.contains(arg)); expectedLength += arg.length(); } assertTrue(usage.contains("a charset encoding")); assertTrue(expectedLength < usage.length()); }