| | |
| | | |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | /** |
| | |
| | | @Test |
| | | public void testAllowsTrailingArgumentsFalse1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", 1000); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", Message.raw("XXX")); |
| | | Assert.assertFalse(sc.allowsTrailingArguments()); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testAllowsTrailingArgumentsFalse2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, |
| | | 2000); |
| | | Message.raw("XXX")); |
| | | Assert.assertFalse(sc.allowsTrailingArguments()); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testAllowsTrailingArgumentsTrue() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, |
| | | "args1 arg2 [arg3 arg4]", 2000); |
| | | "args1 arg2 [arg3 arg4]", Message.raw("XXX")); |
| | | Assert.assertTrue(sc.allowsTrailingArguments()); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetMaxTrailingArguments1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", 1000); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", Message.raw("XXX")); |
| | | Assert.assertEquals(sc.getMaxTrailingArguments(), 0); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetMaxTrailingArguments2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, |
| | | 2000); |
| | | Message.raw("XXX")); |
| | | Assert.assertEquals(sc.getMaxTrailingArguments(), 0); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetMaxTrailingArguments3() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, |
| | | "args1 arg2 [arg3 arg4]", 2000); |
| | | "args1 arg2 [arg3 arg4]", Message.raw("XXX")); |
| | | Assert.assertEquals(sc.getMaxTrailingArguments(), 4); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetMinTrailingArguments1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", 1000); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", Message.raw("XXX")); |
| | | Assert.assertEquals(sc.getMinTrailingArguments(), 0); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetMinTrailingArguments2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, |
| | | 2000); |
| | | Message.raw("XXX")); |
| | | Assert.assertEquals(sc.getMinTrailingArguments(), 0); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetMinTrailingArguments3() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, |
| | | "args1 arg2 [arg3 arg4]", 2000); |
| | | "args1 arg2 [arg3 arg4]", Message.raw("XXX")); |
| | | Assert.assertEquals(sc.getMinTrailingArguments(), 2); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetTrailingArgumentsDisplayName1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", 1000); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", Message.raw("XXX")); |
| | | Assert.assertNull(sc.getTrailingArgumentsDisplayName()); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetTrailingArgumentsDisplayName2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, |
| | | 2000); |
| | | Message.raw("XXX")); |
| | | Assert.assertNull(sc.getTrailingArgumentsDisplayName()); |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void testGetTrailingArgumentsDisplayName3() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, |
| | | "args1 arg2 [arg3 arg4]", 2000); |
| | | "args1 arg2 [arg3 arg4]", Message.raw("XXX")); |
| | | Assert.assertEquals(sc.getTrailingArgumentsDisplayName(), |
| | | "args1 arg2 [arg3 arg4]"); |
| | | } |
| | |
| | | @Test |
| | | public void testGetTrailingArguments1() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", 1000); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command1", Message.raw("XXX")); |
| | | parser.parseArguments(new String[] { "sub-command1" }); |
| | | Assert.assertTrue(sc.getTrailingArguments().isEmpty()); |
| | | } |
| | |
| | | @Test |
| | | public void testGetTrailingArguments2() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null, |
| | | 2000); |
| | | Message.raw("XXX")); |
| | | parser.parseArguments(new String[] { "sub-command2" }); |
| | | Assert.assertTrue(sc.getTrailingArguments().isEmpty()); |
| | | } |
| | |
| | | @Test |
| | | public void testGetTrailingArguments3() throws Exception { |
| | | SubCommandArgumentParser parser = new SubCommandArgumentParser(this |
| | | .getClass().getName(), "test description", true); |
| | | .getClass().getName(), Message.raw("test description"), true); |
| | | SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4, |
| | | "args1 arg2 [arg3 arg4]", 2000); |
| | | "args1 arg2 [arg3 arg4]", Message.raw("XXX")); |
| | | parser |
| | | .parseArguments(new String[] { "sub-command2", "arg1", "arg2", "arg3" }); |
| | | Assert.assertEquals(sc.getTrailingArguments(), Arrays.asList(new String[] { |