@Test public void testExecute() { UpdateOrderConfCommand cmd = new UpdateOrderConfCommand(); Options options = ServerUtil.buildCommandlineOptions(new Options()); String[] subargs = new String[] {"-t unit-test", "-v default-broker:8", "-m post"}; final CommandLine commandLine = ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser()); assertThat(commandLine.getOptionValue('t').trim()).isEqualTo("unit-test"); assertThat(commandLine.getOptionValue('v').trim()).isEqualTo("default-broker:8"); assertThat(commandLine.getOptionValue('m').trim()).isEqualTo("post"); }
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String topic = commandLine.getOptionValue('t').trim(); String type = commandLine.getOptionValue('m').trim(); if ("get".equals(type)) { defaultMQAdminExt.start(); String orderConf = defaultMQAdminExt.getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("get orderConf success. topic=[%s], orderConf=[%s] ", topic, orderConf); return; } else if ("put".equals(type)) { defaultMQAdminExt.start(); String orderConf = ""; if (commandLine.hasOption('v')) { orderConf = commandLine.getOptionValue('v').trim(); } if (UtilAll.isBlank(orderConf)) { throw new Exception("please set orderConf with option -v."); } defaultMQAdminExt.createOrUpdateOrderConf(topic, orderConf, true); System.out.printf("update orderConf success. topic=[%s], orderConf=[%s]", topic, orderConf.toString()); return; } else if ("delete".equals(type)) { defaultMQAdminExt.start(); defaultMQAdminExt.deleteKvConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("delete orderConf success. topic=[%s]", topic); return; } ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }
UpdateOrderConfCommand implements SubCommand { @Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String topic = commandLine.getOptionValue('t').trim(); String type = commandLine.getOptionValue('m').trim(); if ("get".equals(type)) { defaultMQAdminExt.start(); String orderConf = defaultMQAdminExt.getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("get orderConf success. topic=[%s], orderConf=[%s] ", topic, orderConf); return; } else if ("put".equals(type)) { defaultMQAdminExt.start(); String orderConf = ""; if (commandLine.hasOption('v')) { orderConf = commandLine.getOptionValue('v').trim(); } if (UtilAll.isBlank(orderConf)) { throw new Exception("please set orderConf with option -v."); } defaultMQAdminExt.createOrUpdateOrderConf(topic, orderConf, true); System.out.printf("update orderConf success. topic=[%s], orderConf=[%s]", topic, orderConf.toString()); return; } else if ("delete".equals(type)) { defaultMQAdminExt.start(); defaultMQAdminExt.deleteKvConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("delete orderConf success. topic=[%s]", topic); return; } ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } } }
UpdateOrderConfCommand implements SubCommand { @Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String topic = commandLine.getOptionValue('t').trim(); String type = commandLine.getOptionValue('m').trim(); if ("get".equals(type)) { defaultMQAdminExt.start(); String orderConf = defaultMQAdminExt.getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("get orderConf success. topic=[%s], orderConf=[%s] ", topic, orderConf); return; } else if ("put".equals(type)) { defaultMQAdminExt.start(); String orderConf = ""; if (commandLine.hasOption('v')) { orderConf = commandLine.getOptionValue('v').trim(); } if (UtilAll.isBlank(orderConf)) { throw new Exception("please set orderConf with option -v."); } defaultMQAdminExt.createOrUpdateOrderConf(topic, orderConf, true); System.out.printf("update orderConf success. topic=[%s], orderConf=[%s]", topic, orderConf.toString()); return; } else if ("delete".equals(type)) { defaultMQAdminExt.start(); defaultMQAdminExt.deleteKvConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("delete orderConf success. topic=[%s]", topic); return; } ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  }
UpdateOrderConfCommand implements SubCommand { @Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String topic = commandLine.getOptionValue('t').trim(); String type = commandLine.getOptionValue('m').trim(); if ("get".equals(type)) { defaultMQAdminExt.start(); String orderConf = defaultMQAdminExt.getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("get orderConf success. topic=[%s], orderConf=[%s] ", topic, orderConf); return; } else if ("put".equals(type)) { defaultMQAdminExt.start(); String orderConf = ""; if (commandLine.hasOption('v')) { orderConf = commandLine.getOptionValue('v').trim(); } if (UtilAll.isBlank(orderConf)) { throw new Exception("please set orderConf with option -v."); } defaultMQAdminExt.createOrUpdateOrderConf(topic, orderConf, true); System.out.printf("update orderConf success. topic=[%s], orderConf=[%s]", topic, orderConf.toString()); return; } else if ("delete".equals(type)) { defaultMQAdminExt.start(); defaultMQAdminExt.deleteKvConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("delete orderConf success. topic=[%s]", topic); return; } ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  @Override String commandName(); @Override String commandDesc(); @Override Options buildCommandlineOptions(Options options); @Override void execute(final CommandLine commandLine, final Options options,
        RPCHook rpcHook); }
UpdateOrderConfCommand implements SubCommand { @Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); try { String topic = commandLine.getOptionValue('t').trim(); String type = commandLine.getOptionValue('m').trim(); if ("get".equals(type)) { defaultMQAdminExt.start(); String orderConf = defaultMQAdminExt.getKVConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("get orderConf success. topic=[%s], orderConf=[%s] ", topic, orderConf); return; } else if ("put".equals(type)) { defaultMQAdminExt.start(); String orderConf = ""; if (commandLine.hasOption('v')) { orderConf = commandLine.getOptionValue('v').trim(); } if (UtilAll.isBlank(orderConf)) { throw new Exception("please set orderConf with option -v."); } defaultMQAdminExt.createOrUpdateOrderConf(topic, orderConf, true); System.out.printf("update orderConf success. topic=[%s], orderConf=[%s]", topic, orderConf.toString()); return; } else if ("delete".equals(type)) { defaultMQAdminExt.start(); defaultMQAdminExt.deleteKvConfig(NamesrvUtil.NAMESPACE_ORDER_TOPIC_CONFIG, topic); System.out.printf("delete orderConf success. topic=[%s]", topic); return; } ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options); } catch (Exception e) { throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); } finally { defaultMQAdminExt.shutdown(); } }  @Override String commandName(); @Override String commandDesc(); @Override Options buildCommandlineOptions(Options options); @Override void execute(final CommandLine commandLine, final Options options,
        RPCHook rpcHook);  }