org.apache.commons.cli.Options#getOption ( )源码实例Demo

下面列出了org.apache.commons.cli.Options#getOption ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ia-rcade   文件: TestCommandLineOptionsFactory.java
@Test
public void testDeduceFromMameRuntimeWithBooleanOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mameOpts = clof.deduceFromMameRuntime(mame).getOptions();

    assertTrue(mameOpts.hasOption("waitvsync"));

    Option opt = mameOpts.getOption("waitvsync");

    assertFalse(opt.hasArg());

}
 
源代码2 项目: ia-rcade   文件: TestCommandLineOptionsFactory.java
@Test
public void testDeduceFromMameRuntimeWithNegativeBooleanOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mameOpts = clof.deduceFromMameRuntime(mame).getOptions();

    assertTrue(mameOpts.hasOption("nowaitvsync"));

    Option opt = mameOpts.getOption("nowaitvsync");

    assertFalse(opt.hasArg());

}
 
源代码3 项目: ia-rcade   文件: TestCommandLineOptionsFactory.java
@Test
public void testDeduceFromMameRuntimeWithNonBooleanOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mameOpts = clof.deduceFromMameRuntime(mame).getOptions();

    assertTrue(mameOpts.hasOption("rompath"));
    assertFalse(mameOpts.hasOption("norompath"));

    Option opt = mameOpts.getOption("rompath");

    assertTrue(opt.hasArg());

}
 
源代码4 项目: ia-rcade   文件: TestCommandLineOptionsFactory.java
@Test
public void testDeduceFromMameRuntimeWithNonBooleanOptionHavingDefaultValueLikeBoolean ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mameOpts = clof.deduceFromMameRuntime(mame).getOptions();

    assertTrue(mameOpts.hasOption("prescale"));
    assertFalse(mameOpts.hasOption("noprescale"));

    Option opt = mameOpts.getOption("prescale");

    assertTrue(opt.hasArg());

}
 
源代码5 项目: ia-rcade   文件: TestCommandLineOptionsFactory.java
@Test
public void testDeduceFromMameRuntimeWithCommandOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options commands 
        = clof.deduceFromMameRuntime(mame).getCommands();

    assertTrue(commands.hasOption("help"));

    Option command = commands.getOption("help");

    assertFalse(command.hasArg());

}
 
源代码6 项目: ia-rcade   文件: TestCommandLineOptionsFactory.java
@Test
public void testDeduceFromMameRuntimeWithMediaTypeOption ()
        throws FileNotFoundException,
               IOException,
               InterruptedException,
               MameExecutionException {
    
    FakeMameRuntime mame = new FakeMameRuntime();
    List<InputStream> inputStreams = new ArrayList<>();
    inputStreams.add(
        new FileInputStream("src/test/resources/showconfig.txt"));
    inputStreams.add(
        new FileInputStream("src/test/resources/showusage.txt"));
    mame.setInputStreamsToReturn(inputStreams);
    CommandLineOptionsFactory clof = new CommandLineOptionsFactory ();
    Options mediaTypes 
        = clof.deduceFromMameRuntime(mame).getMediaTypes();

    assertTrue(mediaTypes.hasOption("cart"));

    Option opt = mediaTypes.getOption("cart");

    assertTrue(opt.hasArg());

}
 
源代码7 项目: powsybl-core   文件: AbstractToolTest.java
protected void assertOption(Options options, String optionName, boolean isRequired, boolean hasArgument) {
    Option option = options.getOption(optionName);
    assertNotNull(option);
    assertEquals(isRequired, option.isRequired());
    assertEquals(hasArgument, option.hasArg());
}