Java 类org.apache.commons.cli.PosixParser 实例源码

项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:UpdateTopicSubCommandTest.java   
@Test
public void testExecute() {
    UpdateTopicSubCommand cmd = new UpdateTopicSubCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {
        "-b 127.0.0.1:10911",
        "-c default-cluster",
        "-t unit-test",
        "-r 8",
        "-w 8",
        "-p 6",
        "-o false",
        "-u false",
        "-s false"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    assertThat(commandLine.getOptionValue('b').trim()).isEqualTo("127.0.0.1:10911");
    assertThat(commandLine.getOptionValue('c').trim()).isEqualTo("default-cluster");
    assertThat(commandLine.getOptionValue('r').trim()).isEqualTo("8");
    assertThat(commandLine.getOptionValue('w').trim()).isEqualTo("8");
    assertThat(commandLine.getOptionValue('t').trim()).isEqualTo("unit-test");
    assertThat(commandLine.getOptionValue('p').trim()).isEqualTo("6");
    assertThat(commandLine.getOptionValue('o').trim()).isEqualTo("false");
    assertThat(commandLine.getOptionValue('u').trim()).isEqualTo("false");
    assertThat(commandLine.getOptionValue('s').trim()).isEqualTo("false");
}
项目:cyberduck    文件:TerminalTransferFactoryTest.java   
@Test
public void testFilter() throws Exception {
    final CommandLineParser parser = new PosixParser();

    final Transfer transfer = new TerminalTransferFactory().create(parser.parse(TerminalOptionsBuilder.options(), new String[]{"--download", "rackspace://cdn.cyberduck.ch/remote/*.css"}),
            new Host(new SwiftProtocol()), new Path("/remote/*.css", EnumSet.of(Path.Type.directory)), Collections.<TransferItem>emptyList());
    assertEquals(Transfer.Type.download, transfer.getType());
    final PathCache cache = new PathCache(1);
    transfer.withCache(cache);
    cache.clear();
    cache.put(new Path("/remote", EnumSet.of(Path.Type.directory)), new AttributedList<Path>(Collections.singletonList(new Path("/remote/file.css", EnumSet.of(Path.Type.file)))));
    assertFalse(transfer.list(null, null, new Path("/remote", EnumSet.of(Path.Type.directory)), new Local("/tmp"), new DisabledListProgressListener()).isEmpty());
    cache.clear();
    cache.put(new Path("/remote", EnumSet.of(Path.Type.directory)), new AttributedList<Path>(Collections.singletonList(new Path("/remote/file.png", EnumSet.of(Path.Type.file)))));
    assertTrue(transfer.list(null, null, new Path("/remote", EnumSet.of(Path.Type.directory)), new Local("/tmp"), new DisabledListProgressListener()).isEmpty());
}
项目:https-github.com-apache-zookeeper    文件:AddAuthCommand.java   
@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
    Parser parser = new PosixParser();
    CommandLine cl;
    try {
        cl = parser.parse(options, cmdArgs);
    } catch (ParseException ex) {
        throw new CliParseException(ex);
    }

    args = cl.getArgs();
    if (args.length < 2) {
        throw new CliParseException(getUsageStr());
    }

    return this;
}
项目:https-github.com-apache-zookeeper    文件:DeleteAllCommand.java   
@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
    Parser parser = new PosixParser();
    CommandLine cl;
    try {
        cl = parser.parse(options, cmdArgs);
    } catch (ParseException ex) {
        throw new CliParseException(ex);
    }
    args = cl.getArgs();
    if (args.length < 2) {
        throw new CliParseException(getUsageStr());
    }

    return this;
}
项目:https-github.com-apache-zookeeper    文件:SyncCommand.java   
@Override
public CliCommand parse(String[] cmdArgs) throws CliParseException {
    Parser parser = new PosixParser();
    CommandLine cl;
    try {
        cl = parser.parse(options, cmdArgs);
    } catch (ParseException ex) {
        throw new CliParseException(ex);
    }
    args = cl.getArgs();
    if (args.length < 2) {
        throw new CliParseException(getUsageStr());
    }

    return this;
}
项目:hadoop    文件:DFSUtil.java   
/**
 * Parse the arguments for commands
 * 
 * @param args the argument to be parsed
 * @param helpDescription help information to be printed out
 * @param out Printer
 * @param printGenericCommandUsage whether to print the 
 *              generic command usage defined in ToolRunner
 * @return true when the argument matches help option, false if not
 */
