1   package org.kohsuke.args4j;
2   
3   public class InheritanceTest extends Args4JTestBase {
4   
5       @Override
6       public Object getTestObject() {
7           return new Inheritance();
8       }
9       
10      public void testMyself() {
11          args = new String[]{"-m","Thats me"};
12          Inheritance bo = (Inheritance)testObject;
13          try {
14              parser.parseArgument(args);
15              assertEquals("Value for class itself not arrived", "Thats me", bo.me);
16          } catch (CmdLineException e) {
17              fail("This exception should not occur");
18          }
19      }
20  
21      public void testFather() {
22          args = new String[]{"-f","My father"};
23          Inheritance bo = (Inheritance)testObject;
24          try {
25              parser.parseArgument(args);
26              assertEquals("Value for class itself not arrived", "My father", bo.father);
27          } catch (CmdLineException e) {
28              fail("This exception should not occur");
29          }
30      }
31  
32      public void testGrandfather() {
33          args = new String[]{"-g","My fathers father"};
34          Inheritance bo = (Inheritance)testObject;
35          try {
36              parser.parseArgument(args);
37              assertEquals("Value for class itself not arrived", "My fathers father", bo.grandpa);
38          } catch (CmdLineException e) {
39              fail("This exception should not occur");
40          }
41      }
42      
43      public void testMother() {
44          args = new String[]{"-mom","Hi Mom"};
45          Inheritance bo = (Inheritance)testObject;
46          try {
47              parser.parseArgument(args);
48              assertNull("Annotations are not designed for use in interfaces", bo.mom);
49          } catch (CmdLineException e) {
50              //no-op
51          }
52      }
53      
54  }