1   import junit.framework.TestCase;
2   import org.kohsuke.args4j.CmdLineParser;
3   import org.kohsuke.args4j.ExampleMode;
4   import org.kohsuke.args4j.Option;
5   
6   import java.io.File;
7   
8   /***
9    * Tests {@link CmdLineParser#printExample(ExampleMode)}
10   *
11   * @author Kohsuke Kawaguchi
12   */
13  public class ExampleTest extends TestCase {
14      @Option(required=true,name="-a",usage="this is X")
15      int x;
16  
17      @Option(name="-b",usage="this is Y",metaVar="<output>")
18      File y;
19  
20      public void test1() {
21          String s = new CmdLineParser(this).printExample(ExampleMode.ALL);
22          System.out.println("["+s +"]");
23          assertEquals(" -a N -b <output>",s);
24      }
25  
26      public void test2() {
27          String s = new CmdLineParser(this).printExample(ExampleMode.REQUIRED);
28          System.out.println("["+s +"]");
29          assertEquals(" -a N",s);
30      }
31  }