@Test public void testRequiredArgs() throws Exception { NoHandleApplicationOptionHandler handler = new NoHandleApplicationOptionHandler(); YarnClusterInfoCommand command = new YarnClusterInfoCommand(handler); command.run("-a", "aaa", "-c", "ccc"); assertThat(handler.output, is("output")); }
@Test public void testCustomOptionHandlerFailure() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expectMessage(is("no jee")); CustomClusterInfoOptionHandler handler = new CustomClusterInfoOptionHandler(); YarnClusterInfoCommand command = new YarnClusterInfoCommand(handler); command.run("-a", "foo"); }
@Test public void testFailureNoArgs() throws Exception { thrown.expect(IllegalStateException.class); thrown.expectMessage(containsString("Cluster Id and Application Id must be defined")); NoRunClusterInfoOptionHandler handler = new NoRunClusterInfoOptionHandler(); YarnClusterInfoCommand command = new YarnClusterInfoCommand(handler); command.run(new String[0]); }
@Test public void testShouldNotFail() throws Exception { NoRunClusterInfoOptionHandler handler = new NoRunClusterInfoOptionHandler(); YarnClusterInfoCommand command = new YarnClusterInfoCommand(handler); command.run("-a", "xxx", "-c", "xxx", "-v"); }