public static boolean parseHelpArgument(String[] args,
    String helpDescription, PrintStream out, boolean printGenericCommandUsage) {
  if (args.length == 1) {
    try {
      CommandLineParser parser = new PosixParser();
      CommandLine cmdLine = parser.parse(helpOptions, args);
      if (cmdLine.hasOption(helpOpt.getOpt())
          || cmdLine.hasOption(helpOpt.getLongOpt())) {
        // should print out the help information
        out.println(helpDescription + "\n");
        if (printGenericCommandUsage) {
          ToolRunner.printGenericCommandUsage(out);
        }
        return true;
      }
    } catch (ParseException pe) {
      return false;
    }
  }
  return false;
}
项目:rmq4note    文件:UpdateTopicSubCommandTest.java   
@Test
public void testExecute() {
    UpdateTopicSubCommand cmd = new UpdateTopicSubCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {
        "-b 127.0.0.1:10911",
        "-c default-cluster",
        "-t unit-test",
        "-r 8",
        "-w 8",
        "-p 6",
        "-o false",
        "-u false",
        "-s false"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    assertThat(commandLine.getOptionValue('b').trim()).isEqualTo("127.0.0.1:10911");
    assertThat(commandLine.getOptionValue('c').trim()).isEqualTo("default-cluster");
    assertThat(commandLine.getOptionValue('r').trim()).isEqualTo("8");
    assertThat(commandLine.getOptionValue('w').trim()).isEqualTo("8");
    assertThat(commandLine.getOptionValue('t').trim()).isEqualTo("unit-test");
    assertThat(commandLine.getOptionValue('p').trim()).isEqualTo("6");
    assertThat(commandLine.getOptionValue('o').trim()).isEqualTo("false");
    assertThat(commandLine.getOptionValue('u').trim()).isEqualTo("false");
    assertThat(commandLine.getOptionValue('s').trim()).isEqualTo("false");
}
项目:aliyun-oss-hadoop-fs    文件:DFSUtil.java   
/**
 * Parse the arguments for commands
 * 
 * @param args the argument to be parsed
 * @param helpDescription help information to be printed out
 * @param out Printer
 * @param printGenericCommandUsage whether to print the 
 *              generic command usage defined in ToolRunner
 * @return true when the argument matches help option, false if not
 */
public static boolean parseHelpArgument(String[] args,
    String helpDescription, PrintStream out, boolean printGenericCommandUsage) {
  if (args.length == 1) {
    try {
      CommandLineParser parser = new PosixParser();
      CommandLine cmdLine = parser.parse(helpOptions, args);
      if (cmdLine.hasOption(helpOpt.getOpt())
          || cmdLine.hasOption(helpOpt.getLongOpt())) {
        // should print out the help information
        out.println(helpDescription + "\n");
        if (printGenericCommandUsage) {
          ToolRunner.printGenericCommandUsage(out);
        }
        return true;
      }
    } catch (ParseException pe) {
      return false;
    }
  }
  return false;
}
项目:GeoCrawler    文件:NutchServer.java   
public static void main(String[] args) throws ParseException {
  CommandLineParser parser = new PosixParser();
  Options options = createOptions();
  CommandLine commandLine = parser.parse(options, args);
  if (commandLine.hasOption(CMD_HELP)) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.printHelp("NutchServer", options, true);
    return;
  }

  if (commandLine.hasOption(CMD_PORT)) {
    port = Integer.parseInt(commandLine.getOptionValue(CMD_PORT));
  }

  if (commandLine.hasOption(CMD_HOST)) {
    host = commandLine.getOptionValue(CMD_HOST);
  }

  startServer();
}
项目:big-c    文件:DFSUtil.java   
/**
 * Parse the arguments for commands
 * 
 * @param args the argument to be parsed
 * @param helpDescription help information to be printed out
 * @param out Printer
 * @param printGenericCommandUsage whether to print the 
 *              generic command usage defined in ToolRunner
 * @return true when the argument matches help option, false if not
 */
