Java 类com.beust.jcommander.validators.PositiveInteger 实例源码

项目:VarJ    文件:PositiveIntegerTest.java   
@Test
public void validateTest() {
  class Arg {
    @Parameter(names = { "-p", "--port" }, description = "Shows help", validateWith = PositiveInteger.class)
    private int port = 0;
  }
  Arg arg = new Arg();
  JCommander jc = new JCommander(arg);
  jc.parse(new String[] { "-p", "8080" });

}
项目:VarJ    文件:PositiveIntegerTest.java   
@Test(expectedExceptions = ParameterException.class)
public void validateTest2() {
  class Arg {
    @Parameter(names = { "-p", "--port" }, description = "Shows help", validateWith = PositiveInteger.class)
    private int port = 0;
  }
  Arg arg = new Arg();
  JCommander jc = new JCommander(arg);
  jc.parse(new String[] { "-p", "" });
}
项目:VarJ    文件:PositiveIntegerTest.java   
@Test(expectedExceptions = ParameterException.class)
public void validateTest3() {
  class Arg {
    @Parameter(names = { "-p", "--port" }, description = "Shows help", validateWith = PositiveInteger.class)
    private int port = 0;
  }
  Arg arg = new Arg();
  JCommander jc = new JCommander(arg);
  jc.parse(new String[] { "-p", "-1" });
}
项目:VarJ    文件:PositiveIntegerTest.java   
@Test(expectedExceptions = ParameterException.class)
public void validateTest4() {
  class Arg {
    @Parameter(names = { "-p", "--port" }, description = "Port Number", validateWith = PositiveInteger.class)
    private int port = 0;
  }
  Arg arg = new Arg();
  JCommander jc = new JCommander(arg);
  jc.parse(new String[] { "-p", "abc" });
}
项目:VarJ    文件:PositiveIntegerTest.java   
@Test(expectedExceptions = ParameterException.class)
public void validateTest5() {
  class Arg {
    @Parameter(names = { "-p", "--port" }, description = "Port Number", validateWith = PositiveInteger.class)
    private int port = 0;
  }

  Arg arg = new Arg();
  JCommander jc = new JCommander(arg);
  jc.parse(new String[] { "--port", " " });
}