This is an automated email from the ASF dual-hosted git repository. jinrongtong pushed a commit to branch 4.9.x in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/4.9.x by this push: new a53a9f0249 Remove getBrokerClusterAclConfig from admin and server (#7653) a53a9f0249 is described below commit a53a9f024928b643f91275b5bf2f82ac3b0b6c1b Author: rongtong <jinrongto...@163.com> AuthorDate: Fri Dec 15 10:19:32 2023 +0800 Remove getBrokerClusterAclConfig from admin and server (#7653) --- .../broker/processor/AdminBrokerProcessor.java | 26 ----- .../rocketmq/client/impl/MQClientAPIImpl.java | 27 ----- .../rocketmq/common/protocol/RequestCode.java | 2 - .../GetBrokerClusterAclConfigResponseBody.java | 46 -------- .../GetBrokerClusterAclConfigResponseHeader.java | 43 ------- .../rocketmq/tools/admin/DefaultMQAdminExt.java | 6 - .../tools/admin/DefaultMQAdminExtImpl.java | 7 -- .../apache/rocketmq/tools/admin/MQAdminExt.java | 4 - .../rocketmq/tools/command/MQAdminStartup.java | 2 - .../command/acl/GetAccessConfigSubCommand.java | 127 --------------------- .../command/acl/GetAccessConfigSubCommandTest.java | 36 ------ 11 files changed, 326 deletions(-) diff --git a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java index c9d2cacf60..259e760571 100644 --- a/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java +++ b/broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java @@ -31,7 +31,6 @@ import org.apache.rocketmq.common.protocol.body.ProducerTableInfo; import org.apache.rocketmq.common.protocol.header.GetAllProducerInfoRequestHeader; import org.apache.rocketmq.common.topic.TopicValidator; import org.apache.rocketmq.broker.transaction.queue.TransactionalMessageUtil; -import org.apache.rocketmq.common.AclConfig; import org.apache.rocketmq.common.MQVersion; import org.apache.rocketmq.common.MixAll; import org.apache.rocketmq.common.PlainAccessConfig; @@ -76,8 +75,6 @@ import org.apache.rocketmq.common.protocol.header.DeleteSubscriptionGroupRequest import org.apache.rocketmq.common.protocol.header.DeleteTopicRequestHeader; import org.apache.rocketmq.common.protocol.header.GetAllTopicConfigResponseHeader; import org.apache.rocketmq.common.protocol.header.GetBrokerAclConfigResponseHeader; -import org.apache.rocketmq.common.protocol.header.GetBrokerClusterAclConfigResponseBody; -import org.apache.rocketmq.common.protocol.header.GetBrokerClusterAclConfigResponseHeader; import org.apache.rocketmq.common.protocol.header.GetBrokerConfigResponseHeader; import org.apache.rocketmq.common.protocol.header.GetConsumeStatsInBrokerHeader; import org.apache.rocketmq.common.protocol.header.GetConsumeStatsRequestHeader; @@ -247,8 +244,6 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor { return updateGlobalWhiteAddrsConfig(ctx, request); case RequestCode.RESUME_CHECK_HALF_MESSAGE: return resumeCheckHalfMessage(ctx, request); - case RequestCode.GET_BROKER_CLUSTER_ACL_CONFIG: - return getBrokerClusterAclConfig(ctx, request); default: return getUnknownCmdResponse(ctx, request); } @@ -466,27 +461,6 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor { return null; } - private RemotingCommand getBrokerClusterAclConfig(ChannelHandlerContext ctx, RemotingCommand request) { - - final RemotingCommand response = RemotingCommand.createResponseCommand(GetBrokerClusterAclConfigResponseHeader.class); - - try { - AccessValidator accessValidator = this.brokerController.getAccessValidatorMap().get(PlainAccessValidator.class); - GetBrokerClusterAclConfigResponseBody body = new GetBrokerClusterAclConfigResponseBody(); - AclConfig aclConfig = accessValidator.getAllAclConfig(); - body.setGlobalWhiteAddrs(aclConfig.getGlobalWhiteAddrs()); - body.setPlainAccessConfigs(aclConfig.getPlainAccessConfigs()); - response.setCode(ResponseCode.SUCCESS); - response.setBody(body.encode()); - response.setRemark(null); - return response; - } catch (Exception e) { - log.error("Failed to generate a proper getBrokerClusterAclConfig response", e); - } - - return null; - } - private RemotingCommand getUnknownCmdResponse(ChannelHandlerContext ctx, RemotingCommand request) { String error = " request type " + request.getCode() + " not supported"; final RemotingCommand response = diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java index b2b8b9bd58..743c6411ea 100644 --- a/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java +++ b/client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java @@ -45,7 +45,6 @@ import org.apache.rocketmq.client.log.ClientLogger; import org.apache.rocketmq.client.producer.SendCallback; import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.client.producer.SendStatus; -import org.apache.rocketmq.common.AclConfig; import org.apache.rocketmq.common.DataVersion; import org.apache.rocketmq.common.MQVersion; import org.apache.rocketmq.common.MixAll; @@ -100,7 +99,6 @@ import org.apache.rocketmq.common.protocol.header.DeleteTopicRequestHeader; import org.apache.rocketmq.common.protocol.header.EndTransactionRequestHeader; import org.apache.rocketmq.common.protocol.header.GetAllProducerInfoRequestHeader; import org.apache.rocketmq.common.protocol.header.GetBrokerAclConfigResponseHeader; -import org.apache.rocketmq.common.protocol.header.GetBrokerClusterAclConfigResponseBody; import org.apache.rocketmq.common.protocol.header.GetConsumeStatsInBrokerHeader; import org.apache.rocketmq.common.protocol.header.GetConsumeStatsRequestHeader; import org.apache.rocketmq.common.protocol.header.GetConsumerConnectionListRequestHeader; @@ -411,31 +409,6 @@ public class MQClientAPIImpl { } - public AclConfig getBrokerClusterConfig(final String addr, - final long timeoutMillis) throws InterruptedException, RemotingTimeoutException, - RemotingSendRequestException, RemotingConnectException, MQBrokerException { - RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.GET_BROKER_CLUSTER_ACL_CONFIG, null); - - RemotingCommand response = this.remotingClient.invokeSync(MixAll.brokerVIPChannel(this.clientConfig.isVipChannelEnabled(), addr), request, timeoutMillis); - assert response != null; - switch (response.getCode()) { - case ResponseCode.SUCCESS: { - if (response.getBody() != null) { - GetBrokerClusterAclConfigResponseBody body = - GetBrokerClusterAclConfigResponseBody.decode(response.getBody(), GetBrokerClusterAclConfigResponseBody.class); - AclConfig aclConfig = new AclConfig(); - aclConfig.setGlobalWhiteAddrs(body.getGlobalWhiteAddrs()); - aclConfig.setPlainAccessConfigs(body.getPlainAccessConfigs()); - return aclConfig; - } - } - default: - break; - } - throw new MQBrokerException(response.getCode(), response.getRemark(), addr); - - } - public SendResult sendMessage( final String addr, final String brokerName, diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java b/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java index 9912382fff..8189e5a8b4 100644 --- a/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java +++ b/common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java @@ -78,8 +78,6 @@ public class RequestCode { public static final int UPDATE_GLOBAL_WHITE_ADDRS_CONFIG = 53; - public static final int GET_BROKER_CLUSTER_ACL_CONFIG = 54; - public static final int PUT_KV_CONFIG = 100; public static final int GET_KV_CONFIG = 101; diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerClusterAclConfigResponseBody.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerClusterAclConfigResponseBody.java deleted file mode 100644 index 10ea210c82..0000000000 --- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerClusterAclConfigResponseBody.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.rocketmq.common.protocol.header; - -import org.apache.rocketmq.common.PlainAccessConfig; -import org.apache.rocketmq.remoting.protocol.RemotingSerializable; - -import java.util.List; - -public class GetBrokerClusterAclConfigResponseBody extends RemotingSerializable { - - private List<String> globalWhiteAddrs; - - private List<PlainAccessConfig> plainAccessConfigs; - - public List<String> getGlobalWhiteAddrs() { - return globalWhiteAddrs; - } - - public void setGlobalWhiteAddrs(List<String> globalWhiteAddrs) { - this.globalWhiteAddrs = globalWhiteAddrs; - } - - public List<PlainAccessConfig> getPlainAccessConfigs() { - return plainAccessConfigs; - } - - public void setPlainAccessConfigs(List<PlainAccessConfig> plainAccessConfigs) { - this.plainAccessConfigs = plainAccessConfigs; - } -} diff --git a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerClusterAclConfigResponseHeader.java b/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerClusterAclConfigResponseHeader.java deleted file mode 100644 index dbff54a0e8..0000000000 --- a/common/src/main/java/org/apache/rocketmq/common/protocol/header/GetBrokerClusterAclConfigResponseHeader.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.rocketmq.common.protocol.header; - -import org.apache.rocketmq.common.PlainAccessConfig; -import org.apache.rocketmq.remoting.CommandCustomHeader; -import org.apache.rocketmq.remoting.annotation.CFNotNull; -import org.apache.rocketmq.remoting.exception.RemotingCommandException; - -import java.util.List; - -public class GetBrokerClusterAclConfigResponseHeader implements CommandCustomHeader { - - @CFNotNull - private List<PlainAccessConfig> plainAccessConfigs; - - @Override - public void checkFields() throws RemotingCommandException { - } - - public List<PlainAccessConfig> getPlainAccessConfigs() { - return plainAccessConfigs; - } - - public void setPlainAccessConfigs(List<PlainAccessConfig> plainAccessConfigs) { - this.plainAccessConfigs = plainAccessConfigs; - } -} diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java index 2206bc175a..f341281fbb 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java @@ -25,7 +25,6 @@ import org.apache.rocketmq.client.ClientConfig; import org.apache.rocketmq.client.QueryResult; import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; -import org.apache.rocketmq.common.AclConfig; import org.apache.rocketmq.common.PlainAccessConfig; import org.apache.rocketmq.common.TopicConfig; import org.apache.rocketmq.common.admin.ConsumeStats; @@ -196,11 +195,6 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt { return defaultMQAdminExtImpl.examineBrokerClusterAclVersionInfo(addr); } - @Override public AclConfig examineBrokerClusterAclConfig( - String addr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException { - return defaultMQAdminExtImpl.examineBrokerClusterAclConfig(addr); - } - @Override public void createAndUpdateSubscriptionGroupConfig(String addr, SubscriptionGroupConfig config) throws RemotingException, diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java index ddb23cc304..2a71a2c953 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java @@ -41,7 +41,6 @@ import org.apache.rocketmq.common.MixAll; import org.apache.rocketmq.common.PlainAccessConfig; import org.apache.rocketmq.common.ServiceState; import org.apache.rocketmq.common.TopicConfig; -import org.apache.rocketmq.common.AclConfig; import org.apache.rocketmq.common.UtilAll; import org.apache.rocketmq.common.admin.ConsumeStats; import org.apache.rocketmq.common.admin.OffsetWrapper; @@ -227,12 +226,6 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner { return this.mqClientInstance.getMQClientAPIImpl().getBrokerClusterAclInfo(addr, timeoutMillis); } - @Override - public AclConfig examineBrokerClusterAclConfig( - String addr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException { - return this.mqClientInstance.getMQClientAPIImpl().getBrokerClusterConfig(addr, timeoutMillis); - } - @Override public void createAndUpdateSubscriptionGroupConfig(String addr, SubscriptionGroupConfig config) throws RemotingException, diff --git a/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java b/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java index 58e3fb7138..ae8e3b2630 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java @@ -24,7 +24,6 @@ import java.util.Set; import org.apache.rocketmq.client.MQAdmin; import org.apache.rocketmq.client.exception.MQBrokerException; import org.apache.rocketmq.client.exception.MQClientException; -import org.apache.rocketmq.common.AclConfig; import org.apache.rocketmq.common.PlainAccessConfig; import org.apache.rocketmq.common.TopicConfig; import org.apache.rocketmq.common.admin.ConsumeStats; @@ -87,9 +86,6 @@ public interface MQAdminExt extends MQAdmin { ClusterAclVersionInfo examineBrokerClusterAclVersionInfo(final String addr) throws RemotingException, MQBrokerException, InterruptedException, MQClientException; - AclConfig examineBrokerClusterAclConfig(final String addr) throws RemotingException, MQBrokerException, - InterruptedException, MQClientException; - void createAndUpdateSubscriptionGroupConfig(final String addr, final SubscriptionGroupConfig config) throws RemotingException, MQBrokerException, InterruptedException, MQClientException; diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java index c69b7bf9e6..22d88974ce 100644 --- a/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java +++ b/tools/src/main/java/org/apache/rocketmq/tools/command/MQAdminStartup.java @@ -30,7 +30,6 @@ import org.apache.rocketmq.remoting.protocol.RemotingCommand; import org.apache.rocketmq.srvutil.ServerUtil; import org.apache.rocketmq.tools.command.acl.ClusterAclConfigVersionListSubCommand; import org.apache.rocketmq.tools.command.acl.DeleteAccessConfigSubCommand; -import org.apache.rocketmq.tools.command.acl.GetAccessConfigSubCommand; import org.apache.rocketmq.tools.command.acl.UpdateAccessConfigSubCommand; import org.apache.rocketmq.tools.command.acl.UpdateGlobalWhiteAddrSubCommand; import org.apache.rocketmq.tools.command.broker.BrokerConsumeStatsSubCommad; @@ -227,7 +226,6 @@ public class MQAdminStartup { initCommand(new DeleteAccessConfigSubCommand()); initCommand(new ClusterAclConfigVersionListSubCommand()); initCommand(new UpdateGlobalWhiteAddrSubCommand()); - initCommand(new GetAccessConfigSubCommand()); initCommand(new ExportMetadataCommand()); initCommand(new ExportConfigsCommand()); diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/acl/GetAccessConfigSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/acl/GetAccessConfigSubCommand.java deleted file mode 100644 index 483d136240..0000000000 --- a/tools/src/main/java/org/apache/rocketmq/tools/command/acl/GetAccessConfigSubCommand.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.rocketmq.tools.command.acl; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.OptionGroup; -import org.apache.commons.cli.Options; -import org.apache.rocketmq.client.exception.MQBrokerException; -import org.apache.rocketmq.client.exception.MQClientException; -import org.apache.rocketmq.common.AclConfig; -import org.apache.rocketmq.common.PlainAccessConfig; -import org.apache.rocketmq.remoting.RPCHook; -import org.apache.rocketmq.remoting.exception.RemotingException; -import org.apache.rocketmq.srvutil.ServerUtil; -import org.apache.rocketmq.tools.admin.DefaultMQAdminExt; -import org.apache.rocketmq.tools.command.CommandUtil; -import org.apache.rocketmq.tools.command.SubCommand; -import org.apache.rocketmq.tools.command.SubCommandException; - -import java.lang.reflect.Field; -import java.util.List; -import java.util.Set; - -public class GetAccessConfigSubCommand implements SubCommand { - @Override public String commandName() { - return "getAclConfig"; - } - - @Override public String commandAlias() { - return "getAccessConfigSubCommand"; - } - - @Override public String commandDesc() { - return "List all of acl config information in cluster"; - } - - @Override public Options buildCommandlineOptions(Options options) { - OptionGroup optionGroup = new OptionGroup(); - - Option opt = new Option("b", "brokerAddr", true, "query acl config version for which broker"); - optionGroup.addOption(opt); - - opt = new Option("c", "clusterName", true, "query acl config version for specified cluster"); - optionGroup.addOption(opt); - - optionGroup.setRequired(true); - options.addOptionGroup(optionGroup); - - return options; - } - - @Override public void execute(CommandLine commandLine, Options options, - RPCHook rpcHook) throws SubCommandException { - - DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); - defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); - - try { - - if (commandLine.hasOption('b')) { - String addr = commandLine.getOptionValue('b').trim(); - defaultMQAdminExt.start(); - printClusterBaseInfo(defaultMQAdminExt, addr); - return; - - } else if (commandLine.hasOption('c')) { - String clusterName = commandLine.getOptionValue('c').trim(); - - defaultMQAdminExt.start(); - - Set<String> masterSet = - CommandUtil.fetchMasterAddrByClusterName(defaultMQAdminExt, clusterName); - for (String addr : masterSet) { - printClusterBaseInfo(defaultMQAdminExt, addr); - } - return; - } - - ServerUtil.printCommandLineHelp("mqadmin " + this.commandName(), options); - } catch (Exception e) { - throw new SubCommandException(this.getClass().getSimpleName() + " command failed", e); - } finally { - defaultMQAdminExt.shutdown(); - } - } - - private void printClusterBaseInfo( - final DefaultMQAdminExt defaultMQAdminExt, final String addr) throws - InterruptedException, MQBrokerException, RemotingException, MQClientException, IllegalAccessException { - AclConfig aclConfig = defaultMQAdminExt.examineBrokerClusterAclConfig(addr); - List<PlainAccessConfig> configs = aclConfig.getPlainAccessConfigs(); - List<String> globalWhiteAddrs = aclConfig.getGlobalWhiteAddrs(); - System.out.printf("\n"); - System.out.printf("%-20s: %s\n", "globalWhiteRemoteAddresses", globalWhiteAddrs.toString()); - System.out.printf("\n"); - System.out.printf("accounts:\n"); - if (configs != null && configs.size() > 0) { - for (PlainAccessConfig config : configs) { - Field[] fields = config.getClass().getDeclaredFields(); - for (Field field : fields) { - field.setAccessible(true); - if (field.get(config) != null) { - System.out.printf("%-1s %-18s: %s\n", "", field.getName(), field.get(config).toString()); - } else { - System.out.printf("%-1s %-18s: %s\n", "", field.getName(), ""); - } - } - System.out.printf("\n"); - } - } - } -} diff --git a/tools/src/test/java/org/apache/rocketmq/tools/command/acl/GetAccessConfigSubCommandTest.java b/tools/src/test/java/org/apache/rocketmq/tools/command/acl/GetAccessConfigSubCommandTest.java deleted file mode 100644 index 6a7694ef0a..0000000000 --- a/tools/src/test/java/org/apache/rocketmq/tools/command/acl/GetAccessConfigSubCommandTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.rocketmq.tools.command.acl; - -import org.apache.commons.cli.*; -import org.apache.rocketmq.srvutil.ServerUtil; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class GetAccessConfigSubCommandTest { - - @Test - public void testExecute() { - GetAccessConfigSubCommand cmd = new GetAccessConfigSubCommand(); - Options options = ServerUtil.buildCommandlineOptions(new Options()); - String[] subargs = new String[] {"-c default-cluster"}; - final CommandLine commandLine = - ServerUtil.parseCmdLine("mqadmin " + cmd.commandName(), subargs, cmd.buildCommandlineOptions(options), new PosixParser()); - assertThat(commandLine.getOptionValue('c').trim()).isEqualTo("default-cluster"); - } -}