public static boolean parseHelpArgument(String[] args,
    String helpDescription, PrintStream out, boolean printGenericCommandUsage) {
  if (args.length == 1) {
    try {
      CommandLineParser parser = new PosixParser();
      CommandLine cmdLine = parser.parse(helpOptions, args);
      if (cmdLine.hasOption(helpOpt.getOpt())
          || cmdLine.hasOption(helpOpt.getLongOpt())) {
        // should print out the help information
        out.println(helpDescription + "\n");
        if (printGenericCommandUsage) {
          ToolRunner.printGenericCommandUsage(out);
        }
        return true;
      }
    } catch (ParseException pe) {
      return false;
    }
  }
  return false;
}
项目:rocketmq    文件:UpdateTopicSubCommandTest.java   
@Test
public void testExecute() {
    UpdateTopicSubCommand cmd = new UpdateTopicSubCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {
        "-b 127.0.0.1:10911",
        "-c default-cluster",
        "-t unit-test",
        "-r 8",
        "-w 8",
        "-p 6",
        "-o false",
        "-u false",
        "-s false"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    assertThat(commandLine.getOptionValue('b').trim()).isEqualTo("127.0.0.1:10911");
    assertThat(commandLine.getOptionValue('c').trim()).isEqualTo("default-cluster");
    assertThat(commandLine.getOptionValue('r').trim()).isEqualTo("8");
    assertThat(commandLine.getOptionValue('w').trim()).isEqualTo("8");
    assertThat(commandLine.getOptionValue('t').trim()).isEqualTo("unit-test");
    assertThat(commandLine.getOptionValue('p').trim()).isEqualTo("6");
    assertThat(commandLine.getOptionValue('o').trim()).isEqualTo("false");
    assertThat(commandLine.getOptionValue('u').trim()).isEqualTo("false");
    assertThat(commandLine.getOptionValue('s').trim()).isEqualTo("false");
}
项目:SparkToParquet    文件:Flags.java   
public static void setFromCommandLineArgs(Options options, String[] args) {
    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cl = parser.parse(options, args);
        // 参数默认值
        THE_INSTANCE.windowLength = new Duration(
                Integer.parseInt(cl.getOptionValue(AppMain.WINDOW_LENGTH, "30")) * 1000);
        THE_INSTANCE.slideInterval = new Duration(
                Integer.parseInt(cl.getOptionValue(AppMain.SLIDE_INTERVAL, "5")) * 1000);
        THE_INSTANCE.kafka_broker = cl.getOptionValue(AppMain.KAFKA_BROKER, "kafka:9092");
        THE_INSTANCE.kafka_topic = cl.getOptionValue(AppMain.KAFKA_TOPIC, "apache");
        THE_INSTANCE.parquet_file = cl.getOptionValue(AppMain.PARQUET_FILE, "/user/spark/");
        THE_INSTANCE.initialized = true;
    } catch (ParseException e) {
        THE_INSTANCE.initialized = false;
        System.err.println("Parsing failed.  Reason: " + e.getMessage());
    }
}
项目:TopPI    文件:TopPIcli.java   
public static void main(String[] args) throws Exception {
    Options options = getOptions();

    try {
        CommandLineParser parser = new PosixParser();
        GenericOptionsParser hadoopCmd = new GenericOptionsParser(args);
        CommandLine cmd = parser.parse(options, hadoopCmd.getRemainingArgs());

        if (cmd.getArgs().length < 2 || cmd.getArgs().length > 3 || cmd.hasOption('h')) {
            printMan(options);
        } else if (!cmd.hasOption('k')) {
            System.err.println("-k parameter is mandatory");
            System.exit(1);
        } else if (cmd.hasOption('g')) {
            hadoop(args);
        } else {
            standalone(cmd);
        }
    } catch (ParseException e) {
        printMan(options);
    }
}
项目:mesfavoris    文件:BugCLI13Test.java   
@Test
public void testCLI13() throws ParseException
{
    final String debugOpt = "debug";
    @SuppressWarnings("static-access")
    Option debug = OptionBuilder
        .withArgName( debugOpt )
        .withDescription( "turn on debugging" )
        .withLongOpt( debugOpt )
        .hasArg()
        .create( 'd' );
    Options options = new Options();
    options.addOption( debug );
    CommandLine commandLine = new PosixParser().parse( options, new String[]{"-d", "true"} );

    assertEquals("true", commandLine.getOptionValue( debugOpt ));
    assertEquals("true", commandLine.getOptionValue( 'd' ));
    assertTrue(commandLine.hasOption( 'd'));
    assertTrue(commandLine.hasOption( debugOpt));
}
项目:mesfavoris    文件:BugsTest.java   
@Test
public void test15046() throws Exception
{
    CommandLineParser parser = new PosixParser();
    String[] CLI_ARGS = new String[] {"-z", "c"};

    Options options = new Options();
    options.addOption(new Option("z", "timezone", true, "affected option"));

    parser.parse(options, CLI_ARGS);

    //now add conflicting option
    options.addOption("c", "conflict", true, "conflict option");
    CommandLine line = parser.parse(options, CLI_ARGS);
    assertEquals( line.getOptionValue('z'), "c" );
    assertTrue( !line.hasOption("c") );
}
项目:mesfavoris    文件:BugsTest.java   
@Test
public void test31148() throws ParseException
{
    Option multiArgOption = new Option("o","option with multiple args");
    multiArgOption.setArgs(1);

    Options options = new Options();
    options.addOption(multiArgOption);

    Parser parser = new PosixParser();
    String[] args = new String[]{};
    Properties props = new Properties();
    props.setProperty("o","ovalue");
    CommandLine cl = parser.parse(options,args,props);

    assertTrue(cl.hasOption('o'));
    assertEquals("ovalue",cl.getOptionValue('o'));
}
项目:mesfavoris    文件:BugCLI13Test.java   
@Test
public void testCLI13() throws ParseException
{
    final String debugOpt = "debug";
    @SuppressWarnings("static-access")
    Option debug = OptionBuilder
        .withArgName( debugOpt )
        .withDescription( "turn on debugging" )
        .withLongOpt( debugOpt )
        .hasArg()
        .create( 'd' );
    Options options = new Options();
    options.addOption( debug );
    CommandLine commandLine = new PosixParser().parse( options, new String[]{"-d", "true"} );

    assertEquals("true", commandLine.getOptionValue( debugOpt ));
    assertEquals("true", commandLine.getOptionValue( 'd' ));
    assertTrue(commandLine.hasOption( 'd'));
    assertTrue(commandLine.hasOption( debugOpt));
}
项目:mesfavoris    文件:BugsTest.java   
@Test
public void test15046() throws Exception
{
    CommandLineParser parser = new PosixParser();
    String[] CLI_ARGS = new String[] {"-z", "c"};

    Options options = new Options();
    options.addOption(new Option("z", "timezone", true, "affected option"));

    parser.parse(options, CLI_ARGS);

    //now add conflicting option
    options.addOption("c", "conflict", true, "conflict option");
    CommandLine line = parser.parse(options, CLI_ARGS);
    assertEquals( line.getOptionValue('z'), "c" );
    assertTrue( !line.hasOption("c") );
}
项目:mesfavoris    文件:BugCLI13Test.java   
@Test
public void testCLI13() throws ParseException
{
    final String debugOpt = "debug";
    @SuppressWarnings("static-access")
    Option debug = OptionBuilder
        .withArgName( debugOpt )
        .withDescription( "turn on debugging" )
        .withLongOpt( debugOpt )
        .hasArg()
        .create( 'd' );
    Options options = new Options();
    options.addOption( debug );
    CommandLine commandLine = new PosixParser().parse( options, new String[]{"-d", "true"} );

    assertEquals("true", commandLine.getOptionValue( debugOpt ));
    assertEquals("true", commandLine.getOptionValue( 'd' ));
    assertTrue(commandLine.hasOption( 'd'));
    assertTrue(commandLine.hasOption( debugOpt));
}
项目:mesfavoris    文件:BugsTest.java   
@Test
public void test15046() throws Exception
{
    CommandLineParser parser = new PosixParser();
    String[] CLI_ARGS = new String[] {"-z", "c"};

    Options options = new Options();
    options.addOption(new Option("z", "timezone", true, "affected option"));

    parser.parse(options, CLI_ARGS);

    //now add conflicting option
    options.addOption("c", "conflict", true, "conflict option");
    CommandLine line = parser.parse(options, CLI_ARGS);
    assertEquals( line.getOptionValue('z'), "c" );
    assertTrue( !line.hasOption("c") );
}
项目:mesfavoris    文件:BugsTest.java   
@Test
public void test31148() throws ParseException
{
    Option multiArgOption = new Option("o","option with multiple args");
    multiArgOption.setArgs(1);

    Options options = new Options();
    options.addOption(multiArgOption);

    Parser parser = new PosixParser();
    String[] args = new String[]{};
    Properties props = new Properties();
    props.setProperty("o","ovalue");
    CommandLine cl = parser.parse(options,args,props);

    assertTrue(cl.hasOption('o'));
    assertEquals("ovalue",cl.getOptionValue('o'));
}
项目:mesfavoris    文件:BugCLI13Test.java   
@Test
public void testCLI13() throws ParseException
{
    final String debugOpt = "debug";
    @SuppressWarnings("static-access")
    Option debug = OptionBuilder
        .withArgName( debugOpt )
        .withDescription( "turn on debugging" )
        .withLongOpt( debugOpt )
        .hasArg()
        .create( 'd' );
    Options options = new Options();
    options.addOption( debug );
    CommandLine commandLine = new PosixParser().parse( options, new String[]{"-d", "true"} );

    assertEquals("true", commandLine.getOptionValue( debugOpt ));
    assertEquals("true", commandLine.getOptionValue( 'd' ));
    assertTrue(commandLine.hasOption( 'd'));
    assertTrue(commandLine.hasOption( debugOpt));
}
项目:mesfavoris    文件:BugsTest.java   
@Test
public void test15046() throws Exception
{
    CommandLineParser parser = new PosixParser();
    String[] CLI_ARGS = new String[] {"-z", "c"};

    Options options = new Options();
    options.addOption(new Option("z", "timezone", true, "affected option"));

    parser.parse(options, CLI_ARGS);

    //now add conflicting option
    options.addOption("c", "conflict", true, "conflict option");
    CommandLine line = parser.parse(options, CLI_ARGS);
    assertEquals( line.getOptionValue('z'), "c" );
    assertTrue( !line.hasOption("c") );
}
项目:mesfavoris    文件:BugsTest.java   
@Test
public void test31148() throws ParseException
{
    Option multiArgOption = new Option("o","option with multiple args");
    multiArgOption.setArgs(1);

    Options options = new Options();
    options.addOption(multiArgOption);

    Parser parser = new PosixParser();
    String[] args = new String[]{};
    Properties props = new Properties();
    props.setProperty("o","ovalue");
    CommandLine cl = parser.parse(options,args,props);

    assertTrue(cl.hasOption('o'));
    assertEquals("ovalue",cl.getOptionValue('o'));
}
项目:flink    文件:MesosSessionClusterEntrypoint.java   
public static void main(String[] args) {
    // startup checks and logging
    EnvironmentInformation.logEnvironmentInfo(LOG, MesosSessionClusterEntrypoint.class.getSimpleName(), args);
    SignalHandler.register(LOG);
    JvmShutdownSafeguard.installAsShutdownHook(LOG);

    // load configuration incl. dynamic properties
    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(ALL_OPTIONS, args);
    }
    catch (Exception e){
        LOG.error("Could not parse the command-line options.", e);
        System.exit(STARTUP_FAILURE_RETURN_CODE);
        return;
    }

    Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd);
    Configuration configuration = MesosEntrypointUtils.loadConfiguration(dynamicProperties, LOG);

    MesosSessionClusterEntrypoint clusterEntrypoint = new MesosSessionClusterEntrypoint(configuration, dynamicProperties);

    clusterEntrypoint.startCluster();
}
项目:flink    文件:MesosJobClusterEntrypoint.java   
public static void main(String[] args) {
    // startup checks and logging
    EnvironmentInformation.logEnvironmentInfo(LOG, MesosJobClusterEntrypoint.class.getSimpleName(), args);
    SignalHandler.register(LOG);
    JvmShutdownSafeguard.installAsShutdownHook(LOG);

    // load configuration incl. dynamic properties
    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(ALL_OPTIONS, args);
    }
    catch (Exception e){
        LOG.error("Could not parse the command-line options.", e);
        System.exit(STARTUP_FAILURE_RETURN_CODE);
        return;
    }

    Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd);
    Configuration configuration = MesosEntrypointUtils.loadConfiguration(dynamicProperties, LOG);

    MesosJobClusterEntrypoint clusterEntrypoint = new MesosJobClusterEntrypoint(configuration, dynamicProperties);

    clusterEntrypoint.startCluster();
}
项目:s3-inventory-usage-examples    文件:ArgumentParser.java   
public ArgumentParser() {
    final Option input =
            new Option(KEY_INPUT, longOptInput, true,
                    "read in this S3 URI to get inventory manifest files");
    final Option output =
            new Option(KEY_OUTPUT, longOptOutput, true,
                    "write new files back to this output S3 URI prefix");
    this.options = new Options();
    input.setRequired(true);
    this.options.addOption(input);
    output.setRequired(true);
    this.options.addOption(output);
    this.parser = new PosixParser();
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:QueryConsumeQueueCommand.java   
public static void main(String[] args) {
    QueryConsumeQueueCommand cmd = new QueryConsumeQueueCommand();

    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[]{"-t TopicTest", "-q 0", "-i 6447", "-b 100.81.165.119:10911"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options),
            new PosixParser());
    cmd.execute(commandLine, options, null);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:ConsumerStatusSubCommandTest.java   
@Ignore
@Test
public void testExecute() throws SubCommandException {
    ConsumerStatusSubCommand cmd = new ConsumerStatusSubCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-g default-group", "-i cid_one"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:ConsumerProgressSubCommandTest.java   
@Ignore
@Test
public void testExecute() throws SubCommandException {
    ConsumerProgressSubCommand cmd = new ConsumerProgressSubCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-g default-group"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:ResetOffsetByTimeOldCommandTest.java   
@Test
public void testExecute() {
    ResetOffsetByTimeOldCommand cmd = new ResetOffsetByTimeOldCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-g default-group", "-t unit-test", "-s 1412131213231", "-f false"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    assertThat(commandLine.getOptionValue('g').trim()).isEqualTo("default-group");
    assertThat(commandLine.getOptionValue('t').trim()).isEqualTo("unit-test");
    assertThat(commandLine.getOptionValue('s').trim()).isEqualTo("1412131213231");
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:GetConsumerStatusCommandTest.java   
@Ignore
@Test
public void testExecute() throws SubCommandException {
    GetConsumerStatusCommand cmd = new GetConsumerStatusCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-g default-group", "-t unit-test", "-i clientid"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:ResetOffsetByTimeCommandTest.java   
@Ignore
@Test
public void testExecute() throws SubCommandException {
    ResetOffsetByTimeCommand cmd = new ResetOffsetByTimeCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-g default-group", "-t unit-test", "-s 1412131213231", "-f false"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:BrokerConsumeStatsSubCommadTest.java   
@Ignore
@Test
public void testExecute() throws SubCommandException {
    BrokerConsumeStatsSubCommad cmd = new BrokerConsumeStatsSubCommad();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-b 127.0.0.1:10911", "-t 3000", "-l 5", "-o true"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:GetBrokerConfigCommandTest.java   
@Ignore
@Test
public void testExecute() throws SubCommandException {
    GetBrokerConfigCommand cmd = new GetBrokerConfigCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-b 127.0.0.1:10911", "-c default-cluster"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:SendMsgStatusCommandTest.java   
@Test
public void testExecute() {
    SendMsgStatusCommand cmd = new SendMsgStatusCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-b 127.0.0.1:10911", "-s 1024 -c 10"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    //cmd.execute(commandLine, options, null);
}
项目:rocketmq-rocketmq-all-4.1.0-incubating    文件:UpdateBrokerConfigSubCommandTest.java   
@Ignore
@Test
public void testExecute() throws SubCommandException {
    UpdateBrokerConfigSubCommand cmd = new UpdateBrokerConfigSubCommand();
    Options options = ServerUtil.buildCommandlineOptions(new Options());
    String[] subargs = new String[] {"-b 127.0.0.1:10911", "-c default-cluster", "-k topicname", "-v unit_test"};
    final CommandLine commandLine =
        ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);
}