1 10 11 package org.apache.commons.cli; 12 13 import junit.framework.Test; 14 import junit.framework.TestCase; 15 import junit.framework.TestSuite; 16 17 public class BuildTest extends TestCase 18 { 19 20 public static Test suite() { 21 return new TestSuite(BuildTest.class); 22 } 23 24 public BuildTest(String name) 25 { 26 super(name); 27 } 28 29 public void setUp() 30 { 31 32 } 33 34 public void tearDown() 35 { 36 37 } 38 39 public void testSimple() 40 { 41 Options opts = new Options(); 42 43 opts.addOption("a", 44 false, 45 "toggle -a"); 46 47 opts.addOption("b", 48 true, 49 "toggle -b"); 50 } 51 52 public void testDuplicateSimple() 53 { 54 Options opts = new Options(); 55 opts.addOption("a", 56 false, 57 "toggle -a"); 58 59 opts.addOption("a", 60 true, 61 "toggle -a*"); 62 63 assertEquals( "last one in wins", "toggle -a*", opts.getOption("a").getDescription() ); 64 } 65 66 public void testLong() 67 { 68 Options opts = new Options(); 69 70 opts.addOption("a", 71 "--a", 72 false, 73 "toggle -a"); 74 75 opts.addOption("b", 76 "--b", 77 true, 78 "set -b"); 79 80 } 81 82 public void testDuplicateLong() 83 { 84 Options opts = new Options(); 85 opts.addOption("a", 86 "--a", 87 false, 88 "toggle -a"); 89 90 opts.addOption("a", 91 "--a", 92 false, 93 "toggle -a*"); 94 assertEquals( "last one in wins", "toggle -a*", opts.getOption("a").getDescription() ); 95 } 96 } 97 | Popular Tags |